AVFoundation - Depth capture after raw freezes the camera

I am working on a camera app that has an option to take a photo in either raw or depth mode. When I first make a raw image and then a depth one it causes camera preview to get stuck. Capture session is not running anymore and depth data returns nil. It only happens in this sequence.


isDepthDataDeliveryEnabled is set to true in both AVCapturePhotoOutput and AVCapturePhotoSettings, the last one is set just before capturing a photo. What might be the problem?

Replies

Could you show the code where you preview image ?


I understand that in fact you get raw and processed and cannot preview raw

https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/capturing_still_and_live_photos/capturing_photos_in_raw_format


You cannot change mode while session is running: it risks freezing preview. Is it what you experience ?

Capturing depth data requires that a capture session set up its internal rendering pipeline differently. If you intend to capture depth data at all, set this property to

true
before calling the
AVCaptureSession
startRunning()
method. Changing this property while the session is running requires a lengthy reconfiguration of the capture render pipeline: Live Photo captures in progress will end immediately, unfulfilled photo requests will abort, and video preview will temporarily freeze.


https://developer.apple.com/documentation/avfoundation/avcapturephotooutput/2866565-isdepthdatadeliveryenabled