0

I know that drawMatches function does not show all of the matches of its matches1to2 parameter. This is based on its other parameters and flags (e.g. "do not show single lines"). I am wondering is there any way to get access to the output matches (the matches that drawMatches displays) in an array format (e.g. DMatch structure)? If so, how? Thanks a lot.

Bahar S
  • 403
  • 3
  • 16
  • I don't get your question. You have you give the two `vector` and the `vector>` as input to `drawMatches`, which only draws the input. Why would you need to get a `DMatch` array as output ? – BConic Feb 28 '14 at 07:55
  • 1
    Thanks AldurDisciple. I tried to draw matches using (vector matches1to2> (the same vector as what I used as the input argument of the "drawMatches" function) myselft, without using the "drawMatches" function. But it was much different from the output of "drawMatches". mine contained a lot of lines in contrast to drawMatches' that contained only a few lines. – Bahar S Feb 28 '14 at 15:10
  • From what I can read in the documentation, `drawMatches` always draw all the matches, and the options and flags are related to the drawing of keypoints. Maybe the implementation you made had a bug ? – BConic Feb 28 '14 at 16:11

1 Answers1

2

I think this is what you are looking for


for (std::vector<cv::DMatch>::const_iterator it= Matches.begin();it!= Matches.end(); ++it){
    float x= keypoints1[it->queryIdx].pt.x;
    float y= keypoints1[it->queryIdx].pt.y;
    circle( copy, Point2f(x,y), 2, Scalar(255,255,255), -1, 8, 0 );
    points1.push_back(cv::Point2f(x,y));

    x= keypoints2[it->trainIdx].pt.x;
    y= keypoints2[it->trainIdx].pt.y;
    points2.push_back(cv::Point2f(x,y));
}

points1 and points2 will thus represent keypoints which match

Xan
  • 74,770
  • 16
  • 179
  • 206