So I'm making an application with the use of FAST detectors and FREAK descriptors. When it comes to the matching I wanted to use the BRUTEFORCE_HAMMING matching, but I don't get the expected results (gives more matches with images that have nothing to do with the original, then images that look alike)
I tried the following code
MatOfDMatch matches = new MatOfDMatch();
matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);
matcher.match(descriptors,descriptors1,matches);
MatOfDMatch goedematches = new MatOfDMatch();
double max_dist = 0;
double min_dist = 100;
//if (descriptors.cols() == descriptors1.cols())
//{
for( int i = 0; i < descriptors.rows(); i++ )
{ double dist = matches.toArray()[i].distance;
if( dist < min_dist ) min_dist = dist;
if( dist > max_dist ) max_dist = dist;
}
// should only draw good matches
for( int i = 0; i < descriptors.rows(); i++ )
{ MatOfDMatch temp = new MatOfDMatch();
if( matches.toArray()[i].distance <= 2*min_dist )
{ temp.fromArray(matches.toArray()[i]);
goedematches.push_back(temp);
}
// }
}
Log.d("LOG!", "Number of good matches= " + goedematches.size());
But it gives back "bad" results. So my question is, are there other methods of doing this matching with FREAK descriptors? (I use the OpenCV Library 2.4.4 and the Java wrapper, so no C-code)
You might be getting bad results because FREAK is not rotation and scale invariant on its own. Try using the BRISK keypoint detection and FREAK descriptors around those keypoints.
JavaCV allows you to use the BRISK keypoint detection if you set the descriptor mat to null.