Reputation: 106
I have a set of points <Point2f> Left
and another <Point2f> Right
, that could have the same or different size()
. I know that the first point in Left corresponds to the first point in Right etc. Is there a way to construct a vector <Dmatch> matches
in order to proceed, e.g. to draw them using drawMatches
? I am using c++.
Upvotes: 2
Views: 1030
Reputation: 2660
Do you know the correspondences?
If they are a different size, you need to know the correspondences. In any case, assuming that they are the same size and in correspondence, here is how you'd do it (didn't compile this so it may have an error)
DMatch is a simple wrapper for book keeping to track of indicies
vector<DMatch> matches(left.size());
for(size_t i = 0; i <left.size(); ++i)
matches[i] = Dmatch(i, i, 0);
// make keypoints
vector<KeyPoint> kp_left(left.size());
for(size_t i = 0; i < left.size(); ++i)
kp_left[i] = Keypoint(left[i], 1);
// do the same for the right image
// draw the stuff
drawMatches(left_image, keypts_left, right_image, keypts_right, matches, out_image);
imshow("matches", out_image);
waitKey(0);
Upvotes: 1