【ORB_SLAM2源码解读】TUM、EuRoC单目数据集跑通ORB_SLAM2

文章目录

    • TUM Dataset
    • 实验结果
    • mono_tum运行视频
    • EuRoC Dataset
    • 实验结果
    • 系统System.cc的TrackMonocular()函数都干了什么?

TUM Dataset

TUM Dataset 数据集下载地址

TUM1.yaml 是数据集 freiburg1 的相机参数
TUM2.yaml 是数据集 freiburg2 的相机参数
TUM3.yaml 是数据集 freiburg3 的相机参数

在这里插入图片描述
mono_tum 是单目的可执行程序
ORBvoc.txt 是回环检测要用到的词典

mono_tum运行命令

cd /ORB_SLAM2
./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM1.yaml /home/q/projects/ORB_SLAM2/TUM_Dataset/rgbd_dataset_freiburg1_xyz

实验结果

在这里插入图片描述

mono_tum运行视频

mono_tum运行视频

# Camera Parameters. Camera calibration and distortion parameters (OpenCV) 
Camera.fx: 517.306408
Camera.fy: 516.469215
Camera.cx: 318.643040
Camera.cy: 255.313989
# 畸变系数
Camera.k1: 0.262383
Camera.k2: -0.953104
Camera.p1: -0.005358
Camera.p2: 0.002628
Camera.k3: 1.163314
# Camera frames per second 
Camera.fps: 30.0
# Color order of the images (0: BGR, 1: RGB. It is ignored if images are grayscale)
Camera.RGB: 1
# ORB Parameters
# ORB Extractor: Number of features per image
ORBextractor.nFeatures: 1000
# ORB Extractor: Scale factor between levels in the scale pyramid 	
ORBextractor.scaleFactor: 1.2
# ORB Extractor: Number of levels in the scale pyramid	
ORBextractor.nLevels: 8
# ORB Extractor: Fast threshold
# Image is divided in a grid. At each cell FAST are extracted imposing a minimum response.
# Firstly we impose iniThFAST. If no corners are detected we impose a lower value minThFAST
# You can lower these values if your images have low contrast			
ORBextractor.iniThFAST: 20
ORBextractor.minThFAST: 7
#--------------------------------------------------------------------------------------------
Viewer.KeyFrameSize: 0.05
Viewer.KeyFrameLineWidth: 1
Viewer.GraphLineWidth: 0.9
Viewer.PointSize:2
Viewer.CameraSize: 0.08
Viewer.CameraLineWidth: 3
Viewer.ViewpointX: 0
Viewer.ViewpointY: -0.7
Viewer.ViewpointZ: -1.8
Viewer.ViewpointF: 500

单目的初始化很麻烦,所以去畸变是在ORB_SLAM2系统里面做的,所以传入系统的是原始的没有处理的图片。

SLAM.TrackMonocular(im,tframe);

EuRoC Dataset

EuRoC Dataset 数据集下载地址

cd /ORB_SLAM2
./Examples/Monocular/mono_euroc Vocabulary/ORBvoc.txt Examples/Monocular/EuRoC.yaml /home/q/projects/ORB_SLAM2/EuRoC_Dataset/mav0/cam0/data Examples/Monocular/EuRoC_TimeStamps/MH01.txt 

实验结果

在这里插入图片描述在这里插入图片描述

系统System.cc的TrackMonocular()函数都干了什么?

cv::Mat System::TrackMonocular(const cv::Mat &im, const double &timestamp)
  • 判断传感器类型mSensor!=MONOCULAR

  • 判断mbActivateLocalizationMode这个变量的值
    如果是真关闭local mapping线程执行tracking线程
    如果是假开启local mapping线程和tracking线程

  • 判断mbReset这个变量的值
    ORB_SLAM2算法源码解读之mbReset = true

  • cv::Mat Tcw = mpTracker->GrabImageMonocular(im,timestamp);

GrabImageMonocular做的工作有
彩色图像转换为灰度图

判断这两个变量的值
mStateNOT_INITIALIZED || mStateNO_IMAGES_YET
构造mCurrentFrame
主要的区别就是没有初始化会调用创建一个特征点的ORBextractor* mpIniORBextractor;提取两倍的特征点
初始化正常运行之后只提取一倍的特征点ORBextractor* mpORBextractorLeft,

经过一系列判断主角来了他就是tracking线程

  • Track();
    先来一个图感受一下,核心还是变量,终于明白为啥说指针是C语言的灵魂了,感觉一切都是变量!哈哈
    【ORB_SLAM2源码解读】TUM、EuRoC单目数据集跑通ORB_SLAM2_第1张图片
unique_lock<mutex> lock2(mMutexState);
mTrackingState = mpTracker->mState;
mTrackedMapPoints = mpTracker->mCurrentFrame.mvpMapPoints;
 mTrackedKeyPointsUn = mpTracker->mCurrentFrame.mvKeysUn;

 return Tcw;

你可能感兴趣的:(从零开始学习SLAM实战教程,ORB_SLAM2,ORB_SLAM3)