首页 > 其他 > 详细

ORBSLAM2代码阅读-头文件-system.h

时间:2020-06-18 19:08:28      阅读:90      评论:0      收藏:0      [点我收藏+]
技术分享图片
  1 /**
  2 * This file is part of ORB-SLAM2.
  3 *
  4 * Copyright (C) 2014-2016 Raúl Mur-Artal <raulmur at unizar dot es> (University of Zaragoza)
  5 * For more information see <https://github.com/raulmur/ORB_SLAM2>
  6 *
  7 * ORB-SLAM2 is free software: you can redistribute it and/or modify
  8 * it under the terms of the GNU General Public License as published by
  9 * the Free Software Foundation, either version 3 of the License, or
 10 * (at your option) any later version.
 11 *
 12 * ORB-SLAM2 is distributed in the hope that it will be useful,
 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 15 * GNU General Public License for more details.
 16 *
 17 * You should have received a copy of the GNU General Public License
 18 * along with ORB-SLAM2. If not, see <http://www.gnu.org/licenses/>.
 19 */
 20 
 21 
 22 #ifndef SYSTEM_H
 23 #define SYSTEM_H
 24 
 25 #include<string>
 26 #include<thread>
 27 #include<opencv2/core/core.hpp>
 28 
 29 #include "Tracking.h"
 30 #include "FrameDrawer.h"
 31 #include "MapDrawer.h"
 32 #include "Map.h"
 33 #include "LocalMapping.h"
 34 #include "LoopClosing.h"
 35 #include "KeyFrameDatabase.h"
 36 #include "ORBVocabulary.h"
 37 #include "Viewer.h"
 38 
 39 namespace ORB_SLAM2
 40 {
 41 
 42 class Viewer;
 43 class FrameDrawer;
 44 class Map;
 45 class Tracking;
 46 class LocalMapping;
 47 class LoopClosing;
 48 
 49 class System
 50 {
 51 public:
 52     // Input sensor
 53     enum eSensor{
 54         MONOCULAR=0,
 55         STEREO=1,
 56         RGBD=2
 57     };
 58 
 59 public:
 60 
 61     // Initialize the SLAM system. It launches the Local Mapping, Loop Closing and Viewer threads.
 62     System(const string &strVocFile, const string &strSettingsFile, const eSensor sensor, const bool bUseViewer = true);
 63 
 64     // Proccess the given stereo frame. Images must be synchronized and rectified.
 65     // Input images: RGB (CV_8UC3) or grayscale (CV_8U). RGB is converted to grayscale.
 66     // Returns the camera pose (empty if tracking fails).
 67     cv::Mat TrackStereo(const cv::Mat &imLeft, const cv::Mat &imRight, const double &timestamp);
 68 
 69     // Process the given rgbd frame. Depthmap must be registered to the RGB frame.
 70     // Input image: RGB (CV_8UC3) or grayscale (CV_8U). RGB is converted to grayscale.
 71     // Input depthmap: Float (CV_32F).
 72     // Returns the camera pose (empty if tracking fails).
 73     cv::Mat TrackRGBD(const cv::Mat &im, const cv::Mat &depthmap, const double &timestamp);
 74 
 75     // Proccess the given monocular frame
 76     // Input images: RGB (CV_8UC3) or grayscale (CV_8U). RGB is converted to grayscale.
 77     // Returns the camera pose (empty if tracking fails).
 78     cv::Mat TrackMonocular(const cv::Mat &im, const double &timestamp);
 79 
 80     // This stops local mapping thread (map building) and performs only camera tracking.
 81     void ActivateLocalizationMode();
 82     // This resumes local mapping thread and performs SLAM again.
 83     void DeactivateLocalizationMode();
 84 
 85     // Reset the system (clear map)
 86     void Reset();
 87 
 88     // All threads will be requested to finish.
 89     // It waits until all threads have finished.
 90     // This function must be called before saving the trajectory.
 91     void Shutdown();
 92 
 93     // Save camera trajectory in the TUM RGB-D dataset format.
 94     // Only for stereo and RGB-D. This method does not work for monocular.
 95     // Call first Shutdown()
 96     // See format details at: http://vision.in.tum.de/data/datasets/rgbd-dataset
 97     void SaveTrajectoryTUM(const string &filename);
 98 
 99     // Save keyframe poses in the TUM RGB-D dataset format.
100     // This method works for all sensor input.
101     // Call first Shutdown()
102     // See format details at: http://vision.in.tum.de/data/datasets/rgbd-dataset
103     void SaveKeyFrameTrajectoryTUM(const string &filename);
104 
105     // Save camera trajectory in the KITTI dataset format.
106     // Only for stereo and RGB-D. This method does not work for monocular.
107     // Call first Shutdown()
108     // See format details at: http://www.cvlibs.net/datasets/kitti/eval_odometry.php
109     void SaveTrajectoryKITTI(const string &filename);
110 
111     // TODO: Save/Load functions
112     // SaveMap(const string &filename);
113     // LoadMap(const string &filename);
114 
115 private:
116 
117     // Input sensor
118     eSensor mSensor;
119 
120     // ORB vocabulary used for place recognition and feature matching.
121     ORBVocabulary* mpVocabulary;
122 
123     // KeyFrame database for place recognition (relocalization and loop detection).
124     KeyFrameDatabase* mpKeyFrameDatabase;
125 
126     // Map structure that stores the pointers to all KeyFrames and MapPoints.
127     Map* mpMap;
128 
129     // Tracker. It receives a frame and computes the associated camera pose.
130     // It also decides when to insert a new keyframe, create some new MapPoints and
131     // performs relocalization if tracking fails.
132     Tracking* mpTracker;
133 
134     // Local Mapper. It manages the local map and performs local bundle adjustment.
135     LocalMapping* mpLocalMapper;
136 
137     // Loop Closer. It searches loops with every new keyframe. If there is a loop it performs
138     // a pose graph optimization and full bundle adjustment (in a new thread) afterwards.
139     LoopClosing* mpLoopCloser;
140 
141     // The viewer draws the map and the current camera pose. It uses Pangolin.
142     Viewer* mpViewer;
143 
144     FrameDrawer* mpFrameDrawer;
145     MapDrawer* mpMapDrawer;
146 
147     // System threads: Local Mapping, Loop Closing, Viewer.
148     // The Tracking thread "lives" in the main execution thread that creates the System object.
149     std::thread* mptLocalMapping;
150     std::thread* mptLoopClosing;
151     std::thread* mptViewer;
152 
153     // Reset flag
154     std::mutex mMutexReset;
155     bool mbReset;
156 
157     // Change mode flags
158     std::mutex mMutexMode;
159     bool mbActivateLocalizationMode;
160     bool mbDeactivateLocalizationMode;
161 };
162 
163 }// namespace ORB_SLAM
164 
165 #endif // SYSTEM_H
View Code

结构图

技术分享图片

 

 

 

 重要变量

    ORBVocabulary* mpVocabulary;
    KeyFrameDatabase* mpKeyFrameDatabase;
    Map* mpMap;
    Tracking* mpTracker;
    LocalMapping* mpLocalMapper;
    LoopClosing* mpLoopCloser;
    Viewer* mpViewer;
    FrameDrawer* mpFrameDrawer;
    MapDrawer* mpMapDrawer;

启动线程:

    std::thread* mptLocalMapping;
    std::thread* mptLoopClosing;
    std::thread* mptViewer;

 

ORBSLAM2代码阅读-头文件-system.h

原文:https://www.cnblogs.com/polipolu/p/13159109.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!