SLAM十四讲用一天看完了,顺便花一天看了下ORB,brief,ORB-SLAM2原文,现在开始学习里面具体代码。今天主要看ORB特征提取,放vs中的代码:
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <stdio.h>
using namespace cv;
using namespace std;
int main() {
Mat src = imread("E:\\xxb\\3.jpg");
//VideoCapture cap(0);
imshow("原图", src);
Mat gray_src, outimage;
cvtColor(src, gray_src, CV_BGR2GRAY);
std::vector<KeyPoint> keypoints_1;
Mat descriptors_1;
Ptr<FeatureDetector> detector = ORB::create();
Ptr<DescriptorExtractor> descriptor = ORB::create();
detector->detect(gray_src, keypoints_1);
descriptor->compute(gray_src, keypoints_1, descriptors_1);
drawKeypoints(src, keypoints_1, outimage, Scalar::all(-1), DrawMatchesFlags::DEFAULT);
imshow("opencv提取ORB特征点", outimage);
while (1)
{
if (waitKey(10) == 27)break;//按Esc退出
}
return 0;
}
当中用debug x64 运行出现报错,原因是工程中debug依赖项添加了opencv_world310.lib
提取结果如图,分布不均匀;这是opencv的结果。
ORB-slam2中首先分块进行