Using OpenCV to Match Template Multiple Times
OpenCV has a matchTemplate function that let you seach for matches between an image and a given template.
There is a tutorial on that.
However, the tutorial falls short. It only explain how to match 1 occurence.
I know the answer is somewhere in the result
.. But I am a newbie and cannot figure out. Do are others.
I found the best answer from: OpenCV-Code.com
The genius part of the code is that it finds a match with minMaxLoc
, then it floodFill
it. Then it can repeat.
I have used it for an iOS project to count the number of matching templates. Here’s the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|