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
179
180
181
182
183
184
185
186
187
188
189
190
//! 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-ml")]
use objc2_core_ml::*;
use objc2_foundation::*;
use crate::*;
extern_class!(
/// The VNCoreMLModel uses an CoreML based model and prepares it for use with VNCoreMLRequests.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vncoremlmodel?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct VNCoreMLModel;
);
extern_conformance!(
unsafe impl NSObjectProtocol for VNCoreMLModel {}
);
impl VNCoreMLModel {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[cfg(feature = "objc2-core-ml")]
/// Create a model container to be used with VNCoreMLRequest based on a Core ML model. This can fail if the model is not supported. Examples for a model that is not supported is a model that does not take an image as any of its inputs.
///
///
/// Parameter `model`: The MLModel from CoreML to be used.
///
///
/// Parameter `error`: Returns the error code and description, if the model is not supported.
#[unsafe(method(modelForMLModel:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn modelForMLModel_error(
model: &MLModel,
) -> Result<Retained<Self>, Retained<NSError>>;
/// The name of the MLFeatureValue that Vision will set from the VNRequestHandler. Vision will use the first input it finds by default but it can be set to another featureName instead.
#[unsafe(method(inputImageFeatureName))]
#[unsafe(method_family = none)]
pub unsafe fn inputImageFeatureName(&self) -> Retained<NSString>;
/// Setter for [`inputImageFeatureName`][Self::inputImageFeatureName].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setInputImageFeatureName:))]
#[unsafe(method_family = none)]
pub unsafe fn setInputImageFeatureName(&self, input_image_feature_name: &NSString);
#[cfg(feature = "objc2-core-ml")]
/// An optional object conforming to the MLFeatureProvider protocol that is used by the model during the predict call to support inputs that are not supplied by Vision. Vision will provide the image for the inputImageFeatureName from the the VNRequestHandler. A feature provider is necessary for models that have more than one input and require those parameters to be set. Models that only have one image input will not use the feature provider as that input will be set by Vision.
#[unsafe(method(featureProvider))]
#[unsafe(method_family = none)]
pub unsafe fn featureProvider(
&self,
) -> Option<Retained<ProtocolObject<dyn MLFeatureProvider>>>;
#[cfg(feature = "objc2-core-ml")]
/// Setter for [`featureProvider`][Self::featureProvider].
#[unsafe(method(setFeatureProvider:))]
#[unsafe(method_family = none)]
pub unsafe fn setFeatureProvider(
&self,
feature_provider: Option<&ProtocolObject<dyn MLFeatureProvider>>,
);
);
}
/// Methods declared on superclass `NSObject`.
impl VNCoreMLModel {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// The VNCoreMLRequest uses a VNCoreMLModel, that is based on a CoreML MLModel object, to run predictions with that model. Depending on the model the returned
/// observation is either a VNClassificationObservation for classifier models, VNPixelBufferObservations for image-to-image models, VNRecognizedObjectObservation for object recognition models or VNCoreMLFeatureValueObservation for everything else. All -[VNObservation confidence] values are forwarded from relevant models as is, and do not conform to a common [0, 1] range rule
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vncoremlrequest?language=objc)
#[unsafe(super(VNImageBasedRequest, VNRequest, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "VNRequest")]
pub struct VNCoreMLRequest;
);
#[cfg(feature = "VNRequest")]
extern_conformance!(
unsafe impl NSCopying for VNCoreMLRequest {}
);
#[cfg(feature = "VNRequest")]
unsafe impl CopyingHelper for VNCoreMLRequest {
type Result = Self;
}
#[cfg(feature = "VNRequest")]
extern_conformance!(
unsafe impl NSObjectProtocol for VNCoreMLRequest {}
);
#[cfg(feature = "VNRequest")]
impl VNCoreMLRequest {
extern_methods!(
/// The model from CoreML wrapped in a VNCoreMLModel.
#[unsafe(method(model))]
#[unsafe(method_family = none)]
pub unsafe fn model(&self) -> Retained<VNCoreMLModel>;
#[cfg(feature = "VNTypes")]
#[unsafe(method(imageCropAndScaleOption))]
#[unsafe(method_family = none)]
pub unsafe fn imageCropAndScaleOption(&self) -> VNImageCropAndScaleOption;
#[cfg(feature = "VNTypes")]
/// Setter for [`imageCropAndScaleOption`][Self::imageCropAndScaleOption].
#[unsafe(method(setImageCropAndScaleOption:))]
#[unsafe(method_family = none)]
pub unsafe fn setImageCropAndScaleOption(
&self,
image_crop_and_scale_option: VNImageCropAndScaleOption,
);
/// Create a new request with a model.
///
///
/// Parameter `model`: The VNCoreMLModel to be used.
#[unsafe(method(initWithModel:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithModel(this: Allocated<Self>, model: &VNCoreMLModel)
-> Retained<Self>;
#[cfg(feature = "block2")]
/// Create a new request with a model.
///
///
/// Parameter `model`: The VNCoreMLModel to be used.
///
///
/// Parameter `completionHandler`: The block that is invoked when the request has been performed.
///
/// # Safety
///
/// `completion_handler` must be a valid pointer or null.
#[unsafe(method(initWithModel:completionHandler:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithModel_completionHandler(
this: Allocated<Self>,
model: &VNCoreMLModel,
completion_handler: VNRequestCompletionHandler,
) -> Retained<Self>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[cfg(feature = "block2")]
/// # Safety
///
/// `completion_handler` must be a valid pointer or null.
#[unsafe(method(initWithCompletionHandler:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCompletionHandler(
this: Allocated<Self>,
completion_handler: VNRequestCompletionHandler,
) -> Retained<Self>;
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(feature = "VNRequest")]
impl VNCoreMLRequest {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
/// [Apple's documentation](https://developer.apple.com/documentation/vision/vncoremlrequestrevision1?language=objc)
pub static VNCoreMLRequestRevision1: NSUInteger = 1;