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"))]
84unsafe impl NSCopying for VNGenerateOpticalFlowRequest {}
85
86#[cfg(all(feature = "VNRequest", feature = "VNTargetedImageRequest"))]
87unsafe impl CopyingHelper for VNGenerateOpticalFlowRequest {
88    type Result = Self;
89}
90
91#[cfg(all(feature = "VNRequest", feature = "VNTargetedImageRequest"))]
92unsafe impl NSObjectProtocol for VNGenerateOpticalFlowRequest {}
93
94#[cfg(all(feature = "VNRequest", feature = "VNTargetedImageRequest"))]
95impl VNGenerateOpticalFlowRequest {
96    extern_methods!(
97        /// The level of accuracy used to compute the optical flow. Default is VNGenerateOpticalFlowRequestComputationAccuracyMedium.
98        ///
99        /// The computational time typically trends with the accuracy level.  This parameter allows for selective tuning by the client application.
100        #[unsafe(method(computationAccuracy))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn computationAccuracy(&self)
103            -> VNGenerateOpticalFlowRequestComputationAccuracy;
104
105        /// Setter for [`computationAccuracy`][Self::computationAccuracy].
106        #[unsafe(method(setComputationAccuracy:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn setComputationAccuracy(
109            &self,
110            computation_accuracy: VNGenerateOpticalFlowRequestComputationAccuracy,
111        );
112
113        /// Pixel format type of the output buffer. Valid values are kCVPixelFormatType_TwoComponent32Float and kCVPixelFormatType_TwoComponent16Half.
114        /// Default is kCVPixelFormatType_TwoComponent32Float.
115        #[unsafe(method(outputPixelFormat))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn outputPixelFormat(&self) -> OSType;
118
119        /// Setter for [`outputPixelFormat`][Self::outputPixelFormat].
120        #[unsafe(method(setOutputPixelFormat:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn setOutputPixelFormat(&self, output_pixel_format: OSType);
123
124        /// Setting this to YES will keep the raw pixel buffer coming from the the ML network. The default is NO.
125        ///
126        /// When set to YES, the outputPixelFormat is ignored. Setting this for revision 1 is a no-op as it is not ML-based.
127        #[unsafe(method(keepNetworkOutput))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn keepNetworkOutput(&self) -> bool;
130
131        /// Setter for [`keepNetworkOutput`][Self::keepNetworkOutput].
132        #[unsafe(method(setKeepNetworkOutput:))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn setKeepNetworkOutput(&self, keep_network_output: bool);
135
136        #[cfg(feature = "VNObservation")]
137        /// VNPixelBufferObservation results.
138        #[unsafe(method(results))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn results(&self) -> Option<Retained<NSArray<VNPixelBufferObservation>>>;
141    );
142}
143
144/// Methods declared on superclass `VNTargetedImageRequest`.
145#[cfg(all(feature = "VNRequest", feature = "VNTargetedImageRequest"))]
146impl VNGenerateOpticalFlowRequest {
147    extern_methods!(
148        #[unsafe(method(init))]
149        #[unsafe(method_family = init)]
150        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
151
152        #[cfg(feature = "block2")]
153        #[unsafe(method(initWithCompletionHandler:))]
154        #[unsafe(method_family = init)]
155        pub unsafe fn initWithCompletionHandler(
156            this: Allocated<Self>,
157            completion_handler: VNRequestCompletionHandler,
158        ) -> Retained<Self>;
159
160        #[cfg(all(feature = "VNRequestHandler", feature = "objc2-core-video"))]
161        /// Create a new request that targets an image in a pixel buffer.
162        ///
163        ///
164        /// Parameter `pixelBuffer`: The pixel buffer containing the targeted image.
165        ///
166        /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
167        #[unsafe(method(initWithTargetedCVPixelBuffer:options:))]
168        #[unsafe(method_family = init)]
169        pub unsafe fn initWithTargetedCVPixelBuffer_options(
170            this: Allocated<Self>,
171            pixel_buffer: &CVPixelBuffer,
172            options: &NSDictionary<VNImageOption, AnyObject>,
173        ) -> Retained<Self>;
174
175        #[cfg(all(
176            feature = "VNRequestHandler",
177            feature = "block2",
178            feature = "objc2-core-video"
179        ))]
180        /// Create a new request that targets an image in a pixel buffer.
181        ///
182        ///
183        /// Parameter `pixelBuffer`: The pixel buffer containing the targeted image.
184        ///
185        /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
186        ///
187        /// Parameter `completionHandler`: The block that is invoked when the request has been performed.
188        #[unsafe(method(initWithTargetedCVPixelBuffer:options:completionHandler:))]
189        #[unsafe(method_family = init)]
190        pub unsafe fn initWithTargetedCVPixelBuffer_options_completionHandler(
191            this: Allocated<Self>,
192            pixel_buffer: &CVPixelBuffer,
193            options: &NSDictionary<VNImageOption, AnyObject>,
194            completion_handler: VNRequestCompletionHandler,
195        ) -> Retained<Self>;
196
197        #[cfg(all(feature = "VNRequestHandler", feature = "objc2-core-graphics"))]
198        /// Create a new request with a targeted CGImage.
199        ///
200        ///
201        /// Parameter `cgImage`: The CGImageRef of the targeted image.
202        ///
203        /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
204        #[unsafe(method(initWithTargetedCGImage:options:))]
205        #[unsafe(method_family = init)]
206        pub unsafe fn initWithTargetedCGImage_options(
207            this: Allocated<Self>,
208            cg_image: &CGImage,
209            options: &NSDictionary<VNImageOption, AnyObject>,
210        ) -> Retained<Self>;
211
212        #[cfg(all(
213            feature = "VNRequestHandler",
214            feature = "block2",
215            feature = "objc2-core-graphics"
216        ))]
217        /// Create a new request with a targeted CGImage.
218        ///
219        ///
220        /// Parameter `cgImage`: The CGImageRef of the targeted image.
221        ///
222        /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
223        ///
224        /// Parameter `completionHandler`: The block that is invoked when the request has been performed.
225        #[unsafe(method(initWithTargetedCGImage:options:completionHandler:))]
226        #[unsafe(method_family = init)]
227        pub unsafe fn initWithTargetedCGImage_options_completionHandler(
228            this: Allocated<Self>,
229            cg_image: &CGImage,
230            options: &NSDictionary<VNImageOption, AnyObject>,
231            completion_handler: VNRequestCompletionHandler,
232        ) -> Retained<Self>;
233
234        #[cfg(all(feature = "VNRequestHandler", feature = "objc2-core-image"))]
235        /// Create a new request with a targeted CIImage.
236        ///
237        ///
238        /// Parameter `ciImage`: The CIImage of the targeted image.
239        ///
240        /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
241        #[unsafe(method(initWithTargetedCIImage:options:))]
242        #[unsafe(method_family = init)]
243        pub unsafe fn initWithTargetedCIImage_options(
244            this: Allocated<Self>,
245            ci_image: &CIImage,
246            options: &NSDictionary<VNImageOption, AnyObject>,
247        ) -> Retained<Self>;
248
249        #[cfg(all(
250            feature = "VNRequestHandler",
251            feature = "block2",
252            feature = "objc2-core-image"
253        ))]
254        /// Create a new request with a targeted CIImage.
255        ///
256        ///
257        /// Parameter `ciImage`: The CIImage of the targeted image.
258        ///
259        /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
260        ///
261        /// Parameter `completionHandler`: The block that is invoked when the request has been performed.
262        #[unsafe(method(initWithTargetedCIImage:options:completionHandler:))]
263        #[unsafe(method_family = init)]
264        pub unsafe fn initWithTargetedCIImage_options_completionHandler(
265            this: Allocated<Self>,
266            ci_image: &CIImage,
267            options: &NSDictionary<VNImageOption, AnyObject>,
268            completion_handler: VNRequestCompletionHandler,
269        ) -> Retained<Self>;
270
271        #[cfg(feature = "VNRequestHandler")]
272        /// Create a new request with a targeted image URL.
273        ///
274        ///
275        /// Parameter `imageURL`: The URL of the targeted image.
276        ///
277        /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
278        #[unsafe(method(initWithTargetedImageURL:options:))]
279        #[unsafe(method_family = init)]
280        pub unsafe fn initWithTargetedImageURL_options(
281            this: Allocated<Self>,
282            image_url: &NSURL,
283            options: &NSDictionary<VNImageOption, AnyObject>,
284        ) -> Retained<Self>;
285
286        #[cfg(all(feature = "VNRequestHandler", feature = "block2"))]
287        /// Create a new request with a targeted image URL.
288        ///
289        ///
290        /// Parameter `imageURL`: The URL of the targeted image.
291        ///
292        /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
293        ///
294        /// Parameter `completionHandler`: The block that is invoked when the request has been performed.
295        #[unsafe(method(initWithTargetedImageURL:options:completionHandler:))]
296        #[unsafe(method_family = init)]
297        pub unsafe fn initWithTargetedImageURL_options_completionHandler(
298            this: Allocated<Self>,
299            image_url: &NSURL,
300            options: &NSDictionary<VNImageOption, AnyObject>,
301            completion_handler: VNRequestCompletionHandler,
302        ) -> Retained<Self>;
303
304        #[cfg(feature = "VNRequestHandler")]
305        /// Create a new request with a targeted image data.
306        ///
307        ///
308        /// Parameter `imageData`: The data of the targeted image.
309        ///
310        /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
311        #[unsafe(method(initWithTargetedImageData:options:))]
312        #[unsafe(method_family = init)]
313        pub unsafe fn initWithTargetedImageData_options(
314            this: Allocated<Self>,
315            image_data: &NSData,
316            options: &NSDictionary<VNImageOption, AnyObject>,
317        ) -> Retained<Self>;
318
319        #[cfg(all(feature = "VNRequestHandler", feature = "block2"))]
320        /// Create a new request with a targeted image data.
321        ///
322        ///
323        /// Parameter `imageData`: The data of the targeted image.
324        ///
325        /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
326        ///
327        /// Parameter `completionHandler`: The block that is invoked when the request has been performed.
328        #[unsafe(method(initWithTargetedImageData:options:completionHandler:))]
329        #[unsafe(method_family = init)]
330        pub unsafe fn initWithTargetedImageData_options_completionHandler(
331            this: Allocated<Self>,
332            image_data: &NSData,
333            options: &NSDictionary<VNImageOption, AnyObject>,
334            completion_handler: VNRequestCompletionHandler,
335        ) -> Retained<Self>;
336
337        #[cfg(all(feature = "VNRequestHandler", feature = "objc2-core-media"))]
338        /// Create a new request with a targeted CMSampleBuffer.
339        ///
340        ///
341        /// Parameter `sampleBuffer`: The CMSampleBuffer containing the CVImageBuffer to be used by the request.
342        ///
343        /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
344        #[unsafe(method(initWithTargetedCMSampleBuffer:options:))]
345        #[unsafe(method_family = init)]
346        pub unsafe fn initWithTargetedCMSampleBuffer_options(
347            this: Allocated<Self>,
348            sample_buffer: &CMSampleBuffer,
349            options: &NSDictionary<VNImageOption, AnyObject>,
350        ) -> Retained<Self>;
351
352        #[cfg(all(
353            feature = "VNRequestHandler",
354            feature = "block2",
355            feature = "objc2-core-media"
356        ))]
357        /// Create a new request with a targeted CMSampleBuffer.
358        ///
359        ///
360        /// Parameter `sampleBuffer`: The CMSampleBuffer containing the CVImageBuffer to be used by the request.
361        ///
362        /// Parameter `options`: A dictionary with options specifying auxiliary information for the image.
363        ///
364        /// Parameter `completionHandler`: The block that is invoked after the request has been performed.
365        #[unsafe(method(initWithTargetedCMSampleBuffer:options:completionHandler:))]
366        #[unsafe(method_family = init)]
367        pub unsafe fn initWithTargetedCMSampleBuffer_options_completionHandler(
368            this: Allocated<Self>,
369            sample_buffer: &CMSampleBuffer,
370            options: &NSDictionary<VNImageOption, AnyObject>,
371            completion_handler: VNRequestCompletionHandler,
372        ) -> Retained<Self>;
373    );
374}
375
376/// Methods declared on superclass `NSObject`.
377#[cfg(all(feature = "VNRequest", feature = "VNTargetedImageRequest"))]
378impl VNGenerateOpticalFlowRequest {
379    extern_methods!(
380        #[unsafe(method(new))]
381        #[unsafe(method_family = new)]
382        pub unsafe fn new() -> Retained<Self>;
383    );
384}
385
386/// [Apple's documentation](https://developer.apple.com/documentation/vision/vngenerateopticalflowrequestrevision1?language=objc)
387pub static VNGenerateOpticalFlowRequestRevision1: NSUInteger = 1;
388
389/// [Apple's documentation](https://developer.apple.com/documentation/vision/vngenerateopticalflowrequestrevision2?language=objc)
390pub static VNGenerateOpticalFlowRequestRevision2: NSUInteger = 2;