%YAML:1.0#--------------------------------------------------------------------------------------------# Camera Parameters. Adjust them!#--------------------------------------------------------------------------------------------Camera.type:"PinHole"# Camera calibration and distortion parameters (OpenCV) Camera.fx:614.3472290039062Camera.fy:613.3615112304688Camera.cx:314.36767578125Camera.cy:239.8182830810547Camera.k1:0.0Camera.k2:0.0Camera.p1:0.0Camera.p2:0.0Camera.k3:0.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:1# Camera resolutionCamera.width:1920Camera.height:1080#--------------------------------------------------------------------------------------------# ORB Parameters#--------------------------------------------------------------------------------------------# ORB Extractor: Number of features per imageORBextractor.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:20ORBextractor.minThFAST:7#--------------------------------------------------------------------------------------------# Viewer Parameters#--------------------------------------------------------------------------------------------Viewer.KeyFrameSize:0.05Viewer.KeyFrameLineWidth:5Viewer.GraphLineWidth:0.9Viewer.PointSize:2Viewer.CameraSize:0.08Viewer.CameraLineWidth:3Viewer.ViewpointX:0Viewer.ViewpointY:-0.7Viewer.ViewpointZ:-1.8Viewer.ViewpointF:500
//
// Created by xiang on 11/29/17.
//
// 该文件将打开给定的视频文件,并将图像传递给ORB-SLAM2进行定位
// 需要opencv
#include<opencv2/opencv.hpp>// ORB-SLAM的系统接口
#include"System.h"#include<string>#include<chrono>// for time stamp
#include<iostream>usingnamespacestd;// 参数文件与字典文件
// 如果你系统上的路径不同,请修改它
// 第二个路径建议用相对路径
stringparameterFile="./myvideo.yaml";stringvocFile="../../Vocabulary/ORBvoc.txt";// 视频文件,修改的话需要和你的视频名字一起改
stringvideoFile="./video.mp4";intmain(intargc,char**argv){// 声明 ORB-SLAM3 系统
ORB_SLAM3::SystemSLAM(vocFile,parameterFile,ORB_SLAM3::System::MONOCULAR,true);// 获取视频图像
cv::VideoCapturecap(videoFile);// change to 1 if you want to use USB camera.
// 记录系统时间
autostart=chrono::system_clock::now();while(1){cv::Matframe;cap>>frame;// 读取相机数据
if(frame.data==nullptr)break;// rescale because image is too large
cv::Matframe_resized;cv::resize(frame,frame_resized,cv::Size(640,480));autonow=chrono::system_clock::now();autotimestamp=chrono::duration_cast<chrono::milliseconds>(now-start);SLAM.TrackMonocular(frame_resized,double(timestamp.count())/1000.0);cv::waitKey(30);}SLAM.Shutdown();return0;}