问题描述
请有人给我看示例代码或告诉我如何使用这个类和方法.我只想将查询图像中的 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
*/
查找与查询图像最相似"的图像取决于您的应用程序.也许匹配的关键点的数量就足够了.或者您可能需要更复杂的相似性度量.
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.
这篇关于如何在opencv中使用基于flann的匹配器,或者一般是flann?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!