objc2_cinematic/generated/CNDetection.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-media")]
9use objc2_core_media::*;
10#[cfg(feature = "objc2-core-video")]
11use objc2_core_video::*;
12use objc2_foundation::*;
13
14use crate::*;
15
16/// [Apple's documentation](https://developer.apple.com/documentation/cinematic/cndetectionid?language=objc)
17// NS_TYPED_EXTENSIBLE_ENUM
18pub type CNDetectionID = i64;
19
20/// [Apple's documentation](https://developer.apple.com/documentation/cinematic/cndetectiongroupid?language=objc)
21// NS_TYPED_EXTENSIBLE_ENUM
22pub type CNDetectionGroupID = i64;
23
24/// The type of object that was detected.
25///
26/// Special detection types include:
27/// - autoFocus: from the autofocus system of the camera
28/// - fixedFocus: an explicit request to focus at a fixed disparity
29/// - custom: an object tracked via a custom tracker
30///
31/// See also [Apple's documentation](https://developer.apple.com/documentation/cinematic/cndetectiontype?language=objc)
32// NS_ENUM
33#[repr(transparent)]
34#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
35pub struct CNDetectionType(pub NSInteger);
36impl CNDetectionType {
37 #[doc(alias = "CNDetectionTypeUnknown")]
38 pub const Unknown: Self = Self(0);
39 #[doc(alias = "CNDetectionTypeHumanFace")]
40 pub const HumanFace: Self = Self(1);
41 #[doc(alias = "CNDetectionTypeHumanHead")]
42 pub const HumanHead: Self = Self(2);
43 #[doc(alias = "CNDetectionTypeHumanTorso")]
44 pub const HumanTorso: Self = Self(3);
45 #[doc(alias = "CNDetectionTypeCatBody")]
46 pub const CatBody: Self = Self(4);
47 #[doc(alias = "CNDetectionTypeDogBody")]
48 pub const DogBody: Self = Self(5);
49 #[doc(alias = "CNDetectionTypeCatHead")]
50 pub const CatHead: Self = Self(9);
51 #[doc(alias = "CNDetectionTypeDogHead")]
52 pub const DogHead: Self = Self(10);
53 #[doc(alias = "CNDetectionTypeSportsBall")]
54 pub const SportsBall: Self = Self(11);
55 #[doc(alias = "CNDetectionTypeAutoFocus")]
56 pub const AutoFocus: Self = Self(100);
57 #[doc(alias = "CNDetectionTypeFixedFocus")]
58 pub const FixedFocus: Self = Self(101);
59 #[doc(alias = "CNDetectionTypeCustom")]
60 pub const Custom: Self = Self(102);
61}
62
63unsafe impl Encode for CNDetectionType {
64 const ENCODING: Encoding = NSInteger::ENCODING;
65}
66
67unsafe impl RefEncode for CNDetectionType {
68 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
69}
70
71extern_class!(
72 /// A cinematic detection of a subject.
73 ///
74 /// Specifies the type, distance (as disparity), bounds (as a normalized rectangle), and time (as CMTime) of the detection.
75 /// Detections obtained from the cinematic script include a detectionID that can be used to track the detection over time.
76 /// Some types of detections also include a detectionGroupID that associates related detections (e.g. the face and torso of the same person).
77 ///
78 /// See also [Apple's documentation](https://developer.apple.com/documentation/cinematic/cndetection?language=objc)
79 #[unsafe(super(NSObject))]
80 #[derive(Debug, PartialEq, Eq, Hash)]
81 pub struct CNDetection;
82);
83
84unsafe impl Send for CNDetection {}
85
86unsafe impl Sync for CNDetection {}
87
88extern_conformance!(
89 unsafe impl NSCopying for CNDetection {}
90);
91
92unsafe impl CopyingHelper for CNDetection {
93 type Result = Self;
94}
95
96extern_conformance!(
97 unsafe impl NSObjectProtocol for CNDetection {}
98);
99
100impl CNDetection {
101 extern_methods!(
102 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-media"))]
103 /// Initialize a cinematic detection.
104 ///
105 /// For playback and edit, most detections are obtained by from the cinematic script rather than being created.
106 /// However, if you need to add a custom track, you can build an array of detections to create one.
107 /// Any detections you create will not have a valid detectionID until the custom track is added to the cinematic script.
108 /// Doing so will return the assigned detectionID. Any detections newly obtained from the cinematic script will have their assigned detectionID.
109 ///
110 /// - Parameters:
111 /// - time: the presentation time of the frame in which the detection occurred
112 /// - detectionType: the type of object that was detected (face, torso, cat, dog, etc.)
113 /// - normalizedRect: the rectangle within the image where the object occurs, normalized such that (0.0, 0.0) is the top-left and (1.0, 1.0) is the bottom-right
114 /// - focusDisparity: the disparity to use in order to focus on the object (use the static `disparity` method to compute if unknown)
115 #[unsafe(method(initWithTime:detectionType:normalizedRect:focusDisparity:))]
116 #[unsafe(method_family = init)]
117 pub unsafe fn initWithTime_detectionType_normalizedRect_focusDisparity(
118 this: Allocated<Self>,
119 time: CMTime,
120 detection_type: CNDetectionType,
121 normalized_rect: CGRect,
122 focus_disparity: c_float,
123 ) -> Retained<Self>;
124
125 #[cfg(feature = "objc2-core-media")]
126 /// The presentation time of the frame in which the detection occurred.
127 #[unsafe(method(time))]
128 #[unsafe(method_family = none)]
129 pub unsafe fn time(&self) -> CMTime;
130
131 /// The type of object that was detected (face, torso, cat, dog, etc.)
132 #[unsafe(method(detectionType))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn detectionType(&self) -> CNDetectionType;
135
136 #[cfg(feature = "objc2-core-foundation")]
137 /// The rectangle within the image where the object occurs, normalized such that (0.0, 0.0) is the top-left and (1.0, 1.0) is the bottom-right.
138 #[unsafe(method(normalizedRect))]
139 #[unsafe(method_family = none)]
140 pub unsafe fn normalizedRect(&self) -> CGRect;
141
142 /// The disparity to use in order to focus on the object.
143 /// If the disparity is unknown, use the class method to find it: `disparityInNormalizedRect:sourceDisparity:detectionType:priorDisparity:`.
144 #[unsafe(method(focusDisparity))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn focusDisparity(&self) -> c_float;
147
148 /// An unique identifier assigned by the cinematic script to all detections of the same subject and detection type across time.
149 /// If you build a custom detection track, the detectionID will be assigned when you add it to the script.
150 #[unsafe(method(detectionID))]
151 #[unsafe(method_family = none)]
152 pub unsafe fn detectionID(&self) -> CNDetectionID;
153
154 /// An unique identifier assigned by the cinematic script to all detections of the same subject and related detection types across time.
155 /// For example, the face/torso detections of the same person are assigned the same detectionGroupID.
156 #[unsafe(method(detectionGroupID))]
157 #[unsafe(method_family = none)]
158 pub unsafe fn detectionGroupID(&self) -> CNDetectionGroupID;
159
160 /// Determine whether a given detectionID is valid
161 #[unsafe(method(isValidDetectionID:))]
162 #[unsafe(method_family = none)]
163 pub unsafe fn isValidDetectionID(detection_id: CNDetectionID) -> bool;
164
165 /// Determine whether a given detectionGroupID is valid
166 #[unsafe(method(isValidDetectionGroupID:))]
167 #[unsafe(method_family = none)]
168 pub unsafe fn isValidDetectionGroupID(detection_group_id: CNDetectionGroupID) -> bool;
169
170 /// A localized accessibility label converting a specific detection type into a broad category (person, pet, etc.).
171 #[unsafe(method(accessibilityLabelForDetectionType:))]
172 #[unsafe(method_family = none)]
173 pub unsafe fn accessibilityLabelForDetectionType(
174 detection_type: CNDetectionType,
175 ) -> Retained<NSString>;
176
177 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-video"))]
178 /// Determine the disparity to use to focus on the object in the rectangle.
179 /// - Parameters:
180 /// - disparityBuffer: A pixel buffer from the cinematic disparity track for the frame in which the object occurs.
181 /// - normalizedRect: The rectangle within the disparity buffer where the object occurs, normalized such that (0.0, 0.0) is the top-left and (1.0, 1.0) is the bottom-right of the disparity buffer.
182 /// - detectionType: The type of object expected within the rectangle. Pass `CNDetectionTypeUnknown` if unknown.
183 /// - priorDisparity: The disparity of the object in the prior frame. This helps ensure the object is not mistaken for another that enters the same rectangle. Pass `NAN` if there is no known prior, such as in the first frame in which the object is being tracked.
184 #[unsafe(method(disparityInNormalizedRect:sourceDisparity:detectionType:priorDisparity:))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn disparityInNormalizedRect_sourceDisparity_detectionType_priorDisparity(
187 normalized_rect: CGRect,
188 source_disparity: &CVPixelBuffer,
189 detection_type: CNDetectionType,
190 prior_disparity: c_float,
191 ) -> c_float;
192
193 #[unsafe(method(init))]
194 #[unsafe(method_family = init)]
195 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
196
197 #[unsafe(method(new))]
198 #[unsafe(method_family = new)]
199 pub unsafe fn new() -> Retained<Self>;
200 );
201}