objc2_cinematic/generated/
CNObjectTracker.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#[cfg(feature = "objc2-metal")]
14use objc2_metal::*;
15
16use crate::*;
17
18extern_class!(
19    /// [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnboundsprediction?language=objc)
20    #[unsafe(super(NSObject))]
21    #[derive(Debug, PartialEq, Eq, Hash)]
22    pub struct CNBoundsPrediction;
23);
24
25extern_conformance!(
26    unsafe impl NSCopying for CNBoundsPrediction {}
27);
28
29unsafe impl CopyingHelper for CNBoundsPrediction {
30    type Result = Self;
31}
32
33extern_conformance!(
34    unsafe impl NSObjectProtocol for CNBoundsPrediction {}
35);
36
37impl CNBoundsPrediction {
38    extern_methods!(
39        #[cfg(feature = "objc2-core-foundation")]
40        /// bounds of the detected object in normalized coordinates where (0.0, 0.0) is the upper left corner, and (1.0, 1.0) is the lower right
41        #[unsafe(method(normalizedBounds))]
42        #[unsafe(method_family = none)]
43        pub unsafe fn normalizedBounds(&self) -> CGRect;
44
45        #[cfg(feature = "objc2-core-foundation")]
46        /// Setter for [`normalizedBounds`][Self::normalizedBounds].
47        #[unsafe(method(setNormalizedBounds:))]
48        #[unsafe(method_family = none)]
49        pub unsafe fn setNormalizedBounds(&self, normalized_bounds: CGRect);
50
51        /// the probability that a well-defined object is within the bounds — a number between 0.0 and 1.0.
52        #[unsafe(method(confidence))]
53        #[unsafe(method_family = none)]
54        pub unsafe fn confidence(&self) -> c_float;
55
56        /// Setter for [`confidence`][Self::confidence].
57        #[unsafe(method(setConfidence:))]
58        #[unsafe(method_family = none)]
59        pub unsafe fn setConfidence(&self, confidence: c_float);
60    );
61}
62
63/// Methods declared on superclass `NSObject`.
64impl CNBoundsPrediction {
65    extern_methods!(
66        #[unsafe(method(init))]
67        #[unsafe(method_family = init)]
68        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
69
70        #[unsafe(method(new))]
71        #[unsafe(method_family = new)]
72        pub unsafe fn new() -> Retained<Self>;
73    );
74}
75
76extern_class!(
77    /// Converts a normalized point or rectangle into a detection track that tracks an object over time.
78    ///
79    /// See also [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnobjecttracker?language=objc)
80    #[unsafe(super(NSObject))]
81    #[derive(Debug, PartialEq, Eq, Hash)]
82    pub struct CNObjectTracker;
83);
84
85extern_conformance!(
86    unsafe impl NSObjectProtocol for CNObjectTracker {}
87);
88
89impl CNObjectTracker {
90    extern_methods!(
91        /// Indicates whether the current device supports object detection and tracking.
92        #[unsafe(method(isSupported))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn isSupported() -> bool;
95
96        #[cfg(feature = "objc2-metal")]
97        /// Create a new detection track builder.
98        /// - Parameters:
99        /// - commandQueue: the command queue of a metal device to which commands should be submitted to perform work
100        #[unsafe(method(initWithCommandQueue:))]
101        #[unsafe(method_family = init)]
102        pub unsafe fn initWithCommandQueue(
103            this: Allocated<Self>,
104            command_queue: &ProtocolObject<dyn MTLCommandQueue>,
105        ) -> Retained<Self>;
106
107        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-video"))]
108        /// Find the bounds of an object at the given point. Can be used to convert a normalized point in an image to a rectangle that can be used to start tracking.
109        /// - Parameters:
110        /// - point: location of object in image in normalized coordinates where (0.0, 0.0) is the upper left corner, and (1.0, 1.0) is the lower right
111        /// - sourceImage: pixel buffer containing the image
112        /// - Returns: A prediction, which includes bounds that can be used to start tracking, or `nil` if no discernible object is detected.
113        #[unsafe(method(findObjectAtPoint:sourceImage:))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn findObjectAtPoint_sourceImage(
116            &self,
117            point: CGPoint,
118            source_image: &CVPixelBuffer,
119        ) -> Option<Retained<CNBoundsPrediction>>;
120
121        #[cfg(all(
122            feature = "objc2-core-foundation",
123            feature = "objc2-core-media",
124            feature = "objc2-core-video"
125        ))]
126        /// Start creating a detection track to track an object within the given bounds.
127        /// - Parameters:
128        /// - time: the presentation time of the first frame in the detection track
129        /// - normalizedBounds: the bounds of the object to track in normalized coordinates where (0.0, 0.0) is the upper left corner, and (1.0, 1.0) is the lower right
130        /// - sourceImage: image buffer containing the image
131        /// - sourceDisparity: disparity buffer containing depth information
132        /// - Returns: whether the object can be tracked
133        /// - Note: if the object can be tracked, a detection is added to the detection track being built
134        #[unsafe(method(startTrackingAt:within:sourceImage:sourceDisparity:))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn startTrackingAt_within_sourceImage_sourceDisparity(
137            &self,
138            time: CMTime,
139            normalized_bounds: CGRect,
140            source_image: &CVPixelBuffer,
141            source_disparity: &CVPixelBuffer,
142        ) -> bool;
143
144        #[cfg(all(feature = "objc2-core-media", feature = "objc2-core-video"))]
145        /// Continue tracking an object for which tracking has started, and add a new detection to the detection track being built.
146        /// - Parameters:
147        /// - time: the presentation time of the frame to be added to the detection track
148        /// - Returns: a prediction of where the object is in the source image
149        #[unsafe(method(continueTrackingAt:sourceImage:sourceDisparity:))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn continueTrackingAt_sourceImage_sourceDisparity(
152            &self,
153            time: CMTime,
154            source_image: &CVPixelBuffer,
155            source_disparity: &CVPixelBuffer,
156        ) -> Option<Retained<CNBoundsPrediction>>;
157
158        #[cfg(feature = "CNDetectionTrack")]
159        /// Finish constructing the detection track and return it.
160        /// - Returns: a detection track which tracks the object
161        #[unsafe(method(finishDetectionTrack))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn finishDetectionTrack(&self) -> Retained<CNDetectionTrack>;
164
165        /// Reset the builder to construct a new detection track.
166        #[unsafe(method(resetDetectionTrack))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn resetDetectionTrack(&self);
169
170        #[unsafe(method(init))]
171        #[unsafe(method_family = init)]
172        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
173
174        #[unsafe(method(new))]
175        #[unsafe(method_family = new)]
176        pub unsafe fn new() -> Retained<Self>;
177    );
178}