Skip to main content

apple_vision/
lib.rs

1#![doc = include_str!("../README.md")]
2//!
3//! ---
4//!
5//! # API Documentation
6//!
7//! Safe Rust bindings for Apple's
8//! [Vision](https://developer.apple.com/documentation/vision) framework —
9//! OCR, object detection, face landmarks, and other on-device computer
10//! vision tasks.
11//!
12//! v0.15.1 keeps the full Apple Vision request surface, adds explicit
13//! request-handler/video-processing wrappers, and ships an audited coverage
14//! matrix plus a split Swift bridge.
15
16#![cfg_attr(docsrs, feature(doc_cfg))]
17
18pub mod error;
19pub mod ffi;
20
21#[cfg(feature = "recognize_text")]
22#[cfg_attr(docsrs, doc(cfg(feature = "recognize_text")))]
23pub mod recognize_text;
24
25#[cfg(feature = "recognize_text")]
26#[cfg_attr(docsrs, doc(cfg(feature = "recognize_text")))]
27pub mod processing;
28
29#[cfg(feature = "detect_faces")]
30#[cfg_attr(docsrs, doc(cfg(feature = "detect_faces")))]
31pub mod detect_faces;
32
33#[cfg(feature = "detect_barcodes")]
34#[cfg_attr(docsrs, doc(cfg(feature = "detect_barcodes")))]
35pub mod detect_barcodes;
36
37#[cfg(feature = "saliency")]
38#[cfg_attr(docsrs, doc(cfg(feature = "saliency")))]
39pub mod saliency;
40
41#[cfg(feature = "face_landmarks")]
42#[cfg_attr(docsrs, doc(cfg(feature = "face_landmarks")))]
43pub mod face_landmarks;
44
45#[cfg(feature = "body_pose")]
46#[cfg_attr(docsrs, doc(cfg(feature = "body_pose")))]
47pub mod body_pose;
48
49#[cfg(feature = "hand_pose")]
50#[cfg_attr(docsrs, doc(cfg(feature = "hand_pose")))]
51pub mod hand_pose;
52
53#[cfg(feature = "contours")]
54#[cfg_attr(docsrs, doc(cfg(feature = "contours")))]
55pub mod contours;
56
57#[cfg(feature = "animals")]
58#[cfg_attr(docsrs, doc(cfg(feature = "animals")))]
59pub mod animals;
60
61#[cfg(feature = "classify")]
62#[cfg_attr(docsrs, doc(cfg(feature = "classify")))]
63pub mod classify;
64
65#[cfg(feature = "rectangles")]
66#[cfg_attr(docsrs, doc(cfg(feature = "rectangles")))]
67pub mod rectangles;
68
69#[cfg(feature = "horizon")]
70#[cfg_attr(docsrs, doc(cfg(feature = "horizon")))]
71pub mod horizon;
72
73#[cfg(feature = "feature_print")]
74#[cfg_attr(docsrs, doc(cfg(feature = "feature_print")))]
75pub mod feature_print;
76
77#[cfg(feature = "humans")]
78#[cfg_attr(docsrs, doc(cfg(feature = "humans")))]
79pub mod humans;
80
81#[cfg(feature = "aesthetics")]
82#[cfg_attr(docsrs, doc(cfg(feature = "aesthetics")))]
83pub mod aesthetics;
84
85#[cfg(feature = "segmentation")]
86#[cfg_attr(docsrs, doc(cfg(feature = "segmentation")))]
87pub mod segmentation;
88
89#[cfg(feature = "optical_flow")]
90#[cfg_attr(docsrs, doc(cfg(feature = "optical_flow")))]
91pub mod optical_flow;
92
93#[cfg(feature = "coreml")]
94#[cfg_attr(docsrs, doc(cfg(feature = "coreml")))]
95pub mod coreml;
96
97#[cfg(feature = "tracking")]
98#[cfg_attr(docsrs, doc(cfg(feature = "tracking")))]
99pub mod tracking;
100
101// v0.13: new request types
102pub mod animal_body_pose;
103pub mod human_body_pose_3d;
104pub mod text_rectangles;
105pub mod objectness_saliency;
106pub mod person_instance_mask;
107pub mod trajectories;
108pub mod registration;
109
110pub use error::VisionError;
111
112#[cfg(feature = "recognize_text")]
113pub use processing::{
114    ImageRequestHandler, Observation, RecognizedTextObservation, Request, RequestKind,
115    SequenceRequestHandler, TimeRange, VideoCadence, VideoProcessingOptions, VideoProcessor,
116};
117
118#[cfg(feature = "recognize_text")]
119pub use recognize_text::{BoundingBox, RecognitionLevel, RecognizedText, TextRecognizer};
120
121#[cfg(feature = "detect_faces")]
122pub use detect_faces::{DetectedFace, FaceDetector};
123
124#[cfg(feature = "detect_barcodes")]
125pub use detect_barcodes::{detect_barcodes_in_path, DetectedBarcode};
126
127#[cfg(feature = "saliency")]
128pub use saliency::{attention_saliency_in_path, SalientRegion};
129
130#[cfg(feature = "face_landmarks")]
131pub use face_landmarks::{detect_face_landmarks_in_path, FaceWithLandmarks, LandmarkPoint};
132
133#[cfg(feature = "body_pose")]
134pub use body_pose::{detect_human_body_pose_in_path, DetectedBodyPose, JointPoint};
135
136#[cfg(feature = "hand_pose")]
137pub use hand_pose::{detect_human_hand_pose_in_path, DetectedHandPose};
138
139#[cfg(feature = "contours")]
140pub use contours::{detect_contours_in_path, Contour, ContourOptions};
141
142#[cfg(feature = "animals")]
143pub use animals::{recognize_animals_in_path, RecognizedAnimal};
144
145#[cfg(feature = "classify")]
146pub use classify::{classify_image_in_path, Classification};
147
148#[cfg(feature = "rectangles")]
149pub use rectangles::{
150    detect_document_segmentation_in_path, detect_rectangles_in_path, RectangleObservation,
151    RectangleOptions,
152};
153
154#[cfg(feature = "horizon")]
155pub use horizon::detect_horizon_in_path;
156
157#[cfg(feature = "feature_print")]
158pub use feature_print::{generate_image_feature_print_in_path, FeaturePrint};
159
160#[cfg(feature = "humans")]
161pub use humans::{detect_human_rectangles_in_path, DetectedHuman};
162
163#[cfg(feature = "aesthetics")]
164pub use aesthetics::{
165    calculate_aesthetics_scores_in_path, detect_face_capture_quality_in_path,
166    AestheticsScores, FaceCaptureQuality,
167};
168
169#[cfg(feature = "segmentation")]
170pub use segmentation::{
171    generate_foreground_instance_mask_in_path, generate_person_segmentation_in_path,
172    InstanceMask, SegmentationMask, SegmentationQuality,
173};
174
175#[cfg(feature = "optical_flow")]
176pub use optical_flow::{generate_optical_flow_in_paths, OpticalFlowAccuracy};
177
178#[cfg(feature = "coreml")]
179pub use coreml::coreml_classify_in_path;
180
181pub use animal_body_pose::{detect_animal_body_pose, AnimalJoint};
182pub use human_body_pose_3d::{detect_human_body_pose_3d, HumanJoint3D};
183pub use text_rectangles::{detect_text_rectangles, TextRect};
184pub use objectness_saliency::{objectness_saliency, ObjectnessRegion};
185pub use person_instance_mask::{person_instance_mask, PersonInstanceMask};
186pub use trajectories::{detect_trajectories, Trajectory};
187pub use registration::{
188    register_homographic, register_translational, HomographicAlignment, TranslationalAlignment,
189};
190
191#[cfg(feature = "tracking")]
192pub use tracking::{
193    HomographicImageTracker, ObjectTracker, OpticalFlowFrame, OpticalFlowTracker,
194    RectangleTracker, TranslationalImageTracker,
195};
196
197/// Common imports.
198pub mod prelude {
199    #[cfg(feature = "animals")]
200    pub use crate::animals::{recognize_animals_in_path, RecognizedAnimal};
201    #[cfg(feature = "body_pose")]
202    pub use crate::body_pose::{detect_human_body_pose_in_path, DetectedBodyPose, JointPoint};
203    #[cfg(feature = "classify")]
204    pub use crate::classify::{classify_image_in_path, Classification};
205    #[cfg(feature = "contours")]
206    pub use crate::contours::{detect_contours_in_path, Contour, ContourOptions};
207    #[cfg(feature = "detect_barcodes")]
208    pub use crate::detect_barcodes::{detect_barcodes_in_path, DetectedBarcode};
209    #[cfg(feature = "detect_faces")]
210    pub use crate::detect_faces::{DetectedFace, FaceDetector};
211    pub use crate::error::VisionError;
212    #[cfg(feature = "face_landmarks")]
213    pub use crate::face_landmarks::{
214        detect_face_landmarks_in_path, FaceWithLandmarks, LandmarkPoint,
215    };
216    #[cfg(feature = "feature_print")]
217    pub use crate::feature_print::{generate_image_feature_print_in_path, FeaturePrint};
218    #[cfg(feature = "hand_pose")]
219    pub use crate::hand_pose::{detect_human_hand_pose_in_path, DetectedHandPose};
220    #[cfg(feature = "horizon")]
221    pub use crate::horizon::detect_horizon_in_path;
222    #[cfg(feature = "humans")]
223    pub use crate::humans::{detect_human_rectangles_in_path, DetectedHuman};
224    #[cfg(feature = "rectangles")]
225    pub use crate::rectangles::{
226        detect_document_segmentation_in_path, detect_rectangles_in_path, RectangleObservation,
227        RectangleOptions,
228    };
229    #[cfg(feature = "recognize_text")]
230    pub use crate::processing::{
231        ImageRequestHandler, Observation, RecognizedTextObservation, Request, RequestKind,
232        SequenceRequestHandler, TimeRange, VideoCadence, VideoProcessingOptions, VideoProcessor,
233    };
234    #[cfg(feature = "recognize_text")]
235    pub use crate::recognize_text::{
236        BoundingBox, RecognitionLevel, RecognizedText, TextRecognizer,
237    };
238    #[cfg(feature = "saliency")]
239    pub use crate::saliency::{attention_saliency_in_path, SalientRegion};
240    #[cfg(feature = "tracking")]
241    pub use crate::tracking::{
242        HomographicImageTracker, ObjectTracker, OpticalFlowFrame, OpticalFlowTracker,
243        RectangleTracker, TranslationalImageTracker,
244    };
245}