Skip to content

Commit

Permalink
V0.4: Beta version, 21 April 2021
Browse files Browse the repository at this point in the history
- Changed OpenCV dynamic matrices to static matrices to speed up the code.

- Capability to measure running time of the system threads.

- Compatibility with OpenCV 4.0 (Requires at least OpenCV 3.0)

- Fixed minor bugs.
  • Loading branch information
richard-elvira committed Apr 21, 2021
1 parent ef97841 commit a80b467
Show file tree
Hide file tree
Showing 66 changed files with 2,237 additions and 4,256 deletions.
30 changes: 16 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,20 @@ endif()

LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)

find_package(OpenCV 3)
find_package(OpenCV 4.0)
if(NOT OpenCV_FOUND)
find_package(OpenCV 2.4.3 QUIET)
if(NOT OpenCV_FOUND)
message(FATAL_ERROR "OpenCV > 2.4.3 not found.")
endif()
find_package(OpenCV 3.0)
if(NOT OpenCV_FOUND)
message(FATAL_ERROR "OpenCV > 3.0 not found.")
endif()
endif()

MESSAGE("OPENCV VERSION:")
MESSAGE(${OpenCV_VERSION})

find_package(Eigen3 3.1.0 REQUIRED)
find_package(Pangolin REQUIRED)
find_package(realsense2)

include_directories(
${PROJECT_SOURCE_DIR}
Expand All @@ -72,7 +73,6 @@ src/Atlas.cc
src/Map.cc
src/MapDrawer.cc
src/Optimizer.cc
src/PnPsolver.cc
src/Frame.cc
src/KeyFrameDatabase.cc
src/Sim3Solver.cc
Expand All @@ -84,6 +84,7 @@ src/CameraModels/Pinhole.cpp
src/CameraModels/KannalaBrandt8.cpp
src/OptimizableTypes.cpp
src/MLPnPsolver.cpp
src/TwoViewReconstruction.cc
include/System.h
include/Tracking.h
include/LocalMapping.h
Expand All @@ -98,7 +99,6 @@ include/Atlas.h
include/Map.h
include/MapDrawer.h
include/Optimizer.h
include/PnPsolver.h
include/Frame.h
include/KeyFrameDatabase.h
include/Sim3Solver.h
Expand All @@ -112,7 +112,8 @@ include/CameraModels/KannalaBrandt8.h
include/OptimizableTypes.h
include/MLPnPsolver.h
include/TwoViewReconstruction.h
src/TwoViewReconstruction.cc)
include/Config.h
)

add_subdirectory(Thirdparty/g2o)

Expand All @@ -127,14 +128,17 @@ ${PROJECT_SOURCE_DIR}/Thirdparty/g2o/lib/libg2o.so
)


# Build examples
### Build examples

# RGB-D examples
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/RGB-D)

add_executable(rgbd_tum
Examples/RGB-D/rgbd_tum.cc)
target_link_libraries(rgbd_tum ${PROJECT_NAME})


# Stereo examples
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/Stereo)

add_executable(stereo_kitti
Expand All @@ -149,7 +153,7 @@ add_executable(stereo_tum_vi
Examples/Stereo/stereo_tum_vi.cc)
target_link_libraries(stereo_tum_vi ${PROJECT_NAME})


# Monocular examples
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/Monocular)

add_executable(mono_tum
Expand All @@ -168,7 +172,7 @@ add_executable(mono_tum_vi
Examples/Monocular/mono_tum_vi.cc)
target_link_libraries(mono_tum_vi ${PROJECT_NAME})


# Monocular-Inertial examples
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/Monocular-Inertial)

add_executable(mono_inertial_euroc
Expand All @@ -179,16 +183,14 @@ add_executable(mono_inertial_tum_vi
Examples/Monocular-Inertial/mono_inertial_tum_vi.cc)
target_link_libraries(mono_inertial_tum_vi ${PROJECT_NAME})


# Stereo-Inertial examples
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/Stereo-Inertial)

