OpenCVSharp MatchTemplate 掩码

问题描述

我目前正在尝试遮罩一个对象,模板和遮罩的宽度/高度都相同,在当前的共享代码中,我实际上对模板和遮罩使用了相同的图像,但仍然出现尺寸错误

错误 OpenCvSharp.OpenCVException: '_templ.size() == _mask.size()'

代码

Mat tplMat = new Mat("c:\tmp\Image1.png",ImreadModes.Grayscale);
Mat tplMatMask = new Mat("c:\tmp\Image1mask.png",ImreadModes.Grayscale);
Mat refMat = new Mat("c:\tmp\test1.png",ImreadModes.Grayscale);
Mat res = new Mat();

Cv2.MatchTemplate(tplMat,refMat,res,TemplateMatchModes.CCoeffnormed,tplMat);

此行出错 Cv2.MatchTemplate(tplMat,tplMat);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)