Does the matching work in OpenCV 2.4.4?
The Reason I ask this question is the following: when I match both my descriptors that are of the size 64x241 and 64x258 with
matcher.match(descriptorsa,descriptorsb,matches);
the matches contain 1x258 matches... how is this possible when the descriptors in the first image only contain 241 descriptors?
EDIT:
These are the matches after I did the matcher.match(descriptorsa,descriptorsb,matches);
function.
Matches on the original picture
Here i get 258 matches with the original image, while the image has nothing to do with the original one, after being filtered (see first)
and The image that is almost identical to the original, which has gives 61 matches after being filtered.
The code is the following:
Mat img1 = Highgui.imread("mnt/sdcard/TLK.png");
Mat img2 = Highgui.imread("mnt/sdcard/TLK3.png");
MatOfKeyPoint points1 = new MatOfKeyPoint();
MatOfKeyPoint points2 = new MatOfKeyPoint();
// FAST detector
FeatureDetector fast = FeatureDetector.create(FeatureDetector.FAST);
FeatureDetector fast1 = FeatureDetector.create(FeatureDetector.FAST);
// Detects all the keypoints
fast1.detect(img1,points1);
fast.detect(img2, points2);
// FREAK descriptor
long time2 = System.currentTimeMillis();
descriptor2 = DescriptorExtractor.create(DescriptorExtractor.FREAK);
descriptor3 = DescriptorExtractor.create(DescriptorExtractor.FREAK);
Mat descriptorsDB = new Mat();
Mat descriptorsCamera = new Mat();
descriptor3.compute(img1, points1, descriptorsDB);
descriptor2.compute(img2, points2, descriptorsCamera);
//matcher
MatOfDMatch matches = new MatOfDMatch();
matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);
matcher.match(descriptorsDB,descriptorsCamera,matches);
Log.d("LOG!", "Aantal goeie matches na de .match= " + matches.size());
MatOfDMatch goedematches = new MatOfDMatch();
double max_dist = 0;
double min_dist = 100000;
if (descriptorsDB.cols() == descriptorsCamera.cols())
{
// calculates max and min distance between keypoints
for( int i = 0; i < descriptorsDB.rows(); i++ )
{ double dist = matches.toArray()[i].distance;
if( dist < min_dist ) min_dist = dist;
if( dist > max_dist ) max_dist = dist;
}
// tekent enkel goeie matches
for( int i = 0; i < descriptorsDB.rows(); i++ )
{ MatOfDMatch temp = new MatOfDMatch();
if( matches.toArray()[i].distance <= 2*min_dist )
{ temp.fromArray(matches.toArray()[i]);
goedematches.push_back(temp);
}
}