Skip to content

Please help me, imgproc::match_template How to use #131

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

Closed
zoain-it opened this issue May 21, 2020 · 2 comments
Closed

Please help me, imgproc::match_template How to use #131

zoain-it opened this issue May 21, 2020 · 2 comments

Comments

@zoain-it
Copy link

I don't know how to use this library.

use opencv::{core, highgui, imgcodecs, imgproc, prelude::*};

fn main() {
    let s = imgcodecs::imread("~/Downloads/s.jpg", imgcodecs::IMREAD_COLOR).unwrap();
    let t = imgcodecs::imread("~/Downloads/t.jpg", imgcodecs::IMREAD_COLOR).unwrap();
    let mask = imgcodecs::imread("", imgcodecs::IMREAD_GRAYSCALE).unwrap();
    let zero = Mat::zeros(
        s.rows() - t.rows() + 1,
        s.cols() - t.cols() + 1,
        core::CV_32FC1,
    )
    .unwrap();
    let mut result = zero.to_mat().unwrap();
    imgproc::match_template(&s, &t, &result, imgproc::TM_CCORR_NORMED, &mask);
}

The version of opencv is 0.36
截屏2020-05-21 下午8 49 30
As shown above.

How do I modify it to make it work?

@twistedfall
Copy link
Owner

You need to pass mutable reference because it's an output argument:

&mut result

@zoain-it
Copy link
Author

Thanks, I got it.

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