apple-vision 0.16.2

Safe Rust bindings for Apple's Vision framework — OCR, object detection, face landmarks on macOS
Documentation
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
#![doc = include_str!("../README.md")]
//!
//! ---
//!
//! # API Documentation
//!
//! Safe Rust bindings for Apple's
//! [Vision](https://developer.apple.com/documentation/vision) framework —
//! OCR, object detection, face landmarks, and other on-device computer
//! vision tasks.
//!
//! v0.16.0 adds a Tier-1 `async_api` module for one-shot OCR / face / barcode /
//! segmentation requests while keeping the full audited Vision request surface
//! and the split Swift bridge / coverage matrix introduced in v0.15.x.

#![cfg_attr(docsrs, feature(doc_cfg))]

pub mod error;
pub mod ffi;
pub mod geometry;
pub mod recognized_points;
pub mod request_base;
pub mod sdk;

#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub mod async_api;

#[cfg(feature = "recognize_text")]
#[cfg_attr(docsrs, doc(cfg(feature = "recognize_text")))]
pub mod recognize_text;

#[cfg(feature = "recognize_text")]
#[cfg_attr(docsrs, doc(cfg(feature = "recognize_text")))]
pub mod processing;

#[cfg(feature = "detect_faces")]
#[cfg_attr(docsrs, doc(cfg(feature = "detect_faces")))]
pub mod detect_faces;

#[cfg(feature = "detect_barcodes")]
#[cfg_attr(docsrs, doc(cfg(feature = "detect_barcodes")))]
pub mod detect_barcodes;

#[cfg(feature = "saliency")]
#[cfg_attr(docsrs, doc(cfg(feature = "saliency")))]
pub mod saliency;

#[cfg(feature = "face_landmarks")]
#[cfg_attr(docsrs, doc(cfg(feature = "face_landmarks")))]
pub mod face_landmarks;

#[cfg(feature = "body_pose")]
#[cfg_attr(docsrs, doc(cfg(feature = "body_pose")))]
pub mod body_pose;

#[cfg(feature = "hand_pose")]
#[cfg_attr(docsrs, doc(cfg(feature = "hand_pose")))]
pub mod hand_pose;

#[cfg(feature = "contours")]
#[cfg_attr(docsrs, doc(cfg(feature = "contours")))]
pub mod contours;

#[cfg(feature = "animals")]
#[cfg_attr(docsrs, doc(cfg(feature = "animals")))]
pub mod animals;

#[cfg(feature = "classify")]
#[cfg_attr(docsrs, doc(cfg(feature = "classify")))]
pub mod classify;

#[cfg(feature = "rectangles")]
#[cfg_attr(docsrs, doc(cfg(feature = "rectangles")))]
pub mod rectangles;

#[cfg(feature = "horizon")]
#[cfg_attr(docsrs, doc(cfg(feature = "horizon")))]
pub mod horizon;

#[cfg(feature = "feature_print")]
#[cfg_attr(docsrs, doc(cfg(feature = "feature_print")))]
pub mod feature_print;

#[cfg(feature = "humans")]
#[cfg_attr(docsrs, doc(cfg(feature = "humans")))]
pub mod humans;

#[cfg(feature = "aesthetics")]
#[cfg_attr(docsrs, doc(cfg(feature = "aesthetics")))]
pub mod aesthetics;

#[cfg(feature = "segmentation")]
#[cfg_attr(docsrs, doc(cfg(feature = "segmentation")))]
pub mod segmentation;

#[cfg(feature = "optical_flow")]
#[cfg_attr(docsrs, doc(cfg(feature = "optical_flow")))]
pub mod optical_flow;

#[cfg(feature = "coreml")]
#[cfg_attr(docsrs, doc(cfg(feature = "coreml")))]
pub mod coreml;

#[cfg(feature = "tracking")]
#[cfg_attr(docsrs, doc(cfg(feature = "tracking")))]
pub mod tracking;

// v0.13: new request types
pub mod animal_body_pose;
pub mod human_body_pose_3d;
pub mod objectness_saliency;
pub mod person_instance_mask;
pub mod registration;
pub mod text_rectangles;
pub mod trajectories;

pub use error::VisionError;
pub use geometry::{
    element_type_size, image_point_for_face_landmark_point, image_point_for_normalized_point,
    image_point_for_normalized_point_using_region_of_interest, image_rect_for_normalized_rect,
    image_rect_for_normalized_rect_using_region_of_interest,
    normalized_face_bounding_box_point_for_landmark_point, normalized_identity_rect,
    normalized_point_for_image_point, normalized_point_for_image_point_using_region_of_interest,
    normalized_rect_for_image_rect, normalized_rect_for_image_rect_using_region_of_interest,
    normalized_rect_is_identity_rect, Transform3D, VisionCircle, VisionGeometryUtils, VisionPoint,
    VisionPoint3D, VisionVector,
};
pub use recognized_points::{
    HumanBodyRecognizedPoint3D, RecognizedPoint, RecognizedPoint3D, RecognizedPoints3DObservation,
    RecognizedPointsObservation, VisionDetectedPoint, VisionRecognizedPoint,
    VisionRecognizedPoint3D,
};
pub use request_base::{
    ImageAlignmentObservation, ImageBasedRequest, ImageRegistrationRequest, NormalizedRect,
    PixelBufferObservation, RequestProgress, RequestProgressHandler, RequestProgressProviding,
    RequestRevisionProviding, StatefulRequest, TargetedImageRequest, TrackingLevel,
    TrackingRequest,
};
pub use sdk::{
    vision_version_number, AnimalIdentifier, BarcodeCompositeType, BarcodeSymbology, ComputeStage,
    ElementType, ImageCropAndScaleOption, ImageOption, PointsClassification,
    RecognizedPoint3DGroupKey, RecognizedPointGroupKey, VisionErrorCode, VISION_ERROR_DOMAIN,
};

#[cfg(feature = "recognize_text")]
pub use processing::{
    ImageRequestHandler, Observation, RecognizedTextObservation, Request, RequestKind,
    SequenceRequestHandler, TimeRange, VideoCadence, VideoProcessingOptions, VideoProcessor,
    VideoProcessorCadence, VideoProcessorFrameRateCadence, VideoProcessorRequestProcessingOptions,
    VideoProcessorTimeIntervalCadence,
};

#[cfg(feature = "recognize_text")]
pub use recognize_text::{
    BoundingBox, RecognitionLevel, RecognizedText, RecognizedTextCandidate, TextRecognizer,
};

#[cfg(feature = "detect_faces")]
pub use detect_faces::{DetectedFace, FaceDetector};

#[cfg(feature = "detect_barcodes")]
pub use detect_barcodes::{
    detect_barcodes_in_path, BarcodeCompositeType as DetectedBarcodeCompositeType,
    BarcodeSymbology as DetectedBarcodeSymbology, DetectedBarcode,
};

#[cfg(feature = "saliency")]
pub use saliency::{attention_saliency_in_path, SalientRegion};

#[cfg(feature = "face_landmarks")]
pub use face_landmarks::{
    detect_face_landmarks_in_path, FaceLandmarkRegion, FaceLandmarkRegion2D, FaceLandmarks,
    FaceLandmarks2D, FaceLandmarksRequest, FaceObservationAccepting, FaceWithLandmarks,
    LandmarkPoint, RequestFaceLandmarksConstellation,
};

#[cfg(feature = "body_pose")]
pub use body_pose::{
    detect_human_body_pose_in_path, detect_human_body_pose_observations_in_path, DetectedBodyPose,
    HumanBodyPoseJointGroupName, HumanBodyPoseJointName, HumanBodyPoseObservation, JointPoint,
};

#[cfg(feature = "hand_pose")]
pub use hand_pose::{
    detect_human_hand_pose_in_path, detect_human_hand_pose_observations_in_path, DetectedHandPose,
    HandChirality, HumanHandPoseJointGroupName, HumanHandPoseJointName, HumanHandPoseObservation,
};

#[cfg(feature = "contours")]
pub use contours::{
    detect_contours_in_path, detect_contours_observation_in_path, Contour, ContourOptions,
    ContoursObservation, VisionContour,
};

#[cfg(feature = "animals")]
pub use animals::{
    recognize_animals_in_path, AnimalIdentifier as RecognizedAnimalIdentifier, RecognizedAnimal,
};

#[cfg(feature = "classify")]
pub use classify::{classify_image_in_path, Classification};

#[cfg(feature = "rectangles")]
pub use rectangles::{
    detect_document_segmentation_in_path, detect_rectangles_in_path, RectangleObservation,
    RectangleOptions,
};

#[cfg(feature = "horizon")]
pub use horizon::{
    detect_horizon_in_path, detect_horizon_observation_in_path, AffineTransform, HorizonObservation,
};

#[cfg(feature = "feature_print")]
pub use feature_print::{generate_image_feature_print_in_path, FeaturePrint};

#[cfg(feature = "humans")]
pub use humans::{detect_human_rectangles_in_path, DetectedHuman};

#[cfg(feature = "aesthetics")]
pub use aesthetics::{
    calculate_aesthetics_scores_in_path, detect_face_capture_quality_in_path, AestheticsScores,
    FaceCaptureQuality,
};

