├── .gitignore
├── CMakeLists.txt
├── LICENSE
├── README.md
├── cmake
└── FindSuiteParse.cmake
├── package.xml
├── src
├── FullSystem
│ ├── CoarseInitializer.cpp
│ ├── CoarseInitializer.h
│ ├── CoarseTracker.cpp
│ ├── CoarseTracker.h
│ ├── FullSystem.cpp
│ ├── FullSystem.h
│ ├── FullSystemDebugStuff.cpp
│ ├── FullSystemMarginalize.cpp
│ ├── FullSystemOptPoint.cpp
│ ├── FullSystemOptimize.cpp
│ ├── HessianBlocks.cpp
│ ├── HessianBlocks.h
│ ├── ImmaturePoint.cpp
│ ├── ImmaturePoint.h
│ ├── PixelSelector.h
│ ├── PixelSelector2.cpp
│ ├── PixelSelector2.h
│ ├── ResidualProjections.h
│ ├── Residuals.cpp
│ ├── Residuals.h
│ ├── ScaleOptimizer.cpp
│ └── ScaleOptimizer.h
├── IOWrapper
│ ├── ImageDisplay.h
│ ├── ImageDisplay_dummy.cpp
│ ├── ImageRW.h
│ ├── ImageRW_dummy.cpp
│ ├── OpenCV
│ │ ├── ImageDisplay_OpenCV.cpp
│ │ └── ImageRW_OpenCV.cpp
│ ├── Output3DWrapper.h
│ └── Pangolin
│ │ ├── KeyFrameDisplay.cpp
│ │ ├── KeyFrameDisplay.h
│ │ ├── PangolinSOSVIOViewer.cpp
│ │ └── PangolinSOSVIOViewer.h
├── LoopClosure
│ ├── LoopHandler.cpp
│ ├── LoopHandler.h
│ ├── PoseEstimator.cpp
│ ├── PoseEstimator.h
│ ├── ScanContext.cpp
│ └── ScanContext.h
├── OptimizationBackend
│ ├── AccumulatedSCHessian.cpp
│ ├── AccumulatedSCHessian.h
│ ├── AccumulatedTopHessian.cpp
│ ├── AccumulatedTopHessian.h
│ ├── EnergyFunctional.cpp
│ ├── EnergyFunctional.h
│ ├── EnergyFunctionalStructs.cpp
│ ├── EnergyFunctionalStructs.h
│ ├── MatrixAccumulators.h
│ ├── RawResidualJacobian.h
│ └── ScaleAccumulator.h
├── SlamNode.cpp
├── SlamNode.h
├── main.cpp
└── util
│ ├── FrameShell.h
│ ├── ImageAndExposure.h
│ ├── IndexThreadReduce.h
│ ├── MinimalImage.h
│ ├── NumType.h
│ ├── Undistort.cpp
│ ├── Undistort.h
│ ├── globalCalib.cpp
│ ├── globalCalib.h
│ ├── globalFuncs.h
│ ├── nanoflann.h
│ ├── settings.cpp
│ └── settings.h
├── tests
├── EuRoC
│ ├── calib.yaml
│ ├── camera0.txt
│ ├── camera1.txt
│ └── euroc.launch
├── KITTI
│ ├── 0_2
│ │ ├── calib.yaml
│ │ ├── camera0.txt
│ │ └── camera1.txt
│ ├── 4_12
│ │ ├── calib.yaml
│ │ ├── camera0.txt
│ │ └── camera1.txt
│ └── kitti.launch
├── Malaga
│ ├── calib.yaml
│ ├── camera0.txt
│ ├── camera1.txt
│ └── malaga.launch
├── RobotCar
│ ├── calib.yaml
│ ├── camera0.txt
│ ├── camera1.txt
│ └── robotcar.launch
└── TUMVI
│ ├── calib.yaml
│ ├── camera0.txt
│ ├── camera1.txt
│ ├── pcalib0.txt
│ ├── pcalib1.txt
│ ├── tumvi.launch
│ ├── vignette0.png
│ └── vignette1.png
└── thirdparty
├── Sophus
├── CMakeLists.txt
├── FindEigen3.cmake
├── README
├── SophusConfig.cmake.in
├── cmake_modules
│ └── FindEigen3.cmake
└── sophus
│ ├── rxso3.hpp
│ ├── se2.hpp
│ ├── se3.hpp
│ ├── sim3.hpp
│ ├── so2.hpp
│ ├── so3.hpp
│ ├── sophus.hpp
│ ├── test_rxso3.cpp
│ ├── test_se2.cpp
│ ├── test_se3.cpp
│ ├── test_sim3.cpp
│ ├── test_so2.cpp
│ ├── test_so3.cpp
│ └── tests.hpp
└── g2o
├── CMakeLists.txt
├── README.md
├── build.sh
├── cmake_modules
├── FindBLAS.cmake
├── FindEigen3.cmake
└── FindLAPACK.cmake
├── config.h.in
└── g2o
├── config.h
├── core
├── CMakeLists.txt
├── base_binary_edge.h
├── base_binary_edge.hpp
├── base_dynamic_vertex.h
├── base_edge.h
├── base_multi_edge.h
├── base_multi_edge.hpp
├── base_unary_edge.h
├── base_unary_edge.hpp
├── base_vertex.h
├── base_vertex.hpp
├── batch_stats.cpp
├── batch_stats.h
├── block_solver.h
├── block_solver.hpp
├── cache.cpp
├── cache.h
├── creators.h
├── dynamic_aligned_buffer.hpp
├── eigen_types.h
├── estimate_propagator.cpp
├── estimate_propagator.h
├── factory.cpp
├── factory.h
├── g2o_core_api.h
├── hyper_dijkstra.cpp
├── hyper_dijkstra.h
├── hyper_graph.cpp
├── hyper_graph.h
├── hyper_graph_action.cpp
├── hyper_graph_action.h
├── io_helper.h
├── jacobian_workspace.cpp
├── jacobian_workspace.h
├── linear_solver.h
├── marginal_covariance_cholesky.cpp
├── marginal_covariance_cholesky.h
├── matrix_operations.h
├── matrix_structure.cpp
├── matrix_structure.h
├── openmp_mutex.h
├── optimizable_graph.cpp
├── optimizable_graph.h
├── optimization_algorithm.cpp
├── optimization_algorithm.h
├── optimization_algorithm_dogleg.cpp
├── optimization_algorithm_dogleg.h
├── optimization_algorithm_factory.cpp
├── optimization_algorithm_factory.h
├── optimization_algorithm_gauss_newton.cpp
├── optimization_algorithm_gauss_newton.h
├── optimization_algorithm_levenberg.cpp
├── optimization_algorithm_levenberg.h
├── optimization_algorithm_property.h
├── optimization_algorithm_with_hessian.cpp
├── optimization_algorithm_with_hessian.h
├── ownership.h
├── parameter.cpp
├── parameter.h
├── parameter_container.cpp
├── parameter_container.h
├── robust_kernel.cpp
├── robust_kernel.h
├── robust_kernel_factory.cpp
├── robust_kernel_factory.h
├── robust_kernel_impl.cpp
├── robust_kernel_impl.h
├── solver.cpp
├── solver.h
├── sparse_block_matrix.h
├── sparse_block_matrix.hpp
├── sparse_block_matrix_ccs.h
├── sparse_block_matrix_diagonal.h
├── sparse_block_matrix_test.cpp
├── sparse_optimizer.cpp
├── sparse_optimizer.h
├── sparse_optimizer_terminate_action.cpp
└── sparse_optimizer_terminate_action.h
├── solvers
└── eigen
│ ├── CMakeLists.txt
│ ├── linear_solver_eigen.h
│ └── solver_eigen.cpp
├── stuff
├── CMakeLists.txt
├── color_macros.h
├── command_args.cpp
├── command_args.h
├── filesys_tools.cpp
├── filesys_tools.h
├── g2o_stuff_api.h
├── macros.h
├── misc.h
├── opengl_primitives.cpp
├── opengl_primitives.h
├── opengl_wrapper.h
├── os_specific.c
├── os_specific.h
├── property.cpp
├── property.h
├── sampler.cpp
├── sampler.h
├── scoped_pointer.h
├── sparse_helper.cpp
├── sparse_helper.h
├── string_tools.cpp
├── string_tools.h
├── tictoc.cpp
├── tictoc.h
├── timeutil.cpp
├── timeutil.h
└── unscented.h
└── types
└── slam3d
├── CMakeLists.txt
├── dquat2mat.cpp
├── dquat2mat.h
├── dquat2mat_maxima_generated.cpp
├── edge_se3.cpp
├── edge_se3.h
├── g2o_types_slam3d_api.h
├── isometry3d_gradients.cpp
├── isometry3d_gradients.h
├── isometry3d_mappings.cpp
├── isometry3d_mappings.h
├── se3_ops.h
├── se3_ops.hpp
├── se3quat.h
├── types_slam3d.cpp
├── types_slam3d.h
├── vertex_se3.cpp
└── vertex_se3.h
/.gitignore:
--------------------------------------------------------------------------------
1 | thirdparty/g2o/build
2 | thirdparty/g2o/lib
3 |
4 | tests/Aqua
5 | tests/Gazebo
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | PROJECT(sos_slam)
2 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
3 |
4 | set(BUILD_TYPE Release)
5 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
6 |
7 | find_package(SuiteParse REQUIRED)
8 | find_package(Eigen3 REQUIRED)
9 | find_package(Boost COMPONENTS system thread)
10 | find_package(Pangolin 0.2 REQUIRED)
11 | find_package(OpenCV REQUIRED)
12 | find_package(PCL REQUIRED)
13 | find_package(catkin REQUIRED COMPONENTS
14 | geometry_msgs
15 | roscpp
16 | rosbag
17 | sensor_msgs
18 | cv_bridge
19 | image_transport
20 | message_filters
21 | )
22 |
23 | catkin_package()
24 |
25 | add_definitions("-DENABLE_SSE")
26 | set(CMAKE_CXX_FLAGS "${SSE_FLAGS} -O3 -g -march=native")
27 |
28 | include_directories(
29 | src
30 | thirdparty/Sophus
31 | thirdparty/sse2neon
32 | thirdparty/g2o
33 | ${EIGEN3_INCLUDE_DIR}
34 | ${catkin_INCLUDE_DIRS}
35 | ${Pangolin_INCLUDE_DIRS}
36 | ${OpenCV_INCLUDE_DIRS}
37 | ${PCL_INCLUDE_DIRS}
38 | ${CSPARSE_INCLUDE_DIR}
39 | ${CHOLMOD_INCLUDE_DIR}
40 | )
41 |
42 | link_directories(${PCL_LIBRARY_DIRS})
43 | add_definitions(${PCL_DEFINITIONS})
44 |
45 | add_library(sos_slam_lib
46 | src/SlamNode.cpp
47 | src/FullSystem/FullSystem.cpp
48 | src/FullSystem/FullSystemOptimize.cpp
49 | src/FullSystem/FullSystemOptPoint.cpp
50 | src/FullSystem/FullSystemDebugStuff.cpp
51 | src/FullSystem/FullSystemMarginalize.cpp
52 | src/FullSystem/Residuals.cpp
53 | src/FullSystem/ScaleOptimizer.cpp
54 | src/FullSystem/CoarseInitializer.cpp
55 | src/FullSystem/CoarseTracker.cpp
56 | src/FullSystem/ImmaturePoint.cpp
57 | src/FullSystem/HessianBlocks.cpp
58 | src/FullSystem/PixelSelector2.cpp
59 | src/OptimizationBackend/EnergyFunctional.cpp
60 | src/OptimizationBackend/AccumulatedTopHessian.cpp
61 | src/OptimizationBackend/AccumulatedSCHessian.cpp
62 | src/OptimizationBackend/EnergyFunctionalStructs.cpp
63 | src/util/settings.cpp
64 | src/util/Undistort.cpp
65 | src/util/globalCalib.cpp
66 | src/IOWrapper/Pangolin/KeyFrameDisplay.cpp
67 | src/IOWrapper/Pangolin/PangolinSOSVIOViewer.cpp
68 | src/IOWrapper/OpenCV/ImageDisplay_OpenCV.cpp
69 | src/IOWrapper/OpenCV/ImageRW_OpenCV.cpp
70 | src/LoopClosure/LoopHandler.cpp
71 | src/LoopClosure/ScanContext.cpp
72 | src/LoopClosure/PoseEstimator.cpp
73 | )
74 |
75 | add_executable(sos_slam_node src/main.cpp)
76 |
77 | target_link_libraries(sos_slam_node
78 | sos_slam_lib
79 | ${catkin_LIBRARIES}
80 | ${BOOST_THREAD_LIBRARY}
81 | ${Pangolin_LIBRARIES}
82 | ${OpenCV_LIBS}
83 | ${PCL_LIBRARIES}
84 | ${PROJECT_SOURCE_DIR}/thirdparty/g2o/lib/libg2o_core.so
85 | ${PROJECT_SOURCE_DIR}/thirdparty/g2o/lib/libg2o_types_slam3d.so
86 | ${PROJECT_SOURCE_DIR}/thirdparty/g2o/lib/libg2o_solver_eigen.so
87 | boost_system boost_thread cxsparse)
88 |
89 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Scale Optimized Spline SLAM (SOS-SLAM)
2 |
3 | ## Related Publications
4 | - **Direct Sparse Odometry**, J. Engel, V. Koltun, D. Cremers, IEEE Transactions on Pattern Analysis and Machine Intelligence, 2018.
5 | - **Extending Monocular Visual Odometry to Stereo Camera Systems by Scale Optimization**, J. Mo and J. Sattar, IEEE/RSJ International Conference on Intelligent Robots and Systems, 2019.
6 | - **A Fast and Robust Place Recognition Approach for Stereo Visual Odometry Using LiDAR Descriptors**, J. Mo and J. Sattar, IEEE/RSJ International Conference on Intelligent Robots and Systems, 2020.
7 | - **Fast Direct Stereo Visual SLAM**, J. Mo, Md Jahidul Islam, and J. Sattar, IEEE Robotics and Automation Letters, 2022.
8 | - **Continuous-Time Spline Visual-Inertial Odometry**, J. Mo and J. Sattar, IEEE International Conference on Robotics and Automation, 2022.
9 |
10 |
11 | ## Installation
12 | 0. Dependencies: [ROS](https://www.ros.org/) (middleware), [DSO dependencies](https://github.com/JakobEngel/dso#21-required-dependencies) ([OpenCV](https://opencv.org/), [Pangolin](https://github.com/stevenlovegrove/Pangolin)), and [PCL](https://pointclouds.org/) (for 3D loop closure).
13 |
14 | 1. Build g2o library (for global pose optimization when loop closure is enabled):
15 | ```
16 | cd thirdparty/g2o
17 | bash build.sh
18 | ```
19 |
20 | 2. Build SOS-SLAM:
21 | ```
22 | cd catkin_ws/src
23 | git clone https://github.com/IRVLab/SOS-SLAM.git
24 | cd ..
25 | catkin_make
26 | ```
27 |
28 | ## Usage
29 | 1. Preparation (examples of popular datasets are [provided](https://github.com/IRVLab/SOS-SLAM/tree/main/tests))
30 | - [Calibrate](https://github.com/ethz-asl/kalibr) your stereo visual-inertial rig and convert to [this format](https://github.com/IRVLab/SOS-SLAM/tree/main/tests/EuRoC):
31 | - Refer to [DSO](https://github.com/JakobEngel/dso) for more details of intrisic parameters ([cameraX.txt](https://github.com/IRVLab/SOS-SLAM/blob/main/tests/EuRoC/camera0.txt)).
32 | - Put a small number in [T_cam1_cam0[2,2]](https://github.com/IRVLab/SOS-SLAM/blob/main/tests/EuRoC/calib.yaml#L15) for numerical stability if images are stereo pre-rectified.
33 | - Create a [launch file](https://github.com/IRVLab/SOS-SLAM/blob/main/tests/EuRoC/euroc.launch):
34 | - **scale_opt_thres**: scale optimization accept threshold (e.g., 15.0), set -1 to disable scale optimization.
35 | - **weight_imu_dso**: relative weight between inertial and visual systems (e.g., 6.0), set -1 to ignore IMU measurements.
36 | - **loop_lidar_range**: imitated LiDAR scan range (e.g., 40.0 meters), set -1 to disable place recognition.
37 | - check ROS parameter acquisition (*getParam()* and *param()*) in [main.cpp](https://github.com/IRVLab/SOS-SLAM/blob/main/src/main.cpp) and [settings.cpp](https://github.com/IRVLab/SOS-SLAM/blob/main/src/util/settings.cpp) for more optional parameters.
38 |
39 | 2. Run
40 | ```
41 | roslaunch sos_slam [YOUR_LAUNCH_FILE]
42 | ```
43 |
44 | ### Outputs
45 | - Published ROS Topics:
46 | - **pose_cam0_in_world/current**: pose of the most recent frame (not final, minimal lagging).
47 | - **pose_cam0_in_world/marginalized**: pose of the most recently marginalized frame (final, several keyframes behind).
48 | - **poses.txt** will also be written to ~/.ros for pose evaluation once done.
--------------------------------------------------------------------------------
/cmake/FindSuiteParse.cmake:
--------------------------------------------------------------------------------
1 | FIND_PATH(CHOLMOD_INCLUDE_DIR NAMES cholmod.h amd.h camd.h
2 | PATHS
3 | ${SUITE_SPARSE_ROOT}/include
4 | /usr/include/suitesparse
5 | /usr/include/ufsparse
6 | /opt/local/include/ufsparse
7 | /usr/local/include/ufsparse
8 | /sw/include/ufsparse
9 | )
10 |
11 | FIND_LIBRARY(CHOLMOD_LIBRARY NAMES cholmod
12 | PATHS
13 | ${SUITE_SPARSE_ROOT}/lib
14 | /usr/lib
15 | /usr/local/lib
16 | /opt/local/lib
17 | /sw/lib
18 | )
19 |
20 | FIND_LIBRARY(AMD_LIBRARY NAMES SHARED NAMES amd
21 | PATHS
22 | ${SUITE_SPARSE_ROOT}/lib
23 | /usr/lib
24 | /usr/local/lib
25 | /opt/local/lib
26 | /sw/lib
27 | )
28 |
29 | FIND_LIBRARY(CAMD_LIBRARY NAMES camd
30 | PATHS
31 | ${SUITE_SPARSE_ROOT}/lib
32 | /usr/lib
33 | /usr/local/lib
34 | /opt/local/lib
35 | /sw/lib
36 | )
37 |
38 | FIND_LIBRARY(SUITESPARSECONFIG_LIBRARY NAMES suitesparseconfig
39 | PATHS
40 | ${SUITE_SPARSE_ROOT}/lib
41 | /usr/lib
42 | /usr/local/lib
43 | /opt/local/lib
44 | /sw/lib
45 | )
46 |
47 |
48 | # Different platforms seemingly require linking against different sets of libraries
49 | IF(CYGWIN)
50 | FIND_PACKAGE(PkgConfig)
51 | FIND_LIBRARY(COLAMD_LIBRARY NAMES colamd
52 | PATHS
53 | /usr/lib
54 | /usr/local/lib
55 | /opt/local/lib
56 | /sw/lib
57 | )
58 | PKG_CHECK_MODULES(LAPACK lapack)
59 |
60 | SET(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARY} ${AMD_LIBRARY} ${CAMD_LIBRARY} ${COLAMD_LIBRARY} ${CCOLAMD_LIBRARY} ${LAPACK_LIBRARIES})
61 |
62 | # MacPorts build of the SparseSuite requires linking against extra libraries
63 |
64 | ELSEIF(APPLE)
65 |
66 | FIND_LIBRARY(COLAMD_LIBRARY NAMES colamd
67 | PATHS
68 | /usr/lib
69 | /usr/local/lib
70 | /opt/local/lib
71 | /sw/lib
72 | )
73 |
74 | FIND_LIBRARY(CCOLAMD_LIBRARY NAMES ccolamd
75 | PATHS
76 | /usr/lib
77 | /usr/local/lib
78 | /opt/local/lib
79 | /sw/lib
80 | )
81 |
82 | FIND_LIBRARY(METIS_LIBRARY NAMES metis
83 | PATHS
84 | /usr/lib
85 | /usr/local/lib
86 | /opt/local/lib
87 | /sw/lib
88 | )
89 |
90 | SET(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARY} ${AMD_LIBRARY} ${CAMD_LIBRARY} ${COLAMD_LIBRARY} ${CCOLAMD_LIBRARY} ${METIS_LIBRARY} "-framework Accelerate")
91 | ELSE(APPLE)
92 | SET(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARY} ${AMD_LIBRARY})
93 | ENDIF(CYGWIN)
94 |
95 | IF(CHOLMOD_INCLUDE_DIR AND CHOLMOD_LIBRARIES)
96 | SET(CHOLMOD_FOUND TRUE)
97 | ELSE(CHOLMOD_INCLUDE_DIR AND CHOLMOD_LIBRARIES)
98 | SET(CHOLMOD_FOUND FALSE)
99 | ENDIF(CHOLMOD_INCLUDE_DIR AND CHOLMOD_LIBRARIES)
100 |
101 | # Look for csparse; note the difference in the directory specifications!
102 | FIND_PATH(CSPARSE_INCLUDE_DIR NAMES cs.h
103 | PATHS
104 | /usr/include/suitesparse
105 | /usr/include
106 | /opt/local/include
107 | /usr/local/include
108 | /sw/include
109 | /usr/include/ufsparse
110 | /opt/local/include/ufsparse
111 | /usr/local/include/ufsparse
112 | /sw/include/ufsparse
113 | )
114 |
115 | FIND_LIBRARY(CSPARSE_LIBRARY NAMES cxsparse
116 | PATHS
117 | /usr/lib
118 | /usr/local/lib
119 | /opt/local/lib
120 | /sw/lib
121 | )
122 |
123 | IF(CSPARSE_INCLUDE_DIR AND CSPARSE_LIBRARY)
124 | SET(CSPARSE_FOUND TRUE)
125 | ELSE(CSPARSE_INCLUDE_DIR AND CSPARSE_LIBRARY)
126 | SET(CSPARSE_FOUND FALSE)
127 | ENDIF(CSPARSE_INCLUDE_DIR AND CSPARSE_LIBRARY)
128 |
129 |
--------------------------------------------------------------------------------
/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | sos_slam
4 | 0.0.0
5 | The sos_slam package
6 |
7 | Jiawei Mo
8 |
9 | GPLv3
10 | catkin
11 | gazebo_ros
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/FullSystem/CoarseTracker.h:
--------------------------------------------------------------------------------
1 | // Copyright (C) <2022>
2 |
3 | // This program is free software: you can redistribute it and/or modify
4 | // it under the terms of the GNU General Public License as published by
5 | // the Free Software Foundation, either version 3 of the License, or
6 | // (at your option) any later version.
7 |
8 | // This program is distributed in the hope that it will be useful,
9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | // GNU General Public License for more details.
12 |
13 | // You should have received a copy of the GNU General Public License
14 | // along with this program. If not, see .
15 |
16 | // This file is modified from
17 |
18 | #pragma once
19 |
20 | #include "ScaleOptimizer.h"
21 |
22 | namespace dso {
23 | class CoarseTracker : public ScaleOptimizer {
24 | public:
25 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
26 |
27 | CoarseTracker(int w, int h, const std::vector &tfm_vec,
28 | const Mat33f &K1);
29 |
30 | void setCoarseTrackingRef(std::vector frameHessians);
31 |
32 | void scaleCoarseDepthL0(float scale);
33 |
34 | void debugPlotIDepthMap(float *minID, float *maxID,
35 | std::vector &wraps);
36 | void debugPlotIDepthMapFloat(std::vector &wraps);
37 |
38 | bool trackNewestCoarse(FrameHessian *newFrameHessian, SE3 &lastToNew_out,
39 | AffLight &aff_g2l_out, int coarsestLvl,
40 | Vec5 minResForAbort, Vec5 &lastResiduals,
41 | IOWrap::Output3DWrapper *wrap = 0);
42 |
43 | // act as pure ouptut
44 | int refFrameID;
45 | FrameHessian *lastRef;
46 | AffLight lastRef_aff_g2l;
47 | Vec3 lastFlowIndicators;
48 | double firstCoarseRMSE;
49 |
50 | private:
51 | void makeCoarseDepthL0(std::vector frameHessians);
52 |
53 | Vec6 calcResPose(int lvl, const SE3 &refToNew, AffLight aff_g2l,
54 | float cutoffTH, bool plot_img = false);
55 | void calcGSSSEPose(int lvl, Mat88 &H_out, Vec8 &b_out, const SE3 &refToNew,
56 | AffLight aff_g2l);
57 |
58 | // warped buffers
59 | float *poseBufWarped_idepth;
60 | float *poseBufWarped_u;
61 | float *poseBufWarped_v;
62 | float *poseBufWarped_dx;
63 | float *poseBufWarped_dy;
64 | float *poseBufWarped_residual;
65 | float *poseBufWarped_weight;
66 | float *poseBufWarped_refColor;
67 | int poseBufWarped_n;
68 |
69 | FrameHessian *newFrame;
70 | Accumulator9 poseAcc;
71 | };
72 |
73 | class CoarseDistanceMap {
74 | public:
75 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
76 |
77 | Mat33f K[PYR_LEVELS];
78 | Mat33f Ki[PYR_LEVELS];
79 |
80 | CoarseDistanceMap(int w, int h);
81 | ~CoarseDistanceMap();
82 |
83 | void makeDistanceMap(std::vector frameHessians,
84 | FrameHessian *frame);
85 |
86 | void makeInlierVotes(std::vector frameHessians);
87 |
88 | void makeK(CalibHessian *HCalib);
89 |
90 | float *fwdWarpedIDDistFinal;
91 |
92 | void addIntoDistFinal(int u, int v);
93 |
94 | private:
95 | int w[PYR_LEVELS];
96 | int h[PYR_LEVELS];
97 |
98 | PointFrameResidual **coarseProjectionGrid;
99 | int *coarseProjectionGridnum;
100 | Eigen::Vector2i *bfsList1;
101 | Eigen::Vector2i *bfsList2;
102 |
103 | void growDistBFS(int bfsNum);
104 | };
105 |
106 | } // namespace dso
107 |
--------------------------------------------------------------------------------
/src/FullSystem/ImmaturePoint.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 |
26 | #include "util/NumType.h"
27 |
28 | #include "HessianBlocks.h"
29 | namespace dso {
30 |
31 | struct ImmaturePointTemporaryResidual {
32 | public:
33 | ResState state_state;
34 | double state_energy;
35 | ResState state_NewState;
36 | double state_NewEnergy;
37 | FrameHessian *target;
38 | };
39 |
40 | enum ImmaturePointStatus {
41 | IPS_GOOD = 0, // traced well and good
42 | IPS_OOB, // OOB: end tracking & marginalize!
43 | IPS_OUTLIER, // energy too high: if happens again: outlier!
44 | IPS_SKIPPED, // traced well and good (but not actually traced).
45 | IPS_BADCONDITION, // not traced because of bad condition.
46 | IPS_UNINITIALIZED
47 | }; // not even traced once.
48 |
49 | class ImmaturePoint {
50 | public:
51 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
52 | // static values
53 | float color[MAX_RES_PER_POINT];
54 | float weights[MAX_RES_PER_POINT];
55 |
56 | Mat22f gradH;
57 | Vec2f gradH_ev;
58 | Mat22f gradH_eig;
59 | float energyTH;
60 | float u, v;
61 | FrameHessian *host;
62 | int idxInImmaturePoints;
63 |
64 | float quality;
65 |
66 | float my_type;
67 |
68 | float idepth_min;
69 | float idepth_max;
70 | ImmaturePoint(int u_, int v_, FrameHessian *host_, float type,
71 | CalibHessian *HCalib);
72 | ~ImmaturePoint();
73 |
74 | ImmaturePointStatus traceOn(FrameHessian *frame,
75 | const Mat33f &hostToFrame_KRKi,
76 | const Vec3f &hostToFrame_Kt,
77 | const Vec2f &hostToFrame_affine,
78 | CalibHessian *HCalib, bool debugPrint = false);
79 |
80 | ImmaturePointStatus lastTraceStatus;
81 | Vec2f lastTraceUV;
82 | float lastTracePixelInterval;
83 |
84 | float idepth_GT;
85 |
86 | double linearizeResidual(CalibHessian *HCalib, const float outlierTHSlack,
87 | ImmaturePointTemporaryResidual *tmpRes, float &Hdd,
88 | float &bd, float idepth);
89 | float getdPixdd(CalibHessian *HCalib, ImmaturePointTemporaryResidual *tmpRes,
90 | float idepth);
91 |
92 | float calcResidual(CalibHessian *HCalib, const float outlierTHSlack,
93 | ImmaturePointTemporaryResidual *tmpRes, float idepth);
94 |
95 | private:
96 | };
97 |
98 | } // namespace dso
99 |
--------------------------------------------------------------------------------
/src/FullSystem/PixelSelector2.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 |
26 | #include "util/NumType.h"
27 |
28 | namespace dso {
29 |
30 | enum PixelSelectorStatus { PIXSEL_VOID = 0, PIXSEL_1, PIXSEL_2, PIXSEL_3 };
31 |
32 | class FrameHessian;
33 |
34 | class PixelSelector {
35 | public:
36 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
37 | int makeMaps(const FrameHessian *const fh, float *map_out, float density,
38 | int recursionsLeft = 1, bool plot = false, float thFactor = 1);
39 |
40 | PixelSelector(int w, int h);
41 | ~PixelSelector();
42 | int currentPotential;
43 |
44 | bool allowFast;
45 | void makeHists(const FrameHessian *const fh);
46 |
47 | private:
48 | Eigen::Vector3i select(const FrameHessian *const fh, float *map_out, int pot,
49 | float thFactor = 1);
50 |
51 | unsigned char *randomPattern;
52 |
53 | int *gradHist;
54 | float *ths;
55 | float *thsSmoothed;
56 | int thsStep;
57 | const FrameHessian *gradHistFrame;
58 | };
59 |
60 | } // namespace dso
61 |
--------------------------------------------------------------------------------
/src/FullSystem/ResidualProjections.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 |
26 | #include "FullSystem.h"
27 | #include "HessianBlocks.h"
28 | #include "util/NumType.h"
29 | #include "util/settings.h"
30 |
31 | namespace dso {
32 |
33 | EIGEN_STRONG_INLINE float derive_idepth(const Vec3f &t, const float &u,
34 | const float &v, const int &dx,
35 | const int &dy, const float &dxInterp,
36 | const float &dyInterp,
37 | const float &drescale) {
38 | return (dxInterp * drescale * (t[0] - t[2] * u) +
39 | dyInterp * drescale * (t[1] - t[2] * v)) *
40 | SCALE_IDEPTH;
41 | }
42 |
43 | EIGEN_STRONG_INLINE bool projectPoint(const float &u_pt, const float &v_pt,
44 | const float &idepth, const Mat33f &KRKi,
45 | const Vec3f &Kt, float &Ku, float &Kv) {
46 | Vec3f ptp = KRKi * Vec3f(u_pt, v_pt, 1) + Kt * idepth;
47 | Ku = ptp[0] / ptp[2];
48 | Kv = ptp[1] / ptp[2];
49 | return Ku > 1.1f && Kv > 1.1f && Ku < wM3G && Kv < hM3G;
50 | }
51 |
52 | EIGEN_STRONG_INLINE bool
53 | projectPoint(const float &u_pt, const float &v_pt, const float &idepth,
54 | const int &dx, const int &dy, CalibHessian *const &HCalib,
55 | const Mat33f &R, const Vec3f &t, float &drescale, float &u,
56 | float &v, float &Ku, float &Kv, Vec3f &KliP, float &new_idepth) {
57 | KliP = Vec3f((u_pt + dx - HCalib->cxl()) * HCalib->fxli(),
58 | (v_pt + dy - HCalib->cyl()) * HCalib->fyli(), 1);
59 |
60 | Vec3f ptp = R * KliP + t * idepth;
61 | drescale = 1.0f / ptp[2];
62 | new_idepth = idepth * drescale;
63 |
64 | if (!(drescale > 0))
65 | return false;
66 |
67 | u = ptp[0] * drescale;
68 | v = ptp[1] * drescale;
69 | Ku = u * HCalib->fxl() + HCalib->cxl();
70 | Kv = v * HCalib->fyl() + HCalib->cyl();
71 |
72 | return Ku > 1.1f && Kv > 1.1f && Ku < wM3G && Kv < hM3G;
73 | }
74 |
75 | } // namespace dso
76 |
--------------------------------------------------------------------------------
/src/FullSystem/Residuals.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 |
26 | #include "util/globalCalib.h"
27 | #include "vector"
28 |
29 | #include "OptimizationBackend/RawResidualJacobian.h"
30 | #include "util/NumType.h"
31 | #include "util/globalFuncs.h"
32 | #include
33 | #include
34 |
35 | namespace dso {
36 | class PointHessian;
37 | class FrameHessian;
38 | class CalibHessian;
39 |
40 | class EFResidual;
41 |
42 | enum ResLocation { ACTIVE = 0, LINEARIZED, MARGINALIZED, NONE };
43 | enum ResState { IN = 0, OOB, OUTLIER };
44 |
45 | struct FullJacRowT {
46 | Eigen::Vector2f projectedTo[MAX_RES_PER_POINT];
47 | };
48 |
49 | class PointFrameResidual {
50 | public:
51 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW
52 |
53 | EFResidual *efResidual;
54 |
55 | static int instanceCounter;
56 |
57 | ResState state_state;
58 | double state_energy;
59 | ResState state_NewState;
60 | double state_NewEnergy;
61 | double state_NewEnergyWithOutlier;
62 |
63 | void setState(ResState s) { state_state = s; }
64 |
65 | PointHessian *point;
66 | FrameHessian *host;
67 | FrameHessian *target;
68 | RawResidualJacobian *J;
69 |
70 | bool isNew;
71 |
72 | Eigen::Vector2f projectedTo[MAX_RES_PER_POINT];
73 | Vec3f centerProjectedTo;
74 |
75 | ~PointFrameResidual();
76 | PointFrameResidual();
77 | PointFrameResidual(PointHessian *point_, FrameHessian *host_,
78 | FrameHessian *target_);
79 | double linearize(CalibHessian *HCalib);
80 |
81 | void resetOOB() {
82 | state_NewEnergy = state_energy = 0;
83 | state_NewState = ResState::OUTLIER;
84 |
85 | setState(ResState::IN);
86 | };
87 | void applyRes(bool copyJacobians);
88 |
89 | void debugPlot();
90 |
91 | void printRows(std::vector &v, VecX &r, int nFrames, int nPoints, int M,
92 | int res);
93 | };
94 | } // namespace dso
95 |
--------------------------------------------------------------------------------
/src/FullSystem/ScaleOptimizer.h:
--------------------------------------------------------------------------------
1 | // Copyright (C) <2022>
2 |
3 | // This program is free software: you can redistribute it and/or modify
4 | // it under the terms of the GNU General Public License as published by
5 | // the Free Software Foundation, either version 3 of the License, or
6 | // (at your option) any later version.
7 |
8 | // This program is distributed in the hope that it will be useful,
9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | // GNU General Public License for more details.
12 |
13 | // You should have received a copy of the GNU General Public License
14 | // along with this program. If not, see .
15 |
16 | // This file is modified from
17 |
18 | #pragma once
19 |
20 | #include "IOWrapper/Output3DWrapper.h"
21 | #include "OptimizationBackend/MatrixAccumulators.h"
22 | #include "OptimizationBackend/ScaleAccumulator.h"
23 | #include "util/NumType.h"
24 | #include "util/settings.h"
25 |
26 | #include
27 | #include
28 |
29 | namespace dso {
30 | struct CalibHessian;
31 | struct FrameHessian;
32 | struct PointFrameResidual;
33 |
34 | template
35 | T *allocAligned(int size, std::vector &rawPtrVec) {
36 | const int padT = 1 + ((1 << b) / sizeof(T));
37 | T *ptr = new T[size + padT];
38 | rawPtrVec.push_back(ptr);
39 | T *alignedPtr = (T *)((((uintptr_t)(ptr + padT)) >> b) << b);
40 | return alignedPtr;
41 | }
42 |
43 | class ScaleOptimizer {
44 | public:
45 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
46 |
47 | ScaleOptimizer(int w, int h, const std::vector &tfm_cam1_cam0,
48 | const Mat33f &K1);
49 | ~ScaleOptimizer();
50 |
51 | void makeK(CalibHessian *HCalib);
52 |
53 | float optimizeScale(FrameHessian *fh1, float &scale, int coarsestLvl);
54 |
55 | protected:
56 | std::vector ptrToDelete;
57 |
58 | float *idepth[PYR_LEVELS];
59 | float *weight_sums[PYR_LEVELS];
60 | float *weight_sums_bak[PYR_LEVELS];
61 |
62 | Mat33f Ki[PYR_LEVELS];
63 | float fx[PYR_LEVELS];
64 | float fy[PYR_LEVELS];
65 | float cx[PYR_LEVELS];
66 | float cy[PYR_LEVELS];
67 | int w[PYR_LEVELS];
68 | int h[PYR_LEVELS];
69 |
70 | // pc buffers
71 | float *pc_u[PYR_LEVELS];
72 | float *pc_v[PYR_LEVELS];
73 | float *pc_idepth[PYR_LEVELS];
74 | float *pc_color[PYR_LEVELS];
75 | int pc_n[PYR_LEVELS];
76 |
77 | /**************************Scale Optimization***************************/
78 | void calcGSSSEScale(int lvl, float &H_out, float &b_out, float scale);
79 | Vec6 calcResScale(int lvl, float scale, float cutoffTH,
80 | bool plot_img = false);
81 |
82 | // Transformation from frame0 to frame1
83 | SE3 tfmF0ToF1;
84 |
85 | // cam1 params
86 | float fx1[PYR_LEVELS];
87 | float fy1[PYR_LEVELS];
88 | float cx1[PYR_LEVELS];
89 | float cy1[PYR_LEVELS];
90 |
91 | // warped buffers
92 | float *scaleBufWarped_rx1;
93 | float *scaleBufWarped_rx2;
94 | float *scaleBufWarped_rx3;
95 | float *scaleBufWarped_dx;
96 | float *scaleBufWarped_dy;
97 | float *scaleBufWarped_residual;
98 | float *scaleBufWarped_weight;
99 | float *scaleBufWarped_ref_color;
100 | int scaleBufWarped_n;
101 |
102 | FrameHessian *fhStereo;
103 | ScaleAccumulator scaleAcc;
104 | };
105 |
106 | } // namespace dso
107 |
--------------------------------------------------------------------------------
/src/IOWrapper/ImageDisplay.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 | #include "util/MinimalImage.h"
26 | #include "util/NumType.h"
27 | #include
28 |
29 | namespace dso {
30 |
31 | namespace IOWrap {
32 |
33 | void displayImage(const char *windowName, const MinimalImageB *img,
34 | bool autoSize = false);
35 | void displayImage(const char *windowName, const MinimalImageB3 *img,
36 | bool autoSize = false);
37 | void displayImage(const char *windowName, const MinimalImageF *img,
38 | bool autoSize = false);
39 | void displayImage(const char *windowName, const MinimalImageF3 *img,
40 | bool autoSize = false);
41 | void displayImage(const char *windowName, const MinimalImageB16 *img,
42 | bool autoSize = false);
43 |
44 | void displayImageStitch(const char *windowName,
45 | const std::vector images, int cc = 0,
46 | int rc = 0);
47 | void displayImageStitch(const char *windowName,
48 | const std::vector images, int cc = 0,
49 | int rc = 0);
50 | void displayImageStitch(const char *windowName,
51 | const std::vector images, int cc = 0,
52 | int rc = 0);
53 | void displayImageStitch(const char *windowName,
54 | const std::vector images, int cc = 0,
55 | int rc = 0);
56 |
57 | int waitKey(int milliseconds);
58 | void closeAllWindows();
59 |
60 | } // namespace IOWrap
61 |
62 | } // namespace dso
63 |
--------------------------------------------------------------------------------
/src/IOWrapper/ImageDisplay_dummy.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #include "IOWrapper/ImageDisplay.h"
25 |
26 | namespace dso {
27 |
28 | namespace IOWrap {
29 | void displayImage(const char *windowName, const MinimalImageB *img,
30 | bool autoSize){};
31 | void displayImage(const char *windowName, const MinimalImageB3 *img,
32 | bool autoSize){};
33 | void displayImage(const char *windowName, const MinimalImageF *img,
34 | bool autoSize){};
35 | void displayImage(const char *windowName, const MinimalImageF3 *img,
36 | bool autoSize){};
37 | void displayImage(const char *windowName, const MinimalImageB16 *img,
38 | bool autoSize){};
39 |
40 | void displayImageStitch(const char *windowName,
41 | const std::vector images, int cc,
42 | int rc){};
43 | void displayImageStitch(const char *windowName,
44 | const std::vector images, int cc,
45 | int rc){};
46 | void displayImageStitch(const char *windowName,
47 | const std::vector images, int cc,
48 | int rc){};
49 | void displayImageStitch(const char *windowName,
50 | const std::vector images, int cc,
51 | int rc){};
52 |
53 | int waitKey(int milliseconds) { return 0; };
54 | void closeAllWindows(){};
55 | } // namespace IOWrap
56 |
57 | } // namespace dso
58 |
--------------------------------------------------------------------------------
/src/IOWrapper/ImageRW.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 | #include "util/MinimalImage.h"
26 | #include "util/NumType.h"
27 |
28 | namespace dso {
29 | namespace IOWrap {
30 |
31 | MinimalImageB *readImageBW_8U(std::string filename);
32 | MinimalImageB3 *readImageRGB_8U(std::string filename);
33 | MinimalImage *readImageBW_16U(std::string filename);
34 |
35 | MinimalImageB *readStreamBW_8U(char *data, int numBytes);
36 |
37 | void writeImage(std::string filename, MinimalImageB *img);
38 | void writeImage(std::string filename, MinimalImageB3 *img);
39 | void writeImage(std::string filename, MinimalImageF *img);
40 | void writeImage(std::string filename, MinimalImageF3 *img);
41 |
42 | } // namespace IOWrap
43 | } // namespace dso
44 |
--------------------------------------------------------------------------------
/src/IOWrapper/ImageRW_dummy.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #include "IOWrapper/ImageRW.h"
25 |
26 | namespace dso {
27 |
28 | namespace IOWrap {
29 |
30 | MinimalImageB *readImageBW_8U(std::string filename) {
31 | printf("not implemented. bye!\n");
32 | return 0;
33 | };
34 | MinimalImageB3 *readImageRGB_8U(std::string filename) {
35 | printf("not implemented. bye!\n");
36 | return 0;
37 | };
38 | MinimalImage *readImageBW_16U(std::string filename) {
39 | printf("not implemented. bye!\n");
40 | return 0;
41 | };
42 | MinimalImageB *readStreamBW_8U(char *data, int numBytes) {
43 | printf("not implemented. bye!\n");
44 | return 0;
45 | };
46 | void writeImage(std::string filename, MinimalImageB *img){};
47 | void writeImage(std::string filename, MinimalImageB3 *img){};
48 | void writeImage(std::string filename, MinimalImageF *img){};
49 | void writeImage(std::string filename, MinimalImageF3 *img){};
50 |
51 | } // namespace IOWrap
52 |
53 | } // namespace dso
54 |
--------------------------------------------------------------------------------
/src/IOWrapper/Pangolin/KeyFrameDisplay.h:
--------------------------------------------------------------------------------
1 | // Copyright (C) <2022>
2 |
3 | // This program is free software: you can redistribute it and/or modify
4 | // it under the terms of the GNU General Public License as published by
5 | // the Free Software Foundation, either version 3 of the License, or
6 | // (at your option) any later version.
7 |
8 | // This program is distributed in the hope that it will be useful,
9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | // GNU General Public License for more details.
12 |
13 | // You should have received a copy of the GNU General Public License
14 | // along with this program. If not, see .
15 |
16 | // This file is modified from
17 |
18 | #pragma once
19 |
20 | #undef Success
21 | #include "util/NumType.h"
22 | #include
23 | #include
24 |
25 | #include
26 | #include
27 |
28 | namespace dso {
29 | class CalibHessian;
30 | class FrameHessian;
31 | class FrameShell;
32 |
33 | namespace IOWrap {
34 |
35 | template struct InputPointSparse {
36 | float u;
37 | float v;
38 | float idepth;
39 | float idepth_hessian;
40 | float relObsBaseline;
41 | int numGoodRes;
42 | unsigned char color[ppp];
43 | unsigned char status;
44 | };
45 |
46 | struct MyVertex {
47 | float point[3];
48 | unsigned char color[4];
49 | };
50 |
51 | // stores a pointcloud associated to a Keyframe.
52 | class KeyFrameDisplay {
53 |
54 | public:
55 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
56 | KeyFrameDisplay();
57 | ~KeyFrameDisplay();
58 |
59 | // copies points from KF over to internal buffer,
60 | // keeping some additional information so we can render it differently.
61 | void setFromKF(FrameHessian *fh, CalibHessian *HCalib);
62 |
63 | // copies & filters internal data to GL buffer for rendering. if nothing to
64 | // do: does nothing.
65 | void refreshPC();
66 |
67 | // renders cam & pointcloud.
68 | void drawCam(float lineWidth = 1, float *color = 0, float sizeFactor = 1);
69 | void drawPC(float pointSize);
70 |
71 | int id;
72 | bool active;
73 | SE3 tfmCToW;
74 | bool needRefresh;
75 |
76 | inline bool operator<(const KeyFrameDisplay &other) const {
77 | return (id < other.id);
78 | }
79 |
80 | private:
81 | float fx, fy, cx, cy;
82 | float fxi, fyi, cxi, cyi;
83 | int width, height;
84 |
85 | float myScaledTh, myAbsTh, myScale;
86 | int mySparsifyFactor;
87 | int myDisplayMode;
88 | float myMinRelBs;
89 |
90 | int numSparsePoints;
91 | int numSparseBufferSize;
92 | InputPointSparse *originalInputSparse;
93 |
94 | bool bufferValid;
95 | int numGlBufferPoints;
96 | int numGlBufferGoodPoints;
97 | pangolin::GlBuffer vertexBuffer;
98 | pangolin::GlBuffer colorBuffer;
99 | };
100 |
101 | } // namespace IOWrap
102 | } // namespace dso
103 |
--------------------------------------------------------------------------------
/src/IOWrapper/Pangolin/PangolinSOSVIOViewer.h:
--------------------------------------------------------------------------------
1 | // Copyright (C) <2022>
2 |
3 | // This program is free software: you can redistribute it and/or modify
4 | // it under the terms of the GNU General Public License as published by
5 | // the Free Software Foundation, either version 3 of the License, or
6 | // (at your option) any later version.
7 |
8 | // This program is distributed in the hope that it will be useful,
9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | // GNU General Public License for more details.
12 |
13 | // You should have received a copy of the GNU General Public License
14 | // along with this program. If not, see .
15 |
16 | // This file is modified from
17 |
18 | #pragma once
19 | #include "IOWrapper/Output3DWrapper.h"
20 | #include "boost/thread.hpp"
21 | #include "util/MinimalImage.h"
22 | #include
23 | #include