Posts

Post not yet marked as solved
0 Replies
538 Views
So I want to programmatically take a series of photos that include depth data. This should be done using the back 1x camera. My code for setting up the capturing is basically the snippet below. I've removed error handling etc for simplicity. let captureDevice = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .unspecified) else { let input = try AVCaptureDeviceInput(device: captureDevice) captureSession.beginConfiguration() captureSession.addInput(input) captureSession.addOutput(photoOutput) photoOutput.isDepthDataDeliveryEnabled = true photoOutput.isHighResolutionCaptureEnabled = true photoOutput.isDepthDataDeliveryEnabled = true photoOutput.maxPhotoQualityPrioritization = .quality captureSession.sessionPreset = .photo captureSession.commitConfiguration() captureSession.startRunning() Whatever I do I can't get the camera initialized, as soon as isDepthDataDeliveryEnabled is set to true the app throws an exception: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCapturePhotoOutput setDepthDataDeliveryEnabled:] Depth data delivery is not supported in the current configuration' The only device that can even be initialized is builtInDualCamera, but it produces horrible zoomed in photos that are blurry and awful. I can apparently not tell the camera to not zoom in nor to focus? This API is probably the most awful of all API:s I've used in the Apple world. The best documentation I can find are the notes for a sample app: https://developer.apple.com/documentation/avfoundation/additional_data_capture/capturing_photos_with_depth In that sample the same camera is used as I try to use: // Select a depth-capable capture device. guard let videoDevice = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .unspecified) else { fatalError("No dual camera.") } Am I to understand from this that an iPhone 12 Pro can not capture depth? There's a distinct lack of material related to handling depth on the Internet, so probably not many have done it at all. I even tried the sample Lidar app from https://developer.apple.com/documentation/avfoundation/additional_data_capture/capturing_depth_using_the_lidar_camera, but it has bit rot a bit and also fails with various errors as soon as the UI is touched.
Posted Last updated
.