how to improve orb feature matching?

10,876

Solution 1

ORB descriptors are, unlike SURF, binary descriptors. The HAMMING distance is suited for binary descriptors comparison. Use NORM_HAMMING when initializing your BFMatcher.

Solution 2

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:)

Share:
10,876
fnhdx
Author by

fnhdx

Updated on June 04, 2022

Comments

  • fnhdx
    fnhdx almost 2 years

    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.

    enter image description here

    enter image description here

    enter image description here

    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);