亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

ORB-SLAM代碼詳解之SLAM系統初始化

2019-11-10 16:52:47
字體:
來源:轉載
供稿:網友

systemhsystemc的SystemSystem

轉載請注明出處:http://blog.csdn.net/c602273091/article/details/54933760

system.h

這里包含了整個SLAM系統所需要的一起,通過看這個文件可以對ORB-SLAM系統有什么有一個大概的了解。不過之前我們需要對于多線程了解一些基本的東西——信號量【1】和多線程【2】。

具體注釋如下:

/*** This file is part of ORB-SLAM2.** Copyright (C) 2014-2016 Ra煤l Mur-Artal <raulmur at unizar dot es> (University of Zaragoza)* For more information see <https://github.com/raulmur/ORB_SLAM2>** ORB-SLAM2 is free software: you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation, either version 3 of the License, or* (at your option) any later version.** ORB-SLAM2 is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* GNU General Public License for more details.** You should have received a copy of the GNU General Public License* along with ORB-SLAM2. If not, see <http://www.gnu.org/licenses/>.*/#ifndef SYSTEM_H#define SYSTEM_H#include<string>#include<thread>#include<opencv2/core/core.hpp>#include "Tracking.h"#include "FrameDrawer.h"#include "MapDrawer.h"#include "Map.h"#include "LocalMapping.h"#include "LoopClosing.h"#include "KeyFrameDatabase.h"#include "ORBVocabulary.h"#include "Viewer.h"namespace ORB_SLAM2{class Viewer; // 畫圖class FrameDrawer; // 畫每一幀class Map; // 對map進行操作class Tracking; // 追蹤的過程class LocalMapping; // 局部地圖class LoopClosing; // 閉環檢測class System{public: // Input sensor // 輸入設備:單目、立體視覺、RGBD enum eSensor{ MONOCULAR=0, STEREO=1, RGBD=2 };public: // Initialize the SLAM system. It launches the Local Mapping, Loop Closing and Viewer threads. // 對SLAM系統的初始化:包含局部地圖、閉環檢測、視圖三個線程 System(const string &strVocFile, const string &strSettingsFile, const eSensor sensor, const bool bUseViewer = true); // PRoccess the given stereo frame. Images must be synchronized and rectified. // Input images: RGB (CV_8UC3) or grayscale (CV_8U). RGB is converted to grayscale. // Returns the camera pose (empty if tracking fails). cv::Mat TrackStereo(const cv::Mat &imLeft, const cv::Mat &imRight, const double &timestamp); // Process the given rgbd frame. Depthmap must be registered to the RGB frame. // Input image: RGB (CV_8UC3) or grayscale (CV_8U). RGB is converted to grayscale. // Input depthmap: Float (CV_32F). // Returns the camera pose (empty if tracking fails). cv::Mat TrackRGBD(const cv::Mat &im, const cv::Mat &depthmap, const double &timestamp); // Proccess the given monocular frame // Input images: RGB (CV_8UC3) or grayscale (CV_8U). RGB is converted to grayscale. // Returns the camera pose (empty if tracking fails). // 對單目的圖片進行追蹤 cv::Mat TrackMonocular(const cv::Mat &im, const double &timestamp); // This stops local mapping thread (map building) and performs only camera tracking. // 暫停局部地圖的構建,只進行追蹤,這個名字很有迷惑性 void ActivateLocalizationMode(); // This resumes local mapping thread and performs SLAM again. // 重新開啟局部地圖的線程 // 在這里使用的是mutex信號量的多線程編程 void DeactivateLocalizationMode(); // Reset the system (clear map) // 復位清楚地圖 void Reset(); // All threads will be requested to finish. // It waits until all threads have finished. // This function must be called before saving the trajectory. // 等到所有線程結束任務的時候關閉每個線程 void Shutdown(); // Save camera trajectory in the TUM RGB-D dataset format. // Call first Shutdown() // See format details at: http://vision.in.tum.de/data/datasets/rgbd-dataset void SaveTrajectoryTUM(const string &filename); // Save keyframe poses in the TUM RGB-D dataset format. // Use this function in the monocular case. // Call first Shutdown() // See format details at: http://vision.in.tum.de/data/datasets/rgbd-dataset void SaveKeyFrameTrajectoryTUM(const string &filename); // Save camera trajectory in the KITTI dataset format. // Call first Shutdown() // See format details at: http://www.cvlibs.net/datasets/kitti/eval_odometry.php // kitti數據集的保存位姿的方法 void SaveTrajectoryKITTI(const string &filename); // TODO: Save/Load functions // SaveMap(const string &filename); // LoadMap(const string &filename);private: // Input sensor // 輸入的傳感器類型 eSensor mSensor; // 用于特征匹配和閉環檢測的字典 // ORB vocabulary used for place recognition and feature matching. ORBVocabulary* mpVocabulary; // KeyFrame database for place recognition (relocalization and loop detection). // 關鍵幀存儲的地方 KeyFrameDatabase* mpKeyFrameDatabase; // Map structure that stores the pointers to all KeyFrames and MapPoints. // 所有的關鍵幀和點云存儲的地方 Map* mpMap; // Tracker. It receives a frame and computes the associated camera pose. // It also decides when to insert a new keyframe, create some new MapPoints and // performs relocalization if tracking fails. // 追蹤器。接受一幀并且計算相機位姿,并決定何時插入關鍵幀,關鍵點。 // 當追蹤失敗以后進行重定位 Tracking* mpTracker; // Local Mapper. It manages the local map and performs local bundle adjustment. // 構建局部地圖并對局部地圖使用BA。 LocalMapping* mpLocalMapper; // Loop Closer. It searches loops with every new keyframe. If there is a loop it performs // a pose graph optimization and full bundle adjustment (in a new thread) afterwards. // 閉環檢測,每插入一個關鍵幀就計算是否有閉環并且進行全局的BA。 LoopClosing* mpLoopCloser; // The viewer draws the map and the current camera pose. It uses Pangolin. // 使用Pangolin庫看地圖和相機位姿。 Viewer* mpViewer; FrameDrawer* mpFrameDrawer; MapDrawer* mpMapDrawer; // System threads: Local Mapping, Loop Closing, Viewer. // The Tracking thread "lives" in the main execution thread that creates the System object. // 追蹤這個線程是在main函數里面,這里另外開了局部地圖、局部閉環檢測、顯示地圖三個線程 std::thread* mptLocalMapping; std::thread* mptLoopClosing; std::thread* mptViewer; // Reset flag std::mutex mMutexReset; bool mbReset; // Change mode flags std::mutex mMutexMode; bool mbActivateLocalizationMode; bool mbDeactivateLocalizationMode;};}// namespace ORB_SLAM#endif // SYSTEM_H

