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.1 ships text recognition (OCR) only. Object/face detection lands
13//! in v0.2.
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// v0.13: new request types
93pub mod animal_body_pose;
94pub mod human_body_pose_3d;
95pub mod text_rectangles;
96pub mod objectness_saliency;
97pub mod person_instance_mask;
98pub mod trajectories;
99pub mod registration;
100
101pub use error::VisionError;
102
103#[cfg(feature = "recognize_text")]
104pub use recognize_text::{BoundingBox, RecognitionLevel, RecognizedText, TextRecognizer};
105
106#[cfg(feature = "detect_faces")]
107pub use detect_faces::{DetectedFace, FaceDetector};
108
109#[cfg(feature = "detect_barcodes")]
110pub use detect_barcodes::{detect_barcodes_in_path, DetectedBarcode};
111
112#[cfg(feature = "saliency")]
113pub use saliency::{attention_saliency_in_path, SalientRegion};
114
115#[cfg(feature = "face_landmarks")]
116pub use face_landmarks::{detect_face_landmarks_in_path, FaceWithLandmarks, LandmarkPoint};
117
118#[cfg(feature = "body_pose")]
119pub use body_pose::{detect_human_body_pose_in_path, DetectedBodyPose, JointPoint};
120
121#[cfg(feature = "hand_pose")]
122pub use hand_pose::{detect_human_hand_pose_in_path, DetectedHandPose};
123
124#[cfg(feature = "contours")]
125pub use contours::{detect_contours_in_path, Contour, ContourOptions};
126
127#[cfg(feature = "animals")]
128pub use animals::{recognize_animals_in_path, RecognizedAnimal};
129
130#[cfg(feature = "classify")]
131pub use classify::{classify_image_in_path, Classification};
132
133#[cfg(feature = "rectangles")]
134pub use rectangles::{
135    detect_document_segmentation_in_path, detect_rectangles_in_path, RectangleObservation,
136    RectangleOptions,
137};
138
139#[cfg(feature = "horizon")]
140pub use horizon::detect_horizon_in_path;
141
142#[cfg(feature = "feature_print")]
143pub use feature_print::{generate_image_feature_print_in_path, FeaturePrint};
144
145#[cfg(feature = "humans")]
146pub use humans::{detect_human_rectangles_in_path, DetectedHuman};
147
148#[cfg(feature = "aesthetics")]
149pub use aesthetics::{
150    calculate_aesthetics_scores_in_path, detect_face_capture_quality_in_path,
151    AestheticsScores, FaceCaptureQuality,
152};
153
154#[cfg(feature = "segmentation")]
155pub use segmentation::{
156    generate_foreground_instance_mask_in_path, generate_person_segmentation_in_path,
157    InstanceMask, SegmentationMask, SegmentationQuality,
158};
159
160#[cfg(feature = "optical_flow")]
161pub use optical_flow::{generate_optical_flow_in_paths, OpticalFlowAccuracy};
162
163#[cfg(feature = "coreml")]
164pub use coreml::coreml_classify_in_path;
165
166pub use animal_body_pose::{detect_animal_body_pose, AnimalJoint};
167pub use human_body_pose_3d::{detect_human_body_pose_3d, HumanJoint3D};
168pub use text_rectangles::{detect_text_rectangles, TextRect};
169pub use objectness_saliency::{objectness_saliency, ObjectnessRegion};
170pub use person_instance_mask::{person_instance_mask, PersonInstanceMask};
171pub use trajectories::{detect_trajectories, Trajectory};
172pub use registration::{
173    register_homographic, register_translational, HomographicAlignment, TranslationalAlignment,
174};
175
176/// Common imports.
177pub mod prelude {
178    #[cfg(feature = "animals")]
179    pub use crate::animals::{recognize_animals_in_path, RecognizedAnimal};
180    #[cfg(feature = "body_pose")]
181    pub use crate::body_pose::{detect_human_body_pose_in_path, DetectedBodyPose, JointPoint};
182    #[cfg(feature = "classify")]
183    pub use crate::classify::{classify_image_in_path, Classification};
184    #[cfg(feature = "contours")]
185    pub use crate::contours::{detect_contours_in_path, Contour, ContourOptions};
186    #[cfg(feature = "detect_barcodes")]
187    pub use crate::detect_barcodes::{detect_barcodes_in_path, DetectedBarcode};
188    #[cfg(feature = "detect_faces")]
189    pub use crate::detect_faces::{DetectedFace, FaceDetector};
190    pub use crate::error::VisionError;
191    #[cfg(feature = "face_landmarks")]
192    pub use crate::face_landmarks::{
193        detect_face_landmarks_in_path, FaceWithLandmarks, LandmarkPoint,
194    };
195    #[cfg(feature = "feature_print")]
196    pub use crate::feature_print::{generate_image_feature_print_in_path, FeaturePrint};
197    #[cfg(feature = "hand_pose")]
198    pub use crate::hand_pose::{detect_human_hand_pose_in_path, DetectedHandPose};
199    #[cfg(feature = "horizon")]
200    pub use crate::horizon::detect_horizon_in_path;
201    #[cfg(feature = "humans")]
202    pub use crate::humans::{detect_human_rectangles_in_path, DetectedHuman};
203    #[cfg(feature = "rectangles")]
204    pub use crate::rectangles::{
205        detect_document_segmentation_in_path, detect_rectangles_in_path, RectangleObservation,
206        RectangleOptions,
207    };
208    #[cfg(feature = "recognize_text")]
209    pub use crate::recognize_text::{
210        BoundingBox, RecognitionLevel, RecognizedText, TextRecognizer,
211    };
212    #[cfg(feature = "saliency")]
213    pub use crate::saliency::{attention_saliency_in_path, SalientRegion};
214}