Ask Your Question
0

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

asked 2014-05-23 12:09:15 -0600

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.

edit retag flag offensive close merge delete

Comments

1

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

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

berak gravatar imageberak ( 2014-05-23 12:13:02 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-05-26 08:13:33 -0600

Thank you berak! The problem was due to the different type of the matrix result (float) and minVal and maxVal in matchTemplate, which are double.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-05-23 12:09:15 -0600

Seen: 323 times

Last updated: May 26 '14