1

I'm trying to figure out how to get detailed depth data (the raw data) from the front-facing camera on the iPhone X. Apple's docs suggest that AVDepthData will return this data, but I've not be able to confirm this.

Is this the correct property to use to access that data?

Vik
  • 1,301
  • 4
  • 16
  • 29

1 Answers1

2

Yes. The WWDC 2017 session "Capturing Depth in iPhone Photography" (https://developer.apple.com/videos/play/wwdc2017/507/) covers this for the dual-camera set up on the back, and it uses AVDepthData to return depth information. The TrueDepth camera uses the same protocol.

technology08
  • 131
  • 8
  • Yes, I was able to get this up and running by modifying the AVCam sample code. Thanks! – Vik Feb 08 '18 at 01:36
  • 1
    ...and for others coming to this answer, *how* do you modify the sample code? (The key part is selecting the `builtInTrueDepthCamera` capture device.) – rickster Feb 08 '18 at 21:29
  • In the sample code, the key point is to adjust AVCaptureDevice.DiscoverySession to include .builtInTrueDepthCamera. From there, implement: func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?). You're then able to extract the depth data from the photo object return in the delegate callback: let depthData = photo.depthData – Vik Feb 20 '18 at 01:59