OpenCV:Flann匹配器崩溃

10

我正在尝试运行一个可以在图像中检测特征的应用程序,但是当我运行代码以检测BRISK特征、BRIEF描述符和FlannBased匹配器时,它会崩溃并显示以下信息:

OpenCV Error: Unsupported format or combination of formats (type=0
) in buildIndex_, file /home/stefan/git_repos/opencv/modules/flann/src/miniflann.cpp, line 315
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/stefan/git_repos/opencv/modules/flann/src/miniflann.cpp:315: error: (-210) type=0
 in function buildIndex_

Aborted (core dumped)

有任何想法是为什么吗?


你尝试过清理并重启你的计算机了吗? - Øystein W.
是的,但没有改变,同样的错误,flann需要64个描述符值吗?或者flann的类型应该是int、float还是double?我现在有一些固定的值(32和CV_8U),我想要修复它们。 - thedarkside ofthemoon
1个回答

11

也许你已经尝试使用KD-Tree或KMeans了?它们只适用于像SIFT或SURF这样的CV_32F描述符。对于二进制描述符(如BRIEF\ORB\FREAK),您必须使用LSH或分层聚类索引,或者使用简单的暴力搜索。您可以自动管理它,例如像这样。

cv::flann::Index GenFLANNIndex(cv::Mat keys)
{
  switch (keys.type())
    {
    case CV_32F:
      {
        return  cv::flann::Index(keys,cv::flann::KDTreeIndexParams(4));
        break;
       }
    case CV_8U:
      {
        return cv::flann::Index(keys,cv::flann::HierarchicalClusteringIndexParams(),dist_type);
        break;
      }
    default:
      {
        return cv::flann::Index(keys,cv::flann::KDTreeIndexParams(4));
        break;
      }
    }

}
...
cv::flann::Index tree = GenFLANNIndex(descriptors);

由于二进制描述符的不同性质,您必须为它们使用不同的匹配方法,问题不仅仅是CV_32F。 - old-ufo
哎呀...这不太好!你知道学习更多的链接吗?我以前没有做过这种事情。 - thedarkside ofthemoon
1
我已经添加了一个示例,展示如何处理它。 - old-ufo
如果我想使用不同的匹配方式进行比较(例如“BruteForce”和“Flann”),我该怎么办?我也需要将它们分开吗? - thedarkside ofthemoon
你可以在函数中添加一些参数,并根据这些参数的切换生成索引,而不是使用原始类型。 - old-ufo
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接