add_executable(stereo_inertial_euroc
Examples/Stereo-Inertial/stereo_inertial_euroc.cc)
target_link_libraries(stereo_inertial_euroc ${PROJECT_NAME})


add_executable(stereo_inertial_tum_vi
Examples/Stereo-Inertial/stereo_inertial_tum_vi.cc)
target_link_libraries(stereo_inertial_tum_vi ${PROJECT_NAME})


21 changes: 16 additions & 5 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
# ORB-SLAM3
Details of changes between the different versions.

### V0.4: Beta version, 21 April 2021

- Changed OpenCV dynamic matrices to static matrices to speed up the code.

- Capability to measure running time of the system threads.

- Compatibility with OpenCV 4.0 (Requires at least OpenCV 3.0)

- Fixed minor bugs.


### V0.3: Beta version, 4 Sep 2020

- RGB-D compatibility, the RGB-D examples had been adapted to the new version.
- RGB-D compatibility, the RGB-D examples have been adapted to the new version.

- Kitti and TUM dataset compatibility, these examples had been adapted to the new version.
- Kitti and TUM dataset compatibility, these examples have been adapted to the new version.

- ROS compatibility, It had been updated the old references in the code to work with this version.
- ROS compatibility, updated the old references in the code to work with this version.

- Config file parser, the YAML file contains the session configuration, a wrong parametrization may break the execution without any information to solve it. This version parses the file to read all the fields and give a proper answer if one of the fields have been wrong deffined or don't exist.
- Config file parser, the YAML file contains the session configuration, a wrong parametrization may break the execution without any information to solve it. This version parses the file to read all the fields and give a proper answer if one of the fields have been wrongly deffined or does not exist.

- Fixed minor bugs.

Expand All @@ -19,7 +30,7 @@ Initial release. It has these capabilities:

- Multiple-Maps capabilities, it is able to handle multiple maps in the same session and merge them when a common area is detected with a seamless fussion.

- Inertial sensor, the IMU initialization takes a 2 seconds to achieve a scale error less than 5\% and it is reffined in the next 10 seconds until is around 1\%. Inertial measures are integrated at frame rate to estimate the scale, gravity and velocity in order to improve the visual features detection and make the system robust to temporal occlusions.
- Inertial sensor, the IMU initialization takes 2 seconds to achieve a scale error less than 5\% and it is reffined in the next 10 seconds until it is around 1\%. Inertial measures are integrated at frame rate to estimate the scale, gravity and velocity in order to improve the visual features detection and make the system robust to temporal occlusions.

- Fisheye sensor, the fisheye sensors are now fully supported in monocular and stereo.

Expand Down
25 changes: 9 additions & 16 deletions Examples/Monocular-Inertial/mono_inertial_euroc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,19 @@ int main(int argc, char *argv[])

cout.precision(17);

/*cout << "Start processing sequence ..." << endl;
cout << "Images in the sequence: " << nImages << endl;
cout << "IMU data in the sequence: " << nImu << endl << endl;*/

// Create SLAM system. It initializes all system threads and gets ready to process frames.
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::IMU_MONOCULAR, true);

