c++ - OpenCV 3 中的 FLANN 错误

标签 c++ opencv orb flann

我正在运行 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/

相关文章:

c++ - 使用 OpenCV Cuda ORB 特征检测器

opencv - opencv orb 特征检测器中的 bit_pattern_31_[256*4]

c++ - 抛出 'std::bad_alloc' 实例后调用终止

c++ - 为什么我的程序设计为耗尽 RAM 和 CPU 而没有使用所有 RAM 和 CPU?

c++ - 为什么编译器不能从模板中推导出类型,例如 template<typename R(typename... Args)>?

c++ - 搜索参数空间时避免嵌套 for 循环

c++ - OpenCV - 来自相机的实时反馈不流畅

c++ - 如何在 C++ 中使用 ffmpeg 流式传输 opencv Mat

opencv - openCV中的总和

python - 收到 “ValueError: not enough values to unpack (expected 2, got 1)”时,如何强制程序忽略并继续?