存储将单个查询图像与多个图像的列表匹配的关键点索引
Storing keypoints indexes from matching a single query image with a list of several images
我正在使用OpenCV 3.3。 我想在 Vector Dmatch 类型的对象上使用 OpenCV C++ match 函数。 目标是将单个查询图像中的描述符与多个图像列表中的描述符进行匹配。 我知道,当这个函数用于将单个图像中的描述符与另一个图像中的描述符匹配时,对应于每个图像上每个匹配描述符的两个关键点索引将存储在向量中的每个 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 来说,这是一个不如 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;
您可以在循环浏览图像时将所有训练图像的匹配索引值存储到列表中。然后,您可以选择适当的匹配点并根据需要使用它们。
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- Pybind11:将元组列表从Python传递到C++
- 从链接列表c++中删除一个项目
- 如何(从固定列表中)选择一个数字序列,该序列将与目标数字相加
- C++如何通过用户输入删除列表元素
- 读取文件的最后一行并输入到链接列表时出错
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- 是否可以将图像列表保存到文件中?
- 存储将单个查询图像与多个图像的列表匹配的关键点索引
- Qt 图像列表
- 图像中使用CUDA中的白色像素索引列表
- CGIMAGE:支持的图像格式列表
- 从.txt列表中iMREED图像
- OpenCV代码将存储在列表中的描述符与新的图像描述符进行比较
- 静止图像::获取设备列表指针
- 在Qt中以列表或表格的形式动态显示多个图像的最佳方法
- 使用libpng调整图像列表的大小(bicubic)
- OpenCV如何在二进制图像中查找连接组件的列表
- 在列表视图中绘制3个图像和文本
- 如何在MITK中访问图像属性列表和操作