opencv - 如何使用基于 flann 的匹配器,或者通常在 opencv 中使用 flann?

标签 opencv computer-vision

http://opencv.willowgarage.com/documentation/cpp/features2d_common_interfaces_of_descriptor_matchers.html#flannbasedmatcher

请有人能告诉我示例代码或告诉我如何使用这个类和方法。 我只想将查询图像中的 SURF 与通过应用 Flann 设置的图像相匹配。我在示例中看到过许多图像匹配代码,但我仍然无法理解的是量化图像与其他图像相似程度的指标。任何帮助将不胜感激。

最佳答案

这是未经测试的示例代码

using namespace std;
using namespace cv;

Mat query; //the query image
vector<Mat> images;   //set of images in your db

/* ... get the images from somewhere   ... */

vector<vector<KeyPoint> > dbKeypoints;
vector<Mat> dbDescriptors;

vector<KeyPoint> queryKeypoints;
Mat queryDescriptors;

/* ... Extract the descriptors ... */

FlannBasedMatcher flannmatcher;

//train with descriptors from your db
 flannmatcher.add(dbDescriptors);
 flannmatcher.train();

vector<DMatch > matches;

flannmatcher.match(queryDescriptors, matches);

/* for kk=0 to matches.size()

       the best match for queryKeypoints[matches[kk].queryIdx].pt 
       is dbKeypoints[matches[kk].imgIdx][matches[kk].trainIdx].pt

 */

找到与查询图像最“相似”的图像取决于您的应用程序。也许匹配的关键点的数量是足够的。或者您可能需要更复杂的相似性度量。

关于opencv - 如何使用基于 flann 的匹配器,或者通常在 opencv 中使用 flann?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5695034/

相关文章:

c++ - 检测图像中的多个 3d 形状

image-processing - 具有用户图像标记的图像分类模型的特化

opencv - ORB - 物体需要非常靠近相机

matlab - 寻找信息量最大的图像

python - Python OpenCV-Canny边界检测

opencv - 高斯平滑的方差 (sigma) 影响

java - OpenCV 将 Python 代码转换为 Java

python - 从图像中检测圆并裁剪检测到的ROI python

c++ - inRange 和 Mat 错误

python - 如何从 numpy 二维数组中添加或删除特定元素?