#[cfg(feature = "segmentation")]
pub use segmentation::{
    generate_foreground_instance_mask_in_path,
    generate_foreground_instance_mask_observation_in_path, generate_person_segmentation_in_path,
    InstanceMask, InstanceMaskObservation, SegmentationMask, SegmentationQuality,
};

#[cfg(feature = "optical_flow")]
pub use optical_flow::{
    generate_optical_flow_in_paths, generate_optical_flow_observation_in_paths, OpticalFlowAccuracy,
};

#[cfg(feature = "coreml")]
pub use coreml::{
    coreml_classify_in_path, coreml_feature_value_in_path, CoreMLFeatureValue,
    CoreMLFeatureValueObservation, CoreMLImageCropAndScaleOption, CoreMLModel, CoreMLRequest,
};

pub use animal_body_pose::{
    detect_animal_body_pose, AnimalBodyPoseJointGroupName, AnimalBodyPoseJointName, AnimalJoint,
};
pub use human_body_pose_3d::{
    detect_human_body_pose_3d, detect_human_body_pose_3d_observations,
    detect_human_body_recognized_points_3d, BodyHeightEstimation, HumanBodyPose3DJointGroupName,
    HumanBodyPose3DJointName, HumanBodyPose3DObservation,
    HumanBodyPose3DObservationHeightEstimation, HumanJoint3D,
};
pub use objectness_saliency::{objectness_saliency, ObjectnessRegion};
pub use person_instance_mask::{person_instance_mask, PersonInstanceMask};
pub use registration::{
    register_homographic, register_homographic_observation, register_translational,
    register_translational_observation, HomographicAlignment, TranslationalAlignment,
};
pub use text_rectangles::{
    detect_text_observations, detect_text_rectangles, TextObservation, TextRect,
    TextRectanglesRequest,
};
pub use trajectories::{detect_trajectories, Trajectory};

#[cfg(feature = "tracking")]
pub use tracking::{
    HomographicImageTracker, ObjectTracker, OpticalFlowFrame, OpticalFlowTracker, RectangleTracker,
    TrackOpticalFlowRequestComputationAccuracy, TranslationalImageTracker,
};

