Dual photo and depth data delivery(iPhone X)

I'd like to get dual photo and depth data in iPhone X.

Only dual photo delivery works well. But dual photo and depth data delivery does not work well.

The first callback of 'photoOutput' works well. But at the second callback, when you get 'photo.depthData?.depthDataMap' property, exception occurs in Xcode enbironment.

Is there any bug or something?

Accepted Reply

Correct. When doing dual photo capture + depth, only the tele image will have a depth data. The wide will not.

Replies

The DualCamera provides depth only for the field of view of the telephoto lens, since that is the field of view that the two lenses have in common. Thus, when using the DualCamera dual photo feature + depth, only the telephoto image will have a non nil depthData.


What exception is being raised? Check the console. If you've misused the AVFoundation API in any way, we always log to the console, informing you of the reason for the exception being raised.

Thank you for replying my question.

I will show you the 'func photoOutput' code and exception below.


func photoOutput(_ output: AVCapturePhotoOutput,didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {

let photoData = photo.fileDataRepresentation()

let imagePhoto = UIImage(data: photoData!)

UIImageWriteToSavedPhotosAlbum(imagePhoto!, self, nil, nil)

let pixelBuffer:CVPixelBuffer = (photo.depthData?.depthDataMap)! // --> At second callback, exception occurs. The message is "Thread 1: EXC_BREAKPOINT (code=1, subcode=0x102dfe2d0)"

let metadataAttachments: CFDictionary = photo.metadata as CFDictionary

guard let jpegData = ViewController.jpegData(withPixelBuffer: pixelBuffer, attachments: metadataAttachments) else{

print("Unable to create JPEG photo")

return

}

let depthPhoto=UIImage(data:jpegData)

UIImageWriteToSavedPhotosAlbum(depthPhoto!, self, nil, nil)

}

You mean that widephoto image at second callback will not have depth data?

if it were to be a specification, I understand it.

Correct. When doing dual photo capture + depth, only the tele image will have a depth data. The wide will not.