如何使用flann基于matcher,或一般flann在opencv? [英] How to use flann based matcher, or generally flann in opencv?

查看:359
本文介绍了如何使用flann基于matcher,或一般flann在opencv?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

请让别人看看我的示例代码或告诉我如何使用这个类和方法。
我只想将SURF从查询图像匹配到通过应用Flann设置的图像。我已经看到了许多图像匹配代码在样品中,但仍然躲避我是一个度量,以量化图像与其他的相似。

Please can somebody show me sample code or tell me how to use this class and methods. I just want to match SURF's from a query image to those with an image set by applying Flann. I have seen many image match code in the samples but what still eludes me is a metric to quantify how similar an image is to other. Any help will be much appreciated.

推荐答案

这里是未经测试的示例代码

Here's untested sample code

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

 */


b $ b

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

Finding the most 'similar' image to the query image depends on your application. Perhaps the number of matched keypoints is adequate. Or you may need a more complex measure of similarity.

这篇关于如何使用flann基于matcher,或一般flann在opencv?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