objc2_vision/generated/VNGenerateOpticalFlowRequest.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-graphics")]
7use objc2_core_graphics::*;
8#[cfg(feature = "objc2-core-image")]
9use objc2_core_image::*;
10#[cfg(feature = "objc2-core-media")]
11use objc2_core_media::*;
12#[cfg(feature = "objc2-core-video")]
13use objc2_core_video::*;
14use objc2_foundation::*;
15
16use crate::*;
17
18/// The level of optical flow computational accuracy.
19///
20/// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vngenerateopticalflowrequestcomputationaccuracy?language=objc)
21// NS_ENUM
22#[repr(transparent)]
23#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
24pub struct VNGenerateOpticalFlowRequestComputationAccuracy(pub NSUInteger);
25impl VNGenerateOpticalFlowRequestComputationAccuracy {
26 #[doc(alias = "VNGenerateOpticalFlowRequestComputationAccuracyLow")]
27 pub const Low: Self = Self(0);
28 #[doc(alias = "VNGenerateOpticalFlowRequestComputationAccuracyMedium")]
29 pub const Medium: Self = Self(1);
30 #[doc(alias = "VNGenerateOpticalFlowRequestComputationAccuracyHigh")]
31 pub const High: Self = Self(2);
32 #[doc(alias = "VNGenerateOpticalFlowRequestComputationAccuracyVeryHigh")]
33 pub const VeryHigh: Self = Self(3);
34}
35
36unsafe impl Encode for VNGenerateOpticalFlowRequestComputationAccuracy {
37 const ENCODING: Encoding = NSUInteger::ENCODING;
38}
39
40unsafe impl RefEncode for VNGenerateOpticalFlowRequestComputationAccuracy {
41 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44extern_class!(
45 /// VNGenerateOpticalFlowRequest will determine directional change vectors for each pixel in the targeted image to transform it into the image processed
46 /// by the request handler, reporting this result with a single VNPixelBufferObservation.
47 ///
48 ///
49 /// Because this request works at the pixel level, both images must have the same dimensions in order for the request to be successfully performed.
50 /// Setting a region of interest will isolate where the change determination is performed; however, the resultant observation will still be reported
51 /// with a full resolution VNPixelBufferObservation.
52 ///
53 /// Optical flow requests are very resource intensive, so it is recommended that only one request at a time be created and that the handler
54 /// where the request was issued be released immediately after generating optical flows.
55 ///
56 /// Example usage:
57 ///
58 /// - (nullable VNPixelBufferObservation*) opticalFlowFromImage:(CVPixelBufferRef)fromImage toImage:(CVPixelBuffer)toImage error:(NSError**)error
59 /// {
60 /// VNImageRequestHandler* imageRequestHandler = [[VNImageRequestHandler alloc] initWithCVPixelBuffer:fromImage options:
61 /// @
62 /// {}];
63 /// VNGenerateOpticalFlowRequest* request = [[VNGenerateOpticalFlowRequest alloc] initWithTargetedCVPixelBuffer:toImage options:
64 /// @
65 /// {}];
66 /// if (![imageRequestHandler performRequests:
67 /// @
68 /// [ request ] error:error])
69 /// {
70 /// return nil;
71 /// }
72 ///
73 /// return [[request results] firstObject];
74 /// }
75 ///
76 /// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vngenerateopticalflowrequest?language=objc)
77 #[unsafe(super(VNTargetedImageRequest, VNImageBasedRequest, VNRequest, NSObject))]
78 #[derive(Debug, PartialEq, Eq, Hash)]
79 #[cfg(all(feature = "VNRequest", feature = "VNTargetedImageRequest"))]
80 pub struct VNGenerateOpticalFlowRequest;
81);
82
83#[cfg(all(feature = "VNRequest", feature = "VNTargetedImageRequest"))]
84extern_conformance!(
85 unsafe impl NSCopying for VNGenerateOpticalFlowRequest {}
86);
87
88#[cfg(all(feature = "VNRequest", feature = "VNTargetedImageRequest"))]
89unsafe impl CopyingHelper for VNGenerateOpticalFlowRequest {
90 type Result = Self;
91}
92
93#[cfg(all(feature = "VNRequest", feature = "VNTargetedImageRequest"))]
94extern_conformance!(
95 unsafe impl NSObjectProtocol for VNGenerateOpticalFlowRequest {}
96);
97
98#[cfg(all(feature = "VNRequest", feature = "VNTargetedImageRequest"))]
99impl VNGenerateOpticalFlowRequest {
100 extern_methods!(
101 /// The level of accuracy used to compute the optical flow. Default is VNGenerateOpticalFlowRequestComputationAccuracyMedium.
102 ///
103 /// The computational time typically trends with the accuracy level. This parameter allows for selective tuning by the client application.
104 #[unsafe(method(computationAccuracy))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn computationAccuracy(&self)
107 -> VNGenerateOpticalFlowRequestComputationAccuracy;
108
109 /// Setter for [`computationAccuracy`][Self::computationAccuracy].
110 #[unsafe(method(setComputationAccuracy:))]
111 #[unsafe(method_family = none)]
112 pub unsafe fn setComputationAccuracy(
113 &self,
114 computation_accuracy: VNGenerateOpticalFlowRequestComputationAccuracy,
115 );
116
117 /// Pixel format type of the output buffer. Valid values are kCVPixelFormatType_TwoComponent32Float and kCVPixelFormatType_TwoComponent16Half.
118 /// Default is kCVPixelFormatType_TwoComponent32Float.
119 #[unsafe(method(outputPixelFormat))]
120 #[unsafe(method_family = none)]
121 pub unsafe fn outputPixelFormat(&self) -> OSType;
122
123 /// Setter for [`outputPixelFormat`][Self::outputPixelFormat].
124 #[unsafe(method(setOutputPixelFormat:))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn setOutputPixelFormat(&self, output_pixel_format: OSType);
127
128 /// Setting this to YES will keep the raw pixel buffer coming from the the ML network. The default is NO.
129 ///
130 /// When set to YES, the outputPixelFormat is ignored. Setting this for revision 1 is a no-op as it is not ML-based.
131 #[unsafe(method(keepNetworkOutput))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn keepNetworkOutput(&self) -> bool;
134
135 /// Setter for [`keepNetworkOutput`][Self::keepNetworkOutput].
136 #[unsafe(method(setKeepNetworkOutput:))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn setKeepNetworkOutput(&self, keep_network_output: bool);
139
140 #[cfg(feature = "VNObservation")]
141 /// VNPixelBufferObservation results.
142 #[unsafe(method(results))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn results(&self) -> Option<Retained<NSArray<VNPixelBufferObservation>>>;
145 );
146}
147
148/// Methods declared on superclass `VNTargetedImageRequest`.
149#[cfg(all(feature = "VNRequest", feature = "VNTargetedImageRequest"))]
150impl VNGenerateOpticalFlowRequest {
151 extern_methods!(
152 #[unsafe(method(init))]
153 #[unsafe(method_family = init)]
154 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
155
156 #[cfg(feature = "block2")]
157 #[unsafe(method(initWithCompletionHandler:))]
158 #[unsafe(method_family = init)]
159 pub unsafe fn initWithCompletionHandler(
160 this: Allocated<Self>,
161 completion_handler: VNRequestCompletionHandler,
162 ) -> Retained<Self>;
163
164 #[cfg(all(feature = "VNRequestHandler", feature = "objc2-core-video"))]
165 /// Create a new request that targets an image in a pixel buffer.
166 ///
167 ///
168 /// Parameter `pixelBuffer`: The pixel buffer containing the targeted image.
169 ///
170 /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
171 #[unsafe(method(initWithTargetedCVPixelBuffer:options:))]
172 #[unsafe(method_family = init)]
173 pub unsafe fn initWithTargetedCVPixelBuffer_options(
174 this: Allocated<Self>,
175 pixel_buffer: &CVPixelBuffer,
176 options: &NSDictionary<VNImageOption, AnyObject>,
177 ) -> Retained<Self>;
178
179 #[cfg(all(
180 feature = "VNRequestHandler",
181 feature = "block2",
182 feature = "objc2-core-video"
183 ))]
184 /// Create a new request that targets an image in a pixel buffer.
185 ///
186 ///
187 /// Parameter `pixelBuffer`: The pixel buffer containing the targeted image.
188 ///
189 /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
190 ///
191 /// Parameter `completionHandler`: The block that is invoked when the request has been performed.
192 #[unsafe(method(initWithTargetedCVPixelBuffer:options:completionHandler:))]
193 #[unsafe(method_family = init)]
194 pub unsafe fn initWithTargetedCVPixelBuffer_options_completionHandler(
195 this: Allocated<Self>,
196 pixel_buffer: &CVPixelBuffer,
197 options: &NSDictionary<VNImageOption, AnyObject>,
198 completion_handler: VNRequestCompletionHandler,
199 ) -> Retained<Self>;
200
201 #[cfg(all(feature = "VNRequestHandler", feature = "objc2-core-graphics"))]
202 /// Create a new request with a targeted CGImage.
203 ///
204 ///
205 /// Parameter `cgImage`: The CGImageRef of the targeted image.
206 ///
207 /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
208 #[unsafe(method(initWithTargetedCGImage:options:))]
209 #[unsafe(method_family = init)]
210 pub unsafe fn initWithTargetedCGImage_options(
211 this: Allocated<Self>,
212 cg_image: &CGImage,
213 options: &NSDictionary<VNImageOption, AnyObject>,
214 ) -> Retained<Self>;
215
216 #[cfg(all(
217 feature = "VNRequestHandler",
218 feature = "block2",
219 feature = "objc2-core-graphics"
220 ))]
221 /// Create a new request with a targeted CGImage.
222 ///
223 ///
224 /// Parameter `cgImage`: The CGImageRef of the targeted image.
225 ///
226 /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
227 ///
228 /// Parameter `completionHandler`: The block that is invoked when the request has been performed.
229 #[unsafe(method(initWithTargetedCGImage:options:completionHandler:))]
230 #[unsafe(method_family = init)]
231 pub unsafe fn initWithTargetedCGImage_options_completionHandler(
232 this: Allocated<Self>,
233 cg_image: &CGImage,
234 options: &NSDictionary<VNImageOption, AnyObject>,
235 completion_handler: VNRequestCompletionHandler,
236 ) -> Retained<Self>;
237
238 #[cfg(all(feature = "VNRequestHandler", feature = "objc2-core-image"))]
239 /// Create a new request with a targeted CIImage.
240 ///
241 ///
242 /// Parameter `ciImage`: The CIImage of the targeted image.
243 ///
244 /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
245 #[unsafe(method(initWithTargetedCIImage:options:))]
246 #[unsafe(method_family = init)]
247 pub unsafe fn initWithTargetedCIImage_options(
248 this: Allocated<Self>,
249 ci_image: &CIImage,
250 options: &NSDictionary<VNImageOption, AnyObject>,
251 ) -> Retained<Self>;
252
253 #[cfg(all(
254 feature = "VNRequestHandler",
255 feature = "block2",
256 feature = "objc2-core-image"
257 ))]
258 /// Create a new request with a targeted CIImage.
259 ///
260 ///
261 /// Parameter `ciImage`: The CIImage of the targeted image.
262 ///
263 /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
264 ///
265 /// Parameter `completionHandler`: The block that is invoked when the request has been performed.
266 #[unsafe(method(initWithTargetedCIImage:options:completionHandler:))]
267 #[unsafe(method_family = init)]
268 pub unsafe fn initWithTargetedCIImage_options_completionHandler(
269 this: Allocated<Self>,
270 ci_image: &CIImage,
271 options: &NSDictionary<VNImageOption, AnyObject>,
272 completion_handler: VNRequestCompletionHandler,
273 ) -> Retained<Self>;
274
275 #[cfg(feature = "VNRequestHandler")]
276 /// Create a new request with a targeted image URL.
277 ///
278 ///
279 /// Parameter `imageURL`: The URL of the targeted image.
280 ///
281 /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
282 #[unsafe(method(initWithTargetedImageURL:options:))]
283 #[unsafe(method_family = init)]
284 pub unsafe fn initWithTargetedImageURL_options(
285 this: Allocated<Self>,
286 image_url: &NSURL,
287 options: &NSDictionary<VNImageOption, AnyObject>,
288 ) -> Retained<Self>;
289
290 #[cfg(all(feature = "VNRequestHandler", feature = "block2"))]
291 /// Create a new request with a targeted image URL.
292 ///
293 ///
294 /// Parameter `imageURL`: The URL of the targeted image.
295 ///
296 /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
297 ///
298 /// Parameter `completionHandler`: The block that is invoked when the request has been performed.
299 #[unsafe(method(initWithTargetedImageURL:options:completionHandler:))]
300 #[unsafe(method_family = init)]
301 pub unsafe fn initWithTargetedImageURL_options_completionHandler(
302 this: Allocated<Self>,
303 image_url: &NSURL,
304 options: &NSDictionary<VNImageOption, AnyObject>,
305 completion_handler: VNRequestCompletionHandler,
306 ) -> Retained<Self>;
307
308 #[cfg(feature = "VNRequestHandler")]
309 /// Create a new request with a targeted image data.
310 ///
311 ///
312 /// Parameter `imageData`: The data of the targeted image.
313 ///
314 /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
315 #[unsafe(method(initWithTargetedImageData:options:))]
316 #[unsafe(method_family = init)]
317 pub unsafe fn initWithTargetedImageData_options(
318 this: Allocated<Self>,
319 image_data: &NSData,
320 options: &NSDictionary<VNImageOption, AnyObject>,
321 ) -> Retained<Self>;
322
323 #[cfg(all(feature = "VNRequestHandler", feature = "block2"))]
324 /// Create a new request with a targeted image data.
325 ///
326 ///
327 /// Parameter `imageData`: The data of the targeted image.
328 ///
329 /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
330 ///
331 /// Parameter `completionHandler`: The block that is invoked when the request has been performed.
332 #[unsafe(method(initWithTargetedImageData:options:completionHandler:))]
333 #[unsafe(method_family = init)]
334 pub unsafe fn initWithTargetedImageData_options_completionHandler(
335 this: Allocated<Self>,
336 image_data: &NSData,
337 options: &NSDictionary<VNImageOption, AnyObject>,
338 completion_handler: VNRequestCompletionHandler,
339 ) -> Retained<Self>;
340
341 #[cfg(all(feature = "VNRequestHandler", feature = "objc2-core-media"))]
342 /// Create a new request with a targeted CMSampleBuffer.
343 ///
344 ///
345 /// Parameter `sampleBuffer`: The CMSampleBuffer containing the CVImageBuffer to be used by the request.
346 ///
347 /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
348 #[unsafe(method(initWithTargetedCMSampleBuffer:options:))]
349 #[unsafe(method_family = init)]
350 pub unsafe fn initWithTargetedCMSampleBuffer_options(
351 this: Allocated<Self>,
352 sample_buffer: &CMSampleBuffer,
353 options: &NSDictionary<VNImageOption, AnyObject>,
354 ) -> Retained<Self>;
355
356 #[cfg(all(
357 feature = "VNRequestHandler",
358 feature = "block2",
359 feature = "objc2-core-media"
360 ))]
361 /// Create a new request with a targeted CMSampleBuffer.
362 ///
363 ///
364 /// Parameter `sampleBuffer`: The CMSampleBuffer containing the CVImageBuffer to be used by the request.
365 ///
366 /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
367 ///
368 /// Parameter `completionHandler`: The block that is invoked after the request has been performed.
369 #[unsafe(method(initWithTargetedCMSampleBuffer:options:completionHandler:))]
370 #[unsafe(method_family = init)]
371 pub unsafe fn initWithTargetedCMSampleBuffer_options_completionHandler(
372 this: Allocated<Self>,
373 sample_buffer: &CMSampleBuffer,
374 options: &NSDictionary<VNImageOption, AnyObject>,
375 completion_handler: VNRequestCompletionHandler,
376 ) -> Retained<Self>;
377 );
378}
379
380/// Methods declared on superclass `NSObject`.
381#[cfg(all(feature = "VNRequest", feature = "VNTargetedImageRequest"))]
382impl VNGenerateOpticalFlowRequest {
383 extern_methods!(
384 #[unsafe(method(new))]
385 #[unsafe(method_family = new)]
386 pub unsafe fn new() -> Retained<Self>;
387 );
388}
389
390/// [Apple's documentation](https://developer.apple.com/documentation/vision/vngenerateopticalflowrequestrevision1?language=objc)
391pub static VNGenerateOpticalFlowRequestRevision1: NSUInteger = 1;
392
393/// [Apple's documentation](https://developer.apple.com/documentation/vision/vngenerateopticalflowrequestrevision2?language=objc)
394pub static VNGenerateOpticalFlowRequestRevision2: NSUInteger = 2;