I am running Ubuntu 14.04. I am trying to run FLANN with openCV 3 but I get an error.
Everything bellow was tried by using AKAZE and ORB but the code if from my attempt to use ORB.
I use ORB to find the descriptors and key-points.
Ptr<ORB> detector = ORB::create();
std::vector<KeyPoint> keypoints_1, keypoints_2;
Mat descriptors_1, descriptors_2;
detector->detectAndCompute( img_1, noArray(), keypoints_1, descriptors_1 );
detector->detectAndCompute( img_2, noArray(), keypoints_2, descriptors_2 );
After I use ORB, I use the following code to find matches:
FlannBasedMatcher matcher;
std::vector<DMatch> matches;
matcher.match(descriptors_1, descriptors_2, matches);
The code builds fine and everything. When I run the code I get this error:
OpenCV Error: Unsupported format or combination of formats (type=0
) in buildIndex_, file /home/jim/opencv/modules/flann/src/miniflann.cpp, line 315
terminate called after throwing an instance of 'cv::Exception'
what(): /home/jim/opencv/modules/flann/src/miniflann.cpp:315: error: (-210) type=0
in function buildIndex_
Aborted (core dumped)
Can anybody tell me why? Is it something with OpenCV 3 being in BETA state? Is there an alternative to FLANN (except BFMatcher)
So what I said:
in order to use FlannBasedMatcher
you need to convert your descriptors to CV_32F
:
if(descriptors_1.type()!=CV_32F) {
descriptors_1.convertTo(descriptors_1, CV_32F);
}
if(descriptors_2.type()!=CV_32F) {
descriptors_2.convertTo(descriptors_2, CV_32F);
}
you can take a look to this similar question: