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
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...
}