0
我正在使用OpenCV 3.3。 我想在Vector Dmatch类型的对象上使用OpenCV C++匹配函数。 目标是将来自单个查询图像的描述符与来自多个图像列表的描述符进行匹配。 我知道,当使用此函数将描述符从单个图像匹配到另一个单个图像的描述符时,与每个图像上的每个匹配描述符相对应的两个关键点索引都将从该向量存储到每个Dmatch对象中。从匹配单个查询图像和多个图像列表存储关键点索引
例如,如果我做
Mat img_1=imread("path1...");
Mat img_2=imread("path2...");
vector<KeyPoint> keypoints_1, keypoints_2;
Mat descriptors_1, descriptors_2;
detector->detectAndCompute(img_1, Mat(), keypoints_1, descriptors_1);
detector->detectAndCompute(img_2, Mat(), keypoints_2, descriptors_2);
FlannBasedMatcher matcher;
vector<DMatch> matches;
matcher.match(descriptors_1, descriptors_2, matches);
然后如果我想要访问相匹配,所述关键点,对于每个i是一个int是次于matches.size(),然后
int idx=matches[i].trainIdx;
int idy=matches[i].queryIdx;
point2f matched_point1=keypoints1[idx].pt;
point2f matched_point2=keypoints2[idy].pt;
但是,当我试图用来自单个查询图像的描述符与来自多个图像列表的描述符匹配时,会发生什么情况,因为每个Dmatch对象只能容纳两个索引,而我想匹配两个以上的图像。 例如:
vector<Mat> descriptors1;
Mat descriptors2;
matcher.add(descriptors1);
matcher.train();
matcher.match(descriptors2, matches);
这些索引意味着什么?
int idx=matches[i].trainIdx;
int idy=matches[i].queryIdx;