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