I am trying to register two binary images. I used opencv orb detector and matcher to generate and match feature points. However, the matching result looks bad. Can anybody tell me why and how to improve? Thanks. Here are the images and matching result.
Here is the code
OrbFeatureDetector detector; //OrbFeatureDetector detector;SurfFeatureDetector
vector<KeyPoint> keypoints1;
detector.detect(im_edge1, keypoints1);
vector<KeyPoint> keypoints2;
detector.detect(im_edge2, keypoints2);
OrbDescriptorExtractor extractor; //OrbDescriptorExtractor extractor; SurfDescriptorExtractor extractor;
Mat descriptors_1, descriptors_2;
extractor.compute( im_edge1, keypoints1, descriptors_1 );
extractor.compute( im_edge2, keypoints2, descriptors_2 );
//-- Step 3: Matching descriptor vectors with a brute force matcher
BFMatcher matcher(NORM_L2, true); //BFMatcher matcher(NORM_L2);
vector< DMatch> matches;
matcher.match(descriptors_1, descriptors_2, matches);
vector< DMatch > good_matches;
vector<Point2f> featurePoints1;
vector<Point2f> featurePoints2;
for(int i=0; i<int(matches.size()); i++){
good_matches.push_back(matches[i]);
}
//-- Draw only "good" matches
Mat img_matches;
imwrite("img_matches_orb.bmp", img_matches);
Some answers there may be helpful: Improve matching of feature points with OpenCV
It's for SIFT descriptor, but we can also use them for ORB matching:)