When i perform the openCV template matching, i for some reason get my min location to be at the upper left corner, and my max location to be at the upper right corner, which is not where my template is.. I don't why i doesn't perform like that..
it implemented as such.
Point ImageConverter::normCrossCorrelation(Mat imgI,vector<Point2f> points1, vector<uchar> status, int method)
{
Mat res,rec1;
Size size(307,230);
for(int i = 0; i <= points1.size(); i++)
{
if(status[i] == 1)
{
getRectSubPix(imgI,size,points1[i],rec1);
matchTemplate(rec1, ROI, res, method);
//cout << ((float *)(res.operator _IplImage().imageData))[0] << endl;
}
}
normalize(res,res,0,1,NORM_MINMAX,-1,cv::Mat());
double minVal,maxVal;
Point minLoc,maxLoc;
minMaxLoc(res,&minVal,&maxVal,&minLoc,&maxLoc,cv::Mat());
cout << "new location: " << maxLoc << " Maxval: " << maxVal << endl;
return minLoc;
}
The image is a gray image, and it doesn't matter which method i use.. The result is always the same.. what am I doing wrong?