Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

matchTemplate function, result processing

I'am using opencv for some project. And have a task which should be solved. Task is quite simple. I have a main picture and have a template(s) than I compare main pic with template. I use matchTemplate() function. I'am just curiosity about one moment. In documentation I found following info: To identify the matching area, we have to compare the template image against the source image by sliding it. By sliding, we mean moving the patch one pixel at a time (left to right, up to down). At each location, a metric is calculated so it represents how “good” or “bad” the match at that location is (or how similar the patch is to that particular area of the source image). For each location of T over I, you store the metric in the result matrix (R). Each location in R contains the match metric.

So, for example you have the main picture and the template. And you know that there is one entry of template at least in main pic. And it works fine. Also it works fine if you have more then one entry, but you still know how many entries do you have. But if you do not know how many templates are in the main picture 0 or 10? Is any way to calculate it ? Which algorithm should be used? Thanks in advance.