Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

minMaxLoc, maxVal always is 1

Hi everyone

When i use minMaxLoc, to find the best score of matchtemplating, in maxVal i have always value 1.

My code:

void MatchingMethod(int, void*)

{

Mat img_display;
img.copyTo(img_display);
int result_cols = img.cols - templ.cols + 1;
int result_rows = img.rows - templ.rows + 1;
result.create(result_rows, result_cols, CV_32F);
matchTemplate(img_display, templ, result, CV_TM_SQDIFF);
normalize(result, result, 0, 1, NORM_MINMAX, -1, Mat());
/// Localizing the best match with minMaxLoc
double minVal; double maxVal; Point minLoc; Point maxLoc;Point matchLoc;
minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc, Mat());
scores = maxVal;

if (scores > 0.0)
{
    printf("\nWynik:%\F", minVal);
    printf("  %\F", maxVal);
    printf(" %\F", minLoc);
    printf(" %\F", maxLoc);
};

if someone can help me?