The problem with the tutorial is that it knows the object is going to be in the image, and it does not cope with the fact that there are possible no matches at all. There are two main issues in this tutorial code if you want to apply it for your case.
- It always normalizes the map using
normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() );
which means the smallest match (very low score) will still be normalized towards the 1 value. - it always looks for the best hit in your matching map
As you can see here:
/// Localizing the best match with minMaxLoc
double minVal; double maxVal; Point minLoc; Point maxLoc;
Point matchLoc;
minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );
Problem is that in your case, you will have to find a harsh threshold on the non-normalized match score map. If it does not meet the threshold, there will simply be no hit!
maybe show, how you call it, too ?
@berak the same code as the official tutorial, with modification to image paths: https://docs.opencv.org/2.4/doc/tutor...