This package, inspired by the patlevin's face-detection-tflite, also tries to implement parts of Google®'s MediaPipe models in Rust using OpenCV and rust-ndarray.
Note: Due to Github's file size limit, download the face embedding model from the following link: face embeddings
The package provides the following models:
To run the detection:
let face_detection = FaceDetection::new(FaceDetectionModel::BackCamera, None).unwrap();
// test data
let im_bytes: &[u8] = include_bytes!("../test_data/man.jpg");
let image = convert_image_to_mat(im_bytes).unwrap();
let img_shape = image.size().unwrap();
// Face detection
let faces = face_detection.infer(&image, None).unwrap();
let face_roi = face_detection_to_roi(faces[0].clone(), (img_shape.width, img_shape.height)).unwrap();
// Face landmark
let face_landmark = FaceLandmark::new(None).unwrap();
let lmks = face_landmark.infer(&image, Some(face_roi)).unwrap();
// Face irises
let (left_eye_roi, right_eye_roi) = iris_roi_from_face_landmarks(lmks.clone(), (img_shape.width, img_shape.height)).unwrap();
let iris_landmark = IrisLandmark::new(None).unwrap();
let right_iris_lmk = iris_landmark.infer(&image, Some(right_eye_roi), Some(true)).unwrap();
let left_iris_lmk = iris_landmark.infer(&image, Some(left_eye_roi), Some(false)).unwrap();
- OpenCV, as well as opencv-rust library is required. For installation guide, please take a look at opencv-rust