1use crate::Rect;
2use ndarray::ArrayViewD;
3use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum RustFacesError {
8 #[error("IO error: {0}")]
10 IoError(std::io::Error),
11 #[error("Image error: {0}")]
13 ImageError(String),
14 #[error("Inference error: {0}")]
16 InferenceError(String),
17 #[error("Other error: {0}")]
19 Other(String),
20}
21
22impl From<std::io::Error> for RustFacesError {
23 fn from(err: std::io::Error) -> Self {
24 RustFacesError::IoError(err)
25 }
26}
27
28pub type RustFacesResult<R> = Result<R, RustFacesError>;
29
30#[derive(Debug, Clone)]
32pub struct Face {
33 pub rect: Rect,
35 pub confidence: f32,
37 pub landmarks: Option<Vec<(f32, f32)>>,
39}
40
41pub trait FaceDetector: Sync + Send {
43 fn detect(&self, image: ArrayViewD<u8>) -> RustFacesResult<Vec<Face>>;
49}