int proccIm=0;
for (seq = 0; seq<num_seq; seq++)
{

// Main loop
cv::Mat im;
vector<ORB_SLAM3::IMU::Point> vImuMeas;
proccIm = 0;
for(int ni=0; ni<nImages[seq]; ni++, proccIm++)
{
// Read image from file
im = cv::imread(vstrImageFilenames[seq][ni],CV_LOAD_IMAGE_UNCHANGED);
im = cv::imread(vstrImageFilenames[seq][ni],cv::IMREAD_UNCHANGED);

double tframe = vTimestampsCam[seq][ni];

Expand All @@ -150,8 +144,6 @@ int main(int argc, char *argv[])

if(ni>0)
{
// cout << "t_cam " << tframe << endl;

while(vTimestampsImu[seq][first_imu[seq]]<=vTimestampsCam[seq][ni])
{
vImuMeas.push_back(ORB_SLAM3::IMU::Point(vAcc[seq][first_imu[seq]].x,vAcc[seq][first_imu[seq]].y,vAcc[seq][first_imu[seq]].z,
Expand All @@ -161,28 +153,29 @@ int main(int argc, char *argv[])
}
}

/*cout << "first imu: " << first_imu << endl;
cout << "first imu time: " << fixed << vTimestampsImu[first_imu] << endl;
cout << "size vImu: " << vImuMeas.size() << endl;*/

#ifdef COMPILEDWITHC11
std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now();
#else
std::chrono::monotonic_clock::time_point t1 = std::chrono::monotonic_clock::now();
#endif

// Pass the image to the SLAM system
// cout << "tframe = " << tframe << endl;
SLAM.TrackMonocular(im,tframe,vImuMeas); // TODO change to monocular_inertial
SLAM.TrackMonocular(im,tframe,vImuMeas);

#ifdef COMPILEDWITHC11
std::chrono::steady_clock::time_point t2 = std::chrono::steady_clock::now();
#else
std::chrono::monotonic_clock::time_point t2 = std::chrono::monotonic_clock::now();
#endif

#ifdef REGISTER_TIMES
double t_track = std::chrono::duration_cast<std::chrono::duration<double,std::milli> >(t2 - t1).count();
SLAM.InsertTrackTime(t_track);
#endif

double ttrack= std::chrono::duration_cast<std::chrono::duration<double> >(t2 - t1).count();
ttrack_tot += ttrack;
// std::cout << "ttrack: " << ttrack << std::endl;

vTimesTrack[ni]=ttrack;

Expand All @@ -194,7 +187,7 @@ int main(int argc, char *argv[])
T = tframe-vTimestampsCam[seq][ni-1];

if(ttrack<T)
usleep((T-ttrack)*1e6); // 1e6
usleep((T-ttrack)*1e6);
}
if(seq < num_seq - 1)
{
Expand Down
27 changes: 2 additions & 25 deletions Examples/Monocular-Inertial/mono_inertial_tum_vi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ int main(int argc, char **argv)
cout << endl << "-------" << endl;
cout.precision(17);

/*cout << "Start processing sequence ..." << endl;
cout << "Images in the sequence: " << nImages << endl;
cout << "IMU data in the sequence: " << nImu << endl << endl;*/

// Create SLAM system. It initializes all system threads and gets ready to process frames.
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::IMU_MONOCULAR, true, 0, file_name);

Expand All @@ -135,8 +131,6 @@ int main(int argc, char **argv)
// clahe
clahe->apply(im,im);


// cout << "mat type: " << im.type() << endl;
double tframe = vTimestampsCam[seq][ni];

if(im.empty())
Expand All @@ -152,30 +146,24 @@ int main(int argc, char **argv)

if(ni>0)
{
// cout << "t_cam " << tframe << endl;

while(vTimestampsImu[seq][first_imu[seq]]<=vTimestampsCam[seq][ni])
{
vImuMeas.push_back(ORB_SLAM3::IMU::Point(vAcc[seq][first_imu[seq]].x,vAcc[seq][first_imu[seq]].y,vAcc[seq][first_imu[seq]].z,
vGyro[seq][first_imu[seq]].x,vGyro[seq][first_imu[seq]].y,vGyro[seq][first_imu[seq]].z,
vTimestampsImu[seq][first_imu[seq]]));
// cout << "t_imu = " << fixed << vImuMeas.back().t << endl;
first_imu[seq]++;
}
}

// cout << "first imu: " << first_imu[seq] << endl;
/*cout << "first imu time: " << fixed << vTimestampsImu[first_imu] << endl;
cout << "size vImu: " << vImuMeas.size() << endl;*/
#ifdef COMPILEDWITHC11
std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now();
#else
std::chrono::monotonic_clock::time_point t1 = std::chrono::monotonic_clock::now();
#endif

// Pass the image to the SLAM system
// cout << "tframe = " << tframe << endl;
SLAM.TrackMonocular(im,tframe,vImuMeas); // TODO change to monocular_inertial
SLAM.TrackMonocular(im,tframe,vImuMeas);

#ifdef COMPILEDWITHC11
std::chrono::steady_clock::time_point t2 = std::chrono::steady_clock::now();
Expand All @@ -185,7 +173,6 @@ int main(int argc, char **argv)

double ttrack= std::chrono::duration_cast<std::chrono::duration<double> >(t2 - t1).count();
ttrack_tot += ttrack;
// std::cout << "ttrack: " << ttrack << std::endl;

vTimesTrack[ni]=ttrack;

Expand All @@ -197,7 +184,7 @@ int main(int argc, char **argv)
T = tframe-vTimestampsCam[seq][ni-1];

if(ttrack<T)
usleep((T-ttrack)*1e6); // 1e6
usleep((T-ttrack)*1e6);

}
if(seq < num_seq - 1)
Expand All @@ -209,13 +196,9 @@ int main(int argc, char **argv)

}

// cout << "ttrack_tot = " << ttrack_tot << std::endl;
// Stop all threads
SLAM.Shutdown();


// Tracking time statistics

// Save camera trajectory

if (bFileName)
Expand All @@ -241,12 +224,6 @@ int main(int argc, char **argv)
cout << "median tracking time: " << vTimesTrack[nImages[0]/2] << endl;
cout << "mean tracking time: " << totaltime/proccIm << endl;

/*const string kf_file = "kf_" + ss.str() + ".txt";
const string f_file = "f_" + ss.str() + ".txt";
SLAM.SaveTrajectoryEuRoC(f_file);
SLAM.SaveKeyFrameTrajectoryEuRoC(kf_file);*/

return 0;
}