這樣對于ORB-SLAM我們有了一個大致的認識。

接下來我們看System::System(const string &strVocFile, const string &strSettingsFile, const eSensor sensor, const bool bUseViewer).

system.c的System::System

使用understand的control flow,一劍封喉,直接看到各個部分的聯系。流程圖出來了,感覺看起來很爽。 這里寫圖片描述

在這個基礎上,我再對整個流程進行注釋。

System::System(const string &strVocFile, const string &strSettingsFile, const eSensor sensor, const bool bUseViewer):mSensor(sensor),mbReset(false),mbActivateLocalizationMode(false), mbDeactivateLocalizationMode(false){ // Output welcome message cout << endl << "ORB-SLAM2 Copyright (C) 2014-2016 Raul Mur-Artal, University of Zaragoza." << endl << "This program comes with ABSOLUTELY NO WARRANTY;" << endl << "This is free software, and you are welcome to redistribute it" << endl << "under certain conditions. See LICENSE.txt." << endl << endl; cout << "Input sensor was set to: "; // 判斷什么類型的傳感器 if(mSensor==MONOCULAR) cout << "Monocular" << endl; else if(mSensor==STEREO) cout << "Stereo" << endl; else if(mSensor==RGBD) cout << "RGB-D" << endl; //Check settings file // 檢查配置文件是否存在 // cv::FileStorage對xml/YML的配置文件進行操作,讀取配置文件 // yml的配置文件已經讀入fsSettings了 cv::FileStorage fsSettings(strSettingsFile.c_str(), cv::FileStorage::READ); if(!fsSettings.isOpened()) { cerr << "Failed to open settings file at: " << strSettingsFile << endl; exit(-1); } // 加載ORB的字典 //Load ORB Vocabulary cout << endl << "Loading ORB Vocabulary. This could take a while..." << endl; // 加載字典到mpVocabulary mpVocabulary = new ORBVocabulary(); bool bVocLoad = mpVocabulary->loadFromTextFile(strVocFile); if(!bVocLoad) { cerr << "Wrong path to vocabulary. " << endl; cerr << "Falied to open at: " << strVocFile << endl; exit(-1); } cout << "Vocabulary loaded!" << endl << endl; //Create KeyFrame Database // 創建關鍵幀的數據庫 mpKeyFrameDatabase = new KeyFrameDatabase(*mpVocabulary); //Create the Map // 創建地圖 mpMap = new Map(); //Create Drawers. These are used by the Viewer // 創建視圖 mpFrameDrawer = new FrameDrawer(mpMap); // 創建畫圖器 mpMapDrawer = new MapDrawer(mpMap, strSettingsFile); //Initialize the Tracking thread //(it will live in the main thread of execution, the one that called this constructor) mpTracker = new Tracking(this, mpVocabulary, mpFrameDrawer, mpMapDrawer, mpMap, mpKeyFrameDatabase, strSettingsFile, mSensor); //Initialize the Local Mapping thread and launch mpLocalMapper = new LocalMapping(mpMap, mSensor==MONOCULAR); mptLocalMapping = new thread(&ORB_SLAM2::LocalMapping::Run,mpLocalMapper); //Initialize the Loop Closing thread and launch // 初始化局部圖線程 mpLoopCloser = new LoopClosing(mpMap, mpKeyFrameDatabase, mpVocabulary, mSensor!=MONOCULAR); mptLoopClosing = new thread(&ORB_SLAM2::LoopClosing::Run, mpLoopCloser); //Initialize the Viewer thread and launch // 初始化顯示線程 mpViewer = new Viewer(this, mpFrameDrawer,mpMapDrawer,mpTracker,strSettingsFile); if(bUseViewer) mptViewer = new thread(&Viewer::Run, mpViewer); mpTracker->SetViewer(mpViewer); //Set pointers between threads mpTracker->SetLocalMapper(mpLocalMapper); mpTracker->SetLoopClosing(mpLoopCloser); mpLocalMapper->SetTracker(mpTracker); mpLocalMapper->SetLoopCloser(mpLoopCloser); mpLoopCloser->SetTracker(mpTracker); mpLoopCloser->SetLocalMapper(mpLocalMapper);}

接下來對每個類看一下初始化的效果。從字典類,關鍵幀類,地圖類,局部圖類等等看看它們如何進行初始化。

參考鏈接: 【1】mutex: http://www.cplusplus.com/reference/mutex/ 【2】thread: http://www.cplusplus.com/reference/thread/thread/


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
亚洲精品电影网站| 欧美亚洲另类视频| 国产一区二区三区在线观看网站| 91精品国产91| 精品国产美女在线| 欧美在线亚洲在线| 午夜欧美大片免费观看| 精品久久久久久久大神国产| 国产在线播放不卡| 在线播放国产一区中文字幕剧情欧美| 91视频国产精品| 欧美激情亚洲自拍| 国产成人97精品免费看片| 亚洲最新在线视频| 1769国内精品视频在线播放| 亚洲国产精品系列| 国产精品免费福利| 另类美女黄大片| 亚洲精品大尺度| 欧美亚洲另类激情另类| 日韩电视剧在线观看免费网站| 色爱av美腿丝袜综合粉嫩av| 国产伦精品一区二区三区精品视频| 91久久精品美女| 日韩av手机在线看| 欧美猛男性生活免费| 日韩一区在线视频| 国产主播在线一区| 午夜精品蜜臀一区二区三区免费| 4438全国亚洲精品在线观看视频| 亚洲第一级黄色片| www.日本久久久久com.| 欧美亚洲国产视频小说| 国产日产久久高清欧美一区| 高清欧美性猛交xxxx黑人猛交| 国产一区二区丝袜高跟鞋图片| 欧美疯狂xxxx大交乱88av| 少妇高潮 亚洲精品| 97在线免费视频| 欧美日韩免费区域视频在线观看| 免费成人高清视频| 久久精品国产欧美激情| 一道本无吗dⅴd在线播放一区| 亚洲午夜精品久久久久久性色| 国产精品视频xxxx| 久久精品中文字幕| 欧美片一区二区三区| 国产精品久久久久久久久久| 国产精品美女久久| 成人精品aaaa网站| 日韩在线免费av| 伊是香蕉大人久久| 欧美高清在线观看| 在线视频中文亚洲| 久久91精品国产| 久久综合电影一区| 国产一区二区三区三区在线观看| 久久av在线播放| 久久亚洲精品中文字幕冲田杏梨| 国产精品美女在线观看| 国产精品久久在线观看| 伊人一区二区三区久久精品| 国产中文字幕日韩| 成人a视频在线观看| 日韩高清中文字幕| 欧美成人免费va影院高清| 亚洲天堂av女优| 日韩一级黄色av| 国产一区二区三区高清在线观看| 亚洲精品视频久久| 成人国产在线激情| 亚洲男人的天堂在线| 裸体女人亚洲精品一区| 中文字幕综合在线| 亚洲精品国产精品久久清纯直播| 91在线免费网站| 日本欧美精品在线| 日韩av免费看| 97人人模人人爽人人喊中文字| 久久久久久久久久久91| 国产69久久精品成人看| 久久久国产精品亚洲一区| 亚洲黄一区二区| 欧美激情一区二区三区在线视频观看| 91精品国产色综合久久不卡98口| 久久99精品视频一区97| 日本国产欧美一区二区三区| 久久九九有精品国产23| 亚洲欧美日韩中文在线制服| 国产欧美一区二区三区四区| 国产999精品久久久影片官网| 4p变态网欧美系列| 日韩av在线免费| 97国产成人精品视频| 久久国产精品久久久久久| 欧美巨大黑人极品精男| 欧美中文字幕精品| 欧美日韩国产综合新一区| 精品久久在线播放| 亚洲免费成人av电影| 亚洲午夜久久久影院| 成人中文字幕+乱码+中文字幕| 精品成人国产在线观看男人呻吟| 欧美黄色成人网| 久久91精品国产91久久久| 91精品国产综合久久香蕉| 国产精品va在线播放| 久久影视免费观看| 久久6精品影院| 亚洲高清色综合| 日韩电影中文 亚洲精品乱码| 精品动漫一区二区三区| 在线看日韩av| 欧美高清无遮挡| 欧美精品一二区| 精品国产一区二区三区四区在线观看| 亚洲色图五月天| 国产午夜精品一区理论片飘花| 日韩av在线播放资源| 中文字幕精品www乱入免费视频| 成人国产精品久久久| 91国产精品电影| 精品美女永久免费视频| 成人免费看片视频| 国产一区二区丝袜高跟鞋图片| 成人免费视频97| 综合欧美国产视频二区| 欧美韩国理论所午夜片917电影| 日韩电影中文字幕| 国产91|九色| 97超级碰碰碰久久久| 91香蕉亚洲精品| 国内精品视频在线| 亚洲国内高清视频| 成人福利网站在线观看| 91亚洲va在线va天堂va国| 亚洲欧美在线一区二区| 亚洲视频欧美视频| 45www国产精品网站| 亚洲国产91色在线| 97超级碰在线看视频免费在线看| 精品小视频在线| 日韩电影中文字幕一区| 久久免费福利视频| 亚洲另类激情图| 97视频在线观看视频免费视频| 欧美专区日韩视频| 欧洲成人免费aa| 久久国产精品久久久久| 国产欧美精品va在线观看| 日韩精品在线观看视频| 亚洲国产一区二区三区在线观看| 国产色婷婷国产综合在线理论片a| 91精品国产综合久久男男| 亚洲激情电影中文字幕| 亚洲电影免费观看| 国产一区二区三区视频在线观看| 久久免费视频网| 精品国产一区二区三区久久久| 欧美激情亚洲激情| 久久久国产精品x99av| 成人免费高清完整版在线观看| 热久久视久久精品18亚洲精品| 日韩在线观看免费高清完整版|