diff --git a/CMakeLists.txt b/CMakeLists.txt index 08a8af468e..c18cfe5d58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,3 +111,6 @@ add_executable(mono_euroc Examples/Monocular/mono_euroc.cc) target_link_libraries(mono_euroc ${PROJECT_NAME}) +add_executable(mono_kaist +Examples/Monocular/mono_kaist.cc) +target_link_libraries(mono_kaist ${PROJECT_NAME}) \ No newline at end of file diff --git a/Examples/Monocular/KAIST-urban18.yaml b/Examples/Monocular/KAIST-urban18.yaml new file mode 100644 index 0000000000..4b5dfbf131 --- /dev/null +++ b/Examples/Monocular/KAIST-urban18.yaml @@ -0,0 +1,57 @@ +%YAML:1.0 + +#-------------------------------------------------------------------------------------------- +# Camera Parameters. Adjust them! +#-------------------------------------------------------------------------------------------- + +# Camera calibration and distortion parameters (OpenCV) +Camera.fx: 816.9 +Camera.fy: 811.6 +Camera.cx: 608.5 +Camera.cy: 263.5 + +Camera.k1: -5.6143027800000002e-02 +Camera.k2: 1.3952563200000001e-01 +Camera.p1: -1.2155906999999999e-03 +Camera.p2: -9.7281389999999998e-04 + +# Camera frames per second +Camera.fps: 10.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: 4000 + +# 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 + diff --git a/Examples/Monocular/mono_kaist b/Examples/Monocular/mono_kaist new file mode 100755 index 0000000000..8a254bc7a3 Binary files /dev/null and b/Examples/Monocular/mono_kaist differ diff --git a/Examples/Monocular/mono_kaist.cc b/Examples/Monocular/mono_kaist.cc new file mode 100644 index 0000000000..37583ad8c0 --- /dev/null +++ b/Examples/Monocular/mono_kaist.cc @@ -0,0 +1,162 @@ +/** +* This file is part of ORB-SLAM2. +* +* Copyright (C) 2014-2016 Raúl Mur-Artal (University of Zaragoza) +* For more information see +* +* 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 . +*/ + + +#include +#include +#include +#include + +#include + +#include"System.h" + +using namespace std; + +void LoadImages(const string &strSequence, vector &vstrImageFilenames, + vector &vTimestamps); + +int main(int argc, char **argv) +{ + if(argc != 4) + { + cerr << endl << "Usage: ./mono_kaist path_to_vocabulary path_to_settings path_to_sequence" << endl; + return 1; + } + + // Retrieve paths to images + vector vstrImageFilenames; + vector vTimestamps; + LoadImages(string(argv[3]), vstrImageFilenames, vTimestamps); + + int nImages = vstrImageFilenames.size(); + + // Create SLAM system. It initializes all system threads and gets ready to process frames. + ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,true); + + // Vector for tracking time statistics + vector vTimesTrack; + vTimesTrack.resize(nImages); + + cout << endl << "-------" << endl; + cout << "Start processing sequence ..." << endl; + cout << "Images in the sequence: " << nImages << endl << endl; + + // Main loop + cv::Mat im; + for(int ni=0; ni >(t2 - t1).count(); + + vTimesTrack[ni]=ttrack; + + // Wait to load the next frame + double T=0; + if(ni0) + T = tframe-vTimestamps[ni-1]; + + if(ttrack &vstrImageFilenames, vector &vTimestamps) +{ + ifstream fTimes; + vector stringTimestamps; + string strPathTimeFile = strPathToSequence + "/sensor_data/stereo_stamp.csv"; + fTimes.open(strPathTimeFile.c_str()); + if (!fTimes) { + cout << "Could not open file with timestamps!" << endl; + return; + } + while(!fTimes.eof()) + { + string s; + getline(fTimes,s); + if(!s.empty()) + { + stringstream ss; + ss << s; + double t; + ss >> t; + vTimestamps.push_back(t / 10000000000); + stringTimestamps.push_back(s); + } + } + + string strPrefixLeft = strPathToSequence + "/image/stereo_left/"; + + const int nTimes = vTimestamps.size(); + vstrImageFilenames.resize(nTimes); + + for(int i=0; i -#include -#include +#include +#include +#include +#include #include "Tracking.h" #include "FrameDrawer.h"