/// Common imports.
pub mod prelude {
    pub use crate::animal_body_pose::{
        detect_animal_body_pose, AnimalBodyPoseJointGroupName, AnimalBodyPoseJointName, AnimalJoint,
    };
    #[cfg(feature = "animals")]
    pub use crate::animals::{
        recognize_animals_in_path, AnimalIdentifier as RecognizedAnimalIdentifier, RecognizedAnimal,
    };
    #[cfg(feature = "body_pose")]
    pub use crate::body_pose::{
        detect_human_body_pose_in_path, detect_human_body_pose_observations_in_path,
        DetectedBodyPose, HumanBodyPoseJointGroupName, HumanBodyPoseJointName,
        HumanBodyPoseObservation, JointPoint,
    };
    #[cfg(feature = "classify")]
    pub use crate::classify::{classify_image_in_path, Classification};
    #[cfg(feature = "contours")]
    pub use crate::contours::{
        detect_contours_in_path, detect_contours_observation_in_path, Contour, ContourOptions,
        ContoursObservation, VisionContour,
    };
    #[cfg(feature = "coreml")]
    pub use crate::coreml::{
        coreml_classify_in_path, coreml_feature_value_in_path, CoreMLFeatureValue,
        CoreMLFeatureValueObservation, CoreMLImageCropAndScaleOption, CoreMLModel, CoreMLRequest,
    };
    #[cfg(feature = "detect_barcodes")]
    pub use crate::detect_barcodes::{
        detect_barcodes_in_path, BarcodeCompositeType as DetectedBarcodeCompositeType,
        BarcodeSymbology as DetectedBarcodeSymbology, DetectedBarcode,
    };
    #[cfg(feature = "detect_faces")]
    pub use crate::detect_faces::{DetectedFace, FaceDetector};
    pub use crate::error::VisionError;
    #[cfg(feature = "face_landmarks")]
    pub use crate::face_landmarks::{
        detect_face_landmarks_in_path, FaceLandmarkRegion, FaceLandmarkRegion2D, FaceLandmarks,
        FaceLandmarks2D, FaceLandmarksRequest, FaceObservationAccepting, FaceWithLandmarks,
        LandmarkPoint, RequestFaceLandmarksConstellation,
    };
    #[cfg(feature = "feature_print")]
    pub use crate::feature_print::{generate_image_feature_print_in_path, FeaturePrint};
    pub use crate::geometry::{
        element_type_size, image_point_for_face_landmark_point, image_point_for_normalized_point,
        image_point_for_normalized_point_using_region_of_interest, image_rect_for_normalized_rect,
        image_rect_for_normalized_rect_using_region_of_interest,
        normalized_face_bounding_box_point_for_landmark_point, normalized_identity_rect,
        normalized_point_for_image_point,
        normalized_point_for_image_point_using_region_of_interest, normalized_rect_for_image_rect,
        normalized_rect_for_image_rect_using_region_of_interest, normalized_rect_is_identity_rect,
        Transform3D, VisionCircle, VisionGeometryUtils, VisionPoint, VisionPoint3D, VisionVector,
    };
    #[cfg(feature = "hand_pose")]
    pub use crate::hand_pose::{
        detect_human_hand_pose_in_path, detect_human_hand_pose_observations_in_path,
        DetectedHandPose, HandChirality, HumanHandPoseJointGroupName, HumanHandPoseJointName,
        HumanHandPoseObservation,
    };
    #[cfg(feature = "horizon")]
    pub use crate::horizon::{
        detect_horizon_in_path, detect_horizon_observation_in_path, AffineTransform,
        HorizonObservation,
    };
    pub use crate::human_body_pose_3d::{
        detect_human_body_pose_3d, detect_human_body_pose_3d_observations,
        detect_human_body_recognized_points_3d, BodyHeightEstimation,
        HumanBodyPose3DJointGroupName, HumanBodyPose3DJointName, HumanBodyPose3DObservation,
        HumanBodyPose3DObservationHeightEstimation, HumanJoint3D,
    };
    #[cfg(feature = "humans")]
    pub use crate::humans::{detect_human_rectangles_in_path, DetectedHuman};
    #[cfg(feature = "optical_flow")]
    pub use crate::optical_flow::{
        generate_optical_flow_in_paths, generate_optical_flow_observation_in_paths,
        OpticalFlowAccuracy,
    };
    #[cfg(feature = "recognize_text")]
    pub use crate::processing::{
        ImageRequestHandler, Observation, RecognizedTextObservation, Request, RequestKind,
        SequenceRequestHandler, TimeRange, VideoCadence, VideoProcessingOptions, VideoProcessor,
        VideoProcessorCadence, VideoProcessorFrameRateCadence,
        VideoProcessorRequestProcessingOptions, VideoProcessorTimeIntervalCadence,
    };
    #[cfg(feature = "recognize_text")]
    pub use crate::recognize_text::{
        BoundingBox, RecognitionLevel, RecognizedText, RecognizedTextCandidate, TextRecognizer,
    };
    pub use crate::recognized_points::{
        HumanBodyRecognizedPoint3D, RecognizedPoint, RecognizedPoint3D,
        RecognizedPoints3DObservation, RecognizedPointsObservation, VisionDetectedPoint,
        VisionRecognizedPoint, VisionRecognizedPoint3D,
    };
    #[cfg(feature = "rectangles")]
    pub use crate::rectangles::{
        detect_document_segmentation_in_path, detect_rectangles_in_path, RectangleObservation,
        RectangleOptions,
    };
    pub use crate::registration::{
        register_homographic, register_homographic_observation, register_translational,
        register_translational_observation, HomographicAlignment, TranslationalAlignment,
    };
    pub use crate::request_base::{
        ImageAlignmentObservation, ImageBasedRequest, ImageRegistrationRequest, NormalizedRect,
        PixelBufferObservation, RequestProgress, RequestProgressHandler, RequestProgressProviding,
        RequestRevisionProviding, StatefulRequest, TargetedImageRequest, TrackingLevel,
        TrackingRequest,
    };
    #[cfg(feature = "saliency")]
    pub use crate::saliency::{attention_saliency_in_path, SalientRegion};
    pub use crate::sdk::{
        vision_version_number, AnimalIdentifier, BarcodeCompositeType, BarcodeSymbology,
        ComputeStage, ElementType, ImageCropAndScaleOption, ImageOption, PointsClassification,
        RecognizedPoint3DGroupKey, RecognizedPointGroupKey, VisionErrorCode, VISION_ERROR_DOMAIN,
    };
    #[cfg(feature = "segmentation")]
    pub use crate::segmentation::{
        generate_foreground_instance_mask_in_path,
        generate_foreground_instance_mask_observation_in_path,
        generate_person_segmentation_in_path, InstanceMask, InstanceMaskObservation,
        SegmentationMask, SegmentationQuality,
    };
    pub use crate::text_rectangles::{
        detect_text_observations, detect_text_rectangles, TextObservation, TextRect,
        TextRectanglesRequest,
    };
    #[cfg(feature = "tracking")]
    pub use crate::tracking::{
        HomographicImageTracker, ObjectTracker, OpticalFlowFrame, OpticalFlowTracker,
        RectangleTracker, TrackOpticalFlowRequestComputationAccuracy, TranslationalImageTracker,
    };
}