Pregunta

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)

Any ideas why?

¿Fue útil?

Solución

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);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top