java - OpenCV Template matching improper if region set using cvSetImageROI -


i trying match template using javacv. problem that, if set region using cvsetimageroi output not proper, shows rectangle anywhere in resulted output area, if cvsetimageroi not used results proper, shows desired output. following code

public static void main(string c[]) {       iplimage src = cvloadimage("d:\\opencvtest\\1.jpg", 0);       iplimage tmp = cvloadimage("d:\\opencvtest\\close.png", 0);       iplimage result = cvcreateimage(cvsize(src.width() -tmp.width()+1,src.height()-tmp.height() + 1),ipl_depth_32f,1);     cvzero(result);     // cvsetimageroi(src, new cvrect(370, 175, 624, 398));     //cvsetimageroi(result, new cvrect(370, 175, 624 - tmp.width() + 1, 398 - tmp.height() + 1));      cvmatchtemplate(src, tmp, result, cv_tm_ccorr_normed);      double[] min_val = new double[2];     double[] max_val = new double[2];     cvpoint minloc = new cvpoint();     cvpoint maxloc = new cvpoint();      cvminmaxloc(result, min_val, max_val, minloc, maxloc,null);     cvpoint point = new cvpoint();     point.x(maxloc.x() + tmp.width());     point.y(maxloc.y() + tmp.height());     cvrectangle(src, maxloc, point, cvscalar.green, 2, 8, 0);     cvshowimage("lena image", src);     cvwaitkey(0);     cvreleaseimage(src);     cvreleaseimage(tmp);     cvreleaseimage(result); } 


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -