http://opencv.willowgarage.com/documentation/cpp/features2d_common_interfaces_of_descriptor_matchers.html#flannbasedmatcher
请谁能给我看示例代码或告诉我如何使用这个类和方法。我只想通过应用Flann将来自查询图像的SURF匹配到具有图像集的SURF。我在样本中看到了许多图像匹配代码,但我仍然无法量化一个图像与其他图像的相似性程度。任何帮助都将不胜感激。
发布于 2011-04-18 09:07:09
以下是未经测试的示例代码
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
*/找到与查询图像最“相似”的图像取决于您的应用程序。也许匹配的关键点的数量是足够的。或者,您可能需要更复杂的相似性度量。
发布于 2013-04-03 00:22:37
为了减少误报的数量,您可以通过取第一个最近邻居和第二个最近邻居的距离之比来比较这两个邻居。distance( query,mostnearestneighbor)/distance(query,second mostnearestneighbor)< T,比率越小,次近邻到查询描述符的距离越高。因此,这是一个具有很高独特性的翻译。在许多设想配准的计算机视觉论文中使用。
https://stackoverflow.com/questions/5695034
复制相似问题