Opencv - Getting Pixel Coordinates from Feature Matching

前端 未结 1 1547
暗喜
暗喜 2021-02-06 04:03

Can anyone help me? I want to get the x and y coordinates of the best pixels the feature matcher selects in the code provided, using c++ with opencv.

http://opencv.itsee

相关标签:
1条回答
  • 2021-02-06 04:29

    The DMatch class gives you the distance between the two matching KeyPoints (train and query). So, the best pairs detected should have the smallest distance. The tutorial grabs all matches that are less than 2*(minimum pair distance) and considers those the best.

    So, to get the (x, y) coordinates of the best matches. You should use the good_matches (which is a list of DMatch objects) to look up the corresponding indices from the two different KeyPoint vectors (keypoints_1 and keypoints_2). Something like:

    for(size_t i = 0; i < good_matches.size(); i++)
    {
        Point2f point1 = keypoints_1[good_matches[i].queryIdx].pt;
        Point2f point2 = keypoints_2[good_matches[i].trainIdx].pt;
        // do something with the best points...
    }
    
    0 讨论(0)
提交回复
热议问题