Expand Down
12 changes: 8 additions & 4 deletions Examples/Monocular/mono_euroc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int main(int argc, char **argv)
{

// Read image from file
im = cv::imread(vstrImageFilenames[seq][ni],CV_LOAD_IMAGE_UNCHANGED);
im = cv::imread(vstrImageFilenames[seq][ni],cv::IMREAD_UNCHANGED);
double tframe = vTimestampsCam[seq][ni];

if(im.empty())
Expand All @@ -108,15 +108,19 @@ int main(int argc, char **argv)
#endif

// Pass the image to the SLAM system
// cout << "tframe = " << tframe << endl;
SLAM.TrackMonocular(im,tframe); // TODO change to monocular_inertial
SLAM.TrackMonocular(im,tframe);

#ifdef COMPILEDWITHC11
std::chrono::steady_clock::time_point t2 = std::chrono::steady_clock::now();
#else
std::chrono::monotonic_clock::time_point t2 = std::chrono::monotonic_clock::now();
#endif

#ifdef REGISTER_TIMES
double t_track = std::chrono::duration_cast<std::chrono::duration<double,std::milli> >(t2 - t1).count();
SLAM.InsertTrackTime(t_track);
#endif

double ttrack= std::chrono::duration_cast<std::chrono::duration<double> >(t2 - t1).count();

vTimesTrack[ni]=ttrack;
Expand All @@ -129,7 +133,7 @@ int main(int argc, char **argv)
T = tframe-vTimestampsCam[seq][ni-1];

if(ttrack<T)
usleep((T-ttrack)*1e6); // 1e6
usleep((T-ttrack)*1e6);
}

if(seq < num_seq - 1)
Expand Down
4 changes: 0 additions & 4 deletions Examples/Monocular/mono_kitti.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ int main(int argc, char **argv)
vector<float> 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<nImages; ni++)
Expand Down
4 changes: 0 additions & 4 deletions Examples/Monocular/mono_tum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ int main(int argc, char **argv)
vector<float> 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<nImages; ni++)
Expand Down
Loading

0 comments on commit a80b467

Please sign in to comment.