pub trait Detector {
fn detect(&mut self, image: &ImageData<'_>) -> Vec<FaceInfo>;
fn set_window_size(&mut self, wnd_size: u32);
fn set_slide_window_step(&mut self, step_x: u32, step_y: u32);
fn set_min_face_size(&mut self, min_face_size: u32);
fn set_max_face_size(&mut self, max_face_size: u32);
fn set_pyramid_scale_factor(&mut self, scale_factor: f32);
fn set_score_thresh(&mut self, thresh: f64);
}
Required Methods
sourcefn detect(&mut self, image: &ImageData<'_>) -> Vec<FaceInfo>
fn detect(&mut self, image: &ImageData<'_>) -> Vec<FaceInfo>
Detect faces on input image.
(1) The input image should be gray-scale, i.e. num_channels
set to 1.
(2) Currently this function does not give the Euler angles, which are
left with invalid values.
Panics
Panics if image
is not a legal image, e.g. it
- is not gray-scale (
num_channels
is not equal to 1) - has
width
orheight
equal to 0
sourcefn set_window_size(&mut self, wnd_size: u32)
fn set_window_size(&mut self, wnd_size: u32)
Set the size of the sliding window.
The minimum size is constrained as no smaller than 20.
Panics
Panics if wnd_size
is less than 20.
sourcefn set_slide_window_step(&mut self, step_x: u32, step_y: u32)
fn set_slide_window_step(&mut self, step_x: u32, step_y: u32)
Set the sliding window step in horizontal and vertical directions.
The steps should take positive values. Usually a step of 4 is a reasonable choice.
Panics
Panics if step_x
or step_y
is less than or equal to 0.
sourcefn set_min_face_size(&mut self, min_face_size: u32)
fn set_min_face_size(&mut self, min_face_size: u32)
Set the minimum size of faces to detect.
The minimum size is constrained as no smaller than 20.
Panics
Panics if min_face_size
is less than 20.
sourcefn set_max_face_size(&mut self, max_face_size: u32)
fn set_max_face_size(&mut self, max_face_size: u32)
Set the maximum size of faces to detect.
The maximum face size actually used is computed as the minimum among: user specified size, image width, image height.
sourcefn set_pyramid_scale_factor(&mut self, scale_factor: f32)
fn set_pyramid_scale_factor(&mut self, scale_factor: f32)
Set the factor between adjacent scales of image pyramid.
The value of the factor lies in (0.1, 0.99). For example, when it is set as 0.5, an input image of size w x h will be resized to 0.5w x 0.5h, 0.25w x 0.25h, 0.125w x 0.125h, etc.
Panics
Panics if scale_factor
is less than 0.01 or greater than 0.99
sourcefn set_score_thresh(&mut self, thresh: f64)
fn set_score_thresh(&mut self, thresh: f64)
Set the score threshold of detected faces.
Detections with scores smaller than the threshold will not be returned. Typical threshold values include 0.95, 2.8, 4.5. One can adjust the threshold based on his or her own test set.
Smaller values result in more detections (possibly increasing the number of false positives), larger values result in fewer detections (possibly increasing the number of false negatives).
Panics
Panics if thresh
is less than or equal to 0.