OpenCV: Flann crashes

I try to run an application that detects functions in an image, but when I run the code for BRISK functions, BRIEF and FlannBased , it crashes and says:

 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?

+7
opencv
source share
1 answer

Did you try to use KD-Tree or KMeans? They work only for CV_32F descriptors, such as SIFT or SURF. For binary descriptors such as BRIEF \ ORB \ FREAK, you must use either LSH or a hierarchical clustering index. Or just a search for brute force. You can control it automatically, for example, as follows.

 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); 
+9
source share

All Articles