问题描述
即使我使用的文档完全相同,但Opencv模板匹配却给出了错误的匹配:https://docs.opencv.org/master/d4/dc6/tutorial_py_template_matching.html
这是我正在使用的代码:
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat source=null;
Mat template=null;
String filePath="./";
//Load image file
source=Imgcodecs.imread(filePath+"Zub.jpg");
template=Imgcodecs.imread(filePath+"ic_shiny.png");
Mat outputimage=new Mat();
int machMethod=Imgproc.TM_CCOEFF;
//Template matching method
Imgproc.matchTemplate(source,template,outputimage,machMethod);
MinMaxLocResult mmr = Core.minMaxLoc(outputimage);
Point matchLoc=mmr.maxLoc;
//Draw rectangle on result image
Imgproc.rectangle(source,matchLoc,new Point(matchLoc.x + template.cols(),matchLoc.y + template.rows()),new Scalar(255,255,255));
Imgcodecs.imwrite(filePath+"output.jpg",source);
System.out.println("Done.");
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)