1 | initial version |
Many times about. See this and this for more information.
Short answer:
TM_CCOEFF_NORMED
result will be between 0..1 (1=perfect match)normalize(result, result, 0, ...
otherwise you will see always a perfect match2 | No.2 Revision |
Many times about. See this and this for more information.
Short answer:
TM_CCOEFF_NORMED
result will be between 0..1 (1=perfect match)normalize(result, result, 0, ...
otherwise you will see always a perfect matchEDIT as requested...
matchTemplate
result is an image map. result(x,y)
is the result of matching formula calculated in (x,y)... is a score, a matching quality indicator for the point!
minMaxLoc
is needed to get the value and the location for the highest score, so you have maxValue
and maxLoc
. But highest score means the highest of the scores you got for your image, it could be the least worst.
Using
normalize(result, result, 0, 1,...
you will lost information about the quality without counterpart. normalize is useless here!! (use it just for imshow!!!!)
Question 1) is your highest score good enough to accept the matching ? Answer: If it's too low means that matching quality is poor!?!? Question 2) how to define too low ?
Using non _NORMED version (like is TM_CCOEFF) you don't know the value for perfect match than you can't set numeric value for too low. You can use some empiric value valid just for a given image and a given template.
Using _NORMED version (like TM_CCOEFF_NORMED) you know that perfect match is 1.0. If your maxValue is 0.99 you had almost a perfect match. If it's 0.9 you had a good match, if 0.7 may be you had a mismatch !
at the end you can write:
Imgproc.matchTemplate(image, template, result, TM_CCOEFF_NORMED);
Core.MinMaxLocResult mmr = Core.minMaxLoc(result);
double minMatchQuality = 0.9 // with CV_TM_SQDIFF_NORMED you could use 0.1
if mmr.maxValue > minMatchQuality // with CV_TM_SQDIFF_NORMED use maxValue < minMatchQuality
accept the match
else
rejecty the match
3 | No.3 Revision |
Many times about. See this and this for more information.
Short answer:
TM_CCOEFF_NORMED
result will be between 0..1 (1=perfect match)normalize(result, result, 0, ...
otherwise you will see always a perfect matchEDIT as requested...
matchTemplate
result is an image map. result(x,y)
is the result of matching formula calculated in (x,y)... is a score, a matching quality indicator for the point!
minMaxLoc
is needed to get the value and the location for the highest score, so you have maxValue
and maxLoc
. But highest score means the highest of the scores you got for your image, it could be the least worst.
Using
normalize(result, result, 0, 1,...
you will lost information about the quality without counterpart. normalize is useless here!! (use it just for imshow!!!!)
Question 1) is your highest score good enough to accept the matching ? Answer: If it's too low means that matching quality is poor!?!? Question 2) how to define too low ?
Using non _NORMED version (like is TM_CCOEFF) you don't know the value for perfect match than you can't set numeric value for too low. You can use some empiric value valid just for a given image and a given template.
Using _NORMED version (like TM_CCOEFF_NORMED) you know that perfect match is 1.0. If your maxValue is 0.99 you had almost a perfect match. If it's 0.9 you had a good match, if 0.7 may be you had a mismatch !
at the end you can write:
Imgproc.matchTemplate(image, template, result, TM_CCOEFF_NORMED);
Core.MinMaxLocResult mmr = Core.minMaxLoc(result);
double minMatchQuality = 0.9 // with CV_TM_SQDIFF_NORMED you could use 0.1
if mmr.maxValue > minMatchQuality // with CV_TM_SQDIFF_NORMED use maxValue minValue < minMatchQuality
accept the match
else
rejecty the match