ORB_SLAM2安裝編譯測試ubuntu16.04
原始碼:
https://github.com/raulmur/ORB_SLAM2
本人ubuntu16.04系統
1.pre
C++11.
Pangolin
https://github.com/stevenlovegrove/Pangolin
之前教程:https://blog.csdn.net/qq_45539458/article/details/106411290
OpenCV
at leat 2.4.3. Tested with OpenCV 2.4.11 and OpenCV 3.2.
檢視版本
pkg-config opencv --modversion
Eigen3 at least 3.1.0.
檢視版本
vim /usr/local/include/eigen3/Eigen/src/Core/util
or
vim /usr/include/eigen3/Eigen/src/Core/util/Macros.h
sudo apt-get install libeigen3-dev
sudo cp -r /usr/local/include/eigen3/Eigen /usr/local/include
3.2.92
g20,DBoW2
檢視版本
locate g2o
ros have g20,DBoW2
ros(optional)
可選
教程:
https://blog.csdn.net/qq_45539458/article/details/106456408
2.安裝編譯
cd ORB_SLAM2
chmod +x build.sh
vim build.sh
//delete -j
./build.sh
3.測試
14講作業
在CMakeLists.txt 末尾加入
#生成呼叫 myvideo.mp4 可執行檔案
add_executable(myvideo myvideo.cpp)
target_link_libraries(myvideo ${PROJECT_NAME})
#生成呼叫攝像頭可執行檔案
add_executable(myslam myslam.cpp)
target_link_libraries(myslam ${PROJECT_NAME})
將 myslam.cpp、myvideo.cpp、myslam.yaml、myvideo.mp4 放在
ORB_SLAM2/目錄下。
myslam.yaml and myvideo.yaml :
%YAML:1.0
#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------
# Camera calibration and distortion parameters (OpenCV)
Camera.fx: 500.0
Camera.fy: 500.0
Camera.cx: 320.0
Camera.cy: 180.0
Camera.k1: 0
Camera.k2: 0
Camera.p1: 0
Camera.p2: 0
Camera.k3: 0
# 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: 0
#--------------------------------------------------------------------------------------------
# ORB Parameters
#--------------------------------------------------------------------------------------------
# ORB Extractor: Number of features per image
ORBextractor.nFeatures: 2000
# 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 Parameters
#--------------------------------------------------------------------------------------------
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
myslam.cpp:
#include <opencv2/opencv.hpp>
// ORB-SLAM的系統介面
#include "System.h"
#include <string>
#include <chrono> // for time stamp
#include <iostream>
using namespace std;
// 引數檔案與字典檔案
// 如果你係統上的路徑不同,請修改它
string parameterFile = "./myslam.yaml";
string vocFile = "./Vocabulary/ORBvoc.txt";
int main(int argc, char **argv) {
// 宣告 ORB-SLAM2 系統
ORB_SLAM2::System SLAM(vocFile, parameterFile, ORB_SLAM2::System::MONOCULAR, true);
// 獲取相機影像程式碼
cv::VideoCapture cap(0); // change to 1 if you want to use USB camera.
// 解析度設為640x480
cap.set(CV_CAP_PROP_FRAME_WIDTH, 640);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
// 記錄系統時間
auto start = chrono::system_clock::now();
while (1) {
cv::Mat frame;
cap >> frame; // 讀取相機資料
auto now = chrono::system_clock::now();
auto timestamp = chrono::duration_cast<chrono::milliseconds>(now - start);
SLAM.TrackMonocular(frame, double(timestamp.count())/1000.0);
}
return 0;
}
myvideo.cpp:
#include <opencv2/opencv.hpp>
// ORB-SLAM的系統介面
#include "System.h"
#include <string>
#include <chrono> // for time stamp
#include <iostream>
using namespace std;
// 引數檔案與字典檔案
// 如果你係統上的路徑不同,請修改它
string parameterFile = "./myvideo.yaml";
string vocFile = "./Vocabulary/ORBvoc.txt";
// 視訊檔案
string videoFile = "./myvideo.mp4";
int main(int argc, char **argv) {
// 宣告 ORB-SLAM2 系統
ORB_SLAM2::System SLAM(vocFile, parameterFile, ORB_SLAM2::System::MONOCULAR, true);
// 獲取視訊影像
cv::VideoCapture cap(videoFile); // change to 1 if you want to use USB camera.
// 記錄系統時間
auto start = chrono::system_clock::now();
while (1) {
cv::Mat frame;
cap >> frame; // 讀取相機資料
if ( frame.data == nullptr )
break;
// rescale because image is too large
cv::Mat frame_resized;
cv::resize(frame, frame_resized, cv::Size(640,360));
auto now = chrono::system_clock::now();
auto timestamp = chrono::duration_cast<chrono::milliseconds>(now - start);
SLAM.TrackMonocular(frame_resized, double(timestamp.count())/1000.0);
cv::waitKey(30);
}
SLAM.Shutdown();
return 0;
}
mkdir abuild
cd abuild
cmake ../
make
將 ~/ORB_SLAM2/Examples/Monocular 裡 生 成 的
myslam 複製到~/ORB_SLAM2
./myslam
./myslam
相關文章
- Centos下Sphinx中文分詞編譯安裝測試---CoreSeekCentOS中文分詞編譯
- UBuntu16.04下安裝Docker(親測)UbuntuDocker
- ORB_SLAM2之Pangolin的安裝ORBSLAMGo
- 星雲測試插裝編譯流程與CI整合編譯
- 編譯安裝zabbix編譯
- apache編譯安裝Apache編譯
- 編譯安裝nmon編譯
- swoole 編譯安裝編譯
- 編譯安裝Nginx編譯Nginx
- 編譯安裝mysql編譯MySql
- nginx編譯安裝Nginx編譯
- 安裝編譯ffmpeg編譯
- Griffin編譯安裝編譯
- autoit au3 IT管理員使用指南(一)基礎安裝、測試、編譯編譯
- Shell編譯安裝nginx編譯Nginx
- centos PHP 編譯安裝CentOSPHP編譯
- httpd編譯安裝phphttpd編譯PHP
- PHP的編譯安裝PHP編譯
- Mysql 5.7.17 編譯安裝MySql編譯
- ffmpeg安裝之linux編譯安裝Linux編譯
- 安裝測試kafkaKafka
- memcached安裝測試
- mq安裝測試MQ
- sqlserver 安裝測試SQLServer
- ubuntu16.04安裝rosUbuntuROS
- CentOS 下編譯安裝 NginxCentOS編譯Nginx
- CentOS 下編譯安裝 apacheCentOS編譯Apache
- Mac 編譯安裝 PHPRedis 模組Mac編譯PHPRedis
- PHP7 編譯安裝PHP編譯
- Linux編譯安裝NginxLinux編譯Nginx
- CentOS 6.4 編譯安裝 apacheCentOS編譯Apache
- ubuntu編譯安裝kernel教程。Ubuntu編譯
- windows下編譯安裝thriftWindows編譯
- 編譯安裝php7編譯PHP
- php7編譯安裝PHP編譯
- 原始碼編譯安裝Redis原始碼編譯Redis
- 編譯安裝LAMP環境編譯LAMP
- LNMP—Nginx的編譯安裝LNMPNginx編譯