Browse Source

make size of minimum face variable

master
Ruben van de Ven 2 years ago
parent
commit
acf1cd93b1
  1. 3
      src/lib.rs
  2. 2
      src/test.rs
  3. 5
      src/visualhaar.rs

3
src/lib.rs

@ -43,6 +43,7 @@ pub extern "C" fn scan_image(haar: *mut visualhaar::HaarClassifier, @@ -43,6 +43,7 @@ pub extern "C" fn scan_image(haar: *mut visualhaar::HaarClassifier,
input: *const u8,
buffer: *mut u8,
length: usize,
min_face_factor: usize,
debug: bool) {
if haar.is_null() || input.is_null() || buffer.is_null() {
return;
@ -72,7 +73,7 @@ pub extern "C" fn scan_image(haar: *mut visualhaar::HaarClassifier, @@ -72,7 +73,7 @@ pub extern "C" fn scan_image(haar: *mut visualhaar::HaarClassifier,
}
}
let image = haar.scan_image(input_frame, &hm).unwrap().dynamic_img;
let image = haar.scan_image(input_frame, &hm,min_face_factor as u32).unwrap().dynamic_img;
let rgb_img = image.to_rgb();
// image.save("/home/ruben/Documents/Projecten/2020/rust/lena_orig-output-lib.png");
info!("Scanning for faces took done");

2
src/test.rs

@ -47,7 +47,7 @@ fn main() { @@ -47,7 +47,7 @@ fn main() {
let i = ib.as_rgb8().unwrap().clone();
let hm = Some(heatmap::Heatmap::new(heatmap::ColorMaps::Plasma));
let mut sw = Stopwatch::start_new();
let image = haar.scan_image(i, &hm).unwrap().dynamic_img;
let image = haar.scan_image(i, &hm, 4).unwrap().dynamic_img;
info!("Scanning for faces took {}ms", sw.elapsed_ms());
image.save("test-output.png");

5
src/visualhaar.rs

@ -342,7 +342,8 @@ impl HaarClassifier { @@ -342,7 +342,8 @@ impl HaarClassifier {
// }
/// take an ImageBuffer and scan it for faces.
pub fn scan_image(&self, frame: image::ImageBuffer<image::Rgb<u8>, Vec<u8>>, heatmap: &Option<heatmap::Heatmap>) -> Result<Outcome, String> {
/// min_face_factor parameter gives starting size of scan window (frame height / factor). So higher number scans for smaller faces.
pub fn scan_image(&self, frame: image::ImageBuffer<image::Rgb<u8>, Vec<u8>>, heatmap: &Option<heatmap::Heatmap>, min_face_factor: u32) -> Result<Outcome, String> {
let sw = Stopwatch::start_new();
@ -365,7 +366,7 @@ impl HaarClassifier { @@ -365,7 +366,7 @@ impl HaarClassifier {
// let rect = integral.slice(s![3..5, 2..4]);
// let min_size = self.width;
let min_size = frame.height() / 3; // TODO: Make min face size (or factor) variable
let min_size = frame.height() / min_face_factor; // TODO: Make min face size (or factor) variable
let max_window_size = std::cmp::min(img_bw.dimensions().0, img_bw.dimensions().1) as usize;
let mut window_size: usize = min_size.clone() as usize;

Loading…
Cancel
Save