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

matchTemplate difficult to find match #403

Open
pkallos opened this issue Apr 25, 2016 · 1 comment
Open

matchTemplate difficult to find match #403

pkallos opened this issue Apr 25, 2016 · 1 comment

Comments

@pkallos
Copy link

pkallos commented Apr 25, 2016

I think the change in #389 is incompatible with #163 's introduction of the .templateMatches function, which is useful.

In version 5.0.0 you can do the following:

var output = im.matchTemplate(templatePath, 3);
console.log(output.templateMatches(0.8, 1, 1));

and expect it to return the position of matches in the "probability" range 0.8-1.

Change in #389 introduces an output[0] Mat which appears to be normalized to a different range.

The new behavior for .matchTemplate appears to always return the coordinates to the "best match", but doesn't provide a mechanism for checking how closely the result should match the template.

In test cases where you checking a source image that doesn't contain the template image, it is now unclear to me how to check on the quality of the match.

@pkallos
Copy link
Author

pkallos commented Jun 15, 2016

Not to mention that with the new changes to matchTemplate you can't easily return multiple matches, since it just returns one ROI, however using the old version you can run

var output = im.matchTemplate(templatePath, 3);
console.log(output.templateMatches(0.8, 1, 1));

And it will actually return multiple matches (sorted by how closely they match).

@salmanulhaq cc @peterbraden I think the crux of the fix in #389 was this line which fixes the error for certain input files:

OpenCV Error: Assertion failed ((img.depth() == CV_8U || img.depth() == CV_32F) && img.type() == templ.type()) in matchTemplate, file /tmp/opencv20160107-54198-1duzac3/opencv-2.4.12/modules/imgproc/src/templmatch.cpp, line 249

But changing the function to always run

 cv::normalize(m_out->mat, m_out->mat, 0, 1, cv::NORM_MINMAX, -1, cv::Mat());

And return an array breaks the functionality of the . templateMatches function.

Would you guys be okay with me reverting most of this change, all but the CV_8S and then advising those in #387 to just use matchTemplate + templateMatches to get regions of interest in their matches?

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

1 participant