Ask Your Question

Revision history [back]

problem with cvMatchTemplate method

hi there, I'm new in openCV and want to using of cvMatchTemplate but result of this method is not desirable my program is: IplImage *t = cvLoadImage("template.jpg",1); IplImage *i = cvLoadImage("source.jpg",1); IplImage *res = cvCreateImage(cvSize(i->width - t->width+1,i->height - t->height +1),IPL_DEPTH_32F, 1); cvZero(res); cvMatchTemplate(i, t, res, CV_TM_CCORR_NORMED); CvPoint minloc, maxloc; double minval, maxval; cvMinMaxLoc(res,&minval,&maxval,&minloc,&maxloc,NULL); cvRectangle(i, cvPoint(maxloc.x, maxloc.y), cvPoint(maxloc.x + 50, maxloc.y + 50), cvScalar(250,250,250), 2, 0, 0); cvShowImage("Matched area",i); but after running it result image is: image description and my source and template images are:image descriptionimage description (in result image a bigger rectangle is matched with template...!!!). help me to use of template macthing in openCV, special thanks to you.

problem with cvMatchTemplate method

hi there, I'm new in openCV and want to using of cvMatchTemplate cvMatchTemplate but the result of this method is not desirable my desirable. My program is: is:

IplImage *t = cvLoadImage("template.jpg",1);
IplImage *i = cvLoadImage("source.jpg",1);
IplImage *res = cvCreateImage(cvSize(i->width - t->width+1,i->height - t->height +1),IPL_DEPTH_32F, 1);
cvZero(res);
cvMatchTemplate(i, t, res, CV_TM_CCORR_NORMED);
CvPoint minloc, maxloc;
double minval, maxval;
cvMinMaxLoc(res,&minval,&maxval,&minloc,&maxloc,NULL);
cvRectangle(i, cvPoint(maxloc.x, maxloc.y), cvPoint(maxloc.x + 50, maxloc.y + 50), cvScalar(250,250,250), 2, 0, 0);
cvShowImage("Matched area",i);

but after running it the result image is: is:

image description

and my source and template images are:

image description image description

(in result image a bigger rectangle is matched with template...!!!). help template...!!!).

Help me to use of template macthing in openCV, special openCV, Special thanks to you.

click to hide/show revision 3
retagged

problem with cvMatchTemplate method

hi there, I'm new in openCV and want to using of cvMatchTemplate but the result of this method is not desirable. My program is:

IplImage *t = cvLoadImage("template.jpg",1);
IplImage *i = cvLoadImage("source.jpg",1);
IplImage *res = cvCreateImage(cvSize(i->width - t->width+1,i->height - t->height +1),IPL_DEPTH_32F, 1);
cvZero(res);
cvMatchTemplate(i, t, res, CV_TM_CCORR_NORMED);
CvPoint minloc, maxloc;
double minval, maxval;
cvMinMaxLoc(res,&minval,&maxval,&minloc,&maxloc,NULL);
cvRectangle(i, cvPoint(maxloc.x, maxloc.y), cvPoint(maxloc.x + 50, maxloc.y + 50), cvScalar(250,250,250), 2, 0, 0);
cvShowImage("Matched area",i);

but after running it the result image is:

image description

and my source and template images are:

image description image description

(in result image a bigger rectangle is matched with template...!!!).

Help me to use of template macthing in openCV, Special thanks to you.