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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
//! 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-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-graphics")]
use objc2_core_graphics::*;
use objc2_foundation::*;
use crate::*;
extern_class!(
/// VNPoint represents a single, immutable, two-dimensional point in an image.
///
/// It should be noted that VNPoint is not intended as an overall replacement of CGPoint, NSPoint or vec2, but is used by observations that need to present points which may contain additional metadata.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnpoint?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct VNPoint;
);
extern_conformance!(
unsafe impl NSCoding for VNPoint {}
);
extern_conformance!(
unsafe impl NSCopying for VNPoint {}
);
unsafe impl CopyingHelper for VNPoint {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for VNPoint {}
);
extern_conformance!(
unsafe impl NSSecureCoding for VNPoint {}
);
impl VNPoint {
extern_methods!(
/// Returns a VNPoint object that represents the location of (0.0, 0.0).
#[unsafe(method(zeroPoint))]
#[unsafe(method_family = none)]
pub unsafe fn zeroPoint() -> Retained<VNPoint>;
/// Returns a new VNPoint object that is shifted by X and Y offsets of the vector.
///
/// Parameter `vector`: The vector offset to be applied to a source point.
///
/// Parameter `point`: The source point.
///
/// Returns: the translated point.
#[unsafe(method(pointByApplyingVector:toPoint:))]
#[unsafe(method_family = none)]
pub unsafe fn pointByApplyingVector_toPoint(
vector: &VNVector,
point: &VNPoint,
) -> Retained<VNPoint>;
/// Returns the Euclidean distance between two VNPoint objects.
#[deprecated]
#[unsafe(method(distanceBetweenPoint:point:))]
#[unsafe(method_family = none)]
pub unsafe fn distanceBetweenPoint_point(point1: &VNPoint, point2: &VNPoint) -> c_double;
/// Returns the Euclidean distance to another point.
///
/// Parameter `point`: The destination point.
///
/// Returns: the Euclidean distance between the target and specified points.
#[unsafe(method(distanceToPoint:))]
#[unsafe(method_family = none)]
pub unsafe fn distanceToPoint(&self, point: &VNPoint) -> c_double;
/// Initializes a VNPoint object from X and Y coordinates.
#[unsafe(method(initWithX:y:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithX_y(
this: Allocated<Self>,
x: c_double,
y: c_double,
) -> Retained<Self>;
#[cfg(feature = "objc2-core-foundation")]
/// Initializes a VNPoint object from a CGPoint.
#[unsafe(method(initWithLocation:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithLocation(this: Allocated<Self>, location: CGPoint) -> Retained<Self>;
#[cfg(feature = "objc2-core-foundation")]
/// Returns the X and Y coordinates of the point, as CGPoint type, with respect to the origin of the coordinate system the point is defined in.
#[unsafe(method(location))]
#[unsafe(method_family = none)]
pub unsafe fn location(&self) -> CGPoint;
/// Returns the X coordinate of the point with respect to the origin of the coordinate system the point is defined in.
#[unsafe(method(x))]
#[unsafe(method_family = none)]
pub unsafe fn x(&self) -> c_double;
/// Returns the Y coordinate of the point with respect to the origin of the coordinate system the point is defined in.
#[unsafe(method(y))]
#[unsafe(method_family = none)]
pub unsafe fn y(&self) -> c_double;
);
}
/// Methods declared on superclass `NSObject`.
impl VNPoint {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// VNPoint3D represents a single, immutable, three-dimensional point in an image.
///
/// It should be noted that VNPoint3D is not intended as an overall replacement of simd float4x4, but is used by observations that need to present points which may contain additional metadata.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnpoint3d?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct VNPoint3D;
);
extern_conformance!(
unsafe impl NSCoding for VNPoint3D {}
);
extern_conformance!(
unsafe impl NSCopying for VNPoint3D {}
);
unsafe impl CopyingHelper for VNPoint3D {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for VNPoint3D {}
);
extern_conformance!(
unsafe impl NSSecureCoding for VNPoint3D {}
);
impl VNPoint3D {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
);
}
/// Methods declared on superclass `NSObject`.
impl VNPoint3D {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// VNVector is a two-dimensional vector represented its X and Y axis projections. Once created, VNVector objects are immutable.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnvector?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct VNVector;
);
extern_conformance!(
unsafe impl NSCoding for VNVector {}
);
extern_conformance!(
unsafe impl NSCopying for VNVector {}
);
unsafe impl CopyingHelper for VNVector {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for VNVector {}
);
extern_conformance!(
unsafe impl NSSecureCoding for VNVector {}
);
impl VNVector {
extern_methods!(
/// Returns a VNVector object with zero length. The theta for zeroVector is not defined (NaN).
#[unsafe(method(zeroVector))]
#[unsafe(method_family = none)]
pub unsafe fn zeroVector() -> Retained<VNVector>;
/// Returns a vector that is normalized by preserving direction, such as |v|, or vector length = 1.0.
#[unsafe(method(unitVectorForVector:))]
#[unsafe(method_family = none)]
pub unsafe fn unitVectorForVector(vector: &VNVector) -> Retained<VNVector>;
/// Returns a vector that whose X and Y projections multiplied by a scalar value.
#[unsafe(method(vectorByMultiplyingVector:byScalar:))]
#[unsafe(method_family = none)]
pub unsafe fn vectorByMultiplyingVector_byScalar(
vector: &VNVector,
scalar: c_double,
) -> Retained<VNVector>;
/// Adds two vectors v1 and v2 and returns a resulting vector v, such as v = v1 + v2.
#[unsafe(method(vectorByAddingVector:toVector:))]
#[unsafe(method_family = none)]
pub unsafe fn vectorByAddingVector_toVector(
v1: &VNVector,
v2: &VNVector,
) -> Retained<VNVector>;
/// Substructs vector v1 from v2 and returns a resulting vector v, such as v = v2 - v1.
#[unsafe(method(vectorBySubtractingVector:fromVector:))]
#[unsafe(method_family = none)]
pub unsafe fn vectorBySubtractingVector_fromVector(
v1: &VNVector,
v2: &VNVector,
) -> Retained<VNVector>;
/// Caclulates a dot product (aka 'scalar product' or 'inner product') of two vectors v1 and v2 and returns dot product value.
#[unsafe(method(dotProductOfVector:vector:))]
#[unsafe(method_family = none)]
pub unsafe fn dotProductOfVector_vector(v1: &VNVector, v2: &VNVector) -> c_double;
/// Initializes a vector in Cartesian Coordinate space, using its X and Y axis projections.
#[unsafe(method(initWithXComponent:yComponent:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithXComponent_yComponent(
this: Allocated<Self>,
x: c_double,
y: c_double,
) -> Retained<Self>;
/// Initializes a vector in polar coordinate space, using R and Theta (radians), where R is the length of the vector and
/// Theta is the ange that the vector forms with the positive direction of X axis.
#[unsafe(method(initWithR:theta:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithR_theta(
this: Allocated<Self>,
r: c_double,
theta: c_double,
) -> Retained<Self>;
/// Initializes a vector in Cartesian Coordinate space, using two VNPoints - the head and the tail of the vector.
#[unsafe(method(initWithVectorHead:tail:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithVectorHead_tail(
this: Allocated<Self>,
head: &VNPoint,
tail: &VNPoint,
) -> Retained<Self>;
/// Signed projection on X-axis, or X component of the vector. Sign determines direction the vector is facing in X direction.
#[unsafe(method(x))]
#[unsafe(method_family = none)]
pub unsafe fn x(&self) -> c_double;
/// Signed projection on Y-axis, or Y component of the vector. Sign determines direction the vector is facing in Y direction.
#[unsafe(method(y))]
#[unsafe(method_family = none)]
pub unsafe fn y(&self) -> c_double;
/// Radius, or absolute value, or length of the vector.
#[unsafe(method(r))]
#[unsafe(method_family = none)]
pub unsafe fn r(&self) -> c_double;
/// Angle between the vector direction and positive direction of X axis.
#[unsafe(method(theta))]
#[unsafe(method_family = none)]
pub unsafe fn theta(&self) -> c_double;
/// Returns a length, or absolute value, of the vector.
#[unsafe(method(length))]
#[unsafe(method_family = none)]
pub unsafe fn length(&self) -> c_double;
/// Returns a length ^ 2 of a vector.
#[unsafe(method(squaredLength))]
#[unsafe(method_family = none)]
pub unsafe fn squaredLength(&self) -> c_double;
);
}
/// Methods declared on superclass `NSObject`.
impl VNVector {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// VNCircle is two-dimensional circle represented by the center point 'center' and its radius 'radius'. Once created, VNCircle objects are immutable.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vncircle?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct VNCircle;
);
extern_conformance!(
unsafe impl NSCoding for VNCircle {}
);
extern_conformance!(
unsafe impl NSCopying for VNCircle {}
);
unsafe impl CopyingHelper for VNCircle {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for VNCircle {}
);
extern_conformance!(
unsafe impl NSSecureCoding for VNCircle {}
);
impl VNCircle {
extern_methods!(
/// Returns a VNCircle object with center at the Origin [0.0; 0.0] and zero radius.
#[unsafe(method(zeroCircle))]
#[unsafe(method_family = none)]
pub unsafe fn zeroCircle() -> Retained<VNCircle>;
/// Initializes VNCircle object with given circle center and circle radius.
#[unsafe(method(initWithCenter:radius:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCenter_radius(
this: Allocated<Self>,
center: &VNPoint,
radius: c_double,
) -> Retained<Self>;
/// Initializes VNCircle object with given circle center and circle diameter.
#[unsafe(method(initWithCenter:diameter:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCenter_diameter(
this: Allocated<Self>,
center: &VNPoint,
diameter: c_double,
) -> Retained<Self>;
/// Returns YES if the point is inside the circle, including the boundary.
#[unsafe(method(containsPoint:))]
#[unsafe(method_family = none)]
pub unsafe fn containsPoint(&self, point: &VNPoint) -> bool;
/// Returns YES if the point is within the ring bound by two circles [radius - delta; radius + delta].
#[unsafe(method(containsPoint:inCircumferentialRingOfWidth:))]
#[unsafe(method_family = none)]
pub unsafe fn containsPoint_inCircumferentialRingOfWidth(
&self,
point: &VNPoint,
ring_width: c_double,
) -> bool;
/// Returns circle center.
#[unsafe(method(center))]
#[unsafe(method_family = none)]
pub unsafe fn center(&self) -> Retained<VNPoint>;
/// Returns circle radius.
#[unsafe(method(radius))]
#[unsafe(method_family = none)]
pub unsafe fn radius(&self) -> c_double;
/// Returns circle diameter.
#[unsafe(method(diameter))]
#[unsafe(method_family = none)]
pub unsafe fn diameter(&self) -> c_double;
);
}
/// Methods declared on superclass `NSObject`.
impl VNCircle {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// The VNContour class describes a contour provided by a VNContoursObservation.
///
///
/// VNContour objects are lightweight objects that act as a façade which allows access to a small slice of the usually much larger block of data owned by a VNContoursObservation that represents all of the contours detected in an image.
/// While the interface does present the notion of a hierarchy of parent/child contours, the implementation purposefully does not contain any explicit internal bookkeeping for this relationship. Instead, contours are uniquely identified via their indexPath property.
/// As a side effect of this choice, repeated calls to methods that would return relational contours (e.g., -childContours or -childContourAtIndex:error:) are NOT guaranteed to return the same VNContour instances over and over again. If this kind of parent/child object stability is an absolute requirement of the client, then they are responsible for creating the necessary data structures to represent and build that instance-stable hierarchy.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vncontour?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct VNContour;
);
extern_conformance!(
unsafe impl NSCopying for VNContour {}
);
unsafe impl CopyingHelper for VNContour {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for VNContour {}
);
#[cfg(feature = "VNRequestRevisionProviding")]
extern_conformance!(
unsafe impl VNRequestRevisionProviding for VNContour {}
);
impl VNContour {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
/// The path to the target VNContour as it is stored in the owning VNContoursObservation's hierarchy of contours.
#[unsafe(method(indexPath))]
#[unsafe(method_family = none)]
pub unsafe fn indexPath(&self) -> Retained<NSIndexPath>;
/// The total number of child contours in the target contour.
///
/// The use of this property is preferred over childContours.count due to the cost of building the child objects.
#[unsafe(method(childContourCount))]
#[unsafe(method_family = none)]
pub unsafe fn childContourCount(&self) -> NSInteger;
/// The array of the contours enclosed by the target contour.
///
/// This property may come with the cost of instantiating new VNContour objects; therefore, clients are strongly encouraged to hold the results in a local variable instead of repeatedly invoking it.
#[unsafe(method(childContours))]
#[unsafe(method_family = none)]
pub unsafe fn childContours(&self) -> Retained<NSArray<VNContour>>;
/// Returns a VNContour object that is a child of this VNContour at the specified index.
///
/// Parameter `childContourIndex`: The index into the childContours array.
///
/// Parameter `error`: The error returned if the child contour cannot be provided.
///
/// Returns: The VNContour object at the specified index path, or nil of a failure occurs.
#[unsafe(method(childContourAtIndex:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn childContourAtIndex_error(
&self,
child_contour_index: NSUInteger,
) -> Result<Retained<VNContour>, Retained<NSError>>;
/// The number of points that describe the contour.
#[unsafe(method(pointCount))]
#[unsafe(method_family = none)]
pub unsafe fn pointCount(&self) -> NSInteger;
#[cfg(feature = "objc2-core-graphics")]
/// The contour represented as a CGPath in normalized coordinates.
///
/// The path is owned by this object and therefore will be alive as long as the the observation is alive.
#[unsafe(method(normalizedPath))]
#[unsafe(method_family = none)]
pub unsafe fn normalizedPath(&self) -> Retained<CGPath>;
/// The aspect ratio of the contour from the original image aspect ratio expressed as width/height
#[unsafe(method(aspectRatio))]
#[unsafe(method_family = none)]
pub unsafe fn aspectRatio(&self) -> c_float;
/// Simplifies the contour's collection of points into a polygon using the Ramer Douglas Peucker Algorithm.
///
/// See
/// <https
/// ://en.wikipedia.org/wiki/Ramer–Douglas–Peucker_algorithm>
///
/// Parameter `epsilon`: Points that have a perpendicular distance to the line segment they are on which are greater than epsilon are kept, others are eliminated.
///
/// Parameter `error`: The error returned if a simplified contour cannot be created.
///
/// Returns: A new VNContour object with a simplified polygon consisting of a subset of the points that defined the original VNContour.
#[unsafe(method(polygonApproximationWithEpsilon:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn polygonApproximationWithEpsilon_error(
&self,
epsilon: c_float,
) -> Result<Retained<VNContour>, Retained<NSError>>;
);
}