简体   繁体   中英

Matching template images with masks using OpenCV and C++

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:

在此处输入图片说明

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

matchTemplate( img, templ, result, match_method );

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM