Class

AVDepthData

A container for per-pixel distance or disparity information captured by compatible camera devices.

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: (pixelShift / (pixelFocalLength * baselineInMeters)).

The capture pipeline generates disparity or depth maps from camera images containing non-rectilinear data. Camera lenses have small imperfections that cause small distortions in their resultant images compared to an ideal pinhole camera model, so AVDepthData maps contain non-rectilinear (non-distortion-corrected) data as well. Their 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 non-rectilinear, you can use an AVDepthData map as a proxy for depth when rendering effects to its accompanying image, but not to correlate points in 3D space. In order to use depth data for computer vision tasks, you should use the data in the cameraCalibrationData property to rectify the depth data.

There are two ways to capture depth data:

You can also create AVDepthData 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 AVDepthData objects reflecting the edits that have been performed.

Topics

Reading Pixel Depth Information

var depthDataMap: CVPixelBuffer

A pixel buffer containing the depth data's per-pixel depth or disparity data map.

var depthDataType: OSType

The pixel format of the depth data map.

var depthDataAccuracy: AVDepthData.Accuracy

A value indicating the general accuracy of depth data map values.

enum AVDepthData.Accuracy

Values indicating the general accuracy of a depth data map.

var isDepthDataFiltered: Bool

A Boolean value indicating whether the depth map contains temporally smoothed data.

Serializing and Deserializing

func dictionaryRepresentation(forAuxiliaryDataType: AutoreleasingUnsafeMutablePointer<NSString?>?)

Returns a dictionary representation of the depth data suitable for writing into an image file.

init(fromDictionaryRepresentation: [AnyHashable : Any])

Creates a depth data object from depth information such as that found in an image file.

Transforming and Processing

func applyingExifOrientation(CGImagePropertyOrientation)

Returns a derivative depth data object by mirroring or rotating it to the specified orientation.

func converting(toDepthDataType: OSType)

Returns a derivative depth data object by converting the depth data map to the specified data type.

var availableDepthDataTypes: [NSNumber]

The list of depth data formats to which this depth data can be converted.

func replacingDepthDataMap(with: CVPixelBuffer)

Returns a derivative depth data object by replacing the depth data map.

Using Calibration Data

var cameraCalibrationData: AVCameraCalibrationData?

The imaging parameters with which this depth data was captured.

class AVCameraCalibrationData

Information about the camera characteristics used to capture images and depth data.

Relationships

Inherits From

Conforms To

See Also

Depth Data Capture

class AVCaptureDepthDataOutput

A capture output that records scene depth information on compatible camera devices.

Beta

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software