我正在尝试运行一个检测图像特征的应用程序,但是当我运行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)
知道为什么吗?
您可能尝试过使用KD-Tree或KMeans?它们只适用于CV_32F描述符,如SIFT或SURF。对于像BRIEFORBFREAK这样的二进制描述符,您必须使用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);