A container for per-pixel distance or disparity information captured by compatible camera devices.
SDKs
- iOS 11.0+
- macOS 10.13+
- Mac Catalyst 13.0+
- tvOS 11.0+
Framework
- AVFoundation
Declaration
class AVDepthData : NSObject
Overview
Depth data is a generic term for a map of per-pixel data containing depth-related information. A depth data object wraps a disparity or depth map and provides conversion methods, focus information, and camera calibration data to aid in using the map for rendering or computer vision tasks.
A depth map describes at each pixel the distance to an object, in meters.
A disparity map describes normalized shift values for use in comparing two images. The value for each pixel in the map is in units of 1/meters: (pixel
).
The capture pipeline generates disparity or depth maps from camera images containing nonrectilinear data. Camera lenses have small imperfections that cause small distortions in their resultant images compared to an ideal pinhole camera model, so AVDepth
maps contain nonrectilinear (nondistortion-corrected) data as well. The maps' values are warped to match the lens distortion characteristics present in the YUV image pixel buffers captured at the same time.
Because a depth data map is nonrectilinear, you can use an AVDepth
map as a proxy for depth when rendering effects to its accompanying image, but not to correlate points in 3D space. To use depth data for computer vision tasks, use the data in the camera
property to rectify the depth data.
There are two ways to capture depth data:
The
AVCapture
class captures and delivers depth data in a stream (similar to how theDepth Data Output AVCapture
delivers video data).Video Data Output The
AVCapture
class delivers depth data as a property of anPhoto Output AVCapture
object containing the captured image.Photo
You can also create AVDepth
objects using information obtained from image files with the Image I/O framework.
When editing images containing depth information, use the methods listed in Transforming and Processing to generate derivative AVDepth
objects reflecting the edits that have been performed.