Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Improving Template Matching Algorithm for OpenCV

Car detection using OpenCV

I am working on a small personal project where i have to know wether an image shown is a car or not. I am using the basic OpenCV python based template matching.

Positive Image / Template Image

Car Top View :- https://i.sstatic.net/zXr1U.jpg

The simple template matching by using one of the positive image on the other is giving the required result.

Negative Image

But when we are using negative images like https://i.sstatic.net/YLVwc.jpg the template finder is finding this as a positive match.

Methods tried and failed :-

  1. Increase the threshold for template matching :- Increasing the threshold is causing many of the actual positive images to stop matching

  2. Different types of template matching techniques that are there in OpenCV :- Not giving any better result

  3. Using multiple templates to reinforce positive and negative matches:- Doesn't work well for all the cases

Is there a better way to remove the template matching false positives that we are getting. Are there any feature matching or edge detection based techniques that can be used instead of template matching to improve my algorithm.

like image 554
ANIRUDH NJ Avatar asked Oct 23 '25 06:10

ANIRUDH NJ


1 Answers

simple way but might worth trying in your case is to divide your template into ("4") parts - corner and then apply template matching on each of the parts and only accept when the 4 parts are found

also:

  • adding different template while increasing the threshold

  • apply some normalization if it is not already being applied

like image 157
M.Sabaa Avatar answered Oct 25 '25 05:10

M.Sabaa