Browse Source

xml file is now a argument for the lib

master
Ruben van de Ven 2 years ago
parent
commit
7de5440484
  1. 1
      Cargo.lock
  2. 3
      Cargo.toml
  3. 16
      src/lib.rs

1
Cargo.lock generated

@ -2416,6 +2416,7 @@ name = "visual_haarcascades" @@ -2416,6 +2416,7 @@ name = "visual_haarcascades"
version = "0.1.0"
dependencies = [
"image 0.23.4",
"libc",
"log",
"nannou",
"ndarray",

3
Cargo.toml

@ -31,4 +31,5 @@ simplelog = "0.8.0" @@ -31,4 +31,5 @@ simplelog = "0.8.0"
# rscam = "0.5.5"
roxmltree = "0.13.0"
ndarray = "0.13"
stopwatch = "0.0.7"
stopwatch = "0.0.7"
libc = "*"

16
src/lib.rs

@ -7,6 +7,9 @@ mod heatmap; @@ -7,6 +7,9 @@ mod heatmap;
use std::slice;
use image;
use std::{ffi::CStr};
use libc::c_char;
static mut IMAGENR: i32 = 0;
#[no_mangle]
@ -17,9 +20,18 @@ pub extern "C" fn test(x: i32) -> i32 { @@ -17,9 +20,18 @@ pub extern "C" fn test(x: i32) -> i32 {
/// partly inspired by https://bheisler.github.io/post/calling-rust-in-python/
#[no_mangle]
pub extern "C" fn classifier_new()
pub extern "C" fn classifier_new(s: *const c_char)
-> *mut visualhaar::HaarClassifier {
let haar = visualhaar::HaarClassifier::from_xml("/home/ruben/Documents/Projecten/2020/rust/testproject/haarcascade_frontalface_alt2.xml").unwrap();
let c_str = unsafe {
assert!(!s.is_null());
CStr::from_ptr(s)
};
let filename = c_str.to_str().unwrap();
println!("Using cascade file: {}", filename);
let haar = visualhaar::HaarClassifier::from_xml(filename).unwrap();
let boxed_haar = Box::new(haar);
Box::into_raw(boxed_haar)
}

Loading…
Cancel
Save