OpenCV:Flann匹配器崩溃 [英] OpenCV: Flann matcher crashes
问题描述
我试图运行一个检测图像特征的应用程序,但是当我运行BRISK
特征,BRIEF
描述符和FlannBased
匹配器的代码时,它崩溃并说:
I am trying to run an application that detects features in an image, but when I run the code for BRISK
features, BRIEF
descriptors and FlannBased
matcher, it crashes and saying:
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)
有什么想法吗?
推荐答案
可能您已尝试使用KD-Tree或KMeans?它们仅适用于CV_32F描述符,例如SIFT或SURF. 对于像BRIEF \ ORB \ FREAK这样的二进制描述符,您必须使用LSH或Hierarchical clustering index.或简单的蛮力搜索. 您可以自动管理它,例如这样.
Probably you have tried to use KD-Tree or KMeans? They works only for CV_32F descriptors like SIFT or SURF. For binary descriptors like BRIEF\ORB\FREAK you have to use either LSH or Hierarchical clustering index. Or simple bruteforce search. You can manage it automatically, for example like this.
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);
这篇关于OpenCV:Flann匹配器崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!