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.
Asked
Active
Viewed 1,246 times
0
-
I don't get your question. You have you give the two `vector
` and the `vector – BConic Feb 28 '14 at 07:55>` as input to `drawMatches`, which only draws the input. Why would you need to get a `DMatch` array as output ? -
1Thanks 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 Answers
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

milind_mayank
- 81
- 4