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.14 covers the full Apple Vision request surface, including the
13//! stateful tracking requests.
14
15#![cfg_attr(docsrs, feature(doc_cfg))]
16
17pub mod error;
18pub mod ffi;
19
20#[cfg(feature = "recognize_text")]
21#[cfg_attr(docsrs, doc(cfg(feature = "recognize_text")))]
22pub mod recognize_text;
23
24#[cfg(feature = "detect_faces")]
25#[cfg_attr(docsrs, doc(cfg(feature = "detect_faces")))]
26pub mod detect_faces;
27
28#[cfg(feature = "detect_barcodes")]
29#[cfg_attr(docsrs, doc(cfg(feature = "detect_barcodes")))]
30pub mod detect_barcodes;
31
32#[cfg(feature = "saliency")]
33#[cfg_attr(docsrs, doc(cfg(feature = "saliency")))]
34pub mod saliency;
35
36#[cfg(feature = "face_landmarks")]
37#[cfg_attr(docsrs, doc(cfg(feature = "face_landmarks")))]
38pub mod face_landmarks;
39
40#[cfg(feature = "body_pose")]
41#[cfg_attr(docsrs, doc(cfg(feature = "body_pose")))]
42pub mod body_pose;
43
44#[cfg(feature = "hand_pose")]
45#[cfg_attr(docsrs, doc(cfg(feature = "hand_pose")))]
46pub mod hand_pose;
47
48#[cfg(feature = "contours")]
49#[cfg_attr(docsrs, doc(cfg(feature = "contours")))]
50pub mod contours;
51
52#[cfg(feature = "animals")]
53#[cfg_attr(docsrs, doc(cfg(feature = "animals")))]
54pub mod animals;
55
56#[cfg(feature = "classify")]
57#[cfg_attr(docsrs, doc(cfg(feature = "classify")))]
58pub mod classify;
59
60#[cfg(feature = "rectangles")]
61#[cfg_attr(docsrs, doc(cfg(feature = "rectangles")))]
62pub mod rectangles;
63
64#[cfg(feature = "horizon")]
65#[cfg_attr(docsrs, doc(cfg(feature = "horizon")))]
66pub mod horizon;
67
68#[cfg(feature = "feature_print")]
69#[cfg_attr(docsrs, doc(cfg(feature = "feature_print")))]
70pub mod feature_print;
71
72#[cfg(feature = "humans")]
73#[cfg_attr(docsrs, doc(cfg(feature = "humans")))]
74pub mod humans;
75
76#[cfg(feature = "aesthetics")]
77#[cfg_attr(docsrs, doc(cfg(feature = "aesthetics")))]
78pub mod aesthetics;
79
80#[cfg(feature = "segmentation")]
81#[cfg_attr(docsrs, doc(cfg(feature = "segmentation")))]
82pub mod segmentation;
83
84#[cfg(feature = "optical_flow")]
85#[cfg_attr(docsrs, doc(cfg(feature = "optical_flow")))]
86pub mod optical_flow;
87
88#[cfg(feature = "coreml")]
89#[cfg_attr(docsrs, doc(cfg(feature = "coreml")))]
90pub mod coreml;
91
92#[cfg(feature = "tracking")]
93#[cfg_attr(docsrs, doc(cfg(feature = "tracking")))]
94pub mod tracking;
95
96// v0.13: new request types
97pub mod animal_body_pose;
98pub mod human_body_pose_3d;
99pub mod text_rectangles;
100pub mod objectness_saliency;
101pub mod person_instance_mask;
102pub mod trajectories;
103pub mod registration;
104
105pub use error::VisionError;
106
107#[cfg(feature = "recognize_text")]
108pub use recognize_text::{BoundingBox, RecognitionLevel, RecognizedText, TextRecognizer};
109
110#[cfg(feature = "detect_faces")]
111pub use detect_faces::{DetectedFace, FaceDetector};
112
113#[cfg(feature = "detect_barcodes")]
114pub use detect_barcodes::{detect_barcodes_in_path, DetectedBarcode};
115
116#[cfg(feature = "saliency")]
117pub use saliency::{attention_saliency_in_path, SalientRegion};
118
119#[cfg(feature = "face_landmarks")]
120pub use face_landmarks::{detect_face_landmarks_in_path, FaceWithLandmarks, LandmarkPoint};
121
122#[cfg(feature = "body_pose")]
123pub use body_pose::{detect_human_body_pose_in_path, DetectedBodyPose, JointPoint};
124
125#[cfg(feature = "hand_pose")]
126pub use hand_pose::{detect_human_hand_pose_in_path, DetectedHandPose};
127
128#[cfg(feature = "contours")]
129pub use contours::{detect_contours_in_path, Contour, ContourOptions};
130
131#[cfg(feature = "animals")]
132pub use animals::{recognize_animals_in_path, RecognizedAnimal};
133
134#[cfg(feature = "classify")]
135pub use classify::{classify_image_in_path, Classification};
136
137#[cfg(feature = "rectangles")]
138pub use rectangles::{
139    detect_document_segmentation_in_path, detect_rectangles_in_path, RectangleObservation,
140    RectangleOptions,
141};
142
143#[cfg(feature = "horizon")]
144pub use horizon::detect_horizon_in_path;
145
146#[cfg(feature = "feature_print")]
147pub use feature_print::{generate_image_feature_print_in_path, FeaturePrint};
148
149#[cfg(feature = "humans")]
150pub use humans::{detect_human_rectangles_in_path, DetectedHuman};
151
152#[cfg(feature = "aesthetics")]
153pub use aesthetics::{
154    calculate_aesthetics_scores_in_path, detect_face_capture_quality_in_path,
155    AestheticsScores, FaceCaptureQuality,
156};
157
158#[cfg(feature = "segmentation")]
159pub use segmentation::{
160    generate_foreground_instance_mask_in_path, generate_person_segmentation_in_path,
161    InstanceMask, SegmentationMask, SegmentationQuality,
162};
163
164#[cfg(feature = "optical_flow")]
165pub use optical_flow::{generate_optical_flow_in_paths, OpticalFlowAccuracy};
166
167#[cfg(feature = "coreml")]
168pub use coreml::coreml_classify_in_path;
169
170pub use animal_body_pose::{detect_animal_body_pose, AnimalJoint};
171pub use human_body_pose_3d::{detect_human_body_pose_3d, HumanJoint3D};
172pub use text_rectangles::{detect_text_rectangles, TextRect};
173pub use objectness_saliency::{objectness_saliency, ObjectnessRegion};
174pub use person_instance_mask::{person_instance_mask, PersonInstanceMask};
175pub use trajectories::{detect_trajectories, Trajectory};
176pub use registration::{
177    register_homographic, register_translational, HomographicAlignment, TranslationalAlignment,
178};
179
180#[cfg(feature = "tracking")]
181pub use tracking::{
182    HomographicImageTracker, ObjectTracker, OpticalFlowFrame, OpticalFlowTracker,
183    RectangleTracker, TranslationalImageTracker,
184};
185
186/// Common imports.
187pub mod prelude {
188    #[cfg(feature = "animals")]
189    pub use crate::animals::{recognize_animals_in_path, RecognizedAnimal};
190    #[cfg(feature = "body_pose")]
191    pub use crate::body_pose::{detect_human_body_pose_in_path, DetectedBodyPose, JointPoint};
192    #[cfg(feature = "classify")]
193    pub use crate::classify::{classify_image_in_path, Classification};
194    #[cfg(feature = "contours")]
195    pub use crate::contours::{detect_contours_in_path, Contour, ContourOptions};
196    #[cfg(feature = "detect_barcodes")]
197    pub use crate::detect_barcodes::{detect_barcodes_in_path, DetectedBarcode};
198    #[cfg(feature = "detect_faces")]
199    pub use crate::detect_faces::{DetectedFace, FaceDetector};
200    pub use crate::error::VisionError;
201    #[cfg(feature = "face_landmarks")]
202    pub use crate::face_landmarks::{
203        detect_face_landmarks_in_path, FaceWithLandmarks, LandmarkPoint,
204    };
205    #[cfg(feature = "feature_print")]
206    pub use crate::feature_print::{generate_image_feature_print_in_path, FeaturePrint};
207    #[cfg(feature = "hand_pose")]
208    pub use crate::hand_pose::{detect_human_hand_pose_in_path, DetectedHandPose};
209    #[cfg(feature = "horizon")]
210    pub use crate::horizon::detect_horizon_in_path;
211    #[cfg(feature = "humans")]
212    pub use crate::humans::{detect_human_rectangles_in_path, DetectedHuman};
213    #[cfg(feature = "rectangles")]
214    pub use crate::rectangles::{
215        detect_document_segmentation_in_path, detect_rectangles_in_path, RectangleObservation,
216        RectangleOptions,
217    };
218    #[cfg(feature = "recognize_text")]
219    pub use crate::recognize_text::{
220        BoundingBox, RecognitionLevel, RecognizedText, TextRecognizer,
221    };
222    #[cfg(feature = "saliency")]
223    pub use crate::saliency::{attention_saliency_in_path, SalientRegion};
224    #[cfg(feature = "tracking")]
225    pub use crate::tracking::{
226        HomographicImageTracker, ObjectTracker, OpticalFlowFrame, OpticalFlowTracker,
227        RectangleTracker, TranslationalImageTracker,
228    };
229}