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
92pub use error::VisionError;
93
94#[cfg(feature = "recognize_text")]
95pub use recognize_text::{BoundingBox, RecognitionLevel, RecognizedText, TextRecognizer};
96
97#[cfg(feature = "detect_faces")]
98pub use detect_faces::{DetectedFace, FaceDetector};
99
100#[cfg(feature = "detect_barcodes")]
101pub use detect_barcodes::{detect_barcodes_in_path, DetectedBarcode};
102
103#[cfg(feature = "saliency")]
104pub use saliency::{attention_saliency_in_path, SalientRegion};
105
106#[cfg(feature = "face_landmarks")]
107pub use face_landmarks::{detect_face_landmarks_in_path, FaceWithLandmarks, LandmarkPoint};
108
109#[cfg(feature = "body_pose")]
110pub use body_pose::{detect_human_body_pose_in_path, DetectedBodyPose, JointPoint};
111
112#[cfg(feature = "hand_pose")]
113pub use hand_pose::{detect_human_hand_pose_in_path, DetectedHandPose};
114
115#[cfg(feature = "contours")]
116pub use contours::{detect_contours_in_path, Contour, ContourOptions};
117
118#[cfg(feature = "animals")]
119pub use animals::{recognize_animals_in_path, RecognizedAnimal};
120
121#[cfg(feature = "classify")]
122pub use classify::{classify_image_in_path, Classification};
123
124#[cfg(feature = "rectangles")]
125pub use rectangles::{
126    detect_document_segmentation_in_path, detect_rectangles_in_path, RectangleObservation,
127    RectangleOptions,
128};
129
130#[cfg(feature = "horizon")]
131pub use horizon::detect_horizon_in_path;
132
133#[cfg(feature = "feature_print")]
134pub use feature_print::{generate_image_feature_print_in_path, FeaturePrint};
135
136#[cfg(feature = "humans")]
137pub use humans::{detect_human_rectangles_in_path, DetectedHuman};
138
139#[cfg(feature = "aesthetics")]
140pub use aesthetics::{
141    calculate_aesthetics_scores_in_path, detect_face_capture_quality_in_path,
142    AestheticsScores, FaceCaptureQuality,
143};
144
145#[cfg(feature = "segmentation")]
146pub use segmentation::{
147    generate_foreground_instance_mask_in_path, generate_person_segmentation_in_path,
148    InstanceMask, SegmentationMask, SegmentationQuality,
149};
150
151#[cfg(feature = "optical_flow")]
152pub use optical_flow::{generate_optical_flow_in_paths, OpticalFlowAccuracy};
153
154#[cfg(feature = "coreml")]
155pub use coreml::coreml_classify_in_path;
156
157/// Common imports.
158pub mod prelude {
159    #[cfg(feature = "animals")]
160    pub use crate::animals::{recognize_animals_in_path, RecognizedAnimal};
161    #[cfg(feature = "body_pose")]
162    pub use crate::body_pose::{detect_human_body_pose_in_path, DetectedBodyPose, JointPoint};
163    #[cfg(feature = "classify")]
164    pub use crate::classify::{classify_image_in_path, Classification};
165    #[cfg(feature = "contours")]
166    pub use crate::contours::{detect_contours_in_path, Contour, ContourOptions};
167    #[cfg(feature = "detect_barcodes")]
168    pub use crate::detect_barcodes::{detect_barcodes_in_path, DetectedBarcode};
169    #[cfg(feature = "detect_faces")]
170    pub use crate::detect_faces::{DetectedFace, FaceDetector};
171    pub use crate::error::VisionError;
172    #[cfg(feature = "face_landmarks")]
173    pub use crate::face_landmarks::{
174        detect_face_landmarks_in_path, FaceWithLandmarks, LandmarkPoint,
175    };
176    #[cfg(feature = "feature_print")]
177    pub use crate::feature_print::{generate_image_feature_print_in_path, FeaturePrint};
178    #[cfg(feature = "hand_pose")]
179    pub use crate::hand_pose::{detect_human_hand_pose_in_path, DetectedHandPose};
180    #[cfg(feature = "horizon")]
181    pub use crate::horizon::detect_horizon_in_path;
182    #[cfg(feature = "humans")]
183    pub use crate::humans::{detect_human_rectangles_in_path, DetectedHuman};
184    #[cfg(feature = "rectangles")]
185    pub use crate::rectangles::{
186        detect_document_segmentation_in_path, detect_rectangles_in_path, RectangleObservation,
187        RectangleOptions,
188    };
189    #[cfg(feature = "recognize_text")]
190    pub use crate::recognize_text::{
191        BoundingBox, RecognitionLevel, RecognizedText, TextRecognizer,
192    };
193    #[cfg(feature = "saliency")]
194    pub use crate::saliency::{attention_saliency_in_path, SalientRegion};
195}