ORB-SLAM3的Tracking线程,主要从一下几个方面进行讲解:ORB-SLAM3初始化、传感器输入模块、Tracking线程子模块、Tracking线程代码详解。
其中包括ORB-SLAM3整个系统初始化的代码是如何实现的,单目、双目、RBB-D以及结合IMU的输入的情况,Tracking线程是怎么样处理数据的,代码逻辑是怎么样的;按照Tracking线程每一步实现的功能。
ORB-SLAM3在github上开源,开源网址
.h
头文件和cc/cpp
源文件运行ORB-SLAM3的第一步是初始化。初始化ORB-SLAM3是通过System.cc
开始,其对应的头文件为System.h
,以下为System.h
的部分源码:
#include "Tracking.h"
#include "FrameDrawer.h"
#include "MapDrawer.h"
#include "Atlas.h"
#include "LocalMapping.h"
#include "LoopClosing.h"
#include "KeyFrameDatabase.h"
#include "ORBVocabulary.h"
#include "Viewer.h"
#include "ImuTypes.h"
#include "Settings.h"
跟踪线程
的代码局部建图线程
的代码闭环与地图合并线程
的代码System文件相当于初始化代码的入口,Tracking、LocalMapping和LoopClosinng都会用到,FrameDrawer.h就是建图会使用到,地图画出来;Atlas.h就是多地图;KeyFrameDatabase.h就是关键帧的数据库,包括关键帧的构建和数据格式;ORBVocabulary.h就是ORB的词典;Viewer.h对应展示的界面;ImuTypes.h就是IMU定义的数据格式和各种函数和内方法;Settings.h就是参数配置和结构
//Initialize the SLAM system.
//It launches the Local Mapping,
//Loop Closing and Viewer threads
System(const string &strVocFile,
const string &strSettingsFile,
const eSensor sensor,
const bool bUseViewer,
const int initFr,
const string &strSequence = std::string());
System中有string类型的strVocFile,这个对应词袋文件的路径;strSettingsFile对应配置文件的路径,eSensor对应传感器的类型sensor,六种传感器的类型输入(单目、双目、RGB-D和以 及这三种分别与和IMU结合);bool型的bUseViewer代表是否显示可视化的界面,默认为true;int类型initFr代表初始化的帧,默认为0;string型的strSequence代表序列名,图像帧的序列