This is OpenCV's drawMatches()
function:
void drawMatches(Mat img1, vector<KeyPoint> keypoints1,
Mat img2, vector<KeyPoint> keypoints2,
vector<DMatch> matches,
Mat outImg) //want keypoints1[i] = keypoints2[matches[i]]
Notice that matches
is of type vector<DMatch>
. Here is the DMatch
constructor:
DMatch(int queryIdx, int trainIdx, float distance)
Presumably, queryIdx
is an index into one set of keypoints, and trainIdx
is an index into the other set of keypoints.
The question: Is it true that queryIdx
indexes into keypoints1
, and trainIdx
indexes into keypoints2
? Or, is it the other way around?
Presumably, queryIdx is an index into one set of keypoints, and trainIdx is an index into the other set of keypoints.
DMatch. distance - Distance between descriptors.
That depends on how you get matches
.
If you call match function in the order:
match(descriptor_for_keypoints1, descriptor_for_keypoints2, matches)
then queryIdx
refers to keypoints1
and trainIdx
refers to keypoints2
, or vice versa.
the variable "matches" is a list of DMatch objects.
If we are iterating over this list of DMatch objects, then each item will have the following attributes:
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