Open pkallos opened 8 years ago
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?
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:
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.