Matching template images with masks using OpenCV and C++

Deadly 提交于 2019-12-25 02:11:56

问题


How can I match a masked image using matchTemplate() in OpenCV with C++?

This is my masked template image:

And this is my source image:


回答1:


Look at opencv example. You gotta call the matchTemplate function:

matchTemplate( img, templ, result, match_method );



回答2:


matchTemplate's fifth argument is a mask array which you can use for this purpose. In your case, you'll want a binary mask. That is, a Mat with:

  • depth CV_8U, and
  • dimensions equal to your template image, and
  • the pixels you want to ignore from your template set to 0, and
  • the pixels you want to be used set to a non-zero value (typically 1)


来源:https://stackoverflow.com/questions/16029844/matching-template-images-with-masks-using-opencv-and-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!