我正在一个需要录制视频的应用程序上工作,我发现了一个由appcoda编写的帮助程序类,这是指向github repo https://github.com/appcoda/FullScreenCamera的链接,但是我遇到的问题是它曾经有过我运行它,在控制台中收到一个错误,说private static File processImage(File img) throws IOException {
File newImg = File.createTempFile("asdf", ".png");
ImageMagickCmd cmd = new ImageMagickCmd("convert");
IMOperation op = new IMOperation();
op.addImage(img.getAbsolutePath());
op.strip().resample(300).colorspace("gray").autoLevel().threshold(35000).type("bilevel").depth(8).trim();
op.addImage(newImg.getAbsolutePath());
cmd.run(op);
return newImg;
}
后跟noCamerasAvailable
,我还致力于改进代码,但我不知道为什么。这是助手类
captureSessionIsMissing
这是帮助程序类。
答案 0 :(得分:0)
使用 .builtInWideAngleCamera 代替 .builtInDualCamera 来设置AVCaptureDevice。
在您的项目上替换此功能
func configureCaptureDevices() throws {
let session = AVCaptureDevice.DiscoverySession(deviceTypes: [. builtInWideAngleCamera], mediaType: AVMediaType.video, position: .unspecified)
let cameras = session.devices.compactMap { $0 }
guard !cameras.isEmpty else { throw CameraHelperError.noCamerasAvailable }
for camera in cameras {
if camera.position == .front {
self.frontCamera = camera
}
if camera.position == .back {
self.rearCamera = camera
try camera.lockForConfiguration()
camera.focusMode = .continuousAutoFocus
camera.unlockForConfiguration()
}
}
}