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
65extern_conformance!(
66 unsafe impl NSObjectProtocol for VNImageRequestHandler {}
67);
68
69impl VNImageRequestHandler {
70 extern_methods!(
71 #[unsafe(method(init))]
72 #[unsafe(method_family = init)]
73 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
74
75 #[cfg(feature = "objc2-core-video")]
76 /// initWithCVPixelBuffer:options creates a VNImageRequestHandler to be used for performing requests against the image passed in as buffer.
77 ///
78 ///
79 /// 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.
80 ///
81 /// Parameter `options`: A dictionary with options specifying auxiliary information for the buffer/image like VNImageOptionCameraIntrinsics
82 #[unsafe(method(initWithCVPixelBuffer:options:))]
83 #[unsafe(method_family = init)]
84 pub unsafe fn initWithCVPixelBuffer_options(
85 this: Allocated<Self>,
86 pixel_buffer: &CVPixelBuffer,
87 options: &NSDictionary<VNImageOption, AnyObject>,
88 ) -> Retained<Self>;
89
90 #[cfg(feature = "objc2-core-graphics")]
91 /// initWithCGImage:options creates a VNImageRequestHandler to be used for performing requests against the image passed in as a CGImageRef.
92 ///
93 ///
94 /// Parameter `image`: A CGImageRef containing the image to be used for performing the requests. The content of the image cannot be modified.
95 ///
96 /// Parameter `options`: A dictionary with options specifying auxiliary information for the buffer/image like VNImageOptionCameraIntrinsics
97 #[unsafe(method(initWithCGImage:options:))]
98 #[unsafe(method_family = init)]
99 pub unsafe fn initWithCGImage_options(
100 this: Allocated<Self>,
101 image: &CGImage,
102 options: &NSDictionary<VNImageOption, AnyObject>,
103 ) -> Retained<Self>;
104
105 #[cfg(feature = "objc2-core-image")]
106 /// initWithCIImage:options creates a VNImageRequestHandler to be used for performing requests against the image passed in as a CIImage.
107 ///
108 ///
109 /// Parameter `image`: A CIImage containing the image to be used for performing the requests. The content of the image cannot be modified.
110 ///
111 /// Parameter `options`: A dictionary with options specifying auxiliary information for the buffer/image like VNImageOptionCameraIntrinsics
112 ///
113 ///
114 /// 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.
115 #[unsafe(method(initWithCIImage:options:))]
116 #[unsafe(method_family = init)]
117 pub unsafe fn initWithCIImage_options(
118 this: Allocated<Self>,
119 image: &CIImage,
120 options: &NSDictionary<VNImageOption, AnyObject>,
121 ) -> Retained<Self>;
122
123 /// initWithURL:options creates a VNImageRequestHandler to be used for performing requests against an image specified by it's URL
124 ///
125 ///
126 /// 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.
127 ///
128 /// Parameter `options`: A dictionary with options specifying auxiliary information for the buffer/image like VNImageOptionCameraIntrinsics
129 ///
130 ///
131 /// Note: : Request results may not be accurate in simulator due to CI's inability to render certain pixel formats in the simulator
132 #[unsafe(method(initWithURL:options:))]
133 #[unsafe(method_family = init)]
134 pub unsafe fn initWithURL_options(
135 this: Allocated<Self>,
136 image_url: &NSURL,
137 options: &NSDictionary<VNImageOption, AnyObject>,
138 ) -> Retained<Self>;
139
140 /// initWithData:options creates a VNImageRequestHandler to be used for performing requests against an image contained in an NSData object.
141 ///
142 ///
143 /// 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.
144 ///
145 /// Parameter `options`: A dictionary with options specifying auxiliary information for the buffer/image like VNImageOptionCameraIntrinsics
146 ///
147 ///
148 /// Note: : Request results may not be accurate in simulator due to CI's inability to render certain pixel formats in the simulator
149 #[unsafe(method(initWithData:options:))]
150 #[unsafe(method_family = init)]
151 pub fn initWithData_options(
152 this: Allocated<Self>,
153 image_data: &NSData,
154 options: &NSDictionary<VNImageOption, AnyObject>,
155 ) -> Retained<Self>;
156
157 #[cfg(feature = "objc2-core-media")]
158 /// Creates a VNImageRequestHandler to be used for performing requests against the image buffer contained in the CMSampleBufferRef
159 ///
160 ///
161 /// 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.
162 ///
163 /// Parameter `options`: A dictionary with options specifying auxiliary information for the buffer/image like VNImageOptionCameraIntrinsics
164 ///
165 /// Note: CMSampleBuffers can contain metadata like camera intrinsics that will be used by algorithms supporting it unless overwritten by the options.
166 #[unsafe(method(initWithCMSampleBuffer:options:))]
167 #[unsafe(method_family = init)]
168 pub unsafe fn initWithCMSampleBuffer_options(
169 this: Allocated<Self>,
170 sample_buffer: &CMSampleBuffer,
171 options: &NSDictionary<VNImageOption, AnyObject>,
172 ) -> Retained<Self>;
173
174 #[cfg(feature = "VNRequest")]
175 /// performRequests schedules one or more VNRequests to be performed. The function returns once all requests have been finished.
176 ///
177 ///
178 /// The results of the VNRequests as well any possible errors of the individual requests are reported in the VNRequests results and error properties.
179 ///
180 ///
181 /// Parameter `requests`: An NSArray of VNRequests that are to be performed.
182 ///
183 /// 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.
184 ///
185 /// Returns: Returns true if all requests were scheduled and performed. Check individual requests results and errors for their respective success and failures.
186 #[unsafe(method(performRequests:error:_))]
187 #[unsafe(method_family = none)]
188 pub fn performRequests_error(
189 &self,
190 requests: &NSArray<VNRequest>,
191 ) -> Result<(), Retained<NSError>>;
192 );
193}
194
195/// Methods declared on superclass `NSObject`.
196impl VNImageRequestHandler {
197 extern_methods!(
198 #[unsafe(method(new))]
199 #[unsafe(method_family = new)]
200 pub unsafe fn new() -> Retained<Self>;
201 );
202}
203
204extern_class!(
205 /// Performs requests on a sequence of images.
206 ///
207 /// The VNSequenceRequestHandler is created without any specific image source. The -performRequests:on
208 /// <ImageSource
209 /// >:error: methods will retain the image source for no longer than the lifetime of the call.
210 /// The VNSequenceRequestHandler can choose to also cache state information related to the previously-processed image sources.
211 ///
212 /// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnsequencerequesthandler?language=objc)
213 #[unsafe(super(NSObject))]
214 #[derive(Debug, PartialEq, Eq, Hash)]
215 pub struct VNSequenceRequestHandler;
216);
217
218extern_conformance!(
219 unsafe impl NSObjectProtocol for VNSequenceRequestHandler {}
220);
221
222impl VNSequenceRequestHandler {
223 extern_methods!(
224 /// Creates a new object.
225 #[unsafe(method(init))]
226 #[unsafe(method_family = init)]
227 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
228
229 #[cfg(all(feature = "VNRequest", feature = "objc2-core-video"))]
230 /// Perform requests on an image in a CVPixelBuffer.
231 ///
232 ///
233 /// Parameter `requests`: The VNRequests to be performed on the image.
234 ///
235 ///
236 /// Parameter `pixelBuffer`: The CVPixelBuffer containing the image to be processed.
237 ///
238 ///
239 /// 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.
240 #[unsafe(method(performRequests:onCVPixelBuffer:error:_))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn performRequests_onCVPixelBuffer_error(
243 &self,
244 requests: &NSArray<VNRequest>,
245 pixel_buffer: &CVPixelBuffer,
246 ) -> Result<(), Retained<NSError>>;
247
248 #[cfg(all(feature = "VNRequest", feature = "objc2-core-graphics"))]
249 /// Perform requests on an image in a CGImageRef.
250 ///
251 ///
252 /// Parameter `requests`: The VNRequests to be performed on the image.
253 ///
254 ///
255 /// Parameter `image`: The CGImageRef containing the image to be processed.
256 ///
257 ///
258 /// 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.
259 #[unsafe(method(performRequests:onCGImage:error:_))]
260 #[unsafe(method_family = none)]
261 pub unsafe fn performRequests_onCGImage_error(
262 &self,
263 requests: &NSArray<VNRequest>,
264 image: &CGImage,
265 ) -> Result<(), Retained<NSError>>;
266
267 #[cfg(all(feature = "VNRequest", feature = "objc2-core-image"))]
268 /// Perform requests on an image in a CIImage.
269 ///
270 ///
271 /// Parameter `requests`: The VNRequests to be performed on the image.
272 ///
273 ///
274 /// Parameter `image`: The CIImage containing the image to be processed.
275 ///
276 ///
277 /// 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.
278 #[unsafe(method(performRequests:onCIImage:error:_))]
279 #[unsafe(method_family = none)]
280 pub unsafe fn performRequests_onCIImage_error(
281 &self,
282 requests: &NSArray<VNRequest>,
283 image: &CIImage,
284 ) -> Result<(), Retained<NSError>>;
285
286 #[cfg(feature = "VNRequest")]
287 /// Perform requests on an image referenced by an URL.
288 ///
289 ///
290 /// Parameter `requests`: The VNRequests to be performed on the image.
291 ///
292 ///
293 /// Parameter `imageURL`: The URL of the image to be processed. If this is not a file-based URL, the method will fail.
294 ///
295 ///
296 /// 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.
297 #[unsafe(method(performRequests:onImageURL:error:_))]
298 #[unsafe(method_family = none)]
299 pub unsafe fn performRequests_onImageURL_error(
300 &self,
301 requests: &NSArray<VNRequest>,
302 image_url: &NSURL,
303 ) -> Result<(), Retained<NSError>>;
304
305 #[cfg(feature = "VNRequest")]
306 /// Perform requests on an image with its source format in memory.
307 ///
308 ///
309 /// Parameter `requests`: The VNRequests to be performed on the image.
310 ///
311 ///
312 /// Parameter `imageData`: The data representing the source format of the image to be processed.
313 ///
314 ///
315 /// 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.
316 #[unsafe(method(performRequests:onImageData:error:_))]
317 #[unsafe(method_family = none)]
318 pub unsafe fn performRequests_onImageData_error(
319 &self,
320 requests: &NSArray<VNRequest>,
321 image_data: &NSData,
322 ) -> Result<(), Retained<NSError>>;
323
324 #[cfg(all(feature = "VNRequest", feature = "objc2-core-media"))]
325 /// Perform requests on the image buffer contained in the CMSampleBufferRef.
326 ///
327 ///
328 /// Parameter `requests`: The VNRequests to be performed on the image.
329 ///
330 ///
331 /// 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.
332 ///
333 ///
334 /// 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.
335 #[unsafe(method(performRequests:onCMSampleBuffer:error:_))]
336 #[unsafe(method_family = none)]
337 pub unsafe fn performRequests_onCMSampleBuffer_error(
338 &self,
339 requests: &NSArray<VNRequest>,
340 sample_buffer: &CMSampleBuffer,
341 ) -> Result<(), Retained<NSError>>;
342 );
343}
344
345/// Methods declared on superclass `NSObject`.
346impl VNSequenceRequestHandler {
347 extern_methods!(
348 #[unsafe(method(new))]
349 #[unsafe(method_family = new)]
350 pub unsafe fn new() -> Retained<Self>;
351 );
352}