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.itseez.com/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.html#feature-flann-matcher
Been looking around, but can't get anything to work.
Any help is greatly appreciated!
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...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With