Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
432 views
in Technique[技术] by (71.8m points)

c++ - OpenCV drawMatches -- queryIdx and trainIdx

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...