I am working in logo detection application in OpenCV on Android. I have a lot of searches and find that for this purpose most of the time feature detection is used.
So I searched and tried different detectors and matchers, and finally I have written a code that works well with ORBFeatureDetector and BruteForce matcher :
private DescriptorMatcher BruteMatcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);
I found the number of matches and minimum distance and number of good matches like this :
List<DMatch> matches = mat_of_matches.toList();
double max_dist =0, min_dist= 100;
int row_count = matches.size();
for(int i=0;i<row_count;i++)
{
double dist = matches.get(i).distance;
//System.out.println("dist="+dist);
if(dist<min_dist)min_dist = dist;
if(dist>max_dist)max_dist = dist;
}
// Log.e("Max_dist,Min_dist", "Max="+max_dist+", Min="+min_dist);
List<DMatch> good_matches = new ArrayList<DMatch>();
double good_dist = 3*min_dist;
for(int i =0;i<row_count; i++)
{
if(matches.get(i).distance<good_dist)
{
good_matches.add(matches.get(i));
//Log.e("good_matches", "good_match_id="+matches.get(i).trainIdx);
}
}
, and finally I created a threshold like this :
if(row_count>490&&good_matches.size()<60&&min_dist<12)logo_detected=true;
else logo_detected=false;
The problem is that for many other things that are also in the threshold accessed and the application keeps saying the logo is detected .
I want to know what should I do with detected matched features? Is it the right thing to do (thresholding)? Or do I need to do something else to detect the logo ?
Please help, thanks.