objc2_vision/generated/
VNRequestHandler.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5#[cfg(feature = "objc2-core-graphics")]
6use objc2_core_graphics::*;
7#[cfg(feature = "objc2-core-image")]
8use objc2_core_image::*;
9#[cfg(feature = "objc2-core-media")]
10use objc2_core_media::*;
11#[cfg(feature = "objc2-core-video")]
12use objc2_core_video::*;
13use objc2_foundation::*;
14
15use crate::*;
16
17/// Options keys passed into the VNImageRequestHandler creations or requests that take an auxiliary image. These are options that either describe specific properties of an image like the VNImageOptionCameraIntrinsics or how an image needs to be handled like the VNImageOptionCIContext.
18///
19/// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnimageoption?language=objc)
20// NS_TYPED_ENUM
21pub type VNImageOption = NSString;
22
23extern "C" {
24    /// VNImageOptionProperties is the dictionary from CGImageSourceCopyPropertiesAtIndex. This contains metadata that can be used by some algorithms like horizon detection.
25    ///
26    /// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnimageoptionproperties?language=objc)
27    pub static VNImageOptionProperties: &'static VNImageOption;
28}
29
30extern "C" {
31    /// VNImageOptionCameraIntrinsics  Specifies the camera intrinsics as an NSData or CFData representing a matrix_float3x3. See kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix for details
32    ///
33    /// Camera intrinsic matrix is a CFData containing a matrix_float3x3, which is column-major. It has the following contents:
34    /// fx    0    ox
35    /// 0    fy    oy
36    /// 0    0    1
37    /// fx and fy are the focal length in pixels. For square pixels, they will have the same value.
38    /// ox and oy are the coordinates of the principal point. The origin is the upper left of the frame.
39    ///
40    /// Note: When using a CMSampleBuffer as an input and that sample buffer has camera intrinsics attached to it, Vision will use the camera intrinsic from there unless overwritten by passing in as an explicit option which will take precedence.
41    ///
42    /// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnimageoptioncameraintrinsics?language=objc)
43    pub static VNImageOptionCameraIntrinsics: &'static VNImageOption;
44}
45
46extern "C" {
47    /// VNImageOptionCIContext  Specifies the CIContext to be used in Core Image operations of request handler. If this is not specified, Vision will create its own CIContext. This option is helpful when the passed in CIImage is the result of a CIFilter chain that has been executed on a CIContext or uses outputs of a CIImage on a given CIContext as they don't have to transfer to other contexts.
48    ///
49    /// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnimageoptioncicontext?language=objc)
50    pub static VNImageOptionCIContext: &'static VNImageOption;
51}
52
53extern_class!(
54    /// Performs requests on a single image.
55    ///
56    /// The VNImageRequestHandler is created with an image that is used to be used for the requests a client might want to schedule. The VNImageRequestHandler retains, but never modifies, the image source for its entire lifetime. The client also must not modify the content of the image source once the VNImageRequestHandler is created otherwise the results are undefined.
57    /// The VNImageRequestHandler can choose to also cache intermediate representation of the image or other request-specific information for the purposes of runtime performance.
58    ///
59    /// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnimagerequesthandler?language=objc)
60    #[unsafe(super(NSObject))]
61    #[derive(Debug, PartialEq, Eq, Hash)]
62    pub struct VNImageRequestHandler;
63);
64
65unsafe impl NSObjectProtocol for VNImageRequestHandler {}
66
67impl VNImageRequestHandler {
68    extern_methods!(
69        #[unsafe(method(init))]
70        #[unsafe(method_family = init)]
71        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
72
73        #[cfg(feature = "objc2-core-video")]
74        /// initWithCVPixelBuffer:options creates a VNImageRequestHandler to be used for performing requests against the image passed in as buffer.
75        ///
76        ///
77        /// Parameter `pixelBuffer`: A CVPixelBuffer containing the image to be used for performing the requests. The content of the buffer cannot be modified for the lifetime of the VNImageRequestHandler.
78        ///
79        /// Parameter `options`: A dictionary with options specifying auxiliary information for the buffer/image like VNImageOptionCameraIntrinsics
80        #[unsafe(method(initWithCVPixelBuffer:options:))]
81        #[unsafe(method_family = init)]
82        pub unsafe fn initWithCVPixelBuffer_options(
83            this: Allocated<Self>,
84            pixel_buffer: &CVPixelBuffer,
85            options: &NSDictionary<VNImageOption, AnyObject>,
86        ) -> Retained<Self>;
87
88        #[cfg(feature = "objc2-core-graphics")]
89        /// initWithCGImage:options creates a VNImageRequestHandler to be used for performing requests against the image passed in as a CGImageRef.
90        ///
91        ///
92        /// Parameter `image`: A CGImageRef containing the image to be used for performing the requests. The content of the image cannot be modified.
93        ///
94        /// Parameter `options`: A dictionary with options specifying auxiliary information for the buffer/image like VNImageOptionCameraIntrinsics
95        #[unsafe(method(initWithCGImage:options:))]
96        #[unsafe(method_family = init)]
97        pub unsafe fn initWithCGImage_options(
98            this: Allocated<Self>,
99            image: &CGImage,
100            options: &NSDictionary<VNImageOption, AnyObject>,
101        ) -> Retained<Self>;
102
103        #[cfg(feature = "objc2-core-image")]
104        /// initWithCIImage:options creates a VNImageRequestHandler to be used for performing requests against the image passed in as a CIImage.
105        ///
106        ///
107        /// Parameter `image`: A CIImage containing the image to be used for performing the requests. The content of the image cannot be modified.
108        ///
109        /// Parameter `options`: A dictionary with options specifying auxiliary information for the buffer/image like VNImageOptionCameraIntrinsics
110        ///
111        ///
112        /// Note: :  Request results may not be accurate in simulator due to CI's inability to render certain pixel formats in the simulator. The orientation of the original image should be applied for instance by using imageByApplyingOrientation or use the initWithCIImage:options:orientation API.
113        #[unsafe(method(initWithCIImage:options:))]
114        #[unsafe(method_family = init)]
115        pub unsafe fn initWithCIImage_options(
116            this: Allocated<Self>,
117            image: &CIImage,
118            options: &NSDictionary<VNImageOption, AnyObject>,
119        ) -> Retained<Self>;
120
121        /// initWithURL:options creates a VNImageRequestHandler to be used for performing requests against an image specified by it's URL
122        ///
123        ///
124        /// Parameter `imageURL`: A URL pointing at an image to be used for performing the requests. The image has to be in a format that is supported by ImageIO. The content of the image cannot be modified.
125        ///
126        /// Parameter `options`: A dictionary with options specifying auxiliary information for the buffer/image like VNImageOptionCameraIntrinsics
127        ///
128        ///
129        /// Note: :  Request results may not be accurate in simulator due to CI's inability to render certain pixel formats in the simulator
130        #[unsafe(method(initWithURL:options:))]
131        #[unsafe(method_family = init)]
132        pub unsafe fn initWithURL_options(
133            this: Allocated<Self>,
134            image_url: &NSURL,
135            options: &NSDictionary<VNImageOption, AnyObject>,
136        ) -> Retained<Self>;
137
138        /// initWithData:options creates a VNImageRequestHandler to be used for performing requests against an image contained in an NSData object.
139        ///
140        ///
141        /// Parameter `imageData`: An NSData object containing the content of the image to be used for performing the requests. See CIImage imageWithData for supported format. The content of the image cannot be modified.
142        ///
143        /// Parameter `options`: A dictionary with options specifying auxiliary information for the buffer/image like VNImageOptionCameraIntrinsics
144        ///
145        ///
146        /// Note: :  Request results may not be accurate in simulator due to CI's inability to render certain pixel formats in the simulator
147        #[unsafe(method(initWithData:options:))]
148        #[unsafe(method_family = init)]
149        pub fn initWithData_options(
150            this: Allocated<Self>,
151            image_data: &NSData,
152            options: &NSDictionary<VNImageOption, AnyObject>,
153        ) -> Retained<Self>;
154
155        #[cfg(feature = "objc2-core-media")]
156        /// Creates a VNImageRequestHandler to be used for performing requests against the image buffer contained in the CMSampleBufferRef
157        ///
158        ///
159        /// Parameter `sampleBuffer`: A CMSampleBuffer containing the imageBuffer that will be used for performing the requests. Not all types of sample buffers are supported. They need to contain a CVImageBuffer, be valid and ready.
160        ///
161        /// Parameter `options`: A dictionary with options specifying auxiliary information for the buffer/image like VNImageOptionCameraIntrinsics
162        ///
163        /// Note: CMSampleBuffers can contain metadata like camera intrinsics that will be used by algorithms supporting it unless overwritten by the options.
164        #[unsafe(method(initWithCMSampleBuffer:options:))]
165        #[unsafe(method_family = init)]
166        pub unsafe fn initWithCMSampleBuffer_options(
167            this: Allocated<Self>,
168            sample_buffer: &CMSampleBuffer,
169            options: &NSDictionary<VNImageOption, AnyObject>,
170        ) -> Retained<Self>;
171
172        #[cfg(feature = "VNRequest")]
173        /// performRequests schedules one or more VNRequests to be performed. The function returns once all requests have been finished.
174        ///
175        ///
176        /// The results of the VNRequests as well any possible errors of the individual requests are reported in the VNRequests results and error properties.
177        ///
178        ///
179        /// Parameter `requests`: An NSArray of VNRequests that are to be performed.
180        ///
181        /// Parameter `error`: Returns an error that happened during scheduling of the requests. Check individual requests results and errors for their respective success and failures. This parameter is optional.
182        ///
183        /// Returns: Returns true if all requests were scheduled and performed. Check individual requests results and errors for their respective success and failures.
184        #[unsafe(method(performRequests:error:_))]
185        #[unsafe(method_family = none)]
186        pub fn performRequests_error(
187            &self,
188            requests: &NSArray<VNRequest>,
189        ) -> Result<(), Retained<NSError>>;
190    );
191}
192
193/// Methods declared on superclass `NSObject`.
194impl VNImageRequestHandler {
195    extern_methods!(
196        #[unsafe(method(new))]
197        #[unsafe(method_family = new)]
198        pub unsafe fn new() -> Retained<Self>;
199    );
200}
201
202extern_class!(
203    /// Performs requests on a sequence of images.
204    ///
205    /// The VNSequenceRequestHandler is created without any specific image source.  The -performRequests:on
206    /// <ImageSource
207    /// >:error: methods will retain the image source for no longer than the lifetime of the call.
208    /// The VNSequenceRequestHandler can choose to also cache state information related to the previously-processed image sources.
209    ///
210    /// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnsequencerequesthandler?language=objc)
211    #[unsafe(super(NSObject))]
212    #[derive(Debug, PartialEq, Eq, Hash)]
213    pub struct VNSequenceRequestHandler;
214);
215
216unsafe impl NSObjectProtocol for VNSequenceRequestHandler {}
217
218impl VNSequenceRequestHandler {
219    extern_methods!(
220        /// Creates a new object.
221        #[unsafe(method(init))]
222        #[unsafe(method_family = init)]
223        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
224
225        #[cfg(all(feature = "VNRequest", feature = "objc2-core-video"))]
226        /// Perform requests on an image in a CVPixelBuffer.
227        ///
228        ///
229        /// Parameter `requests`: The VNRequests to be performed on the image.
230        ///
231        ///
232        /// Parameter `pixelBuffer`: The CVPixelBuffer containing the image to be processed.
233        ///
234        ///
235        /// Parameter `error`: On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify NULL for this parameter if you do not want the error information.
236        #[unsafe(method(performRequests:onCVPixelBuffer:error:_))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn performRequests_onCVPixelBuffer_error(
239            &self,
240            requests: &NSArray<VNRequest>,
241            pixel_buffer: &CVPixelBuffer,
242        ) -> Result<(), Retained<NSError>>;
243
244        #[cfg(all(feature = "VNRequest", feature = "objc2-core-graphics"))]
245        /// Perform requests on an image in a CGImageRef.
246        ///
247        ///
248        /// Parameter `requests`: The VNRequests to be performed on the image.
249        ///
250        ///
251        /// Parameter `image`: The CGImageRef containing the image to be processed.
252        ///
253        ///
254        /// Parameter `error`: On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify NULL for this parameter if you do not want the error information.
255        #[unsafe(method(performRequests:onCGImage:error:_))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn performRequests_onCGImage_error(
258            &self,
259            requests: &NSArray<VNRequest>,
260            image: &CGImage,
261        ) -> Result<(), Retained<NSError>>;
262
263        #[cfg(all(feature = "VNRequest", feature = "objc2-core-image"))]
264        /// Perform requests on an image in a CIImage.
265        ///
266        ///
267        /// Parameter `requests`: The VNRequests to be performed on the image.
268        ///
269        ///
270        /// Parameter `image`: The CIImage containing the image to be processed.
271        ///
272        ///
273        /// Parameter `error`: On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify NULL for this parameter if you do not want the error information.
274        #[unsafe(method(performRequests:onCIImage:error:_))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn performRequests_onCIImage_error(
277            &self,
278            requests: &NSArray<VNRequest>,
279            image: &CIImage,
280        ) -> Result<(), Retained<NSError>>;
281
282        #[cfg(feature = "VNRequest")]
283        /// Perform requests on an image referenced by an URL.
284        ///
285        ///
286        /// Parameter `requests`: The VNRequests to be performed on the image.
287        ///
288        ///
289        /// Parameter `imageURL`: The URL of the image to be processed.  If this is not a file-based URL, the method will fail.
290        ///
291        ///
292        /// Parameter `error`: On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify NULL for this parameter if you do not want the error information.
293        #[unsafe(method(performRequests:onImageURL:error:_))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn performRequests_onImageURL_error(
296            &self,
297            requests: &NSArray<VNRequest>,
298            image_url: &NSURL,
299        ) -> Result<(), Retained<NSError>>;
300
301        #[cfg(feature = "VNRequest")]
302        /// Perform requests on an image with its source format in memory.
303        ///
304        ///
305        /// Parameter `requests`: The VNRequests to be performed on the image.
306        ///
307        ///
308        /// Parameter `imageData`: The data representing the source format of the image to be processed.
309        ///
310        ///
311        /// Parameter `error`: On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify NULL for this parameter if you do not want the error information.
312        #[unsafe(method(performRequests:onImageData:error:_))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn performRequests_onImageData_error(
315            &self,
316            requests: &NSArray<VNRequest>,
317            image_data: &NSData,
318        ) -> Result<(), Retained<NSError>>;
319
320        #[cfg(all(feature = "VNRequest", feature = "objc2-core-media"))]
321        /// Perform requests on the image buffer contained in the CMSampleBufferRef.
322        ///
323        ///
324        /// Parameter `requests`: The VNRequests to be performed on the image.
325        ///
326        ///
327        /// Parameter `sampleBuffer`: A CMSampleBuffer containing an image that will be used for performing the requests. Not all types of sample buffers are supported. They need to contain a CVImageBuffer, be valid and ready.
328        ///
329        ///
330        /// Parameter `error`: On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify NULL for this parameter if you do not want the error information.
331        #[unsafe(method(performRequests:onCMSampleBuffer:error:_))]
332        #[unsafe(method_family = none)]
333        pub unsafe fn performRequests_onCMSampleBuffer_error(
334            &self,
335            requests: &NSArray<VNRequest>,
336            sample_buffer: &CMSampleBuffer,
337        ) -> Result<(), Retained<NSError>>;
338    );
339}
340
341/// Methods declared on superclass `NSObject`.
342impl VNSequenceRequestHandler {
343    extern_methods!(
344        #[unsafe(method(new))]
345        #[unsafe(method_family = new)]
346        pub unsafe fn new() -> Retained<Self>;
347    );
348}