objc2_av_foundation/generated/AVDepthData.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5#[cfg(feature = "objc2-core-video")]
6use objc2_core_video::*;
7use objc2_foundation::*;
8
9use crate::*;
10
11/// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avdepthdataquality?language=objc)
12// NS_ENUM
13#[repr(transparent)]
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct AVDepthDataQuality(pub NSInteger);
16impl AVDepthDataQuality {
17 #[doc(alias = "AVDepthDataQualityLow")]
18 pub const Low: Self = Self(0);
19 #[doc(alias = "AVDepthDataQualityHigh")]
20 pub const High: Self = Self(1);
21}
22
23unsafe impl Encode for AVDepthDataQuality {
24 const ENCODING: Encoding = NSInteger::ENCODING;
25}
26
27unsafe impl RefEncode for AVDepthDataQuality {
28 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
29}
30
31/// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avdepthdataaccuracy?language=objc)
32// NS_ENUM
33#[repr(transparent)]
34#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
35pub struct AVDepthDataAccuracy(pub NSInteger);
36impl AVDepthDataAccuracy {
37 #[doc(alias = "AVDepthDataAccuracyRelative")]
38 pub const Relative: Self = Self(0);
39 #[doc(alias = "AVDepthDataAccuracyAbsolute")]
40 pub const Absolute: Self = Self(1);
41}
42
43unsafe impl Encode for AVDepthDataAccuracy {
44 const ENCODING: Encoding = NSInteger::ENCODING;
45}
46
47unsafe impl RefEncode for AVDepthDataAccuracy {
48 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
49}
50
51extern_class!(
52 /// An object wrapping a map of disparity or depth pixel data, plus metadata.
53 ///
54 ///
55 /// "Depth Data" is a generic term for a map of pixel data containing depth-related information. AVDepthData 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. CoreVideo supports the following four depth data pixel formats:
56 /// kCVPixelFormatType_DisparityFloat16 = 'hdis'
57 /// kCVPixelFormatType_DisparityFloat32 = 'fdis'
58 /// kCVPixelFormatType_DepthFloat16 = 'hdep'
59 /// kCVPixelFormatType_DepthFloat32 = 'fdep'
60 ///
61 /// The disparity formats describe normalized shift values when comparing two images. Units are 1/meters: ( pixelShift / (pixelFocalLength * baselineInMeters) ).
62 /// The depth formats describe the distance to an object in meters.
63 ///
64 /// Disparity / depth maps are generated from camera images containing non-rectilinear data. Camera lenses have small imperfections that cause small distortions in their resultant images compared to a pinhole camera. AVDepthData maps contain non-rectilinear (non-distortion-corrected) data as well. Their values are warped to match the lens distortion characteristics present in their accompanying YUV image. Therefore an AVDepthData map can be used as a proxy for depth when rendering effects to its accompanying image, but not to correlate points in 3D space. In order to use AVDepthData for computer vision tasks, you should use its accompanying camera calibration data to rectify the depth data (see AVCameraCalibrationData).
65 ///
66 /// When capturing depth data from a camera using AVCaptureDepthDataOutput, AVDepthData objects are delivered to your AVCaptureDepthDataOutputDelegate in a streaming fashion. When capturing depth data along with photos using AVCapturePhotoOutput, depth data is delivered to your AVCapturePhotoCaptureDelegate as a property of an AVCapturePhoto (see -[AVCapturePhotoCaptureDelegate captureOutput:didFinishProcessingPhoto:error:]). When working with image files containing depth information, AVDepthData may be instantiated using information obtained from ImageIO. When editing images containing depth information, derivative AVDepthData objects may be instantiated reflecting the edits that have been performed.
67 ///
68 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avdepthdata?language=objc)
69 #[unsafe(super(NSObject))]
70 #[derive(Debug, PartialEq, Eq, Hash)]
71 pub struct AVDepthData;
72);
73
74unsafe impl NSObjectProtocol for AVDepthData {}
75
76impl AVDepthData {
77 extern_methods!(
78 #[unsafe(method(init))]
79 #[unsafe(method_family = init)]
80 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
81
82 #[unsafe(method(new))]
83 #[unsafe(method_family = new)]
84 pub unsafe fn new() -> Retained<Self>;
85
86 /// Returns an AVDepthData instance from depth information in an image file.
87 ///
88 ///
89 /// Parameter `imageSourceAuxDataInfoDictionary`: A dictionary of primitive depth-related information obtained from CGImageSourceCopyAuxiliaryDataInfoAtIndex.
90 ///
91 /// Parameter `outError`: On return, if the depth data cannot be created, points to an NSError describing the problem.
92 ///
93 /// Returns: An AVDepthData instance, or nil if the auxiliary data info dictionary was malformed.
94 ///
95 ///
96 /// When using ImageIO framework's CGImageSource API to read from a HEIF or JPEG file containing depth data, AVDepthData can be instantiated using the result of CGImageSourceCopyAuxiliaryDataInfoAtIndex, which returns a CFDictionary of primitive map information.
97 #[unsafe(method(depthDataFromDictionaryRepresentation:error:_))]
98 #[unsafe(method_family = none)]
99 pub unsafe fn depthDataFromDictionaryRepresentation_error(
100 image_source_aux_data_info_dictionary: &NSDictionary,
101 ) -> Result<Retained<Self>, Retained<NSError>>;
102
103 /// Returns a converted, derivative AVDepthData instance in the specified depthDataType.
104 ///
105 ///
106 /// Parameter `depthDataType`: The OSType of depthData object to which you'd like to convert. Must be present in availableDepthDataTypes.
107 ///
108 /// Returns: An AVDepthData instance.
109 ///
110 ///
111 /// This method throws an NSInvalidArgumentException if you pass an unrecognized depthDataType. See
112 #[unsafe(method(depthDataByConvertingToDepthDataType:))]
113 #[unsafe(method_family = none)]
114 pub unsafe fn depthDataByConvertingToDepthDataType(
115 &self,
116 depth_data_type: OSType,
117 ) -> Retained<Self>;
118
119 #[cfg(feature = "objc2-core-video")]
120 /// Returns an AVDepthData instance wrapping the replacement depth data map pixel buffer.
121 ///
122 ///
123 /// Parameter `pixelBuffer`: A pixel buffer containing depth data information in one of the 4 supported disparity / depth pixel formats.
124 ///
125 /// Parameter `outError`: On return, if the depth data cannot be created, points to an NSError describing the problem.
126 ///
127 /// Returns: An AVDepthData instance, or nil if the pixel buffer is malformed.
128 ///
129 ///
130 /// When applying complex edits to media containing depth data, you may create a derivative map with arbitrary transforms applied to it, then use this initializer to create a new AVDepthData. Note that this new depth data object has no camera calibration data, so its cameraCalibrationData property always returns nil.
131 #[unsafe(method(depthDataByReplacingDepthDataMapWithPixelBuffer:error:_))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn depthDataByReplacingDepthDataMapWithPixelBuffer_error(
134 &self,
135 pixel_buffer: &CVPixelBuffer,
136 ) -> Result<Retained<Self>, Retained<NSError>>;
137
138 /// Specifies which depth data pixel formats may be used with depthDataByConvertingToDepthDataType:.
139 ///
140 ///
141 /// This property presents the available pixel format types as an array of NSNumbers, each wrapping an OSType (CV pixel format type).
142 #[unsafe(method(availableDepthDataTypes))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn availableDepthDataTypes(&self) -> Retained<NSArray<NSNumber>>;
145
146 /// Returns a dictionary of primitive map information to be used when writing an image file with depth data.
147 ///
148 ///
149 /// Parameter `outAuxDataType`: On output, either kCGImageAuxiliaryDataTypeDisparity or kCGImageAuxiliaryDataTypeDepth, depending on the depth data's file.
150 ///
151 /// Returns: A dictionary of CGImageDestination compatible depth information, or nil if the auxDataType is unsupported.
152 ///
153 ///
154 /// When using ImageIO framework's CGImageDestination API to write depth data to a HEIF or JPEG file, you may use this method to generate a dictionary of primitive map information consumed by CGImageDestinationAddAuxiliaryDataInfo.
155 #[unsafe(method(dictionaryRepresentationForAuxiliaryDataType:))]
156 #[unsafe(method_family = none)]
157 pub unsafe fn dictionaryRepresentationForAuxiliaryDataType(
158 &self,
159 out_aux_data_type: Option<&mut Option<Retained<NSString>>>,
160 ) -> Option<Retained<NSDictionary>>;
161
162 /// Specifies the pixel format type of this depth data object's internal map.
163 ///
164 ///
165 /// One of kCVPixelFormatType_DisparityFloat16, kCVPixelFormatType_DisparityFloat32, kCVPixelFormatType_DepthFloat16, or kCVPixelFormatType_DepthFloat32.
166 #[unsafe(method(depthDataType))]
167 #[unsafe(method_family = none)]
168 pub unsafe fn depthDataType(&self) -> OSType;
169
170 #[cfg(feature = "objc2-core-video")]
171 /// Provides access to the depth data object's internal map.
172 ///
173 ///
174 /// The depth data map's pixel format can be queried using the depthDataType property.
175 #[unsafe(method(depthDataMap))]
176 #[unsafe(method_family = none)]
177 pub unsafe fn depthDataMap(&self) -> Retained<CVPixelBuffer>;
178
179 /// Specifies the overall quality of the depth data map's values.
180 ///
181 ///
182 /// See AVDepthDataQuality documentation for more information.
183 #[unsafe(method(depthDataQuality))]
184 #[unsafe(method_family = none)]
185 pub unsafe fn depthDataQuality(&self) -> AVDepthDataQuality;
186
187 /// Specifies whether the depth data pixel buffer map contains filtered (hole-filled) data.
188 ///
189 ///
190 /// By setting either AVCaptureDepthDataOutput's filteringEnabled property or AVCapturePhotoSettings' depthDataFiltered property to YES, the resulting depth data are filtered to remove invalid pixel values that may be present due to a variety of factors including low light and lens occlusion. If you've requested depth data filtering, all depth data holes are filled. Note that filtering the depth data makes it more usable for applying effects, but alters the data such that it may no longer be suitable for computer vision tasks. Unfiltered depth maps present missing data as NaN.
191 #[unsafe(method(isDepthDataFiltered))]
192 #[unsafe(method_family = none)]
193 pub unsafe fn isDepthDataFiltered(&self) -> bool;
194
195 /// Specifies the accuracy of the units in the depth data map's values.
196 ///
197 ///
198 /// See AVDepthDataAccuracy documentation for more information.
199 #[unsafe(method(depthDataAccuracy))]
200 #[unsafe(method_family = none)]
201 pub unsafe fn depthDataAccuracy(&self) -> AVDepthDataAccuracy;
202
203 #[cfg(feature = "AVCameraCalibrationData")]
204 /// The calibration data of the camera with which AVDepthData map's values are aligned.
205 ///
206 ///
207 /// See AVCameraCalibrationData for more information. This property may return nil if no camera calibration data is available for the depth data.
208 #[unsafe(method(cameraCalibrationData))]
209 #[unsafe(method_family = none)]
210 pub unsafe fn cameraCalibrationData(&self) -> Option<Retained<AVCameraCalibrationData>>;
211 );
212}