我正在运行 Ubuntu 14.04。我正在尝试使用 openCV 3 运行 FLANN,但出现错误。
使用 AKAZE 和 ORB 尝试了以下所有内容,但代码来 self 尝试使用 ORB 时的代码。
我使用 ORB 来查找描述符和关键点。
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 );
使用 ORB 后,我使用以下代码查找匹配项:
FlannBasedMatcher matcher;
std::vector<DMatch> matches;
matcher.match(descriptors_1, descriptors_2, matches);
代码构建良好,一切正常。当我运行代码时出现此错误:
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)
谁能告诉我为什么? OpenCV 3 是否处于 BETA 状态?有没有 FLANN 的替代品(BFMatcher 除外)
最佳答案
所以我说的是:
要使用 FlannBasedMatcher
,您需要将描述符转换为 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);
}
您可以查看this similar question :
关于c++ - OpenCV 3 中的 FLANN 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29694490/