OpenCV 3中的FLANN错误 [英] FLANN error in OpenCV 3

查看:947
本文介绍了OpenCV 3中的FLANN错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Ubuntu 14.04.我正在尝试使用openCV 3运行FLANN,但出现错误.

I am running Ubuntu 14.04. I am trying to run FLANN with openCV 3 but I get an error.

所有波纹都通过使用AKAZE和ORB进行了尝试,但是代码是我尝试使用ORB的.

Everything bellow was tried by using AKAZE and ORB but the code if from my attempt to use ORB.

我使用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 );

使用ORB之后,我使用以下代码查找匹配项:

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)

有人可以告诉我为什么吗? OpenCV 3处于BETA状态是否有问题?是否有FLANN的替代品(BFMatcher除外)

Can anybody tell me why? Is it something with OpenCV 3 being in BETA state? Is there an alternative to FLANN (except BFMatcher)

推荐答案

所以我说的是

要使用FlannBasedMatcher,您需要将描述符转换为CV_32F:

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);
}

您可以查看这个类似的问题:

这篇关于OpenCV 3中的FLANN错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