我有iphone 7+,我试着用深度数据拍摄图像。我使用这段代码进行配置。深度
但继续
func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
print(photo.depthData)
}
结果是尼尔。我怎么能得到depthData。怎么啦?
发布于 2021-12-06 15:56:57
您必须通过检查是否支持isDepthDataDeliveryEnabled
将其设置为true
。
该设备需要一个“背向双摄像机或正面TrueDepth相机”。
这是猜测,但我认为TrueDepth只包括A11 chip+,它是与iPhone 8一起推出的。所以,isDepthDataDeliverySupported
似乎是iPhone 7上的false
。
// Set up photo output for depth data capture.
let photoOutput = AVCapturePhotoOutput()
photoOutput.isDepthDataDeliveryEnabled = photoOutput.isDepthDataDeliverySupported
guard self.captureSession.canAddOutput(photoOutput)
else { fatalError("Can't add photo output.") }
self.captureSession.addOutput(photoOutput)
self.captureSession.sessionPreset = .photo
self.captureSession.commitConfiguration()
https://stackoverflow.com/questions/70248021
复制相似问题