Improve matching of feature points with OpenCV

后端 未结 3 1941
你的背包
你的背包 2020-12-02 05:12

I want to match feature points in stereo images. I\'ve already found and extracted the feature points with different algorithms and now I need a good matching. In this case

3条回答
  •  日久生厌
    2020-12-02 05:27

    An alternate method of determining high-quality feature matches is the ratio test proposed by David Lowe in his paper on SIFT (page 20 for an explanation). This test rejects poor matches by computing the ratio between the best and second-best match. If the ratio is below some threshold, the match is discarded as being low-quality.

    std::vector> matches;
    cv::BFMatcher matcher;
    matcher.knnMatch(descriptors_1, descriptors_2, matches, 2);  // Find two nearest matches
    vector good_matches;
    for (int i = 0; i < matches.size(); ++i)
    {
        const float ratio = 0.8; // As in Lowe's paper; can be tuned
        if (matches[i][0].distance < ratio * matches[i][1].distance)
        {
            good_matches.push_back(matches[i][0]);
        }
    }
    

提交回复
热议问题