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

Categories

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

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

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...