Type Method


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


+ (instancetype)depthDataFromDictionaryRepresentation:(NSDictionary *)imageSourceAuxDataInfoDictionary error:(NSError * _Nullable *)outError;



A dictionary of primitive depth-related information, in the format provided by the CGImageSourceCopyAuxiliaryDataInfoAtIndex function.


When using CGImageSource functions to read from a HEIF, JPEG, or DNG file containing depth data (as well as image data), you can use the CGImageSourceCopyAuxiliaryDataInfoAtIndex function to load primitive depth map information, then use this initializer to create an AVDepthData object, as shown below.

- (nullable AVDepthData *)depthDataFromImageData:(nonnull NSData *)imageData {
	AVDepthData *depthData = nil;
    CGImageSourceRef imageSource = CGImageSourceCreateWithData((CFDataRef)imageData, NULL);
	if (imageSource) {
		NSDictionary *auxDataDictionary = (__bridge NSDictionary *)CGImageSourceCopyAuxiliaryDataInfoAtIndex(imageSource, 0, kCGImageAuxiliaryDataTypeDisparity);
		if (auxDataDictionary) {
			depthData = [AVDepthData depthDataFromDictionaryRepresentation:auxDataDictionary error:NULL];

    return depthData;

See Also

Creating Depth Data

Creating Auxiliary Depth Data Manually

Generate a depth image and attach it to your own image.

- dictionaryRepresentationForAuxiliaryDataType:

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