I am using opencv with opencvsharp.
When doing a matchtemplate and afterwards minmaxloc I only get the first match. How do I get all matches?
Cv.MatchTemplate(tempImg, templateSymbol.Img, resImg, MatchTemplateMethod.CCorrNormed);
double min_val, max_val;
Cv.MinMaxLoc(resImg, out min_val, out max_val);
if (max_val > 0.5)
{
symbolsFound.Add(templateSymbol.Description);
Console.WriteLine(templateSymbol.Description);
}
I only find the first match and I know there are more matches.
See my other answer here where I show how to do exactly what you are asking for. It is written in C++, but should be fairly trivial to port to C#. Instead of using a
std::queueuse a .NET Queue.Essentially, you need to scan across your
resImglooking for all of the maximum (or minimum depending on the comparison algorithm) points, and record as many as you want into some kind of container (list, queue, priority queue, etc…).MinMaxLocwill only return the top match, so that is why you are only getting one match.