使用ORB_SLAM2的方式进行特征检测和提取

比较opencv默认的方式和ORB-SLAM2中对opencv进行重写的方式,两个方法对图像特征提取结果的对比。
为方便比较,写在同一个文件中。主函数如下:

#include <iostream>
#include <opencv2/opencv.hpp>
#include "ORBextractor.h"
#include <vector>

using namespace std;
using namespace cv;
using namespace ORB_SLAM2;

int main()
{
    Mat img1 = imread("000000.png",0);
    ORBextractor* mpORBextractorLeft;

    //orb
    int nFeatures = 2000;
    float fScaleFactor = 1.2;
    int nLevels = 8;
    int fIniThFAST = 20;
    int fMinThFast = 7;

    std::vector<KeyPoint> keypoints1;
    mpORBextractorLeft = new ORBextractor(nFeatures,fScaleFactor,nLevels,fIniThFAST,fMinThFast);
    cv::Mat mDescriptors;
    cv::Mat outimg;
    (*mpORBextractorLeft)(img1,cv::Mat(),keypoints1,mDescriptors);
	drawKeypoints(img1,keypoints1,outimg,Scalar::all(-1));
    cout<<"ORBSLAM2: "<<keypoints1.size()<<endl;
    imshow("ORB_SLAM2", outimg);
    
    //opencv
    std::vector<KeyPoint> keypoints2;
    cv::Mat mDescriptors2;
    Ptr<ORB> orb = ORB::create(2000, 1.2f, 8,31, 0, 2,ORB::HARRIS_SCORE, 31, 20);
    orb->detectAndCompute(img1, Mat(),keypoints2, mDescriptors2);   
    Mat outimg2;
    drawKeypoints(img1,keypoints2,outimg2,Scalar::all(-1));
    cout<<"OpenCV: "<<keypoints2.size()<<endl;
    imshow("OpenCV", outimg2);
    
    waitKey(0);
    
    
    return 0;
}

效果如下

opencv和ORB_SLAM2重写方式的ORB特征检测对比

结论

使用树形结构的ORB-SLAM2的特征提取方式,在提取数量上更多,分布也更均匀。而OpenCV默认的特征提取,特征点的分布较为集中,数量也较少,当把OpenCV方式参数中特征数量设置为2000时,分布无明显变化,还是很集中。因此ORB-SLAM2的作者在这方面下了功夫,对系统定位的鲁棒性有很大的作用。

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值