Way to filter out False Positives in Template Matching
Hi all,
I am trying to detect the screws on metal surfaces so I've implemented a trivial template matcher, in which I feed templates of screws in and spot them in the scene. As you know, in such a case, we have a threshold value (like a sensitivity value) that we tweak based on the false/true negatives we get in the output.
So the very typical problem is that if I set to to a high value, it filters too much and loses the true positives, and when I set it to too low, it gives way too many false positives. The way I see it, there is going to be an optimum value for me, and after that it all will depend on "how further I could filter the false positives out". In this part exactly, I need your help.
How do you think I can filter out the false positives? They are caused by similarities of pixels (of templates) and the parts of the scene, but this is something I cannot change. So far I thought about dividing the surface in the regions and marking down the expected regions where screws are usually expected, kinda like ROI thingy.
But not sure if it makes sense in the long run, since this holds true for harddisks perhaps (screws are always on certain locations) but not other devices.
How do you think one can overcome this problem?
EDIT: So instead using partial templates, I've decided to use "complete" templates (full screws), however now I am increasing number of templates I am looping over. That is, I am creating screw templates from images (of scenes) which are different from each other. For instance, some screw templates now has sunlight reflecting on them whereas others look quite dark. See the following templates;
and then the results I am having are looking like:
Then I think I am now down to the question of " How to find the screws which are not completely visible?"
How do you perform template match (method) ? Has your template same size/rotation of finding ? How do you perform multiple matching filtering (do you clean scores around) ?
read this is-template-matching-the-best-approach-to-go-about-when-finding-the-exact-image-on-the-screen-multiple-times, Template Matching is wrong with specific Reference image
I am using the sample given by OpenCV here. I have several templates though (quarter screw, half screw, etc), instead of 1. I loop over each and look for it in the image, mark it. And BTW I am using the TM_CCOEFF_NORMED way, which I think is the best resulting one. I tried all others as well but this seems to be the one that I should use.