Ask Your Question

Revision history [back]

The problem with the tutorial is that it knows the object is going to be in the image. There are two issues.

  1. 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.
  2. 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!

The problem with the tutorial is that it knows the object is going to be in the image. image, and it does not cope with the fact that there are possible no matches at all. There are two issues.main issues in this tutorial code if you want to apply it for your case.

  1. 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.
  2. 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!