Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BFMatcher - no matches or missunderstood method signature #489

Closed
sjbeskur opened this issue Aug 16, 2023 · 0 comments
Closed

BFMatcher - no matches or missunderstood method signature #489

sjbeskur opened this issue Aug 16, 2023 · 0 comments

Comments

@sjbeskur
Copy link
Contributor

Seems no matter what I try I get Zero matches. I lifted this example and images from the original OpenCV python example but I suspect I am doing something wrong in the conversion?

Any help would be much appreciated.

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let file0 = "img/box.png";
    let file1 = "img/box_in_scene.png";
    
    let img0 = imread(file0, IMREAD_GRAYSCALE)?;
    let img1 = imread(file1, IMREAD_GRAYSCALE)?;

    let mut orb = ORB::default()?;

    let mut kp_a = opencv::core::Vector::new();
    let mut des_a = Mat::default();
    let mut kp_b = opencv::core::Vector::new();
    let mut des_b = Mat::default();
    let mask = Mat::default(); // or no_array(); ??

    let _ = orb.detect_and_compute(&img0, &mask, &mut kp_a, &mut des_a, false);
    let _ = orb.detect_and_compute(&img1, &mask, &mut kp_b, &mut des_b, false);

    // let mut bf_matcher = DescriptorMatcher::create("BruteForce-Hamming")?;
    let mut bf_matcher = BFMatcher::new(NORM_HAMMING, true)?;

    let mut matches = VectorOfDMatch::new();

    // Is this correct?
    let mut query_descriptors: Vector<Mat> = Vector::new();
    query_descriptors.push(des_a);
    query_descriptors.push(des_b);

    //matcher.knn_match(&query_descriptors, &mut matches, 2,&no_array(), false);
    bf_matcher.match_(&query_descriptors, &mut matches, &no_array())?;

    println!("\n MATHES : {} --------------------" , matches.len());

    Ok(())
}
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants