Ask Your Question

How does drawMatches work? (with respect to DMatch)

asked 2012-09-22 08:15:40 -0600


So I have been working on a tracker based on SIFT descriptor. I saw this example of flannMatcher.

I tried to implement it and worked really well.

Now, my question is how does drawMatches work? As it is mentioned here,,%20const%20vector%3CKeyPoint%3E&%20keypoints1,%20const%20Mat&%20img2,%20const%20vector%3CKeyPoint%3E&%20keypoints2,%20const%20vector%3CDMatch%3E&%20matches1to2,%20Mat&%20outImg,%20const%20Scalar&%20matchColor,%20const%20Scalar&%20singlePointColor,%20const%20vector%3Cchar%3E&%20matchesMask,%20int%20flags%29

matches1to2 is a vector of DMatch and it matches from the first image to the second one, which means that keypoints1[i] has a corresponding point in keypoints2[matches[i]]. Now, how does this work?

DMatch has

float distance; 
int queryIdx; // query descriptor index
int trainIdx; // train descriptor index
int imgIdx;   // train image index

So, using these parameters, how can I (manually) check if keypoints1[i] has a corresponding point in keypoints2[matches[i]] ?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2012-09-22 09:53:28 -0600

Vladislav Vinogradov gravatar image

keypoints1[matches[i].queryIdx] has a corresponding point in keypoints2[matches[i].trainIdx]

edit flag offensive delete link more


Thanks. Actually I was trying something similar and found that out. :)

jayrambhia gravatar imagejayrambhia ( 2012-09-22 11:38:20 -0600 )edit

answered 2013-03-21 04:51:55 -0600

Marwen Z gravatar image

updated 2013-03-21 04:53:45 -0600

Hi, I want to get good matches from the ORB feature detection algorithm, so i did like that but i don't know haw push good matching in matches JAVA

    MatOfDMatch matches, matches12, matches21;
    matcher.match( descriptors1, descriptors2, matches12 );
    matcher.match( descriptors2, descriptors1, matches21 );
 // iterate matches12
        DMatch forward = matches12[i];  // error 
        DMatch backward = matches21[forward.trainIdx]; 
        if( backward.trainIdx == forward.queryIdx ) 
         matches.push_back( forward );  // error
edit flag offensive delete link more


I think you should open a new question. This is the place to answers, not questions.

Alejandro Silvestri gravatar imageAlejandro Silvestri ( 2014-08-04 06:54:26 -0600 )edit

Question Tools


Asked: 2012-09-22 08:15:40 -0600

Seen: 5,171 times

Last updated: Mar 21 '13