├── CHANGELOG
├── CMakeLists.txt
├── LICENSE
├── README.md
├── cmake
├── FindEigen3.cmake
├── FindLibZip.cmake
└── FindSuiteParse.cmake
├── doc
├── final_trajectory.png
└── run_outdoor.gif
├── output
└── pose.txt
├── sensor
├── ijrr
│ ├── x_b_lb3.txt
│ ├── x_lb3_c1.csv
│ ├── x_lb3_c2.csv
│ ├── x_lb3_c3.csv
│ ├── x_lb3_c4.csv
│ └── x_lb3_c5.csv
└── nclt
│ ├── x_lb3_c1.csv
│ ├── x_lb3_c2.csv
│ ├── x_lb3_c3.csv
│ ├── x_lb3_c4.csv
│ └── x_lb3_c5.csv
├── src
├── FullSystem
│ ├── CoarseInitializer.cpp
│ ├── CoarseInitializer.h
│ ├── CoarseTracker.cpp
│ ├── CoarseTracker.h
│ ├── CoarseTracker_xiang.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
├── IOWrapper
│ ├── ImageDisplay.h
│ ├── ImageDisplay_dummy.cpp
│ ├── ImageRW.h
│ ├── ImageRW_dummy.cpp
│ ├── OpenCV
│ │ ├── ImageDisplay_OpenCV.cpp
│ │ └── ImageRW_OpenCV.cpp
│ ├── Output3DWrapper.h
│ ├── OutputWrapper
│ │ └── SampleOutputWrapper.h
│ └── Pangolin
│ │ ├── KeyFrameDisplay.cpp
│ │ ├── KeyFrameDisplay.h
│ │ ├── PangolinDSOViewer.cpp
│ │ └── PangolinDSOViewer.h
├── OptimizationBackend
│ ├── AccumulatedSCHessian.cpp
│ ├── AccumulatedSCHessian.h
│ ├── AccumulatedTopHessian.cpp
│ ├── AccumulatedTopHessian.h
│ ├── EnergyFunctional.cpp
│ ├── EnergyFunctional.h
│ ├── EnergyFunctionalStructs.cpp
│ ├── EnergyFunctionalStructs.h
│ ├── MatrixAccumulators.h
│ └── RawResidualJacobian.h
├── main_dso_pangolin.cpp
└── util
│ ├── DatasetReader.h
│ ├── FrameShell.h
│ ├── ImageAndExposure.h
│ ├── IndexThreadReduce.h
│ ├── MinimalImage.h
│ ├── NumType.h
│ ├── Undistort.cpp
│ ├── Undistort.h
│ ├── globalCalib.cpp
│ ├── globalCalib.h
│ ├── globalFuncs.h
│ ├── lsd.cpp
│ ├── lsd.h
│ ├── nanoflann.h
│ ├── settings.cpp
│ └── settings.h
└── 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
└── libzip-1.1.1.tar.gz
/CHANGELOG:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ========= 16.11.2016 ==========
5 | * Added Sample output wrapper IOWrapper/OutputWrapper/SampleOutputWrapper.h.
6 | * Added extensive comments to IOWrapper/Output3DWrapper.h.
7 | * Added support for multiple 3DOutputWrapper simulataneously.
8 | * Added options "quiet=1" and "sampleoutput=1".
9 | * Did some minor code cleaning.
10 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(dso)
3 |
4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -O3")
5 |
6 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
7 |
8 | find_package(SuiteParse REQUIRED)
9 | find_package(Eigen3 REQUIRED)
10 | find_package(Boost COMPONENTS system thread)
11 | find_package(OpenMP REQUIRED)
12 |
13 | find_package(LibZip QUIET)
14 | find_package(Pangolin 0.2 QUIET)
15 | find_package(OpenCV REQUIRED)
16 | find_package(PCL REQUIRED QUIET)
17 |
18 | # flags
19 | add_definitions("-DENABLE_SSE")
20 | #set(CMAKE_CXX_FLAGS
21 | # "${SSE_FLAGS} -O3 -g -std=c++0x -march=native"
22 | # "${SSE_FLAGS} -O3 -g -std=c++0x -fno-omit-frame-pointer"
23 | #)
24 |
25 | if (MSVC)
26 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
27 | endif (MSVC)
28 |
29 | set(dso_SOURCE_FILES
30 | ${PROJECT_SOURCE_DIR}/src/FullSystem/FullSystem.cpp
31 | ${PROJECT_SOURCE_DIR}/src/FullSystem/FullSystemOptimize.cpp
32 | ${PROJECT_SOURCE_DIR}/src/FullSystem/FullSystemOptPoint.cpp
33 | ${PROJECT_SOURCE_DIR}/src/FullSystem/FullSystemDebugStuff.cpp
34 | ${PROJECT_SOURCE_DIR}/src/FullSystem/FullSystemMarginalize.cpp
35 | ${PROJECT_SOURCE_DIR}/src/FullSystem/Residuals.cpp
36 | ${PROJECT_SOURCE_DIR}/src/FullSystem/CoarseTracker.cpp
37 | ${PROJECT_SOURCE_DIR}/src/FullSystem/CoarseInitializer.cpp
38 | ${PROJECT_SOURCE_DIR}/src/FullSystem/ImmaturePoint.cpp
39 | ${PROJECT_SOURCE_DIR}/src/FullSystem/HessianBlocks.cpp
40 | ${PROJECT_SOURCE_DIR}/src/FullSystem/PixelSelector2.cpp
41 | ${PROJECT_SOURCE_DIR}/src/OptimizationBackend/EnergyFunctional.cpp
42 | ${PROJECT_SOURCE_DIR}/src/OptimizationBackend/AccumulatedTopHessian.cpp
43 | ${PROJECT_SOURCE_DIR}/src/OptimizationBackend/AccumulatedSCHessian.cpp
44 | ${PROJECT_SOURCE_DIR}/src/OptimizationBackend/EnergyFunctionalStructs.cpp
45 | ${PROJECT_SOURCE_DIR}/src/util/settings.cpp
46 | ${PROJECT_SOURCE_DIR}/src/util/Undistort.cpp
47 | ${PROJECT_SOURCE_DIR}/src/util/globalCalib.cpp
48 | ${PROJECT_SOURCE_DIR}/src/util/lsd.cpp
49 | )
50 |
51 |
52 | include_directories(
53 | ${catkin_INCLUDE_DIRS}
54 | ${PROJECT_SOURCE_DIR}/src
55 | ${PROJECT_SOURCE_DIR}/thirdparty/Sophus
56 | ${PROJECT_SOURCE_DIR}/thirdparty/sse2neon
57 | ${EIGEN3_INCLUDE_DIR}
58 | ${PCL_INCLUDE_DIRS}
59 | )
60 |
61 | if(OPENMP_FOUND)
62 | message("OPENMP FOUND")
63 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
64 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
65 | endif()
66 |
67 | if (Pangolin_FOUND)
68 | message("--- found PANGOLIN, compiling dso_pangolin library.")
69 | include_directories( ${catkin_INCLUDE_DIRS} ${Pangolin_INCLUDE_DIRS} )
70 | set(dso_pangolin_SOURCE_FILES
71 | ${PROJECT_SOURCE_DIR}/src/IOWrapper/Pangolin/KeyFrameDisplay.cpp
72 | ${PROJECT_SOURCE_DIR}/src/IOWrapper/Pangolin/PangolinDSOViewer.cpp)
73 | set(HAS_PANGOLIN 1)
74 | else ()
75 | message("--- could not find PANGOLIN, not compiling dso_pangolin library.")
76 | message(" this means there will be no 3D display / GUI available for dso_dataset.")
77 | set(dso_pangolin_SOURCE_FILES )
78 | set(HAS_PANGOLIN 0)
79 | endif ()
80 |
81 | if (OpenCV_FOUND)
82 | message("--- found OpenCV, compiling dso_opencv library.")
83 | message("--- OpenCV_VERSION: ${OpenCV_VERSION}")
84 | message("--- OpenCV_INCLUDE_PATH: ${OpenCV_INCLUDE_DIRS}")
85 | message("--- OpenCV_LIB_PATH: ${OpenCV_LIBRARIES}")
86 | include_directories( ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} )
87 | set(dso_opencv_SOURCE_FILES
88 | ${PROJECT_SOURCE_DIR}/src/IOWrapper/OpenCV/ImageDisplay_OpenCV.cpp
89 | ${PROJECT_SOURCE_DIR}/src/IOWrapper/OpenCV/ImageRW_OpenCV.cpp)
90 | set(HAS_OPENCV 1)
91 | else ()
92 | message("--- could not find OpenCV, not compiling dso_opencv library.")
93 | message(" this means there will be no image display, and image read / load functionality.")
94 | set(dso_opencv_SOURCE_FILES
95 | ${PROJECT_SOURCE_DIR}/src/IOWrapper/ImageDisplay_dummy.cpp
96 | ${PROJECT_SOURCE_DIR}/src/IOWrapper/ImageRW_dummy.cpp)
97 | set(HAS_OPENCV 0)
98 | endif ()
99 |
100 | if (LIBZIP_LIBRARY)
101 | message("--- found ziplib (${LIBZIP_VERSION}), compiling with zip capability.")
102 | add_definitions(-DHAS_ZIPLIB=1)
103 | include_directories( ${catkin_INCLUDE_DIRS} ${LIBZIP_INCLUDE_DIR_ZIP} ${LIBZIP_INCLUDE_DIR_ZIPCONF} )
104 | else()
105 | message("--- not found ziplib (${LIBZIP_LIBRARY}), compiling without zip capability.")
106 | set(LIBZIP_LIBRARY "")
107 | endif()
108 |
109 | # compile main library.
110 | include_directories( ${catkin_INCLUDE_DIRS} ${CSPARSE_INCLUDE_DIR} ${CHOLMOD_INCLUDE_DIR})
111 | add_library(dso ${dso_SOURCE_FILES} ${dso_opencv_SOURCE_FILES} ${dso_pangolin_SOURCE_FILES})
112 | target_link_libraries(dso ${OpenCV_LIBRARIES} ${PCL_LIBRARIES})
113 |
114 | #set_property( TARGET dso APPEND_STRING PROPERTY COMPILE_FLAGS -Wall )
115 |
116 |
117 | if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") # OSX
118 | set(BOOST_THREAD_LIBRARY boost_thread-mt)
119 | else()
120 | set(BOOST_THREAD_LIBRARY boost_thread)
121 | endif()
122 |
123 | # build main executable (only if we have both OpenCV and Pangolin)
124 | if (OpenCV_FOUND AND Pangolin_FOUND)
125 | message("--- compiling dso_dataset.")
126 | add_executable(dso_dataset ${PROJECT_SOURCE_DIR}/src/main_dso_pangolin.cpp )
127 | target_link_libraries(dso_dataset dso boost_system cxsparse ${catkin_LIBRARIES} ${BOOST_THREAD_LIBRARY} ${LIBZIP_LIBRARY} ${Pangolin_LIBRARIES} ${OpenCV_LIBRARIES} ${PCL_LIBRARIES})
128 | else()
129 | message("--- not building dso_dataset, since either don't have openCV or Pangolin.")
130 | endif()
131 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Panoramic-LDSO
2 |
3 | **Panoramic-LDSO** (Panoramic Direct LiDAR-assisted Visual Odometry) is designed for fully associating the 360-degree field-of-view (FOV) LiDAR points with the 360-degree FOV panoramic image datas. 360-degree FOV panoramic images can provide more available information, which can compensate inaccurate pose estimation caused by insufficient texture or motion blur from a single view.
4 |
5 | ## Related Work
6 |
7 | [Panoramic Direct LiDAR-assisted Visual Odometry](https://arxiv.org/abs/2409.09287)
8 |
9 | Authors: [*Zikang Yuan*](https://scholar.google.com/citations?hl=zh-CN&user=acxdM9gAAAAJ), *Tianle Xu*, *Xiaoxiang Wang*, *Jinni Geng* and [*Xin Yang*](https://scholar.google.com/citations?user=lsz8OOYAAAAJ&hl=zh-CN)
10 |
11 | ## Demo Video (2024-09-14 Update)
12 |
13 | The **x16 Real-Time Performance (Up)** and **Final Trjaectory and Sparse Map (Down)** on the segment of sequence *2012-01-08* from [*NCLT*](http://robots.engin.umich.edu/nclt/) dataset.
14 |
15 |
16 |

17 |

18 |
19 |
20 | ## Installation
21 |
22 | ### 1. Requirements
23 |
24 | > GCC >= 7.5.0
25 | >
26 | > Cmake >= 3.16.0
27 | >
28 | > [Eigen3](http://eigen.tuxfamily.org/index.php?title=Main_Page) >= 3.3.4
29 | >
30 | > [OpenCV](https://github.com/opencv/opencv) >= 3.3
31 | >
32 | > [PCL](https://pointclouds.org/downloads/) == 1.8 for Ubuntu 18.04, and == 1.10 for Ubuntu 20.04
33 | >
34 | > [Pangolin](https://github.com/stevenlovegrove/Pangolin) == 0.5 or 0.6 for Ubuntu 20.04
35 |
36 | ##### Have Tested On:
37 |
38 | | OS | GCC | Cmake | Eigen3 | OpenCV | PCL | Pangolin |
39 | |:-:|:-:|:-:|:-:|:-:|:-:|:-:|
40 | | Ubuntu 20.04 | 9.4.0 | 3.16.3 | 3.3.7 | 4.2.0 | 1.10.0 | 0.5 |
41 |
42 | ### 2. Clone the directory and build
43 |
44 | ```bash
45 | git clone https://github.com/ZikangYuan/panoramic_lidar_dso.git
46 | mkdir build
47 | cd build
48 | cmake ..
49 | make
50 | ```
51 |
52 | ## Run on Public Datasets
53 |
54 | Noted:
55 |
56 | 1. Before running, please down load the **calib** folder from **[Google drive](https://drive.google.com/drive/folders/1WnvzUzP_s70p4myPf5fsP1Jtr_62PnL1)**, and put it under the .
57 |
58 | 2. Currently the package only supports interfaces to *NCLT* and *IJRR* datasets. If you want to run on other datasets, you'll need to modify the code yourself.
59 |
60 | ### 1. Run on [*NCLT*](http://robots.engin.umich.edu/nclt/)
61 |
62 | Before running, please ensure the dataset format is as follow:
63 |
64 | ```bash
65 |
66 | |____________2012-01-08
67 | |____________lb3
68 | |____________velodyne_sync
69 | |____________2012-09-28
70 | |____________lb3
71 | |____________velodyne_sync
72 | |____________2012-11-04
73 | |____________lb3
74 | |____________velodyne_sync
75 | |____________2012-12-01
76 | |____________lb3
77 | |____________velodyne_sync
78 | |____________2013-02-23
79 | |____________lb3
80 | |____________velodyne_sync
81 | |____________2013-04-05
82 | |____________lb3
83 | |____________velodyne_sync
84 | ```
85 |
86 | Then open the terminal in the path of the /build, and type:
87 |
88 | ```bash
89 | ./dso_dataset dataset= sequence= seg= calib=/calib/nclt/calib undistort=/calib/nclt/U2D_Cam pathSensorPrameter/sensor/nclt/x_lb3_c resultPath=/output/pose.txt mode=1 quiet=0 IJRR=0
90 | ```
91 |
92 | ### 2. Run on [*IJRR*](https://robots.engin.umich.edu/SoftwareData/InfoFord)
93 |
94 | Before running, please ensure the dataset format is as follow:
95 |
96 | ```bash
97 |
98 | |____________ford_1
99 | |____________Timestamp.log
100 | |____________IMAGES
101 | |____________pcd
102 | |____________ford_2
103 | |____________Timestamp.log
104 | |____________IMAGES
105 | |____________pcd
106 | ```
107 |
108 | Then open the terminal in the path of the /build, and type:
109 |
110 | ```bash
111 | ./dso_dataset dataset= sequence= seg= calib=/calib/ijrr/calib undistort=/calib/ijrr/U2D_Cam pathSensorPrameter=/sensor/ijrr/x_lb3_c resultPath=/output/pose.txt mode=1 quiet=0 IJRR=1
112 | ```
113 |
114 | ## Citation
115 |
116 | If you use our work in your research project, please consider citing:
117 |
118 | ```
119 | @article{yuan2024panoramic,
120 | title={Panoramic Direct LiDAR-assisted Visual Odometry},
121 | author={Yuan, Zikang and Xu, Tianle and Wang, Xiaoxiang and Geng, Jinni and Yang, Xin},
122 | journal={arXiv preprint arXiv:2409.09287},
123 | year={2024}
124 | }
125 | ```
126 |
127 | ## Acknowledgments
128 |
129 | Thanks for [DSO](https://github.com/JakobEngel/dso).
130 |
--------------------------------------------------------------------------------
/cmake/FindEigen3.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find Eigen3 lib
2 | #
3 | # This module supports requiring a minimum version, e.g. you can do
4 | # find_package(Eigen3 3.1.2)
5 | # to require version 3.1.2 or newer of Eigen3.
6 | #
7 | # Once done this will define
8 | #
9 | # EIGEN3_FOUND - system has eigen lib with correct version
10 | # EIGEN3_INCLUDE_DIR - the eigen include directory
11 | # EIGEN3_VERSION - eigen version
12 |
13 | # Copyright (c) 2006, 2007 Montel Laurent,
14 | # Copyright (c) 2008, 2009 Gael Guennebaud,
15 | # Copyright (c) 2009 Benoit Jacob
16 | # Redistribution and use is allowed according to the terms of the 2-clause BSD license.
17 |
18 | if(NOT Eigen3_FIND_VERSION)
19 | if(NOT Eigen3_FIND_VERSION_MAJOR)
20 | set(Eigen3_FIND_VERSION_MAJOR 2)
21 | endif(NOT Eigen3_FIND_VERSION_MAJOR)
22 | if(NOT Eigen3_FIND_VERSION_MINOR)
23 | set(Eigen3_FIND_VERSION_MINOR 91)
24 | endif(NOT Eigen3_FIND_VERSION_MINOR)
25 | if(NOT Eigen3_FIND_VERSION_PATCH)
26 | set(Eigen3_FIND_VERSION_PATCH 0)
27 | endif(NOT Eigen3_FIND_VERSION_PATCH)
28 |
29 | set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
30 | endif(NOT Eigen3_FIND_VERSION)
31 |
32 | macro(_eigen3_check_version)
33 | file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
34 |
35 | string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
36 | set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
37 | string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
38 | set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
39 | string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
40 | set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")
41 |
42 | set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION})
43 | if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
44 | set(EIGEN3_VERSION_OK FALSE)
45 | else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
46 | set(EIGEN3_VERSION_OK TRUE)
47 | endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
48 |
49 | if(NOT EIGEN3_VERSION_OK)
50 |
51 | message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, "
52 | "but at least version ${Eigen3_FIND_VERSION} is required")
53 | endif(NOT EIGEN3_VERSION_OK)
54 | endmacro(_eigen3_check_version)
55 |
56 | if (EIGEN3_INCLUDE_DIR)
57 |
58 | # in cache already
59 | _eigen3_check_version()
60 | set(EIGEN3_FOUND ${EIGEN3_VERSION_OK})
61 |
62 | else (EIGEN3_INCLUDE_DIR)
63 |
64 | find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
65 | PATHS
66 | ${CMAKE_INSTALL_PREFIX}/include
67 | ${KDE4_INCLUDE_DIR}
68 | PATH_SUFFIXES eigen3 eigen
69 | )
70 |
71 | if(EIGEN3_INCLUDE_DIR)
72 | _eigen3_check_version()
73 | endif(EIGEN3_INCLUDE_DIR)
74 |
75 | include(FindPackageHandleStandardArgs)
76 | find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK)
77 |
78 | mark_as_advanced(EIGEN3_INCLUDE_DIR)
79 |
80 | endif(EIGEN3_INCLUDE_DIR)
81 |
82 |
--------------------------------------------------------------------------------
/cmake/FindLibZip.cmake:
--------------------------------------------------------------------------------
1 | # Finds libzip.
2 | #
3 | # This module defines:
4 | # LIBZIP_INCLUDE_DIR_ZIP
5 | # LIBZIP_INCLUDE_DIR_ZIPCONF
6 | # LIBZIP_LIBRARY
7 | #
8 |
9 | find_package(PkgConfig)
10 | pkg_check_modules(PC_LIBZIP QUIET libzip)
11 |
12 | find_path(LIBZIP_INCLUDE_DIR_ZIP
13 | NAMES zip.h
14 | HINTS ${PC_LIBZIP_INCLUDE_DIRS})
15 |
16 | find_path(LIBZIP_INCLUDE_DIR_ZIPCONF
17 | NAMES zipconf.h
18 | HINTS ${PC_LIBZIP_INCLUDE_DIRS})
19 |
20 | find_library(LIBZIP_LIBRARY
21 | NAMES zip)
22 |
23 | include(FindPackageHandleStandardArgs)
24 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(
25 | LIBZIP DEFAULT_MSG
26 | LIBZIP_LIBRARY LIBZIP_INCLUDE_DIR_ZIP LIBZIP_INCLUDE_DIR_ZIPCONF)
27 |
28 | set(LIBZIP_VERSION 0)
29 |
30 | if (LIBZIP_INCLUDE_DIR_ZIPCONF)
31 | FILE(READ "${LIBZIP_INCLUDE_DIR_ZIPCONF}/zipconf.h" _LIBZIP_VERSION_CONTENTS)
32 | if (_LIBZIP_VERSION_CONTENTS)
33 | STRING(REGEX REPLACE ".*#define LIBZIP_VERSION \"([0-9.]+)\".*" "\\1" LIBZIP_VERSION "${_LIBZIP_VERSION_CONTENTS}")
34 | endif ()
35 | endif ()
36 |
37 | set(LIBZIP_VERSION ${LIBZIP_VERSION} CACHE STRING "Version number of libzip")
38 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/doc/final_trajectory.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZikangYuan/panoramic_lidar_dso/67da5dfc5d35e8c42a7a7b431137feb211cfa7ee/doc/final_trajectory.png
--------------------------------------------------------------------------------
/doc/run_outdoor.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZikangYuan/panoramic_lidar_dso/67da5dfc5d35e8c42a7a7b431137feb211cfa7ee/doc/run_outdoor.gif
--------------------------------------------------------------------------------
/output/pose.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZikangYuan/panoramic_lidar_dso/67da5dfc5d35e8c42a7a7b431137feb211cfa7ee/output/pose.txt
--------------------------------------------------------------------------------
/sensor/ijrr/x_b_lb3.txt:
--------------------------------------------------------------------------------
1 | 0.34 -0.01 -0.42 0.7056 -0.0001 -0.0003 -0.7086
--------------------------------------------------------------------------------
/sensor/ijrr/x_lb3_c1.csv:
--------------------------------------------------------------------------------
1 | -0.0010 -0.0038 -1.0000 0.4150
2 | -1.0000 -0.0019 0.0010 0.0129
3 | -0.0019 1.0000 -0.0038 0.2998
4 |
--------------------------------------------------------------------------------
/sensor/ijrr/x_lb3_c2.csv:
--------------------------------------------------------------------------------
1 | 0.0026 0.0031 -1.0000 0.4173
2 | -0.3100 0.9507 0.0022 0.3282
3 | 0.9507 0.3100 0.0034 0.0508
4 |
--------------------------------------------------------------------------------
/sensor/ijrr/x_lb3_c3.csv:
--------------------------------------------------------------------------------
1 | 0.0017 -0.0032 -1.0000 0.4154
2 | 0.8056 0.5924 -5.4270e-04 0.1935
3 | 0.5924 -0.8056 0.0035 -0.3247
4 |
--------------------------------------------------------------------------------
/sensor/ijrr/x_lb3_c4.csv:
--------------------------------------------------------------------------------
1 | 0.0070 0.0035 -1.0000 0.4177
2 | 0.8108 -0.5853 0.0036 -0.2092
3 | -0.5852 -0.8108 -0.0069 -0.3080
4 |
5 |
--------------------------------------------------------------------------------
/sensor/ijrr/x_lb3_c5.csv:
--------------------------------------------------------------------------------
1 | 0.0079 0.0013 -1.0000 0.4171
2 | -0.3048 -0.9524 -0.0037 -0.3173
3 | -0.9524 0.3048 -0.0071 0.0764
4 |
--------------------------------------------------------------------------------
/sensor/nclt/x_lb3_c1.csv:
--------------------------------------------------------------------------------
1 | 0.014543, 0.039337, 0.000398, -138.449751, 89.703877, -66.518051
2 |
--------------------------------------------------------------------------------
/sensor/nclt/x_lb3_c2.csv:
--------------------------------------------------------------------------------
1 | -0.032674, 0.025928, 0.000176, 160.101024, 89.836345, -56.101163
2 |
--------------------------------------------------------------------------------
/sensor/nclt/x_lb3_c3.csv:
--------------------------------------------------------------------------------
1 | -0.034969, -0.022993, 0.000030, 95.603967, 89.724274, -48.640335
2 |
--------------------------------------------------------------------------------
/sensor/nclt/x_lb3_c4.csv:
--------------------------------------------------------------------------------
1 | 0.011238, -0.040367, -0.000393, -160.239278, 89.812338, 127.472911
2 |
--------------------------------------------------------------------------------
/sensor/nclt/x_lb3_c5.csv:
--------------------------------------------------------------------------------
1 | 0.041862, -0.001905, -0.000212, 160.868615, 89.914152, 160.619894
2 |
--------------------------------------------------------------------------------
/src/FullSystem/CoarseInitializer.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 |
25 | #pragma once
26 |
27 | #include "util/NumType.h"
28 | #include "OptimizationBackend/MatrixAccumulators.h"
29 | #include "IOWrapper/Output3DWrapper.h"
30 | #include "util/settings.h"
31 | #include "vector"
32 | #include
33 |
34 |
35 |
36 |
37 | namespace dso
38 | {
39 | struct CalibHessian;
40 | struct FrameHessian;
41 | struct frame_hessian;
42 | class FullSystem;
43 |
44 |
45 | struct Pnt
46 | {
47 | public:
48 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
49 | // index in jacobian. never changes (actually, there is no reason why).
50 | float u,v;
51 |
52 | // idepth / isgood / energy during optimization.
53 | float idepth; //!< 该点对应参考帧的逆深度
54 | bool isGood; //!< 点在新图像内, 相机前, 像素值有穷则好
55 | Vec2f energy; //!< [0]残差的平方, [1]正则化项(逆深度减一的平方) // (UenergyPhotometric, energyRegularizer)
56 | bool isGood_new;
57 | float idepth_new; //!< 该点在新的一帧(当前帧)上的逆深度
58 | Vec2f energy_new; //!< 迭代计算的新的能量
59 |
60 | float iR; //!< 逆深度的期望值
61 | float iRSumNum; //!< 子点逆深度信息矩阵之和
62 |
63 | float lastHessian; //!< 逆深度的Hessian, 即协方差, dd*dd
64 | float lastHessian_new; //!< 新一次迭代的协方差
65 |
66 | // max stepsize for idepth (corresponding to max. movement in pixel-space).
67 | float maxstep; //!< 逆深度增加的最大步长
68 |
69 | // idx (x+y*w) of closest point one pyramid level above.
70 | int parent; //!< 上一层中该点的父节点 (距离最近的)的id
71 | float parentDist; //!< 上一层中与父节点的距离
72 |
73 | // idx (x+y*w) of up to 10 nearest points in pixel space.
74 | int neighbours[10]; //!< 图像中离该点最近的10个点
75 | float neighboursDist[10]; //!< 最近10个点的距离
76 |
77 | float my_type; //!< 第0层提取是1, 2, 4, 对应d, 2d, 4d, 其它层是1
78 | float outlierTH; //!< 外点阈值
79 |
80 | // 2019.11.07 yzk
81 | float mdepth;
82 | float midepth;
83 | bool isFromSensor;
84 | // 2019.11.07 yzk
85 | };
86 |
87 | class CoarseInitializer {
88 | public:
89 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
90 | CoarseInitializer(int w, int h);
91 | ~CoarseInitializer();
92 |
93 | // 2019.11.15 yzk
94 | void setFirstFromLidar(CalibHessian* HCalib, FrameHessian* newFrameHessian, FullSystem* fullSystem,
95 | std::vector> cloudPixel[CAM_NUM]);
96 | // 2019.11.15 yzk
97 | void calcTGrads(FrameHessian* newFrameHessian);
98 |
99 | int frameID; //!< 当前加入的帧数
100 | bool fixAffine; //!< 是否优化光度参数
101 | bool printDebug;
102 |
103 | /*
104 | Pnt* points[PYR_LEVELS]; //!< 每一层上的点类, 是第一帧提取出来的
105 | int numPoints[PYR_LEVELS]; //!< 每一层的点数目
106 | */
107 | Pnt* points[CAM_NUM][PYR_LEVELS]; //!< 每一层上的点类, 是第一帧提取出来的
108 | int numPoints[CAM_NUM][PYR_LEVELS]; //!< 每一层的点数目
109 |
110 | AffLight thisToNext_aff; //!< 参考帧与当前帧之间光度系数
111 | SE3 thisToNext; //!< 参考帧与当前帧之间位姿
112 |
113 |
114 | FrameHessian* firstFrame; //!< 第一帧
115 | FrameHessian* newFrame; //!< track中新加入的帧
116 | private:
117 | /*
118 | Mat33 K[PYR_LEVELS]; //!< camera参数
119 | Mat33 Ki[PYR_LEVELS];
120 | double fx[PYR_LEVELS];
121 | double fy[PYR_LEVELS];
122 | double fxi[PYR_LEVELS];
123 | double fyi[PYR_LEVELS];
124 | double cx[PYR_LEVELS];
125 | double cy[PYR_LEVELS];
126 | double cxi[PYR_LEVELS];
127 | double cyi[PYR_LEVELS];
128 | */
129 | Mat33 K[CAM_NUM][PYR_LEVELS]; //!< camera参数
130 | Mat33 Ki[CAM_NUM][PYR_LEVELS];
131 | double fx[CAM_NUM][PYR_LEVELS];
132 | double fy[CAM_NUM][PYR_LEVELS];
133 | double fxi[CAM_NUM][PYR_LEVELS];
134 | double fyi[CAM_NUM][PYR_LEVELS];
135 | double cx[CAM_NUM][PYR_LEVELS];
136 | double cy[CAM_NUM][PYR_LEVELS];
137 | double cxi[CAM_NUM][PYR_LEVELS];
138 | double cyi[CAM_NUM][PYR_LEVELS];
139 |
140 | int w[PYR_LEVELS];
141 | int h[PYR_LEVELS];
142 | void makeK(CalibHessian* HCalib);
143 |
144 | bool snapped; //!< 是否尺度收敛 (暂定)
145 | int snappedAt; //!< 尺度收敛在第几帧
146 |
147 | // pyramid images & levels on all levels
148 | Eigen::Vector3f* dINew[PYR_LEVELS];
149 | Eigen::Vector3f* dIFist[PYR_LEVELS];
150 |
151 | Eigen::DiagonalMatrix wM;
152 |
153 | // temporary buffers for H and b.
154 | Vec10f* JbBuffer; //!< 用来计算Schur的 0-7: sum(dd * dp). 8: sum(res*dd). 9: 1/(1+sum(dd*dd))=inverse hessian entry.
155 | Vec10f* JbBuffer_new; //!< 跌待更新后新的值
156 |
157 | //* 9维向量, 乘积获得9*9矩阵, 并做的累加器
158 | Accumulator9 acc9; //!< Hessian 矩阵
159 | Accumulator9 acc9SC; //!< Schur部分Hessian
160 |
161 |
162 | Vec3f dGrads[PYR_LEVELS]; //!<
163 |
164 | //? 这几个参数很迷
165 | float alphaK; //!< 2.5*2.5
166 | float alphaW; //!< 150*150
167 | float regWeight; //!< 对逆深度的加权值, 0.8
168 | float couplingWeight; //!< 1
169 |
170 | Vec3f calcEC(int lvl); // returns OLD NERGY, NEW ENERGY, NUM TERMS.
171 | void optReg(int lvl);
172 |
173 | void propagateUp(int srcLvl);
174 | void propagateDown(int srcLvl);
175 | float rescale();
176 |
177 | void resetPoints(int lvl);
178 | void doStep(int lvl, float lambda, Vec8f inc);
179 | void applyStep(int lvl);
180 |
181 | void makeGradients(Eigen::Vector3f** data);
182 |
183 | void debugPlot(int lvl, std::vector &wraps);
184 | // 2021.11.14
185 | void makeNN(int cam_idx);
186 | // 2021.11.14
187 | };
188 |
189 |
190 |
191 | //* 作为 KDTreeSingleIndexAdaptor 类的第二个模板参数必须给出, 包括下面的接口
192 | struct FLANNPointcloud
193 | {
194 | inline FLANNPointcloud() {num=0; points=0;}
195 | inline FLANNPointcloud(int n, Pnt* p) : num(n), points(p) {}
196 |
197 | int num;
198 | Pnt* points;
199 |
200 | // 返回数据点的数目
201 | inline size_t kdtree_get_point_count() const { return num; }
202 | // 使用L2度量时使用, 返回向量p1, 到第idx_p2个数据点的欧氏距离
203 | inline float kdtree_distance(const float *p1, const size_t idx_p2,size_t /*size*/) const
204 | {
205 | const float d0=p1[0]-points[idx_p2].u;
206 | const float d1=p1[1]-points[idx_p2].v;
207 | return d0*d0+d1*d1;
208 | }
209 | // 返回第idx个点的第dim维数据
210 | inline float kdtree_get_pt(const size_t idx, int dim) const
211 | {
212 | if (dim==0) return points[idx].u;
213 | else return points[idx].v;
214 | }
215 | // 可选计算bounding box
216 | // false 表示默认
217 | // true 本函数应该返回bb
218 | template
219 | bool kdtree_get_bbox(BBOX& /* bb */) const { return false; }
220 | };
221 |
222 | }
223 |
224 |
225 |
--------------------------------------------------------------------------------
/src/FullSystem/CoarseTracker.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 |
25 | #pragma once
26 |
27 |
28 | #include "util/NumType.h"
29 | #include "vector"
30 | #include
31 | #include "util/settings.h"
32 | #include "OptimizationBackend/MatrixAccumulators.h"
33 | #include "IOWrapper/Output3DWrapper.h"
34 | #include
35 | #include "util/lsd.h"
36 | #include
37 | #include
38 | #include
39 |
40 |
41 |
42 |
43 | namespace dso
44 | {
45 | struct CalibHessian;
46 | struct FrameHessian;
47 | struct PointFrameResidual;
48 |
49 | class CoarseTracker {
50 | public:
51 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
52 |
53 | CoarseTracker(int w, int h);
54 | ~CoarseTracker();
55 |
56 | bool trackNewestCoarse(
57 | FrameHessian* newFrameHessian,
58 | SE3 &lastToNew_out, int coarsestLvl,
59 | Vec5 minResForAbort, SE3 slastToLast, int tries,
60 | IOWrap::Output3DWrapper* wrap=0);
61 |
62 | bool trackNewestCoarse_inv(
63 | FrameHessian* newFrameHessian,
64 | SE3 &lastToNew_out, int coarsestLvl,
65 | Vec5 minResForAbort,
66 | IOWrap::Output3DWrapper* wrap=0);
67 | int nThreads;
68 | std::vector m_RandEngines; // Mersenne twister high quality RNG that support *OpenMP* multi-threading
69 | bool trackNewestCoarse_ransac(
70 | FrameHessian* newFrameHessian,
71 | SE3 &lastToNew_out, int coarsestLvl,
72 | Vec5 minResForAbort, SE3 slastToLast,
73 | IOWrap::Output3DWrapper* wrap=0);
74 |
75 | bool TrackNewestToSelectCam(
76 | SE3 &lastToNew_out, int coarsestLvl,
77 | Vec5 minResForAbort, Vec6& lastRes, bool first = false);
78 | void recurrent(
79 | int num,int numUse,
80 | SE3 &lastToNew_out, int coarsestLvl,
81 | Vec5 &minResForAbort);
82 |
83 | void setCoarseTrackingRef(
84 | std::vector frameHessians,
85 | std::vector idxUse);
86 |
87 | // 2019.11.15 yzk
88 | void makeCoarseDepthForFirstFrame(FrameHessian* fh);
89 | void setCTRefForFirstFrame(std::vector frameHessians);
90 | // 2019.11.15 yzk
91 |
92 | void makeK(CalibHessian* HCalib);
93 |
94 | bool debugPrint, debugPlot;
95 |
96 |
97 | Mat33f K[CAM_NUM][PYR_LEVELS];
98 | Mat33f Ki[CAM_NUM][PYR_LEVELS];
99 | float fx[CAM_NUM][PYR_LEVELS];
100 | float fy[CAM_NUM][PYR_LEVELS];
101 | float fxi[CAM_NUM][PYR_LEVELS];
102 | float fyi[CAM_NUM][PYR_LEVELS];
103 | float cx[CAM_NUM][PYR_LEVELS];
104 | float cy[CAM_NUM][PYR_LEVELS];
105 | float cxi[CAM_NUM][PYR_LEVELS];
106 | float cyi[CAM_NUM][PYR_LEVELS];
107 |
108 |
109 | int w[PYR_LEVELS];
110 | int h[PYR_LEVELS];
111 |
112 | std::vector idxUse;
113 | bool weight[CAM_NUM];
114 |
115 | void debugPlotIDepthMap(float* minID, float* maxID, std::vector &wraps);
116 | void debugPlotIDepthMapFloat(std::vector &wraps);
117 |
118 | FrameHessian* lastRef; //!< 参考帧
119 | // AffLight lastRef_aff_g2l;
120 | AffLight lastRef_aff_g2l[CAM_NUM];
121 | FrameHessian* newFrame; //!< 新来的一帧
122 | int refFrameID; //!< 参考帧id
123 |
124 | bool hasChanged;
125 |
126 | // act as pure ouptut
127 | Vec6 lastResiduals;
128 | Vec3 lastFlowIndicators; //!< 光流指示用, 只有平移和, 旋转+平移的像素移动
129 | double firstCoarseRMSE;
130 | private:
131 |
132 |
133 | void makeCoarseDepthL0(std::vector frameHessians);
134 |
135 | float* idepth[CAM_NUM][PYR_LEVELS];
136 | float* weightSums[PYR_LEVELS];
137 | float* weightSums_bak[PYR_LEVELS];
138 |
139 |
140 | Vec6 calcResAndGS(int lvl, Mat88 &H_out, Vec8 &b_out, const SE3 &refToNew, AffLight aff_g2l, float cutoffTH);
141 | float onlyCalcRes(const SE3 &refToNew, float cutoffTH);
142 | Vec6 calcRes(int lvl, const SE3 &refToNew, SE3 slastToLast, float cutoffTH);
143 | Vec6 calcRes_ransac(int lvl, const SE3 &refToNew, SE3 slastToLast, float cutoffTH, std::vector& idx_to_reproject);
144 | Vec6 calcRes_cross(int lvl, const SE3 &refToNew, SE3 slastToLast, float cutoffTH, std::queue idx[][CAM_NUM]);
145 | void preCompute(int lvl);
146 | Vec6 calcResInv(int lvl, const SE3 &refToNew, float cutoffTH, std::queue& resInliers, Mat66f &H, Vec6f &J_res);
147 | Vec3 calcExtrinRes(
148 | std::vector>& cld,
149 | const SE3 &T_lb3_lidar, float cutoffTH, Mat66f& H, Vec6f& J_res, int itr);
150 | Vec3 calcExtrinRes(
151 | std::vector>& cld,
152 | const SE3 &T_lb3_lidar, float cutoffTH);
153 | void calcGSSSE(int lvl, Mat66 &H_out, Vec6 &b_out, SE3 lastToNew, SE3 slastToLast);
154 | void calcGSSSE_inv(int lvl, Mat66f &H_out, Vec6f &b_out, std::queue& idx);
155 | void calcGSSSE_MutualPSimple(int lvl, Mat66 &H_out, Vec6 &b_out, SE3 lastToNew, SE3 slastToLast);
156 | void calcGS(int lvl, Mat88 &H_out, Vec8 &b_out, const SE3 &refToNew, AffLight aff_g2l);
157 |
158 | // pc buffers
159 | float* pc_u[CAM_NUM][PYR_LEVELS]; //!< 每层上的有逆深度点的坐标x
160 | float* pc_v[CAM_NUM][PYR_LEVELS]; //!< 每层上的有逆深度点的坐标y
161 | float* pc_idepth[CAM_NUM][PYR_LEVELS]; //!< 每层上点的逆深度
162 | float* pc_color[CAM_NUM][PYR_LEVELS]; //!< 每层上点的颜色值
163 | float* pc_Idu[CAM_NUM][PYR_LEVELS]; //!< 每层上点的颜色值在u方向上的梯度
164 | float* pc_Idv[CAM_NUM][PYR_LEVELS]; //!< 每层上点的颜色值在v方向上的梯度
165 | int pc_n[CAM_NUM][PYR_LEVELS]; //!< 每层上点的个数
166 |
167 |
168 | // warped buffers
169 | // float* buf_warped_X; //!< 投影得到的点在主相机坐标系下的X
170 | // float* buf_warped_Y; //!< 投影得到的点在主相机坐标系下的Y
171 | // float* buf_warped_Z; //!< 投影得到的点在主相机坐标系下的Z
172 | // float* buf_warped_idepth; //!< 投影得到的点的逆深度
173 | // float* buf_warped_u; //!< 投影得到的归一化坐标
174 | // float* buf_warped_v; //!< 同上
175 | // float* buf_warped_dx; //!< 投影点的图像梯度
176 | // float* buf_warped_dy; //!< 同上
177 | // float* buf_warped_residual; //!< 投影得到的残差
178 | // float* buf_warped_weight; //!< 投影的huber函数权重
179 | float* buf_warped_Xs[12]; //!< 投影得到的点在主相机坐标系下的X
180 | float* buf_warped_Ys[12]; //!< 投影得到的点在主相机坐标系下的Y
181 | float* buf_warped_Zs[12]; //!< 投影得到的点在主相机坐标系下的Z
182 | float* buf_warped_idepths[12]; //!< 投影得到的点的逆深度
183 | float* buf_warped_us[12]; //!< 投影得到的归一化坐标
184 | float* buf_warped_vs[12]; //!< 同上
185 | float* buf_warped_dxs[12]; //!< 投影点的图像梯度
186 | float* buf_warped_dys[12]; //!< 同上
187 | float* buf_warped_residuals[12]; //!< 投影得到的残差
188 | float* buf_warped_weights[12]; //!< 投影的huber函数权重
189 | int buf_warpeds[12][CAM_NUM*CAM_NUM];
190 | int buf_warped_n; //!< 投影点的个数
191 | Vec6f* buf_dI_dT[PYR_LEVELS];
192 | Mat66f* buf_H[PYR_LEVELS];
193 | float* buf_res[PYR_LEVELS];
194 | float* buf_hw[PYR_LEVELS];
195 |
196 |
197 | std::vector ptrToDelete; //!< 所有的申请的内存指针, 用于析构删除
198 |
199 | Accumulator acc;
200 | Accumulator7 acc7;
201 | };
202 |
203 |
204 | class CoarseDistanceMap {
205 | public:
206 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
207 |
208 | CoarseDistanceMap(int w, int h);
209 | ~CoarseDistanceMap();
210 |
211 | void makeDistanceMap(
212 | std::vector frameHessians,
213 | FrameHessian* frame, int cam_idx);
214 |
215 | void makeInlierVotes(
216 | std::vector frameHessians);
217 |
218 | void makeK( CalibHessian* HCalib, int cam_idx);
219 |
220 |
221 | float* fwdWarpedIDDistFinal; //!< 距离场的数值
222 |
223 | Mat33f K[PYR_LEVELS];
224 | Mat33f Ki[PYR_LEVELS];
225 | float fx[PYR_LEVELS];
226 | float fy[PYR_LEVELS];
227 | float fxi[PYR_LEVELS];
228 | float fyi[PYR_LEVELS];
229 | float cx[PYR_LEVELS];
230 | float cy[PYR_LEVELS];
231 | float cxi[PYR_LEVELS];
232 | float cyi[PYR_LEVELS];
233 | int w[PYR_LEVELS];
234 | int h[PYR_LEVELS];
235 |
236 | void addIntoDistFinal(int u, int v);
237 |
238 |
239 | private:
240 |
241 | PointFrameResidual** coarseProjectionGrid;
242 | int* coarseProjectionGridNum;
243 | Eigen::Vector2i* bfsList1; //!< 投影到frame的坐标
244 | Eigen::Vector2i* bfsList2; //!< 和1轮换使用
245 |
246 | void growDistBFS(int bfsNum);
247 | };
248 |
249 | }
250 |
251 |
--------------------------------------------------------------------------------
/src/FullSystem/CoarseTracker_xiang.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 |
25 | #pragma once
26 |
27 |
28 | #include "util/NumType.h"
29 | #include "vector"
30 | #include
31 | #include "util/settings.h"
32 | #include "OptimizationBackend/MatrixAccumulators.h"
33 | #include "IOWrapper/Output3DWrapper.h"
34 | #include
35 | #include "util/lsd.h"
36 | #include
37 |
38 |
39 |
40 |
41 | namespace dso
42 | {
43 | struct CalibHessian;
44 | struct FrameHessian;
45 | struct PointFrameResidual;
46 |
47 | class CoarseTracker {
48 | public:
49 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
50 |
51 | CoarseTracker(int w, int h);
52 | ~CoarseTracker();
53 |
54 | bool trackNewestCoarse(
55 | FrameHessian* newFrameHessian,
56 | SE3 &lastToNew_out, int coarsestLvl,
57 | Vec5 minResForAbort, SE3 slastToLast, int tries,
58 | IOWrap::Output3DWrapper* wrap=0);
59 |
60 | bool TrackNewestToSelectCam(
61 | SE3 &lastToNew_out, int coarsestLvl,
62 | Vec5 minResForAbort, Vec6& lastRes, bool first = false);
63 | void recurrent(
64 | int num,int numUse,
65 | SE3 &lastToNew_out, int coarsestLvl,
66 | Vec5 &minResForAbort);
67 |
68 | void setCoarseTrackingRef(
69 | std::vector frameHessians,
70 | std::vector idxUse);
71 |
72 | // 2019.11.15 yzk
73 | void makeCoarseDepthForFirstFrame(FrameHessian* fh);
74 | void setCTRefForFirstFrame(std::vector frameHessians);
75 | // 2019.11.15 yzk
76 |
77 | void makeK(CalibHessian* HCalib);
78 |
79 | bool debugPrint, debugPlot;
80 |
81 |
82 | Mat33f K[CAM_NUM][PYR_LEVELS];
83 | Mat33f Ki[CAM_NUM][PYR_LEVELS];
84 | float fx[CAM_NUM][PYR_LEVELS];
85 | float fy[CAM_NUM][PYR_LEVELS];
86 | float fxi[CAM_NUM][PYR_LEVELS];
87 | float fyi[CAM_NUM][PYR_LEVELS];
88 | float cx[CAM_NUM][PYR_LEVELS];
89 | float cy[CAM_NUM][PYR_LEVELS];
90 | float cxi[CAM_NUM][PYR_LEVELS];
91 | float cyi[CAM_NUM][PYR_LEVELS];
92 |
93 |
94 | int w[PYR_LEVELS];
95 | int h[PYR_LEVELS];
96 |
97 | std::vector idxUse;
98 | bool weight[CAM_NUM];
99 |
100 | void debugPlotIDepthMap(float* minID, float* maxID, std::vector &wraps);
101 | void debugPlotIDepthMapFloat(std::vector &wraps);
102 |
103 | FrameHessian* lastRef; //!< 参考帧
104 | // AffLight lastRef_aff_g2l;
105 | AffLight lastRef_aff_g2l[CAM_NUM];
106 | FrameHessian* newFrame; //!< 新来的一帧
107 | int refFrameID; //!< 参考帧id
108 |
109 | bool hasChanged;
110 |
111 | // act as pure ouptut
112 | Vec6 lastResiduals;
113 | Vec3 lastFlowIndicators; //!< 光流指示用, 只有平移和, 旋转+平移的像素移动
114 | double firstCoarseRMSE;
115 | private:
116 |
117 |
118 | void makeCoarseDepthL0(std::vector frameHessians);
119 |
120 | float* idepth[CAM_NUM][PYR_LEVELS];
121 | float* weightSums[PYR_LEVELS];
122 | float* weightSums_bak[PYR_LEVELS];
123 |
124 |
125 | Vec6 calcResAndGS(int lvl, Mat88 &H_out, Vec8 &b_out, const SE3 &refToNew, AffLight aff_g2l, float cutoffTH);
126 | void choose_point(int lvl,std::vector>& point_choose,std::vector>& index);
127 | Vec6 calcRes(int lvl, const SE3 &refToNew, const SE3 refToNews[], SE3 slastToLast, float cutoffTH);
128 | Vec6 calcRes_ransac(int lvl, const SE3 &refToNew, const SE3 refToNews[], SE3 slastToLast, float cutoffTH,std::vector> point_choose);
129 | void cal_InitPoint(int lvl, const SE3 &refToNew, const SE3 refToNews[],std::vector>& index);
130 | int cal_InPoint(const SE3 &refToNew, const SE3 refToNews[],int coarsestLvl);
131 | Vec6 calcResAndInpointnum(int lvl, const SE3 &refToNew, const SE3 refToNews[], SE3 slastToLast, float cutoffTH,int& In_num);
132 | void preCompute(int lvl);
133 | Vec6 calcResInv(int lvl, const SE3 &refToNew, float cutoffTH, Mat66f& H, Vec6f& res);
134 | void ProjectForVisualization(
135 | std::vector>& cld,
136 | SE3 T_lb3_lidar, float res, bool before);
137 | bool getCloseViewObs(const float& x, const float& y, const float& id, const SE3 refToNews[], int idx_ori, int lvl, int& min_idx);
138 | Vec3 calcExtrinRes(
139 | std::vector>& cld,
140 | const SE3 &T_lb3_lidar, float cutoffTH, Mat66f& H, Vec6f& J_res, int itr);
141 | Vec3 calcExtrinRes(
142 | std::vector>& cld,
143 | const SE3 &T_lb3_lidar, float cutoffTH);
144 | void calcGSSSE(int lvl, Mat66 &H_out, Vec6 &b_out, SE3 lastToNew, SE3 slastToLast);
145 | void calcGSSSE_MutualPSimple(int lvl, Mat66 &H_out, Vec6 &b_out, SE3 lastToNew, SE3 slastToLast);
146 | void calcGS(int lvl, Mat88 &H_out, Vec8 &b_out, const SE3 &refToNew, AffLight aff_g2l);
147 |
148 | // pc buffers
149 | float* pc_u[CAM_NUM][PYR_LEVELS]; //!< 每层上的有逆深度点的坐标x
150 | float* pc_v[CAM_NUM][PYR_LEVELS]; //!< 每层上的有逆深度点的坐标y
151 | float* pc_idepth[CAM_NUM][PYR_LEVELS]; //!< 每层上点的逆深度
152 | float* pc_color[CAM_NUM][PYR_LEVELS]; //!< 每层上点的颜色值
153 | float* pc_Idu[CAM_NUM][PYR_LEVELS]; //!< 每层上点的颜色值在u方向上的梯度
154 | float* pc_Idv[CAM_NUM][PYR_LEVELS]; //!< 每层上点的颜色值在v方向上的梯度
155 | int pc_n[CAM_NUM][PYR_LEVELS]; //!< 每层上点的个数
156 |
157 |
158 | // warped buffers
159 | float* buf_warped_X; //!< 投影得到的点在主相机坐标系下的X
160 | float* buf_warped_Y; //!< 投影得到的点在主相机坐标系下的Y
161 | float* buf_warped_Z; //!< 投影得到的点在主相机坐标系下的Z
162 | float* buf_warped_idepth; //!< 投影得到的点的逆深度
163 | float* buf_warped_u; //!< 投影得到的归一化坐标
164 | float* buf_warped_v; //!< 同上
165 | float* buf_warped_dx; //!< 投影点的图像梯度
166 | float* buf_warped_dy; //!< 同上
167 | float* buf_warped_residual; //!< 投影得到的残差
168 | float* buf_warped_weight; //!< 投影的huber函数权重
169 | float* buf_warped_refColor; //!< 投影点参考帧上的灰度值
170 | int buf_warped_n; //!< 投影点的个数
171 | int buf_warped[CAM_NUM*CAM_NUM];
172 | Vec6f* buf_dI_dT[PYR_LEVELS];
173 | Mat66f* buf_H[PYR_LEVELS];
174 |
175 |
176 | std::vector ptrToDelete; //!< 所有的申请的内存指针, 用于析构删除
177 |
178 | Accumulator acc;
179 | Accumulator7 acc7;
180 | };
181 |
182 |
183 | class CoarseDistanceMap {
184 | public:
185 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
186 |
187 | CoarseDistanceMap(int w, int h);
188 | ~CoarseDistanceMap();
189 |
190 | void makeDistanceMap(
191 | std::vector frameHessians,
192 | FrameHessian* frame, int cam_idx);
193 |
194 | void makeInlierVotes(
195 | std::vector frameHessians);
196 |
197 | void makeK( CalibHessian* HCalib, int cam_idx);
198 |
199 |
200 | float* fwdWarpedIDDistFinal; //!< 距离场的数值
201 |
202 | Mat33f K[PYR_LEVELS];
203 | Mat33f Ki[PYR_LEVELS];
204 | float fx[PYR_LEVELS];
205 | float fy[PYR_LEVELS];
206 | float fxi[PYR_LEVELS];
207 | float fyi[PYR_LEVELS];
208 | float cx[PYR_LEVELS];
209 | float cy[PYR_LEVELS];
210 | float cxi[PYR_LEVELS];
211 | float cyi[PYR_LEVELS];
212 | int w[PYR_LEVELS];
213 | int h[PYR_LEVELS];
214 |
215 | void addIntoDistFinal(int u, int v);
216 |
217 |
218 | private:
219 |
220 | PointFrameResidual** coarseProjectionGrid;
221 | int* coarseProjectionGridNum;
222 | Eigen::Vector2i* bfsList1; //!< 投影到frame的坐标
223 | Eigen::Vector2i* bfsList2; //!< 和1轮换使用
224 |
225 | void growDistBFS(int bfsNum);
226 | };
227 |
228 | }
229 |
230 |
--------------------------------------------------------------------------------
/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 |
25 | #pragma once
26 |
27 |
28 | #include "util/NumType.h"
29 |
30 | #include "FullSystem/HessianBlocks.h"
31 | namespace dso
32 | {
33 |
34 | // ImmaturePoint的状态, 残差和目标帧
35 | struct ImmaturePointTemporaryResidual
36 | {
37 | public:
38 | ResState state_state; //!< 逆深度残差的状态
39 | double state_energy; //!< 残差值
40 | ResState state_NewState; //!< 新计算的逆深度残差的状态
41 | double state_NewEnergy; //!< 新计算的残差值
42 | frame_hessian* target;
43 | };
44 |
45 |
46 | enum ImmaturePointStatus {
47 | IPS_GOOD=0, // traced well and good
48 | // 搜索区间超出图像, 尺度变化太大, 两次残差都大于阈值, 不再搜索
49 | IPS_OOB, // OOB: end tracking & marginalize!
50 | // 第一次残差大于阈值, 外点
51 | IPS_OUTLIER, // energy too high: if happens again: outlier!
52 | // 搜索区间太短,但是没激活
53 | IPS_SKIPPED, // traced well and good (but not actually traced).
54 | // 梯度和极线夹角太大
55 | IPS_BADCONDITION, // not traced because of bad condition.
56 | IPS_UNINITIALIZED}; // not even traced once.
57 |
58 |
59 | class ImmaturePoint
60 | {
61 | public:
62 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
63 | // static values
64 | float color[MAX_RES_PER_POINT]; //!< 原图上pattern上对应的像素值
65 | float weights[MAX_RES_PER_POINT]; //!< 原图上pattern对应的权重(与梯度成反比)
66 |
67 | // 2019.12.04 yzk
68 | float idepth_fromSensor;
69 | // 2019.12.04 yzk
70 |
71 | static const int halfpatch_size_ = 4;
72 | static const int patch_size_ = 8;
73 |
74 | Mat22f gradH; //!< 图像梯度hessian矩阵
75 | Vec2f gradH_ev;
76 | Mat22f gradH_eig;
77 | float energyTH;
78 | float u,v; //!< host里的像素坐标
79 | frame_hessian* host; // 2022.1.11
80 | int idxInImmaturePoints;
81 |
82 | float quality; //!< 第二误差/第一误差 作为搜索质量, 越大越好
83 |
84 | float my_type;
85 |
86 | float idepth_min; //!< 逆深度范围
87 | float idepth_max;
88 |
89 | // 2019.12.02 yzk
90 | bool isFromSensor;
91 | // 2019.12.02 yzk
92 |
93 | ImmaturePoint(int u_, int v_, frame_hessian* host_, float type, CalibHessian* HCalib);
94 | ~ImmaturePoint();
95 |
96 | ImmaturePointStatus traceOn(frame_hessian* frame, const Mat33f &hostToFrame_KRKi, const Vec3f &hostToFrame_Kt, const Vec2f &hostToFrame_affine, CalibHessian* HCalib, bool debugPrint=false);
97 |
98 | ImmaturePointStatus lastTraceStatus; //!< 上一次跟踪状态
99 | Vec2f lastTraceUV; //!< 上一次搜索得到的位置
100 | float lastTracePixelInterval; //!< 上一次的搜索范围长度
101 |
102 | float idepth_GT;
103 |
104 | double linearizeResidual(
105 | CalibHessian * HCalib, const float outlierTHSlack,
106 | ImmaturePointTemporaryResidual* tmpRes,
107 | float &Hdd, float &bd,
108 | float idepth);
109 | void resetPosition(float u_, float v_);
110 | double linearizeResPixel(
111 | CalibHessian * HCalib, const float outlierTHSlack,
112 | ImmaturePointTemporaryResidual* tmpRes,
113 | cv::Mat &Hdd, cv::Mat &bd, int level_ref,
114 | float idepth);
115 | double calcResPixel(
116 | CalibHessian * HCalib, const float outlierTHSlack,
117 | ImmaturePointTemporaryResidual* tmpRes,
118 | float idepth, float res);
119 | double ResPixel(
120 | const float outlierTHSlack,
121 | FrameHessian* target, float u, float v,
122 | cv::Mat &Hdd, cv::Mat &bd, int level,
123 | float mean_diff, float idepth);
124 | void getWarpMatrixAffine(
125 | const double idepth,
126 | const Mat33f &KRKi, const Vec3f &Kt,
127 | Mat22f& A_cur_ref);
128 | int getBestSearchLevel(
129 | const Mat22f& A_cur_ref,
130 | const int max_level);
131 | float getdPixdd(
132 | CalibHessian * HCalib,
133 | ImmaturePointTemporaryResidual* tmpRes,
134 | float idepth);
135 |
136 | float calcResidual(
137 | CalibHessian * HCalib, const float outlierTHSlack,
138 | ImmaturePointTemporaryResidual* tmpRes,
139 | float idepth);
140 |
141 | private:
142 | };
143 | }
144 |
145 |
--------------------------------------------------------------------------------
/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 |
25 | #pragma once
26 |
27 | #include "util/NumType.h"
28 | // 2020.07.02 yzk
29 | #include
30 | #include "FullSystem/HessianBlocks.h"
31 | // 2020.07.02 yzk
32 |
33 | namespace dso
34 | {
35 |
36 | enum PixelSelectorStatus {PIXSEL_VOID=0, PIXSEL_1, PIXSEL_2, PIXSEL_3};
37 |
38 |
39 | class FrameHessian;
40 | // 2022.1.10
41 | class frame_hessian;
42 | //
43 |
44 | class PixelSelector
45 | {
46 | public:
47 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
48 | // 2020.07.02
49 | int makeMaps(
50 | const frame_hessian* const fh,
51 | float* map_out, float density, int recursionsLeft=1, bool plot=false, float thFactor=1);
52 | // 2020.07.02
53 |
54 | int makeMapsFromLidar(const frame_hessian* const fh, float* map_out, float density, int recursionsLeft,
55 | bool plot, float thFactor, std::vector> &vCloudPixel, int id=0);
56 | Eigen::Matrix simpleMakeMapsFromLidar(const FrameHessian* const Fh, float* map_out, float density, int recursionsLeft,
57 | bool plot, std::vector> vCloudPixel[CAM_NUM], int id=0);
58 |
59 | PixelSelector(int w, int h);
60 | ~PixelSelector();
61 | int currentPotential; //!< 当前选择像素点的潜力, 就是网格大小, 越大选点越少
62 |
63 | float currentTH;
64 |
65 | bool allowFast;
66 | void makeHists(const frame_hessian* const fh);
67 |
68 | private:
69 | Eigen::Vector3i selectFromLidar(const frame_hessian* const fh, float* map_out, int pot, float thFactor,
70 | std::vector> &vCloudPixel, int idx=0);
71 | Eigen::Matrix simpleSelectFromLidar(const FrameHessian* const fh, float* map_out, float numWant,
72 | std::vector> vCloudPixel[CAM_NUM], int _idx=0);
73 |
74 |
75 | Eigen::Vector3i select(const frame_hessian* const fh,
76 | float* map_out, int pot, float thFactor=1);
77 |
78 |
79 | unsigned char* randomPattern;
80 |
81 |
82 | int* gradHist; //!< 根号梯度平方和分布直方图, 0是所有像素个数
83 | float* ths; //!< 平滑之前的阈值
84 | float* thsSmoothed; //!< 平滑后的阈值
85 | int thsStep;
86 | const frame_hessian* gradHistFrame;
87 | };
88 |
89 |
90 |
91 |
92 | }
93 |
94 |
--------------------------------------------------------------------------------
/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 |
25 | #pragma once
26 |
27 | #include "util/NumType.h"
28 | #include "FullSystem/FullSystem.h"
29 | #include "FullSystem/HessianBlocks.h"
30 | #include "util/settings.h"
31 |
32 | namespace dso
33 | {
34 |
35 | //@ 返回逆深度的导数值
36 | EIGEN_STRONG_INLINE float derive_idepth(
37 | const Vec3f &t, const float &u, const float &v,
38 | const int &dx, const int &dy, const float &dxInterp,
39 | const float &dyInterp, const float &drescale)
40 | {
41 | return (dxInterp*drescale * (t[0]-t[2]*u)
42 | + dyInterp*drescale * (t[1]-t[2]*v))*SCALE_IDEPTH;
43 | }
44 |
45 | //@ 返回u,v的导数值
46 | EIGEN_STRONG_INLINE Vec2f derive_uv(
47 | const Mat33f &R, const float &u, const float &v,
48 | const float &fx, const float &fy,
49 | const float &Ix, const float &Iy,
50 | const float &Ix1, const float &Iy1,
51 | const float &drescale)
52 | {
53 | return Vec2f(drescale* (Ix*(R(0,0)-R(2,0)*u) + Iy*fy/fx*(R(1,0)-R(2,0)*v)) - Ix1,
54 | drescale* (Ix*fx/fy*(R(0,1)-R(2,1)*u) + Iy*(R(1,1)-v*R(2,1))) - Iy1);
55 | }
56 |
57 | //@ 把host上的点变换到target上
58 | EIGEN_STRONG_INLINE bool projectPoint(
59 | const float &u_pt,const float &v_pt,
60 | const float &idepth,
61 | const Mat33f &KRKi, const Vec3f &Kt,
62 | float &Ku, float &Kv, int cam_idx)
63 | {
64 | Vec3f ptp = KRKi * Vec3f(u_pt,v_pt, 1) + Kt*idepth; // host上点除深度
65 | Ku = ptp[0] / ptp[2];
66 | Kv = ptp[1] / ptp[2];
67 | // 2021.12.28
68 | return Ku>1.1f && Kv>1.1f && Kucxl(cam_idx_i))*HCalib->fxli(cam_idx_i),
89 | (v_pt+dy-HCalib->cyl(cam_idx_i))*HCalib->fyli(cam_idx_i),
90 | 1);
91 |
92 | Vec3f ptp = R * KliP + t*idepth;
93 | drescale = 1.0f/ptp[2]; // target帧逆深度 比 host帧逆深度
94 | new_idepth = idepth*drescale; // 新的帧上逆深度
95 |
96 | if(!(drescale>0)) return false;
97 |
98 | // 归一化平面
99 | u = ptp[0] * drescale;
100 | v = ptp[1] * drescale;
101 | // 像素平面
102 | Ku = u*HCalib->fxl(cam_idx_j) + HCalib->cxl(cam_idx_j);
103 | Kv = v*HCalib->fyl(cam_idx_j) + HCalib->cyl(cam_idx_j);
104 |
105 | // 2021.11.25
106 | return Ku>1.1f && Kv>1.1f && Ku0)) return false;
134 |
135 | // 归一化平面
136 | u = ptp[0] * drescale;
137 | v = ptp[1] * drescale;
138 | // 像素平面
139 | Ku = u*fxG[cam_idx][lvl] + cxG[cam_idx][lvl];
140 | Kv = v*fyG[cam_idx][lvl] + cyG[cam_idx][lvl];
141 |
142 | // 2021.11.25
143 | return Ku>1.1f && Kv>1.1f && Ku<(wG[lvl]-2) && Kv<(hG[lvl]-2) && maskG[cam_idx][lvl][(int)Ku+(int)Kv*wG[lvl]];
144 | // 2021.11.25
145 | }
146 |
147 | EIGEN_STRONG_INLINE bool projectPoint(
148 | const Eigen::Vector3f pt, int lvl,
149 | Vec3f &pt_lb3,
150 | CalibHessian* const &HCalib,
151 | const Mat33f &R_lb3l, const Vec3f &t_lb3l,
152 | const Mat33f &R_cl, const Vec3f &t_cl,
153 | const Mat33f &R, const Vec3f &t,
154 | float &u_src, float &v_src,
155 | float &u, float &v,
156 | float &Ku_src, float &Kv_src,
157 | float &Ku, float &Kv,
158 | float &idepth, float &new_idepth,
159 | int cam_idx)// 2021.11.18
160 | {
161 | pt_lb3 = R_lb3l * pt + t_lb3l;
162 | Vec3f p_c = R_cl * pt + t_cl;
163 | // host上归一化平面点
164 | u_src = p_c[0]/p_c[2];
165 | v_src = p_c[1]/p_c[2];
166 | idepth = 1/p_c[2];
167 |
168 | // 像素平面
169 | Ku_src = u_src*fxG[cam_idx][lvl] + cxG[cam_idx][lvl];
170 | Kv_src = v_src*fyG[cam_idx][lvl] + cyG[cam_idx][lvl];
171 |
172 | if(!(Ku_src>1.1f && Kv_src>1.1f && Ku_src0)) return false;
183 |
184 | // 像素平面
185 | Ku = u*fxG[cam_idx][lvl] + cxG[cam_idx][lvl];
186 | Kv = v*fyG[cam_idx][lvl] + cyG[cam_idx][lvl];
187 |
188 | return Ku>1.1f && Kv>1.1f && Ku,
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 |
25 | #pragma once
26 |
27 |
28 | #include "util/globalCalib.h"
29 | #include "vector"
30 |
31 | #include "util/NumType.h"
32 | #include
33 | #include
34 | #include "util/globalFuncs.h"
35 | #include "OptimizationBackend/RawResidualJacobian.h"
36 |
37 | namespace dso
38 | {
39 | class PointHessian;
40 | class frame_hessian;
41 | class CalibHessian;
42 |
43 | class EFResidual;
44 |
45 | enum ResLocation {ACTIVE=0, LINEARIZED, MARGINALIZED, NONE};
46 | enum ResState {IN=0, OOB, OUTLIER}; // IN在内部, OOB 点超出图像, OUTLIER有外点
47 |
48 | struct FullJacRowT
49 | {
50 | Eigen::Vector2f projectedTo[MAX_RES_PER_POINT];
51 | };
52 |
53 | class PointFrameResidual
54 | {
55 | public:
56 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW
57 |
58 | EFResidual* efResidual;
59 |
60 | static int instanceCounter;
61 |
62 |
63 | ResState state_state; //!< 上一次的残差状态
64 | double state_energy; //!< 上一次的能量值
65 | ResState state_NewState; //!< 新的一次计算的状态
66 | double state_NewEnergy; //!< 新的能量, 如果大于阈值则把等于阈值
67 | double state_NewEnergyWithOutlier; //!< 可能具有外点的能量, 可能大于阈值
68 |
69 |
70 | void setState(ResState s) {state_state = s;}
71 |
72 |
73 | PointHessian* point; //!< 点
74 | // 2022.1.11
75 | frame_hessian* host; //!< 主帧
76 | frame_hessian* target; //!< 目标帧//
77 | RawResidualJacobian* J; //!< 残差对变量的各种雅克比
78 |
79 |
80 | bool isNew;
81 |
82 |
83 | Eigen::Vector2f projectedTo[MAX_RES_PER_POINT]; //!< 各个patch的投影坐标
84 | Vec3f centerProjectedTo; //!< patch的中心点投影 [像素x, 像素y, 新帧逆深度]
85 |
86 | ~PointFrameResidual();
87 | PointFrameResidual();
88 | PointFrameResidual(PointHessian* point_, frame_hessian* host_, frame_hessian* target_);
89 | double linearize(CalibHessian* HCalib);
90 |
91 |
92 | void resetOOB()
93 | {
94 | state_NewEnergy = state_energy = 0;
95 | state_NewState = ResState::OUTLIER;
96 |
97 | setState(ResState::IN);
98 | };
99 | void applyRes( bool copyJacobians);
100 |
101 | void debugPlot();
102 |
103 | void printRows(std::vector &v, VecX &r, int nFrames, int nPoints, int M, int res);
104 | };
105 | }
106 |
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 |
25 |
26 | #pragma once
27 | #include
28 | #include "util/NumType.h"
29 | #include "util/MinimalImage.h"
30 |
31 |
32 | namespace dso
33 | {
34 |
35 | namespace IOWrap
36 | {
37 |
38 | void displayImage(const char* windowName, const MinimalImageB* img, bool autoSize = false);
39 | void displayImage(const char* windowName, const MinimalImageB3* img, bool autoSize = false);
40 | void displayImage(const char* windowName, const MinimalImageF* img, bool autoSize = false);
41 | void displayImage(const char* windowName, const MinimalImageF3* img, bool autoSize = false);
42 | void displayImage(const char* windowName, const MinimalImageB16* img, bool autoSize = false);
43 |
44 |
45 | void displayImageStitch(const char* windowName, const std::vector images, int cc=0, int rc=0);
46 | void displayImageStitch(const char* windowName, const std::vector images, int cc=0, int rc=0);
47 | void displayImageStitch(const char* windowName, const std::vector images, int cc=0, int rc=0);
48 | void displayImageStitch(const char* windowName, const std::vector images, int cc=0, int rc=0);
49 |
50 | int waitKey(int milliseconds);
51 | void closeAllWindows();
52 |
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/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 |
25 |
26 | #include "IOWrapper/ImageDisplay.h"
27 |
28 | namespace dso
29 | {
30 |
31 |
32 | namespace IOWrap
33 | {
34 | void displayImage(const char* windowName, const MinimalImageB* img, bool autoSize) {};
35 | void displayImage(const char* windowName, const MinimalImageB3* img, bool autoSize) {};
36 | void displayImage(const char* windowName, const MinimalImageF* img, bool autoSize) {};
37 | void displayImage(const char* windowName, const MinimalImageF3* img, bool autoSize) {};
38 | void displayImage(const char* windowName, const MinimalImageB16* img, bool autoSize) {};
39 |
40 |
41 | void displayImageStitch(const char* windowName, const std::vector images, int cc, int rc) {};
42 | void displayImageStitch(const char* windowName, const std::vector images, int cc, int rc) {};
43 | void displayImageStitch(const char* windowName, const std::vector images, int cc, int rc) {};
44 | void displayImageStitch(const char* windowName, const std::vector images, int cc, int rc) {};
45 |
46 | int waitKey(int milliseconds) {return 0;};
47 | void closeAllWindows() {};
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/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 |
25 |
26 | #pragma once
27 | #include "util/NumType.h"
28 | #include "util/MinimalImage.h"
29 |
30 | // 2020.06.22 yzk
31 | #include
32 | // 2020.06.22 yzk
33 |
34 | namespace dso
35 | {
36 | namespace IOWrap
37 | {
38 |
39 | MinimalImageB* readImageBW_8U(std::string filename);
40 | MinimalImageB3* readImageRGB_8U(std::string filename);
41 | MinimalImage* readImageBW_16U(std::string filename);
42 | // 2019.11.07 yzk
43 | MinimalImage* readDepthImageBW_16U(std::string filename);
44 | // 2019.11.07 yzk
45 | // 2020.06.22 yzk
46 | MinimalImageB* readRosImageBW_8U(cv::Mat &image);
47 | // 2020.06.22 yzk
48 |
49 | MinimalImageB* readStreamBW_8U(char* data, int numBytes);
50 |
51 | void writeImage(std::string filename, MinimalImageB* img);
52 | void writeImage(std::string filename, MinimalImageB3* img);
53 | void writeImage(std::string filename, MinimalImageF* img);
54 | void writeImage(std::string filename, MinimalImageF3* img);
55 |
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/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 |
25 |
26 | #include "IOWrapper/ImageRW.h"
27 |
28 | namespace dso
29 | {
30 |
31 |
32 | namespace IOWrap
33 | {
34 |
35 | MinimalImageB* readImageBW_8U(std::string filename) {printf("not implemented. bye!\n"); return 0;};
36 | MinimalImageB3* readImageRGB_8U(std::string filename) {printf("not implemented. bye!\n"); return 0;};
37 | MinimalImage* readImageBW_16U(std::string filename) {printf("not implemented. bye!\n"); return 0;};
38 | MinimalImageB* readStreamBW_8U(char* data, int numBytes) {printf("not implemented. bye!\n"); return 0;};
39 | void writeImage(std::string filename, MinimalImageB* img) {};
40 | void writeImage(std::string filename, MinimalImageB3* img) {};
41 | void writeImage(std::string filename, MinimalImageF* img) {};
42 | void writeImage(std::string filename, MinimalImageF3* img) {};
43 |
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/IOWrapper/OpenCV/ImageDisplay_OpenCV.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 |
25 |
26 | #include "IOWrapper/ImageDisplay.h"
27 |
28 | #include
29 |
30 | #include
31 | #include
32 |
33 | #include
34 |
35 | #include "util/settings.h"
36 |
37 | namespace dso
38 | {
39 |
40 |
41 | namespace IOWrap
42 | {
43 |
44 | std::unordered_set openWindows;
45 | boost::mutex openCVdisplayMutex;
46 |
47 |
48 |
49 | void displayImage(const char* windowName, const cv::Mat& image, bool autoSize)
50 | {
51 | if(disableAllDisplay) return;
52 |
53 | boost::unique_lock lock(openCVdisplayMutex);
54 | if(!autoSize)
55 | {
56 | if(openWindows.find(windowName) == openWindows.end())
57 | {
58 | cv::namedWindow(windowName, cv::WINDOW_NORMAL);
59 | cv::resizeWindow(windowName, image.cols, image.rows);
60 | openWindows.insert(windowName);
61 | }
62 | }
63 | cv::imshow(windowName, image);
64 | }
65 |
66 |
67 | void displayImageStitch(const char* windowName, const std::vector images, int cc, int rc)
68 | {
69 | if(disableAllDisplay) return;
70 | if(images.size() == 0) return;
71 |
72 | // get dimensions.
73 | int w = images[0]->cols;
74 | int h = images[0]->rows;
75 |
76 | int num = std::max((int)setting_maxFrames, (int)images.size());
77 |
78 | // get optimal dimensions.
79 | int bestCC = 0;
80 | float bestLoss = 1e10;
81 | for(int cc=1;cc<10;cc++)
82 | {
83 | int ww = w * cc;
84 | int hh = h * ((num+cc-1)/cc);
85 |
86 |
87 | float wLoss = ww/16.0f;
88 | float hLoss = hh/10.0f;
89 | float loss = std::max(wLoss, hLoss);
90 |
91 | if(loss < bestLoss)
92 | {
93 | bestLoss = loss;
94 | bestCC = cc;
95 | }
96 | }
97 |
98 | int bestRC = ((num+bestCC-1)/bestCC);
99 | if(cc != 0)
100 | {
101 | bestCC = cc;
102 | bestRC= rc;
103 | }
104 | cv::Mat stitch = cv::Mat(bestRC*h, bestCC*w, images[0]->type());
105 | stitch.setTo(0);
106 | for(int i=0;i<(int)images.size() && i < bestCC*bestRC;i++)
107 | {
108 | int c = i%bestCC;
109 | int r = i/bestCC;
110 |
111 | cv::Mat roi = stitch(cv::Rect(c*w, r*h, w,h));
112 | images[i]->copyTo(roi);
113 | }
114 | displayImage(windowName, stitch, false);
115 | }
116 |
117 |
118 |
119 | void displayImage(const char* windowName, const MinimalImageB* img, bool autoSize)
120 | {
121 | displayImage(windowName, cv::Mat(img->h, img->w, CV_8U, img->data), autoSize);
122 | }
123 | void displayImage(const char* windowName, const MinimalImageB3* img, bool autoSize)
124 | {
125 | displayImage(windowName, cv::Mat(img->h, img->w, CV_8UC3, img->data), autoSize);
126 | }
127 | void displayImage(const char* windowName, const MinimalImageF* img, bool autoSize)
128 | {
129 | displayImage(windowName, cv::Mat(img->h, img->w, CV_32F, img->data)*(1/254.0f), autoSize);
130 | }
131 | void displayImage(const char* windowName, const MinimalImageF3* img, bool autoSize)
132 | {
133 | displayImage(windowName, cv::Mat(img->h, img->w, CV_32FC3, img->data)*(1/254.0f), autoSize);
134 | }
135 | void displayImage(const char* windowName, const MinimalImageB16* img, bool autoSize)
136 | {
137 | displayImage(windowName, cv::Mat(img->h, img->w, CV_16U, img->data), autoSize);
138 | }
139 |
140 |
141 | void displayImageStitch(const char* windowName, const std::vector images, int cc, int rc)
142 | {
143 | std::vector imagesCV;
144 | for(size_t i=0; i < images.size();i++)
145 | imagesCV.push_back(new cv::Mat(images[i]->h, images[i]->w, CV_8U, images[i]->data));
146 | displayImageStitch(windowName, imagesCV, cc, rc);
147 | for(size_t i=0; i < images.size();i++)
148 | delete imagesCV[i];
149 | }
150 | void displayImageStitch(const char* windowName, const std::vector images, int cc, int rc)
151 | {
152 | std::vector imagesCV;
153 | for(size_t i=0; i < images.size();i++)
154 | imagesCV.push_back(new cv::Mat(images[i]->h, images[i]->w, CV_8UC3, images[i]->data));
155 | displayImageStitch(windowName, imagesCV, cc, rc);
156 | for(size_t i=0; i < images.size();i++)
157 | delete imagesCV[i];
158 | }
159 | void displayImageStitch(const char* windowName, const std::vector images, int cc, int rc)
160 | {
161 | std::vector imagesCV;
162 | for(size_t i=0; i < images.size();i++)
163 | imagesCV.push_back(new cv::Mat(images[i]->h, images[i]->w, CV_32F, images[i]->data));
164 | displayImageStitch(windowName, imagesCV, cc, rc);
165 | for(size_t i=0; i < images.size();i++)
166 | delete imagesCV[i];
167 | }
168 | void displayImageStitch(const char* windowName, const std::vector images, int cc, int rc)
169 | {
170 | std::vector imagesCV;
171 | for(size_t i=0; i < images.size();i++)
172 | imagesCV.push_back(new cv::Mat(images[i]->h, images[i]->w, CV_32FC3, images[i]->data));
173 | displayImageStitch(windowName, imagesCV, cc, rc);
174 | for(size_t i=0; i < images.size();i++)
175 | delete imagesCV[i];
176 | }
177 |
178 |
179 |
180 | int waitKey(int milliseconds)
181 | {
182 | if(disableAllDisplay) return 0;
183 |
184 | boost::unique_lock lock(openCVdisplayMutex);
185 | return cv::waitKey(milliseconds);
186 | }
187 |
188 | void closeAllWindows()
189 | {
190 | if(disableAllDisplay) return;
191 | boost::unique_lock lock(openCVdisplayMutex);
192 | cv::destroyAllWindows();
193 | openWindows.clear();
194 | }
195 | }
196 |
197 | }
198 |
--------------------------------------------------------------------------------
/src/IOWrapper/OpenCV/ImageRW_OpenCV.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 |
25 |
26 | #include "IOWrapper/ImageRW.h"
27 | #include
28 | #include
29 | #include
30 |
31 |
32 | namespace dso
33 | {
34 |
35 | namespace IOWrap
36 | {
37 | MinimalImageB* readImageBW_8U(std::string filename)
38 | {
39 | cv::Mat m = cv::imread(filename, CV_LOAD_IMAGE_GRAYSCALE);
40 | if(m.rows*m.cols==0)
41 | {
42 | printf("cv::imread could not read image %s! this may segfault. \n", filename.c_str());
43 | return 0;
44 | }
45 | if(m.type() != CV_8U)
46 | {
47 | printf("cv::imread did something strange! this may segfault. \n");
48 | return 0;
49 | }
50 | MinimalImageB* img = new MinimalImageB(m.cols, m.rows);
51 | memcpy(img->data, m.data, m.rows*m.cols);
52 | return img;
53 | }
54 |
55 | // 2020.06.22 yzk
56 | MinimalImageB* readRosImageBW_8U(cv::Mat &image)
57 | {
58 | cv::Mat m = image.clone();
59 | //cv::imshow("raw image", m);
60 | //cv::waitKey(0);
61 | if(m.rows*m.cols==0)
62 | {
63 | printf("cv::imread could not read image. \n");
64 | return 0;
65 | }
66 | if(m.type() != CV_8U)
67 | {
68 | printf("cv::imread did something strange! this may segfault. \n");
69 | return 0;
70 | }
71 | MinimalImageB* img = new MinimalImageB(m.cols, m.rows);
72 | memcpy(img->data, m.data, m.rows*m.cols);
73 |
74 | return img;
75 | }
76 | // 2020.06.22 yzk
77 |
78 | MinimalImageB3* readImageRGB_8U(std::string filename)
79 | {
80 | cv::Mat m = cv::imread(filename, CV_LOAD_IMAGE_COLOR);
81 | if(m.rows*m.cols==0)
82 | {
83 | printf("cv::imread could not read image %s! this may segfault. \n", filename.c_str());
84 | return 0;
85 | }
86 | if(m.type() != CV_8UC3)
87 | {
88 | printf("cv::imread did something strange! this may segfault. \n");
89 | return 0;
90 | }
91 | MinimalImageB3* img = new MinimalImageB3(m.cols, m.rows);
92 | memcpy(img->data, m.data, 3*m.rows*m.cols);
93 | return img;
94 | }
95 |
96 | MinimalImage* readImageBW_16U(std::string filename)
97 | {
98 | cv::Mat m = cv::imread(filename, CV_LOAD_IMAGE_UNCHANGED);
99 | if(m.rows*m.cols==0)
100 | {
101 | printf("cv::imread could not read image %s! this may segfault. \n", filename.c_str());
102 | return 0;
103 | }
104 | if(m.type() != CV_16U)
105 | {
106 | printf("readImageBW_16U called on image that is not a 16bit grayscale image. this may segfault. \n");
107 | return 0;
108 | }
109 | MinimalImage* img = new MinimalImage(m.cols, m.rows);
110 | memcpy(img->data, m.data, 2*m.rows*m.cols);
111 | return img;
112 | }
113 |
114 | // 2019.11.07 yzk
115 | MinimalImage* readDepthImageBW_16U(std::string filename)
116 | {
117 | cv::Mat m = cv::imread(filename, CV_LOAD_IMAGE_UNCHANGED);
118 | //cv::imshow("original depthimage", m);
119 | if(m.rows*m.cols==0)
120 | {
121 | printf("cv::imread could not read image %s! this may segfault. \n", filename.c_str());
122 | return 0;
123 | }
124 | if(m.type() != CV_16U)
125 | {
126 | printf("readImageBW_16U called on image that is not a 16bit grayscale image. this may segfault. \n");
127 | return 0;
128 | }
129 | MinimalImage* img = new MinimalImage(m.cols, m.rows);
130 | memcpy(img->data, m.data, 2 * m.rows*m.cols);
131 | //memcpy(m.data, img->data, m.rows*m.cols);
132 | //cv::imshow("second depthimage", m);
133 | return img;
134 | }
135 | // 2019.11.07 yzk
136 |
137 | MinimalImageB* readStreamBW_8U(char* data, int numBytes)
138 | {
139 | cv::Mat m = cv::imdecode(cv::Mat(numBytes,1,CV_8U, data), CV_LOAD_IMAGE_GRAYSCALE);
140 | if(m.rows*m.cols==0)
141 | {
142 | printf("cv::imdecode could not read stream (%d bytes)! this may segfault. \n", numBytes);
143 | return 0;
144 | }
145 | if(m.type() != CV_8U)
146 | {
147 | printf("cv::imdecode did something strange! this may segfault. \n");
148 | return 0;
149 | }
150 | MinimalImageB* img = new MinimalImageB(m.cols, m.rows);
151 | memcpy(img->data, m.data, m.rows*m.cols);
152 | return img;
153 | }
154 |
155 |
156 |
157 | void writeImage(std::string filename, MinimalImageB* img)
158 | {
159 | cv::imwrite(filename, cv::Mat(img->h, img->w, CV_8U, img->data));
160 | }
161 | void writeImage(std::string filename, MinimalImageB3* img)
162 | {
163 | cv::imwrite(filename, cv::Mat(img->h, img->w, CV_8UC3, img->data));
164 | }
165 | void writeImage(std::string filename, MinimalImageF* img)
166 | {
167 | cv::imwrite(filename, cv::Mat(img->h, img->w, CV_32F, img->data));
168 | }
169 | void writeImage(std::string filename, MinimalImageF3* img)
170 | {
171 | cv::imwrite(filename, cv::Mat(img->h, img->w, CV_32FC3, img->data));
172 | }
173 |
174 | }
175 |
176 | }
177 |
--------------------------------------------------------------------------------
/src/IOWrapper/Output3DWrapper.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 |
25 |
26 | #pragma once
27 | #include
28 | #include
29 |
30 | #include "util/NumType.h"
31 | #include "util/MinimalImage.h"
32 | #include "map"
33 |
34 | namespace cv {
35 | class Mat;
36 | }
37 |
38 | namespace dso
39 | {
40 |
41 | class FrameHessian;
42 | class CalibHessian;
43 | class FrameShell;
44 |
45 | namespace IOWrap
46 | {
47 |
48 | /* ======================= Some typical usecases: ===============
49 | *
50 | * (1) always get the pose of the most recent frame:
51 | * -> Implement [publishCamPose].
52 | *
53 | * (2) always get the depthmap of the most recent keyframe
54 | * -> Implement [pushDepthImageFloat] (use inverse depth in [image], and pose / frame information from [KF]).
55 | *
56 | * (3) accumulate final model
57 | * -> Implement [publishKeyframes] (skip for final!=false), and accumulate frames.
58 | *
59 | * (4) get evolving model in real-time
60 | * -> Implement [publishKeyframes] (update all frames for final==false).
61 | *
62 | *
63 | *
64 | *
65 | * ==================== How to use the structs: ===================
66 | * [FrameShell]: minimal struct kept for each frame ever tracked.
67 | * ->camToWorld = camera to world transformation
68 | * ->poseValid = false if [camToWorld] is invalid (only happens for frames during initialization).
69 | * ->trackingRef = Shell of the frame this frame was tracked on.
70 | * ->id = ID of that frame, starting with 0 for the very first frame.
71 | *
72 | * ->incoming_id = ID passed into [addActiveFrame( ImageAndExposure* image, int id )].
73 | * ->timestamp = timestamp passed into [addActiveFrame( ImageAndExposure* image, int id )] as image.timestamp.
74 | *
75 | * [FrameHessian]
76 | * ->immaturePoints: contains points that have not been "activated" (they do however have a depth initialization).
77 | * ->pointHessians: contains active points.
78 | * ->pointHessiansMarginalized: contains marginalized points.
79 | * ->pointHessiansOut: contains outlier points.
80 | *
81 | * ->frameID: incremental ID for keyframes only.
82 | * ->shell: corresponding [FrameShell] struct.
83 | *
84 | *
85 | * [CalibHessian]
86 | * ->fxl(), fyl(), cxl(), cyl(): get optimized, most recent (pinhole) camera intrinsics.
87 | *
88 | *
89 | * [PointHessian]
90 | * ->u,v: pixel-coordinates of point.
91 | * ->idepth_scaled: inverse depth of point.
92 | * DO NOT USE [idepth], since it may be scaled with [SCALE_IDEPTH] ... however that is currently set to 1 so never mind.
93 | * ->host: pointer to host-frame of point.
94 | * ->status: current status of point (ACTIVE=0, INACTIVE, OUTLIER, OOB, MARGINALIZED)
95 | * ->numGoodResiduals: number of non-outlier residuals supporting this point (approximate).
96 | * ->maxRelBaseline: value roughly proportional to the relative baseline this point was observed with (0 = no baseline).
97 | * points for which this value is low are badly contrained.
98 | * ->idepth_hessian: hessian value (inverse variance) of inverse depth.
99 | *
100 | * [ImmaturePoint]
101 | * ->u,v: pixel-coordinates of point.
102 | * ->idepth_min, idepth_max: the initialization sais that the inverse depth of this point is very likely
103 | * between these two thresholds (their mean being the best guess)
104 | * ->host: pointer to host-frame of point.
105 | */
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 | class Output3DWrapper
114 | {
115 | public:
116 | Output3DWrapper() {}
117 | virtual ~Output3DWrapper() {}
118 |
119 |
120 | /* Usage:
121 | * Called once after each new Keyframe is inserted & optimized.
122 | * [connectivity] contains for each frame-frame pair the number of [0] active residuals in between them,
123 | * and [1] the number of marginalized reisduals between them.
124 | * frame-frame pairs are encoded as HASH_IDX = [(int)hostFrameKFID << 32 + (int)targetFrameKFID].
125 | * the [***frameKFID] used for hashing correspond to the [FrameHessian]->frameID.
126 | *
127 | * Calling:
128 | * Always called, no overhead if not used.
129 | */
130 | virtual void publishGraph(const std::map, Eigen::aligned_allocator > > &connectivity) {}
131 |
132 |
133 |
134 |
135 |
136 | /* Usage:
137 | * Called after each new Keyframe is inserted & optimized, with all keyframes that were part of the active window during
138 | * that optimization in [frames] (with final=false). Use to access the new frame pose and points.
139 | * Also called just before a frame is marginalized (with final=true) with only that frame in [frames]; at that point,
140 | * no further updates will ever occur to it's optimized values (pose & idepth values of it's points).
141 | *
142 | * If you want always all most recent values for all frames, just use the [final=false] calls.
143 | * If you only want to get the final model, but don't care about it being delay-free, only use the
144 | * [final=true] calls, to save compute.
145 | *
146 | * Calling:
147 | * Always called, negligible overhead if not used.
148 | */
149 | virtual void publishKeyframes(std::vector &frames, bool final, CalibHessian* HCalib) {}
150 |
151 |
152 |
153 |
154 |
155 | /* Usage:
156 | * Called once for each tracked frame, with the real-time, low-delay frame pose.
157 | *
158 | * Calling:
159 | * Always called, no overhead if not used.
160 | */
161 | virtual void publishCamPose(FrameShell* frame, CalibHessian* HCalib) {}
162 |
163 |
164 |
165 |
166 |
167 | /* Usage:
168 | * Called once for each new frame, before it is tracked (i.e., it doesn't have a pose yet).
169 | *
170 | * Calling:
171 | * Always called, no overhead if not used.
172 | */
173 | virtual void pushLiveFrame(FrameHessian* image) {}
174 |
175 |
176 |
177 |
178 | /* called once after a new keyframe is created, with the color-coded, forward-warped inverse depthmap for that keyframe,
179 | * which is used for initial alignment of future frames. Meant for visualization.
180 | *
181 | * Calling:
182 | * Needs to prepare the depth image, so it is only called if [needPushDepthImage()] returned true.
183 | */
184 | // 2021.11.23
185 | virtual void pushDepthImage(std::vector& image) {}
186 | // 2021.11.23
187 | virtual bool needPushDepthImage() {return false;}
188 |
189 |
190 |
191 | /* Usage:
192 | * called once after a new keyframe is created, with the forward-warped inverse depthmap for that keyframe.
193 | * (<= 0 for pixels without inv. depth value, >0 for pixels with inv. depth value)
194 | *
195 | * Calling:
196 | * Always called, almost no overhead if not used.
197 | */
198 | virtual void pushDepthImageFloat(MinimalImageF* image, FrameHessian* KF ) {}
199 |
200 |
201 |
202 | /* call on finish */
203 | virtual void join() {}
204 |
205 | /* call on reset */
206 | virtual void reset() {}
207 |
208 | };
209 |
210 | }
211 | }
212 |
--------------------------------------------------------------------------------
/src/IOWrapper/OutputWrapper/SampleOutputWrapper.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 |
25 | #pragma once
26 | #include "boost/thread.hpp"
27 | #include "util/MinimalImage.h"
28 | #include "IOWrapper/Output3DWrapper.h"
29 |
30 |
31 |
32 | #include "FullSystem/HessianBlocks.h"
33 | #include "util/FrameShell.h"
34 |
35 | namespace dso
36 | {
37 |
38 | class FrameHessian;
39 | class CalibHessian;
40 | class FrameShell;
41 |
42 |
43 | namespace IOWrap
44 | {
45 |
46 | class SampleOutputWrapper : public Output3DWrapper
47 | {
48 | public:
49 | inline SampleOutputWrapper()
50 | {
51 | printf("OUT: Created SampleOutputWrapper\n");
52 | }
53 |
54 | virtual ~SampleOutputWrapper()
55 | {
56 | printf("OUT: Destroyed SampleOutputWrapper\n");
57 | }
58 |
59 | virtual void publishGraph(const std::map, Eigen::aligned_allocator>> &connectivity) override
60 | {
61 | printf("OUT: got graph with %d edges\n", (int)connectivity.size());
62 |
63 | int maxWrite = 5;
64 |
65 | for(const std::pair &p : connectivity)
66 | {
67 | int idHost = p.first>>32;
68 | int idTarget = p.first & ((uint64_t)0xFFFFFFFF);
69 | printf("OUT: Example Edge %d -> %d has %d active and %d marg residuals\n", idHost, idTarget, p.second[0], p.second[1]);
70 | maxWrite--;
71 | if(maxWrite==0) break;
72 | }
73 | }
74 |
75 |
76 |
77 | virtual void publishKeyframes( std::vector &frames, bool final, CalibHessian* HCalib) override
78 | {
79 | for(FrameHessian* f : frames)
80 | {
81 | printf("OUT: KF %d (%s) (id %d, tme %f): %d active, %d marginalized, %d immature points. CameraToWorld:\n",
82 | f->frameID,
83 | final ? "final" : "non-final",
84 | f->shell->incoming_id,
85 | f->shell->timestamp,
86 | (int)f->frame[0]->pointHessians.size(), (int)f->frame[0]->pointHessiansMarginalized.size(), (int)f->frame[0]->immaturePoints.size());// 2022.1.11
87 | std::cout << f->shell->camToWorld.matrix3x4() << "\n";
88 |
89 |
90 | int maxWrite = 5;
91 | for(PointHessian* p : f->frame[0]->pointHessians)// 2022.1.11
92 | {
93 | printf("OUT: Example Point x=%.1f, y=%.1f, idepth=%f, idepth std.dev. %f, %d inlier-residuals\n",
94 | p->u, p->v, p->idepth_scaled, sqrt(1.0f / p->idepth_hessian), p->numGoodResiduals );
95 | maxWrite--;
96 | if(maxWrite==0) break;
97 | }
98 | }
99 | }
100 |
101 | virtual void publishCamPose(FrameShell* frame, CalibHessian* HCalib) override
102 | {
103 | printf("OUT: Current Frame %d (time %f, internal ID %d). CameraToWorld:\n",
104 | frame->incoming_id,
105 | frame->timestamp,
106 | frame->id);
107 | std::cout << frame->camToWorld.matrix3x4() << "\n";
108 | }
109 |
110 |
111 | virtual void pushLiveFrame(FrameHessian* image) override
112 | {
113 | // can be used to get the raw image / intensity pyramid.
114 | }
115 |
116 | virtual void pushDepthImage(std::vector& image) override
117 | {
118 | // can be used to get the raw image with depth overlay.
119 | }
120 | virtual bool needPushDepthImage() override
121 | {
122 | return false;
123 | }
124 |
125 | virtual void pushDepthImageFloat(MinimalImageF* image, FrameHessian* KF ) override
126 | {
127 | printf("OUT: Predicted depth for KF %d (id %d, time %f, internal frame-ID %d). CameraToWorld:\n",
128 | KF->frameID,
129 | KF->shell->incoming_id,
130 | KF->shell->timestamp,
131 | KF->shell->id);
132 | std::cout << KF->shell->camToWorld.matrix3x4() << "\n";
133 |
134 | int maxWrite = 5;
135 | for(int y=0;yh;y++)
136 | {
137 | for(int x=0;xw;x++)
138 | {
139 | if(image->at(x,y) <= 0) continue;
140 |
141 | printf("OUT: Example Idepth at pixel (%d,%d): %f.\n", x,y,image->at(x,y));
142 | maxWrite--;
143 | if(maxWrite==0) break;
144 | }
145 | if(maxWrite==0) break;
146 | }
147 | }
148 |
149 |
150 | };
151 |
152 |
153 |
154 | }
155 |
156 |
157 |
158 | }
159 |
--------------------------------------------------------------------------------
/src/IOWrapper/Pangolin/KeyFrameDisplay.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 |
25 | #pragma once
26 |
27 | #undef Success
28 | #include
29 | #include "util/NumType.h"
30 | #include
31 |
32 | #include
33 | #include
34 | // 2021.12.14
35 | #include "util/settings.h"
36 | // 2021.12.14
37 |
38 | namespace dso
39 | {
40 | class CalibHessian;
41 | class FrameHessian;
42 | class FrameShell;
43 |
44 | namespace IOWrap
45 | {
46 |
47 | template
48 | struct InputPointSparse
49 | {
50 | float u;
51 | float v;
52 | float idpeth;
53 | float idepth_hessian;
54 | float relObsBaseline;
55 | int numGoodRes;
56 | unsigned char color[ppp];
57 | unsigned char status;
58 | };
59 |
60 | struct MyVertex
61 | {
62 | float point[3];
63 | unsigned char color[4];
64 | };
65 |
66 | // stores a pointcloud associated to a Keyframe.
67 | class KeyFrameDisplay
68 | {
69 |
70 | public:
71 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
72 | KeyFrameDisplay();
73 | ~KeyFrameDisplay();
74 |
75 | // copies points from KF over to internal buffer,
76 | // keeping some additional information so we can render it differently.
77 | void setFromKF(FrameHessian* fh, CalibHessian* HCalib);
78 |
79 | // copies points from KF over to internal buffer,
80 | // keeping some additional information so we can render it differently.
81 | void setFromF(FrameShell* fs, CalibHessian* HCalib);
82 |
83 | // copies & filters internal data to GL buffer for rendering. if nothing to do: does nothing.
84 | bool refreshPC(bool canRefresh, float scaledTH, float absTH, int mode, float minBS, int sparsity);
85 |
86 | // renders cam & pointcloud.
87 | void drawCam(float lineWidth = 1, float* color = 0, float sizeFactor=1);
88 | void drawPC(float pointSize);
89 |
90 | int id;
91 | bool active;
92 | SE3 camToWorld;
93 | // 2021.12.20
94 | SE3 camToWorld_gt;
95 | // 2021.12.20
96 |
97 | inline bool operator < (const KeyFrameDisplay& other) const
98 | {
99 | return (id < other.id);
100 | }
101 |
102 |
103 | private:
104 | // 2021.12.13
105 | /*
106 | float fx,fy,cx,cy;
107 | float fxi,fyi,cxi,cyi;
108 | */
109 | float fx[CAM_NUM],fy[CAM_NUM],cx[CAM_NUM],cy[CAM_NUM];
110 | float fxi[CAM_NUM],fyi[CAM_NUM],cxi[CAM_NUM],cyi[CAM_NUM];
111 | // 2021.12.13
112 | int width, height;
113 |
114 | float my_scaledTH, my_absTH, my_scale;
115 | int my_sparsifyFactor;
116 | int my_displayMode;
117 | float my_minRelBS;
118 | bool needRefresh;
119 |
120 |
121 | // 2021.12.14
122 | // int numSparsePoints;
123 | // int numSparseBufferSize;
124 | // InputPointSparse* originalInputSparse;
125 | int numSparsePoints[1];
126 | int numSparseBufferSize[1];
127 | InputPointSparse* originalInputSparse[1];
128 | // 2021.12.14
129 |
130 |
131 | bool bufferValid;
132 | int numGLBufferPoints;
133 | int numGLBufferGoodPoints;
134 | // 2021.12.14
135 | pangolin::GlBuffer vertexBuffer[1/*CAM_NUM*/];
136 | pangolin::GlBuffer colorBuffer[1];
137 | // 2021.12.14
138 | };
139 |
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/src/IOWrapper/Pangolin/PangolinDSOViewer.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 |
25 | #pragma once
26 | #include
27 | #include "boost/thread.hpp"
28 | #include "util/MinimalImage.h"
29 | #include "IOWrapper/Output3DWrapper.h"
30 | #include