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?