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