# 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?

edit retag close merge delete

why the normalize() ?

( 2016-10-20 05:59:00 -0500 )edit
( 2016-10-20 06:03:29 -0500 )edit
1

do you understand, what the normalize() does ?

( 2016-10-20 07:05:49 -0500 )edit

I thnk so. Normalize the values in array to defined range?

( 2016-10-20 07:55:06 -0500 )edit

I want to see the result from funkction minMaxLoc, in range 0.0 - 1.0 where 1.0 is the best score.

( 2016-10-20 07:59:03 -0500 )edit
1

so, the maximal value after that is 1, and the minimal value is 0.

again, if you don't want that, you'd have to remove the normalize() call.

( 2016-10-20 07:59:48 -0500 )edit
1

btw, printf(" %f", maxLoc); (there's no escape sequence like \F anywhere in c/c++)

( 2016-10-20 08:03:19 -0500 )edit

Sort by ยป oldest newest most voted

ok, now i understand. I removed normalize(). Thx for explain.

more

Official site

GitHub

Wiki

Documentation