3

Is there some way for matchTemplate to work with a non-rectangular templ? For example to use the alpha channel, etc to ignore certain pixels when calculating the score?

The various formulas for scores SHOULD generalize to non-rectangular templates.

Alex Rothberg
  • 10,243
  • 13
  • 60
  • 120
  • might help: http://stackoverflow.com/questions/4761940/opencv-template-matching-and-transparency – anderstood Mar 21 '15 at 21:37
  • This is a dupe of https://stackoverflow.com/q/16029844/1709587; the short answer is to use the `mask` parameter to `matchTemplate`. I can't VTC as a dupe because my answer there has no upvotes, though. – Mark Amery Sep 15 '18 at 19:17

1 Answers1

1

If you are using openCV 3 you can use mask to do template match on non-rectangular regions.

But in case you are using openCV 2, you have to write your own function to mask your template and then do template match on the source image.