Reputation: 1890
I need to find objects on images, so I'm trying to do it with AForge library. I've started with very simple pattern and picture, but recognition accuracy is awful already. I'm using ExhaustiveTemplateMatching:
ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0);
Bitmap img = new Bitmap("C:/img.bmp");
Bitmap pat = new Bitmap("C:/pat.bmp");
TemplateMatch[] matchings = tm.ProcessImage(img, pat);
Debug.WriteLine("Similar: " + matchings[0].Similarity);
That's my pattern:
That's my image (it's just rotated pattern). It gets only 0,7400396 similarity:
This is practically equal to pattern's similarity to black square (0,7373355):
What I'm doing wrong, getting so low accuracy? How can I improve it?
Upvotes: 2
Views: 1284
Reputation: 3821
You're expecting this function to perform object recognition, but that's not what it's designed to do. It literally just scans the images and compares pixel values directly in order to calculate similarity. It does not look for key features, handle rotation, scaling, etc... It looks for an exact duplicate of your template image.
Upvotes: 1