可以使用TelephotoCamera从WideAngleCamera,automatically或DualCamera获取相框:
//auto
let device = AVCaptureDevice.default(.builtInDualCamera, for: .video, position: .back)
//telephoto
let device = AVCaptureDevice.default(.builtInTelephotoCamera, for: .video, position: .back)
//wideAngle
let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back)
但如何同时从TelephotoCamera和WideAngleCamera获取帧数(使用dual camera s的设备)。
EDIT1
试图向capture session添加2个输入:
captureSession?.addInput(input)
captureSession?.addInput(input2)
NSInvalidArgumentException: Multiple audio/video AVCaptureInputs are not currently supported
的 EDIT2
尝试为isDualCameraDualPhotoDeliveryEnabled启用capture photo output标记:
capturePhotoOutput?.isDualCameraDualPhotoDeliveryEnabled = true
NSInvalidArgumentException: Dual Camera dual photo delivery is not supported in this configuration
的但
isDualCameraDualPhotoDeliverySupported在false
上提供iPhone 8 Plus
这可能是我问题的原因吗?
仍然没有运气。
答案 0 :(得分:2)
是的,这是可能的。
只需选择正确的配置。
捕获设备应为builtInDualCamera
:
let captureDevice = AVCaptureDevice.default(.builtInDualCamera, for: .video, position: .back)
配置捕获会话后配置捕获照片输出:
captureSession = AVCaptureSession()
captureSession?.sessionPreset = AVCaptureSession.Preset.photo
captureSession?.addInput(input)
captureSession?.addOutput(capturePhotoOutput!)
capturePhotoOutput?.isHighResolutionCaptureEnabled = true
<强> capturePhotoOutput?.isDualCameraDualPhotoDeliveryEnabled = true
强>
在拍摄照片之前配置照片设置:
let photoSettings = AVCapturePhotoSettings()
photoSettings.isAutoStillImageStabilizationEnabled = true
photoSettings.isHighResolutionPhotoEnabled = true
photoSettings.isAutoDualCameraFusionEnabled = false
<强> photoSettings.isDualCameraDualPhotoDeliveryEnabled = true
强>
实施AVCapturePhotoCaptureDelegate
,并覆盖下一个方法:
public func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?)
您将收到2个photoOutput
回调!