Reputation: 45
If matchTemplate finds a match ,the result is displayed using a rectangle around it. But what to do if MatchTemplate does not finds an accurate result? How to handle the minmax values?
Sample query image:
Relevant code snippet:
if ((minValues[0] >= 0.95) || (minValues[0] <= 0.3))
//if ((maxValues[0] >= 0.95))
{
Rectangle rect = new Rectangle(new Point(minLocations[0].X, minLocations[0].Y), new Size(imgTemplate.Width, imgTemplate.Height));
imgSource.Draw(rect, new Bgr(0, 0, 255), 1);
isFoundMatch = true;
ImageViewer.Show(imgSource);
if (isFoundMatch == true)
{
imgSource.Save("C:/Misc/MatchFound/warning.png");
}
}
Edit: I've checked for a template which is not present in the image. But its giving false match.
Upvotes: 0
Views: 121
Reputation:
In the first place, you need to look at the scores for instances you consider valid and those that you consider invalid.
If you see a clear separation between these, then you can set a threshold on the score value. But if there is some overlap between the ranges, the matching score alone is not sufficiently discriminant. Then you will need to find out extra criteria to distinguish true and false positives. These will depend on the type of patterns and the type of confusions that arise. It is uneasy to give general rules.
Upvotes: 2