简体   繁体   English

手动构建向量 <Dmatch> 在opencv中

[英]Construct manually a vector <Dmatch> in opencv

I have a set of points <Point2f> Left and another <Point2f> Right , that could have the same or different size() . 我有一组点<Point2f> Left和另一个<Point2f> Right ,它们可以具有相同或不同的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, eg to draw them using drawMatches ? 我知道Left的第一个点与Right等的第一个点相对应。是否有一种方法可以构造vector <Dmatch> matches以便继续进行操作,例如使用drawMatches绘制它们? I am using c++. 我正在使用c ++。

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 DMatch是用于簿记跟踪索引的简单包装器

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM