【问题标题】:ORB feature matching with FLANN in C++ORB 特征与 C++ 中的 FLANN 匹配
【发布时间】:2018-02-22 06:49:14
【问题描述】:

我正在尝试从两个图像中获取匹配特征点,以进行进一步处理。我通过引用 FLANN 的 SURF 特征匹配的example 编写了以下代码,但在 ORB 中。

代码如下:

#include "opencv2/video/tracking.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/features2D.hpp"


using namespace cv;
using namespace std;



int main(int argc, char** argv)
{
Mat im_left, im_right;
Mat descriptor_1, descriptor_2;

vector<KeyPoint> keypoints_1, keypoints_2;

im_left = imread("im_left.png", IMREAD_GRAYSCALE);
im_left = imread("im_right.png", IMREAD_GRAYSCALE);

Ptr<ORB> detector = ORB::create();
vector<DMatch> matches;
FlannBasedMatcher matcher;
Ptr<DescriptorExtractor> extractor;


detector->detect(im_right, keypoints_1, descriptor_1);
detector->detect(im_left, keypoints_2, descriptor_2);

matcher.match(descriptor_1, descriptor_2, matches);

Mat img_match;

drawMatches(im_left, keypoints_1, im_right, keypoints_2, matches, img_match);
imshow("Matches", img_match);



waitKey(10000);
return 0;
}

但这会引发异常错误:

Project1.exe 中 0x00007FF97D3B9E08 处未处理的异常:Microsoft C++ 异常:内存位置 0x0000009E5D4FE3B0 处的 cv::Exception。发生了

可能是我的代码充满了废话,如果有人可以帮助我解决这个问题,不胜感激。

【问题讨论】:

  • using namespace std; 是一个不好的习惯,如果你现在可以停下来,你可能会避免将来出现很多麻烦。 std:: 前缀的存在是有原因的:它避免与您自己的类、结构和变量发生冲突。
  • Here 是无标记增强现实项目(用 c++ 编程)的教程。这个项目有未来匹配部分和更多关于图像匹配的东西,它可以对你有所帮助。 This是项目的演示视频。
  • 谢谢你,Olzu,会检查的:)再次非常感谢你!

标签: c++ opencv computer-vision


【解决方案1】:
im_left = imread("im_left.png", IMREAD_GRAYSCALE);
im_left = imread("im_right.png", IMREAD_GRAYSCALE);

您已将图像读入同一个变量两次。

【讨论】:

    【解决方案2】:

    ORB 是一个二进制描述符,需要一个不同的(汉明距离)匹配器:

    Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce-Hamming");
    

    (取自:https://docs.opencv.org/3.4.1/dc/d16/tutorial_akaze_tracking.html

    【讨论】:

      猜你喜欢
      • 2017-10-05
      • 1970-01-01
      • 2014-05-16
      • 1970-01-01
      • 2018-09-12
      • 1970-01-01
      • 2014-05-02
      • 2019-06-29
      • 1970-01-01
      相关资源
      最近更新 更多