使用OpenCV和C ++将模板图像与蒙版匹配 [英] Matching template images with masks using OpenCV and C++
本文介绍了使用OpenCV和C ++将模板图像与蒙版匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在带有C ++的OpenCV中使用matchTemplate()匹配蒙版图像?
这是我蒙版的模板图片:
This is my masked template image:
这是我的原始图片:
推荐答案
matchTemplate
的第五个参数是mask
数组,可用于此目的.对于您的情况,您需要一个 binary 掩码.也就是说,Mat
具有:
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:
- 深度
CV_8U
和 - 尺寸等于模板图片,并且
- 您要从模板中忽略的像素设置为0,并且
- 要使用的像素设置为非零值(通常为1)
- 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)
这篇关于使用OpenCV和C ++将模板图像与蒙版匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文