minMaxLoc() always returns values even template doesn't exist in image
matchTemplate(Image, Template, ResImage, CV_TM_CCOEFF);
double Min, Max;
Point MinLoc, MaxLoc;
minMaxLoc(ResImage, &Min, &Max, &MinLoc, &MaxLoc, Mat());
minMaxLoc() always returns values even "Template" doesn't exist in "Image".
How do we know if it really exists or not?
The documentation says that if CV_TM_CCOEFF is used, the best match is MaxLoc.
But MaxLoc always contains values.
minMaxLoc return min and max location and minum and maximum. It always exists
you'll have to find an experimental threshold value, e.g. if
Max < 0.6
- it did not find it.You should use TM_CCOEFF_NORMED
@LBerger, be careful with that suggestion. By using normalized output, even matches with very low scores wil be stretched over the whole 0-1 spectrum. This will screw up matches in my opinion. I always prefer looking for a threshold value for your specific case :)
@StevenPuttemans I'm not so sure. _NORMED versions normalize result respect to lightness and template size. This is completely different from range normalization such as
normalize()
that for sure screw up matches. I'm wrong ?yesI'm agree with @pklab see statistics
you proved me wrong :D
@StevenPuttemans you are so perfect that I was thinking I lost something :-)