# minVal of minmaxLoc is not what I read by direct reading at matchLoc point

Following the tutorial I created the result matrix:

/// Create the result matrix int result_cols = img.cols - templ.cols + 1; int result_rows = img.rows - templ.rows + 1; result.create( result_cols, result_rows, CV_64F );

Then I call machTemplate (with match_metod = 0) and normalize

matchTemplate( img, templ, result, match_method ); normalize( result, result, 0., 1., NORM_MINMAX, -1, Mat() );

Then I search the minimum by minmaxLoc

minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );

cout << " minVal = " << minVal << endl; returns the value minVal = 4.54747e-13

Conversely printing the corresponding matrix element with

cout << "result(j,i) = " << (result.at(double)(matchLoc.x,matchLoc.y)) << endl; I get result(j,i) = 4.19707e-07

Am I reading the matrix element rightly? Otherwise how should read (and write) the element of result matrix?

Thank you for the help.

Mat.at<sometype>(y,x); // row,col here !

also, look here, the result type is probably float , not double