I copied the code of the Feature Matching with FLANN from the OpenCV tutorial page, and made the following changes:
- I used the SIFT features, instead of SURF;
I modified the check for a 'good match'. Instead of
if( matches[i].distance < 2*min_dist )
I used
if( matches[i].distance <= 2*min_dist )
otherwise I would get zero good matches when comparing an image with itself.
Modified parameter in drawing the keypoints:
drawMatches( img1, k1, img2, k2, good_matches, img_matches, Scalar::all(-1), Scalar::all(-1), vector<char>(), DrawMatchesFlags::DEFAULT);
I extracted the SIFT from all the images in the folder Ireland of the INRIA-Holidays dataset. Then I compared each image to all the others and draw the matches.
However there is a strange problem I have never experienced with any other SIFT/Matcher implementation I used in the past:
- the matches for an image I matched against itself are good. Each keypoint is mapped onto itself except for some. See image above.
- When I match I against another image J (with J not equal to I), many points are mapped onto the same one. Some examples are below.
Is there anyone who used the same code from the OpenCV tutorial and can report a different experience from mine?