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#[cfg(feature = "objc2-image-io")]
9use objc2_image_io::*;
10
11use crate::*;
12
13/// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avdepthdataquality?language=objc)
14// NS_ENUM
15#[repr(transparent)]
16#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
17pub struct AVDepthDataQuality(pub NSInteger);
18impl AVDepthDataQuality {
19    #[doc(alias = "AVDepthDataQualityLow")]
20    pub const Low: Self = Self(0);
21    #[doc(alias = "AVDepthDataQualityHigh")]
22    pub const High: Self = Self(1);
23}
24
25unsafe impl Encode for AVDepthDataQuality {
26    const ENCODING: Encoding = NSInteger::ENCODING;
27}
28
29unsafe impl RefEncode for AVDepthDataQuality {
30    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
31}
32
33/// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avdepthdataaccuracy?language=objc)
34// NS_ENUM
35#[repr(transparent)]
36#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
37pub struct AVDepthDataAccuracy(pub NSInteger);
38impl AVDepthDataAccuracy {
39    #[doc(alias = "AVDepthDataAccuracyRelative")]
40    pub const Relative: Self = Self(0);
41    #[doc(alias = "AVDepthDataAccuracyAbsolute")]
42    pub const Absolute: Self = Self(1);
43}
44
45unsafe impl Encode for AVDepthDataAccuracy {
46    const ENCODING: Encoding = NSInteger::ENCODING;
47}
48
49unsafe impl RefEncode for AVDepthDataAccuracy {
50    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
51}
52
53extern_class!(
54    /// An object wrapping a map of disparity or depth pixel data, plus metadata.
55    ///
56    ///
57    /// "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:
58    /// kCVPixelFormatType_DisparityFloat16    = 'hdis'
59    /// kCVPixelFormatType_DisparityFloat32    = 'fdis'
60    /// kCVPixelFormatType_DepthFloat16        = 'hdep'
61    /// kCVPixelFormatType_DepthFloat32        = 'fdep'
62    ///
63    /// The disparity formats describe normalized shift values when comparing two images. Units are 1/meters: ( pixelShift / (pixelFocalLength * baselineInMeters) ).
64    /// The depth formats describe the distance to an object in meters.
65    ///
66    /// 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).
67    ///
68    /// 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.
69    ///
70    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avdepthdata?language=objc)
71    #[unsafe(super(NSObject))]
72    #[derive(Debug, PartialEq, Eq, Hash)]
73    pub struct AVDepthData;
74);
75
76extern_conformance!(
77    unsafe impl NSObjectProtocol for AVDepthData {}
78);
79
80impl AVDepthData {
81    extern_methods!(
82        #[unsafe(method(init))]
83        #[unsafe(method_family = init)]
84        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
85
86        #[unsafe(method(new))]
87        #[unsafe(method_family = new)]
88        pub unsafe fn new() -> Retained<Self>;
89
90        /// Returns an AVDepthData instance from depth information in an image file.
91        ///
92        ///
93        /// Parameter `imageSourceAuxDataInfoDictionary`: A dictionary of primitive depth-related information obtained from CGImageSourceCopyAuxiliaryDataInfoAtIndex.
94        ///
95        /// Parameter `outError`: On return, if the depth data cannot be created, points to an NSError describing the problem.
96        ///
97        /// Returns: An AVDepthData instance, or nil if the auxiliary data info dictionary was malformed.
98        ///
99        ///
100        /// 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.
101        ///
102        /// # Safety
103        ///
104        /// `image_source_aux_data_info_dictionary` generic should be of the correct type.
105        #[unsafe(method(depthDataFromDictionaryRepresentation:error:_))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn depthDataFromDictionaryRepresentation_error(
108            image_source_aux_data_info_dictionary: &NSDictionary,
109        ) -> Result<Retained<Self>, Retained<NSError>>;
110
111        /// Returns a converted, derivative AVDepthData instance in the specified depthDataType.
112        ///
113        ///
114        /// Parameter `depthDataType`: The OSType of depthData object to which you'd like to convert. Must be present in availableDepthDataTypes.
115        ///
116        /// Returns: An AVDepthData instance.
117        ///
118        ///
119        /// This method throws an NSInvalidArgumentException if you pass an unrecognized depthDataType. See
120        #[unsafe(method(depthDataByConvertingToDepthDataType:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn depthDataByConvertingToDepthDataType(
123            &self,
124            depth_data_type: OSType,
125        ) -> Retained<Self>;
126
127        #[cfg(feature = "objc2-image-io")]
128        /// Returns a derivative AVDepthData instance in which the specified Exif orientation has been applied.
129        ///
130        ///
131        /// Parameter `exifOrientation`: One of the 8 standard Exif orientation tags expressing how the depth data should be rotated / mirrored.
132        ///
133        /// Returns: An AVDepthData instance.
134        ///
135        ///
136        /// When applying simple 90 degree rotation or mirroring edits to media containing depth data, you may use this initializer to create a derivative copy of the depth in which the specified orientation is applied to both the underlying pixel map data and the camera calibration data. This method throws an NSInvalidArgumentException if you pass an unrecognized exifOrientation.
137        #[unsafe(method(depthDataByApplyingExifOrientation:))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn depthDataByApplyingExifOrientation(
140            &self,
141            exif_orientation: CGImagePropertyOrientation,
142        ) -> Retained<Self>;
143
144        #[cfg(feature = "objc2-core-video")]
145        /// Returns an AVDepthData instance wrapping the replacement depth data map pixel buffer.
146        ///
147        ///
148        /// Parameter `pixelBuffer`: A pixel buffer containing depth data information in one of the 4 supported disparity / depth pixel formats.
149        ///
150        /// Parameter `outError`: On return, if the depth data cannot be created, points to an NSError describing the problem.
151        ///
152        /// Returns: An AVDepthData instance, or nil if the pixel buffer is malformed.
153        ///
154        ///
155        /// 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.
156        #[unsafe(method(depthDataByReplacingDepthDataMapWithPixelBuffer:error:_))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn depthDataByReplacingDepthDataMapWithPixelBuffer_error(
159            &self,
160            pixel_buffer: &CVPixelBuffer,
161        ) -> Result<Retained<Self>, Retained<NSError>>;
162
163        /// Specifies which depth data pixel formats may be used with depthDataByConvertingToDepthDataType:.
164        ///
165        ///
166        /// This property presents the available pixel format types as an array of NSNumbers, each wrapping an OSType (CV pixel format type).
167        #[unsafe(method(availableDepthDataTypes))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn availableDepthDataTypes(&self) -> Retained<NSArray<NSNumber>>;
170
171        /// Returns a dictionary of primitive map information to be used when writing an image file with depth data.
172        ///
173        ///
174        /// Parameter `outAuxDataType`: On output, either kCGImageAuxiliaryDataTypeDisparity or kCGImageAuxiliaryDataTypeDepth, depending on the depth data's file.
175        ///
176        /// Returns: A dictionary of CGImageDestination compatible depth information, or nil if the auxDataType is unsupported.
177        ///
178        ///
179        /// 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.
180        #[unsafe(method(dictionaryRepresentationForAuxiliaryDataType:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn dictionaryRepresentationForAuxiliaryDataType(
183            &self,
184            out_aux_data_type: Option<&mut Option<Retained<NSString>>>,
185        ) -> Option<Retained<NSDictionary>>;
186
187        /// Specifies the pixel format type of this depth data object's internal map.
188        ///
189        ///
190        /// One of kCVPixelFormatType_DisparityFloat16, kCVPixelFormatType_DisparityFloat32, kCVPixelFormatType_DepthFloat16, or kCVPixelFormatType_DepthFloat32.
191        #[unsafe(method(depthDataType))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn depthDataType(&self) -> OSType;
194
195        #[cfg(feature = "objc2-core-video")]
196        /// Provides access to the depth data object's internal map.
197        ///
198        ///
199        /// The depth data map's pixel format can be queried using the depthDataType property.
200        #[unsafe(method(depthDataMap))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn depthDataMap(&self) -> Retained<CVPixelBuffer>;
203
204        /// Specifies the overall quality of the depth data map's values.
205        ///
206        ///
207        /// See AVDepthDataQuality documentation for more information.
208        #[unsafe(method(depthDataQuality))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn depthDataQuality(&self) -> AVDepthDataQuality;
211
212        /// Specifies whether the depth data pixel buffer map contains filtered (hole-filled) data.
213        ///
214        ///
215        /// 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.
216        #[unsafe(method(isDepthDataFiltered))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn isDepthDataFiltered(&self) -> bool;
219
220        /// Specifies the accuracy of the units in the depth data map's values.
221        ///
222        ///
223        /// See AVDepthDataAccuracy documentation for more information.
224        #[unsafe(method(depthDataAccuracy))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn depthDataAccuracy(&self) -> AVDepthDataAccuracy;
227
228        #[cfg(feature = "AVCameraCalibrationData")]
229        /// The calibration data of the camera with which AVDepthData map's values are aligned.
230        ///
231        ///
232        /// See AVCameraCalibrationData for more information. This property may return nil if no camera calibration data is available for the depth data.
233        #[unsafe(method(cameraCalibrationData))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn cameraCalibrationData(&self) -> Option<Retained<AVCameraCalibrationData>>;
236    );
237}