├── Jacobians.pdf
├── calibs
├── TUM
│ ├── vignette0.png
│ ├── vignette1.png
│ ├── camera0.txt
│ ├── camera1.txt
│ ├── pcalib0.txt
│ ├── pcalib1.txt
│ └── calib.yaml
└── EuRoC
│ ├── camera0.txt
│ ├── camera1.txt
│ └── calib.yaml
├── package.xml
├── thirdparty
└── Sophus
│ ├── README
│ ├── SophusConfig.cmake.in
│ ├── cmake_modules
│ └── FindEigen3.cmake
│ ├── sophus
│ ├── sophus.hpp
│ ├── test_so2.cpp
│ ├── test_so3.cpp
│ ├── test_se2.cpp
│ ├── test_rxso3.cpp
│ ├── test_se3.cpp
│ ├── test_sim3.cpp
│ └── tests.hpp
│ ├── CMakeLists.txt
│ └── FindEigen3.cmake
├── launch
├── euroc.launch
└── tum.launch
├── cmake
├── FindLibZip.cmake
├── FindEigen3.cmake
└── FindSuiteParse.cmake
├── src
├── util
│ ├── globalCalib.h
│ ├── ImageAndExposure.h
│ ├── FrameShell.h
│ ├── globalCalib.cpp
│ ├── MinimalImage.h
│ ├── Undistort.h
│ ├── IndexThreadReduce.h
│ ├── settings.h
│ └── NumType.h
├── IOWrapper
│ ├── ImageRW.h
│ ├── ImageRW_dummy.cpp
│ ├── ImageDisplay_dummy.cpp
│ ├── ImageDisplay.h
│ ├── Pangolin
│ │ ├── KeyFrameDisplay.h
│ │ └── PangolinDSOViewer.h
│ ├── OpenCV
│ │ ├── ImageRW_OpenCV.cpp
│ │ └── ImageDisplay_OpenCV.cpp
│ ├── OutputWrapper
│ │ └── SampleOutputWrapper.h
│ └── Output3DWrapper.h
├── OptimizationBackend
│ ├── RawResidualJacobian.h
│ ├── EnergyFunctionalStructs.h
│ ├── EnergyFunctionalStructs.cpp
│ ├── EnergyFunctional.h
│ ├── AccumulatedSCHessian.h
│ ├── AccumulatedTopHessian.h
│ └── AccumulatedSCHessian.cpp
└── FullSystem
│ ├── PixelSelector2.h
│ ├── Residuals.h
│ ├── ResidualProjections.h
│ ├── ImmaturePoint.h
│ ├── CoarseTracker.h
│ ├── CoarseInitializer.h
│ ├── FullSystemOptPoint.cpp
│ ├── FullSystemMarginalize.cpp
│ └── PixelSelector.h
├── CMakeLists.txt
└── README.md
/Jacobians.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IRVLab/spline_vio/HEAD/Jacobians.pdf
--------------------------------------------------------------------------------
/calibs/TUM/vignette0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IRVLab/spline_vio/HEAD/calibs/TUM/vignette0.png
--------------------------------------------------------------------------------
/calibs/TUM/vignette1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IRVLab/spline_vio/HEAD/calibs/TUM/vignette1.png
--------------------------------------------------------------------------------
/calibs/EuRoC/camera0.txt:
--------------------------------------------------------------------------------
1 | RadTan 0.609912234 0.9527 0.488982713 0.518489583 -0.28340811 0.07395907 0.00019359 1.76187114e-05
2 | 752 480
3 | crop
4 | 752 480
5 |
--------------------------------------------------------------------------------
/calibs/EuRoC/camera1.txt:
--------------------------------------------------------------------------------
1 | RadTan 0.608493351 0.950279167 0.505982713 0.5327875 -0.28368365 0.07451284 -0.00010473 -3.55590700e-05
2 | 752 480
3 | crop
4 | 752 480
5 |
--------------------------------------------------------------------------------
/calibs/TUM/camera0.txt:
--------------------------------------------------------------------------------
1 | EquiDistant 0.373004838186 0.372994740336 0.498890050897 0.502729380663 0.00348238940225 0.000715034845216 -0.00205323614187 0.000202936735918
2 | 512 512
3 | crop
4 | 512 512
5 |
--------------------------------------------------------------------------------
/calibs/TUM/camera1.txt:
--------------------------------------------------------------------------------
1 | EquiDistant 0.371957753309 0.371942262641 0.494334955407 0.498861778606 0.00340031707904 0.00176627815347 -0.00266312569782 0.000329951742393
2 | 512 512
3 | crop
4 | 512 512
5 |
--------------------------------------------------------------------------------
/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | spline_vio
4 | 0.0.0
5 | The spline_vio package
6 |
7 | Jiawei Mo
8 |
9 |
10 | GPLv3
11 |
12 | catkin
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/thirdparty/Sophus/README:
--------------------------------------------------------------------------------
1 | Sophus (version 0.9a)
2 |
3 | C++ implementation of Lie Groups using Eigen.
4 |
5 | Thanks to Steven Lovegrove, Sophus is now fully templated - using the Curiously Recurring Template Pattern (CRTP).
6 |
7 | (In order to go back to the non-templated/double-only version "git checkout a621ff".)
8 |
9 | Installation guide:
10 |
11 | >>>
12 | cd Sophus
13 | mkdir build
14 | cd build
15 | cmake ..
16 | make
17 | <<<
18 |
19 |
20 |
--------------------------------------------------------------------------------
/thirdparty/Sophus/SophusConfig.cmake.in:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # Sophus source dir
3 | set( Sophus_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
4 |
5 | ################################################################################
6 | # Sophus build dir
7 | set( Sophus_DIR "@CMAKE_CURRENT_BINARY_DIR@")
8 |
9 | ################################################################################
10 | set( Sophus_INCLUDE_DIR "@Sophus_INCLUDE_DIR@" )
11 | set( Sophus_INCLUDE_DIRS "@Sophus_INCLUDE_DIR@" )
--------------------------------------------------------------------------------
/thirdparty/Sophus/cmake_modules/FindEigen3.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find Eigen3 lib
2 | # Once done this will define
3 | #
4 | # EIGEN3_FOUND - system has eigen lib
5 | # EIGEN3_INCLUDE_DIR - the eigen include directory
6 |
7 | # Copyright (c) 2006, 2007 Montel Laurent,
8 | # Redistribution and use is allowed according to the terms of the BSD license.
9 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
10 |
11 | if( EIGEN3_INCLUDE_DIR )
12 | # in cache already
13 | set( EIGEN3_FOUND TRUE )
14 | else (EIGEN3_INCLUDE_DIR)
15 | find_path( EIGEN3_INCLUDE_DIR NAMES Eigen/Core
16 | PATH_SUFFIXES eigen3/
17 | HINTS
18 | ${INCLUDE_INSTALL_DIR}
19 | /usr/local/include
20 | ${KDE4_INCLUDE_DIR}
21 | )
22 | include( FindPackageHandleStandardArgs )
23 | find_package_handle_standard_args( Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR )
24 | mark_as_advanced( EIGEN3_INCLUDE_DIR )
25 | endif(EIGEN3_INCLUDE_DIR)
26 |
27 |
--------------------------------------------------------------------------------
/calibs/EuRoC/calib.yaml:
--------------------------------------------------------------------------------
1 | # transformation of the main camera in IMU frame
2 | T_imu:
3 | cols: 4
4 | rows: 4
5 | data: [0.0148655429818, -0.999880929698, 0.00414029679422, -0.0216401454975,
6 | 0.999557249008, 0.0149672133247, 0.025715529948, -0.064676986768,
7 | -0.0257744366974, 0.00375618835797, 0.999660727178, 0.00981073058949,
8 | 0.0, 0.0, 0.0, 1.0]
9 |
10 | rate_hz: 200
11 | accelerometer_noise_density: 2.0000e-3 # [ m / s^2 / sqrt(Hz) ]
12 | accelerometer_random_walk: 3.0000e-3 # [ m / s^3 / sqrt(Hz) ]. ( accel bias diffusion )
13 | gyroscope_noise_density: 1.6968e-04 # [ rad / s / sqrt(Hz) ]
14 | gyroscope_random_walk: 1.9393e-05 # [ rad / s^2 / sqrt(Hz) ] ( gyro bias diffusion )
15 |
16 | # transformation of the main camera in the other camera frame
17 | T_stereo:
18 | cols: 4
19 | rows: 4
20 | data: [1.0000, 0.0023, 0.0004, -0.1101,
21 | -0.0023, 0.9999, 0.0141, 0.0004,
22 | -0.0003, -0.0141, 0.9999, -0.0009,
23 | 0.0, 0.0, 0.0, 1.0]
24 |
--------------------------------------------------------------------------------
/launch/euroc.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/launch/tum.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/calibs/TUM/pcalib0.txt:
--------------------------------------------------------------------------------
1 | 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0 36.0 37.0 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0 49.0 50.0 51.0 52.0 53.0 54.0 55.0 56.0 57.0 58.0 59.0 60.0 61.0 62.0 63.0 64.0 65.0 66.0 67.0 68.0 69.0 70.0 71.0 72.0 73.0 74.0 75.0 76.0 77.0 78.0 79.0 80.0 81.0 82.0 83.0 84.0 85.0 86.0 87.0 88.0 89.0 90.0 91.0 92.0 93.0 94.0 95.0 96.0 97.0 98.0 99.0 100.0 101.0 102.0 103.0 104.0 105.0 106.0 107.0 108.0 109.0 110.0 111.0 112.0 113.0 114.0 115.0 116.0 117.0 118.0 119.0 120.0 121.0 122.0 123.0 124.0 125.0 126.0 127.0 128.0 129.0 130.0 131.0 132.0 133.0 134.0 135.0 136.0 137.0 138.0 139.0 140.0 141.0 142.0 143.0 144.0 145.0 146.0 147.0 148.0 149.0 150.0 151.0 152.0 153.0 154.0 155.0 156.0 157.0 158.0 159.0 160.0 161.0 162.0 163.0 164.0 165.0 166.0 167.0 168.0 169.0 170.0 171.0 172.0 173.0 174.0 175.0 176.0 177.0 178.0 179.0 180.0 181.0 182.0 183.0 184.0 185.0 186.0 187.0 188.0 189.0 190.0 191.0 192.0 193.0 194.0 195.0 196.0 197.0 198.0 199.0 200.0 201.0 202.0 203.0 204.0 205.0 206.0 207.0 208.0 209.0 210.0 211.0 212.0 213.0 214.0 215.0 216.0 217.0 218.0 219.0 220.0 221.0 222.0 223.0 224.0 225.0 226.0 227.0 228.0 229.0 230.0 231.0 232.0 233.0 234.0 235.0 236.0 237.0 238.0 239.0 240.0 241.0 242.0 243.0 244.0 245.0 246.0 247.0 248.0 249.0 250.0 251.0 252.0 253.0 254.0 255.0
--------------------------------------------------------------------------------
/calibs/TUM/pcalib1.txt:
--------------------------------------------------------------------------------
1 | 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0 36.0 37.0 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0 49.0 50.0 51.0 52.0 53.0 54.0 55.0 56.0 57.0 58.0 59.0 60.0 61.0 62.0 63.0 64.0 65.0 66.0 67.0 68.0 69.0 70.0 71.0 72.0 73.0 74.0 75.0 76.0 77.0 78.0 79.0 80.0 81.0 82.0 83.0 84.0 85.0 86.0 87.0 88.0 89.0 90.0 91.0 92.0 93.0 94.0 95.0 96.0 97.0 98.0 99.0 100.0 101.0 102.0 103.0 104.0 105.0 106.0 107.0 108.0 109.0 110.0 111.0 112.0 113.0 114.0 115.0 116.0 117.0 118.0 119.0 120.0 121.0 122.0 123.0 124.0 125.0 126.0 127.0 128.0 129.0 130.0 131.0 132.0 133.0 134.0 135.0 136.0 137.0 138.0 139.0 140.0 141.0 142.0 143.0 144.0 145.0 146.0 147.0 148.0 149.0 150.0 151.0 152.0 153.0 154.0 155.0 156.0 157.0 158.0 159.0 160.0 161.0 162.0 163.0 164.0 165.0 166.0 167.0 168.0 169.0 170.0 171.0 172.0 173.0 174.0 175.0 176.0 177.0 178.0 179.0 180.0 181.0 182.0 183.0 184.0 185.0 186.0 187.0 188.0 189.0 190.0 191.0 192.0 193.0 194.0 195.0 196.0 197.0 198.0 199.0 200.0 201.0 202.0 203.0 204.0 205.0 206.0 207.0 208.0 209.0 210.0 211.0 212.0 213.0 214.0 215.0 216.0 217.0 218.0 219.0 220.0 221.0 222.0 223.0 224.0 225.0 226.0 227.0 228.0 229.0 230.0 231.0 232.0 233.0 234.0 235.0 236.0 237.0 238.0 239.0 240.0 241.0 242.0 243.0 244.0 245.0 246.0 247.0 248.0 249.0 250.0 251.0 252.0 253.0 254.0 255.0
--------------------------------------------------------------------------------
/calibs/TUM/calib.yaml:
--------------------------------------------------------------------------------
1 | # transformation of the main camera in IMU frame
2 | T_imu:
3 | cols: 4
4 | rows: 4
5 | data: [-0.99952504, 0.00750192, -0.02989013, 0.04557484,
6 | 0.02961534, -0.03439736, -0.99896935, -0.0711618,
7 | -0.00852233, -0.99938008, 0.03415885, -0.04468125,
8 | 0.0, 0.0, 0.0, 1.0]
9 |
10 | rate_hz: 200
11 |
12 | # Values from allan plots
13 | # sequence: dataset-calib-imu-static2.bag (full data range)
14 | #accelerometer_noise_density: 0.0014 # m/s^1.5
15 | #accelerometer_random_walk: 0.000086 # m/s^2.5
16 | #gyroscope_noise_density: 0.000080 # rad/s^0.5
17 | #gyroscope_random_walk: 0.0000022 # rad/s^1.5
18 |
19 | # Inflated values (to account for unmodelled effects)
20 | # Those values work well with Kalibr cam-imu calibration.
21 | # - white noise multiplied by 2
22 | # - bias random walk multiplied by 10
23 | accelerometer_noise_density: 0.0028 # m/s^1.5
24 | accelerometer_random_walk: 0.00086 # m/s^2.5
25 | gyroscope_noise_density: 0.00016 # rad/s^0.5
26 | gyroscope_random_walk: 0.000022 # rad/s^1.5
27 |
28 | # transformation of the main camera in the other camera frame
29 | T_stereo:
30 | cols: 4
31 | rows: 4
32 | data: [0.99999945, -0.00082336, -0.00065614, -0.1010611,
33 | 0.00079169, 0.99889946, -0.04689604, -0.00197646,
34 | 0.00069403, 0.04689549, 0.99889956, -0.00117564,
35 | 0.0, 0.0, 0.0, 1.0]
36 |
--------------------------------------------------------------------------------
/src/util/globalCalib.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 | #include "NumType.h"
26 | #include "settings.h"
27 |
28 | namespace dso {
29 | extern int wG[PYR_LEVELS], hG[PYR_LEVELS];
30 | extern float fxG[PYR_LEVELS], fyG[PYR_LEVELS], cxG[PYR_LEVELS], cyG[PYR_LEVELS];
31 |
32 | extern float fxiG[PYR_LEVELS], fyiG[PYR_LEVELS], cxiG[PYR_LEVELS],
33 | cyiG[PYR_LEVELS];
34 |
35 | extern Eigen::Matrix3f KG[PYR_LEVELS], KiG[PYR_LEVELS];
36 |
37 | extern float wM3G;
38 | extern float hM3G;
39 |
40 | void setGlobalCalib(int w, int h, const Eigen::Matrix3f &K);
41 | } // namespace dso
42 |
--------------------------------------------------------------------------------
/src/IOWrapper/ImageRW.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 | #include "util/MinimalImage.h"
26 | #include "util/NumType.h"
27 |
28 | namespace dso {
29 | namespace IOWrap {
30 |
31 | MinimalImageB *readImageBW_8U(std::string filename);
32 | MinimalImageB3 *readImageRGB_8U(std::string filename);
33 | MinimalImage *readImageBW_16U(std::string filename);
34 |
35 | MinimalImageB *readStreamBW_8U(char *data, int numBytes);
36 |
37 | void writeImage(std::string filename, MinimalImageB *img);
38 | void writeImage(std::string filename, MinimalImageB3 *img);
39 | void writeImage(std::string filename, MinimalImageF *img);
40 | void writeImage(std::string filename, MinimalImageF3 *img);
41 |
42 | } // namespace IOWrap
43 | } // namespace dso
44 |
--------------------------------------------------------------------------------
/src/IOWrapper/ImageRW_dummy.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #include "IOWrapper/ImageRW.h"
25 |
26 | namespace dso {
27 |
28 | namespace IOWrap {
29 |
30 | MinimalImageB *readImageBW_8U(std::string filename) {
31 | printf("not implemented. bye!\n");
32 | return 0;
33 | };
34 | MinimalImageB3 *readImageRGB_8U(std::string filename) {
35 | printf("not implemented. bye!\n");
36 | return 0;
37 | };
38 | MinimalImage *readImageBW_16U(std::string filename) {
39 | printf("not implemented. bye!\n");
40 | return 0;
41 | };
42 | MinimalImageB *readStreamBW_8U(char *data, int numBytes) {
43 | printf("not implemented. bye!\n");
44 | return 0;
45 | };
46 | void writeImage(std::string filename, MinimalImageB *img){};
47 | void writeImage(std::string filename, MinimalImageB3 *img){};
48 | void writeImage(std::string filename, MinimalImageF *img){};
49 | void writeImage(std::string filename, MinimalImageF3 *img){};
50 |
51 | } // namespace IOWrap
52 |
53 | } // namespace dso
54 |
--------------------------------------------------------------------------------
/src/OptimizationBackend/RawResidualJacobian.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 |
26 | #include "util/NumType.h"
27 |
28 | namespace dso {
29 | struct RawResidualJacobian {
30 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
31 | // ================== new structure: save independently =============.
32 | VecNRf resF;
33 |
34 | // the two rows of d[x,y]/d[xi].
35 | Vec6f Jpdxi[2]; // 2x6
36 |
37 | // the two rows of d[x,y]/d[C].
38 | VecCf Jpdc[2]; // 2x4
39 |
40 | // the two rows of d[x,y]/d[idepth].
41 | Vec2f Jpdd; // 2x1
42 |
43 | // the two columns of d[r]/d[x,y].
44 | VecNRf JIdx[2]; // 9x2
45 |
46 | // = the two columns of d[r] / d[ab]
47 | VecNRf JabF[2]; // 9x2
48 |
49 | // = JIdx^T * JIdx (inner product). Only as a shorthand.
50 | Mat22f JIdx2; // 2x2
51 | // = Jab^T * JIdx (inner product). Only as a shorthand.
52 | Mat22f JabJIdx; // 2x2
53 | // = Jab^T * Jab (inner product). Only as a shorthand.
54 | Mat22f Jab2; // 2x2
55 | };
56 | } // namespace dso
57 |
--------------------------------------------------------------------------------
/src/FullSystem/PixelSelector2.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 |
26 | #include "util/NumType.h"
27 |
28 | namespace dso {
29 |
30 | enum PixelSelectorStatus { PIXSEL_VOID = 0, PIXSEL_1, PIXSEL_2, PIXSEL_3 };
31 |
32 | class FrameHessian;
33 |
34 | class PixelSelector {
35 | public:
36 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
37 | int makeMaps(const FrameHessian *const fh, float *map_out, float density,
38 | int recursionsLeft = 1, bool plot = false, float thFactor = 1);
39 |
40 | PixelSelector(int w, int h);
41 | ~PixelSelector();
42 | int currentPotential;
43 |
44 | bool allowFast;
45 | void makeHists(const FrameHessian *const fh);
46 |
47 | private:
48 | Eigen::Vector3i select(const FrameHessian *const fh, float *map_out, int pot,
49 | float thFactor = 1);
50 |
51 | unsigned char *randomPattern;
52 |
53 | int *gradHist;
54 | float *ths;
55 | float *thsSmoothed;
56 | int thsStep;
57 | const FrameHessian *gradHistFrame;
58 | };
59 |
60 | } // namespace dso
61 |
--------------------------------------------------------------------------------
/src/util/ImageAndExposure.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 | #include
26 | #include
27 |
28 | namespace dso {
29 |
30 | class ImageAndExposure {
31 | public:
32 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
33 | float *image; // irradiance. between 0 and 256
34 | int w, h; // width and height;
35 | double timestamp;
36 | float exposure_time; // exposure time in ms.
37 | inline ImageAndExposure(int w_, int h_, double timestamp_ = 0)
38 | : w(w_), h(h_), timestamp(timestamp_) {
39 | image = new float[w * h];
40 | exposure_time = 1;
41 | }
42 | inline ~ImageAndExposure() { delete[] image; }
43 |
44 | inline void copyMetaTo(ImageAndExposure &other) {
45 | other.exposure_time = exposure_time;
46 | }
47 |
48 | inline ImageAndExposure *getDeepCopy() {
49 | ImageAndExposure *img = new ImageAndExposure(w, h, timestamp);
50 | img->exposure_time = exposure_time;
51 | memcpy(img->image, image, w * h * sizeof(float));
52 | return img;
53 | }
54 | };
55 |
56 | } // namespace dso
57 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | PROJECT(spline_vio)
2 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
3 |
4 | set(BUILD_TYPE Release)
5 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
6 |
7 | find_package(SuiteParse REQUIRED)
8 | find_package(Eigen3 REQUIRED)
9 | find_package(Boost COMPONENTS system thread)
10 | find_package(Pangolin 0.2 REQUIRED)
11 | find_package(OpenCV REQUIRED)
12 | find_package(catkin REQUIRED COMPONENTS
13 | geometry_msgs
14 | roscpp
15 | rosbag
16 | sensor_msgs
17 | cv_bridge
18 | image_transport
19 | )
20 |
21 | catkin_package()
22 |
23 | add_definitions("-DENABLE_SSE")
24 | set(CMAKE_CXX_FLAGS
25 | "${SSE_FLAGS} -O3 -g -std=c++0x -march=native"
26 | )
27 |
28 | include_directories(
29 | src
30 | thirdparty/Sophus
31 | thirdparty/sse2neon
32 | ${EIGEN3_INCLUDE_DIR}
33 | ${catkin_INCLUDE_DIRS}
34 | ${Pangolin_INCLUDE_DIRS}
35 | ${OpenCV_INCLUDE_DIRS}
36 | ${CSPARSE_INCLUDE_DIR}
37 | ${CHOLMOD_INCLUDE_DIR}
38 | )
39 |
40 | add_library(spline_vio_lib
41 | src/FullSystem/FullSystem.cpp
42 | src/FullSystem/FullSystemOptimize.cpp
43 | src/FullSystem/FullSystemOptPoint.cpp
44 | src/FullSystem/FullSystemDebugStuff.cpp
45 | src/FullSystem/FullSystemMarginalize.cpp
46 | src/FullSystem/Residuals.cpp
47 | src/FullSystem/CoarseInitializer.cpp
48 | src/FullSystem/CoarseTracker.cpp
49 | src/FullSystem/ImmaturePoint.cpp
50 | src/FullSystem/HessianBlocks.cpp
51 | src/FullSystem/PixelSelector2.cpp
52 | src/OptimizationBackend/EnergyFunctional.cpp
53 | src/OptimizationBackend/AccumulatedTopHessian.cpp
54 | src/OptimizationBackend/AccumulatedSCHessian.cpp
55 | src/OptimizationBackend/EnergyFunctionalStructs.cpp
56 | src/util/settings.cpp
57 | src/util/Undistort.cpp
58 | src/util/globalCalib.cpp
59 | src/IOWrapper/Pangolin/KeyFrameDisplay.cpp
60 | src/IOWrapper/Pangolin/PangolinDSOViewer.cpp
61 | src/IOWrapper/OpenCV/ImageDisplay_OpenCV.cpp
62 | src/IOWrapper/OpenCV/ImageRW_OpenCV.cpp
63 | )
64 |
65 | add_executable(spline_vio_node src/main.cpp)
66 |
67 | target_link_libraries(spline_vio_node
68 | spline_vio_lib
69 | ${catkin_LIBRARIES}
70 | ${BOOST_THREAD_LIBRARY}
71 | ${Pangolin_LIBRARIES}
72 | ${OpenCV_LIBS}
73 | boost_system boost_thread cxsparse)
74 |
75 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Continuous-Time Spline Visual-Inertial Odometry
2 |
3 | ## Updates
4 | - [June 2022]: The position and acceleration formulation is suboptimal. Please checkout the [new branch](https://github.com/IRVLab/spline_vio/tree/position_spine_in_imu_frame) for improved formulation.
5 |
6 | ## Related Publications
7 | - **Direct Sparse Odometry**, J. Engel, V. Koltun, D. Cremers, In IEEE Transactions on Pattern Analysis and Machine Intelligence (PAMI), 2018
8 | - **Continuous-Time Spline Visual-Inertial Odometry**, J. Mo and J. Sattar, In IEEE International Conference on Robotics and Automation, 2022, [arXiv](https://arxiv.org/abs/2109.09035).
9 |
10 | ## Dependencies
11 | - [ROS](https://www.ros.org/)
12 |
13 | - [DSO dependencies](https://github.com/JakobEngel/dso#2-installation)
14 |
15 | ## Install
16 | ```
17 | cd catkin_ws/src
18 | git clone https://github.com/IRVLab/spline_vio.git
19 | cd ..
20 | catkin_make
21 | ```
22 |
23 | ## Usage
24 | - Use [Kalibr toolbox](https://github.com/ethz-asl/kalibr) to calibrate camera and IMU.
25 |
26 | - Convert camera parameters to [DSO format](https://github.com/JakobEngel/dso#31-dataset-format).
27 |
28 | - Create a launch file following the example of [tum.launch](https://github.com/IRVLab/spline_vio/blob/master/launch/tum.launch).
29 |
30 | ```
31 | roslaunch spline_vio [YOUR_LAUNCH_FILE]
32 | ```
33 |
34 | - Ctrl-C to terminate the program, the final trajectory (results.txt) will be written to ~/Desktop folder by default.
35 |
36 | ## Output file
37 | - results.txt: poses of all frames, using the TUM RGB-D / TUM monoVO format ([timestamp x y z qx qy qz qw] of the cameraToWorld transformation).
38 |
39 | ## Modifications to DSO for this project
40 | - ROS interface: main.cpp
41 | - Predict pose using spine for front-end tracking: FullSystem::trackNewCoarse()
42 | - IMU/Spline state: HessianBlocks.h
43 | - IMU/Spline Jacobians (check [Jacobians.pdf](https://github.com/IRVLab/spline_vio/blob/main/Jacobians.pdf)): HessianBlocks::getImuHi()
44 | - Constraints Jacobians (check [Jacobians.pdf](https://github.com/IRVLab/spline_vio/blob/main/Jacobians.pdf)): EnergyFunctional::getImuHessianCurrentFrame()
45 | - Solve the constraint nonlinear optimization problem: EnergyFunctional::solveSystemF()
46 |
--------------------------------------------------------------------------------
/src/util/FrameShell.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 |
26 | #include "NumType.h"
27 | #include "algorithm"
28 |
29 | namespace dso {
30 |
31 | class FrameShell {
32 | public:
33 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
34 | int id; // INTERNAL ID, starting at zero.
35 | int incoming_id; // ID passed into DSO
36 | double timestamp; // timestamp passed into DSO.
37 |
38 | // set once after tracking
39 | SE3 camToTrackingRef;
40 | FrameShell *trackingRef;
41 |
42 | // constantly adapted.
43 | double scale;
44 | Vec3 velInWorld;
45 | SE3 camToWorld; // Write: TRACKING, while frame is still fresh; MAPPING: only
46 | // when locked [shellPoseMutex].
47 | AffLight aff_g2l;
48 | bool poseValid;
49 |
50 | // statisitcs
51 | int statistics_outlierResOnThis;
52 | int statistics_goodResOnThis;
53 | int marginalizedAt;
54 | double movedByOpt;
55 |
56 | inline FrameShell() {
57 | id = 0;
58 | poseValid = true;
59 | camToWorld = SE3();
60 | timestamp = 0;
61 | marginalizedAt = -1;
62 | movedByOpt = 0;
63 | statistics_outlierResOnThis = statistics_goodResOnThis = 0;
64 | trackingRef = 0;
65 | camToTrackingRef = SE3();
66 | }
67 | };
68 |
69 | } // namespace dso
70 |
--------------------------------------------------------------------------------
/thirdparty/Sophus/sophus/sophus.hpp:
--------------------------------------------------------------------------------
1 | // This file is part of Sophus.
2 | //
3 | // Copyright 2013 Hauke Strasdat
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to
7 | // deal in the Software without restriction, including without limitation the
8 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 | // sell copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 | // IN THE SOFTWARE.
22 |
23 | #ifndef SOPHUS_HPP
24 | #define SOPHUS_HPP
25 |
26 | #include
27 |
28 | // fix log1p not being found on Android in Eigen
29 | #if defined( ANDROID )
30 | #include
31 | namespace std {
32 | using ::log1p;
33 | }
34 | #endif
35 |
36 | #include
37 | #include
38 |
39 | namespace Sophus {
40 | using namespace Eigen;
41 |
42 | template
43 | struct SophusConstants {
44 | EIGEN_ALWAYS_INLINE static
45 | const Scalar epsilon() {
46 | return static_cast(1e-10);
47 | }
48 |
49 | EIGEN_ALWAYS_INLINE static
50 | const Scalar pi() {
51 | return static_cast(M_PI);
52 | }
53 | };
54 |
55 | template<>
56 | struct SophusConstants {
57 | EIGEN_ALWAYS_INLINE static
58 | float epsilon() {
59 | return static_cast(1e-5);
60 | }
61 |
62 | EIGEN_ALWAYS_INLINE static
63 | float pi() {
64 | return static_cast(M_PI);
65 | }
66 | };
67 |
68 | class SophusException : public std::runtime_error {
69 | public:
70 | SophusException (const std::string& str)
71 | : runtime_error("Sophus exception: " + str) {
72 | }
73 | };
74 |
75 | }
76 |
77 | #endif
78 |
--------------------------------------------------------------------------------
/src/IOWrapper/ImageDisplay_dummy.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #include "IOWrapper/ImageDisplay.h"
25 |
26 | namespace dso {
27 |
28 | namespace IOWrap {
29 | void displayImage(const char *windowName, const MinimalImageB *img,
30 | bool autoSize){};
31 | void displayImage(const char *windowName, const MinimalImageB3 *img,
32 | bool autoSize){};
33 | void displayImage(const char *windowName, const MinimalImageF *img,
34 | bool autoSize){};
35 | void displayImage(const char *windowName, const MinimalImageF3 *img,
36 | bool autoSize){};
37 | void displayImage(const char *windowName, const MinimalImageB16 *img,
38 | bool autoSize){};
39 |
40 | void displayImageStitch(const char *windowName,
41 | const std::vector images, int cc,
42 | int rc){};
43 | void displayImageStitch(const char *windowName,
44 | const std::vector images, int cc,
45 | int rc){};
46 | void displayImageStitch(const char *windowName,
47 | const std::vector images, int cc,
48 | int rc){};
49 | void displayImageStitch(const char *windowName,
50 | const std::vector images, int cc,
51 | int rc){};
52 |
53 | int waitKey(int milliseconds) { return 0; };
54 | void closeAllWindows(){};
55 | } // namespace IOWrap
56 |
57 | } // namespace dso
58 |
--------------------------------------------------------------------------------
/src/IOWrapper/ImageDisplay.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 | #include "util/MinimalImage.h"
26 | #include "util/NumType.h"
27 | #include
28 |
29 | namespace dso {
30 |
31 | namespace IOWrap {
32 |
33 | void displayImage(const char *windowName, const MinimalImageB *img,
34 | bool autoSize = false);
35 | void displayImage(const char *windowName, const MinimalImageB3 *img,
36 | bool autoSize = false);
37 | void displayImage(const char *windowName, const MinimalImageF *img,
38 | bool autoSize = false);
39 | void displayImage(const char *windowName, const MinimalImageF3 *img,
40 | bool autoSize = false);
41 | void displayImage(const char *windowName, const MinimalImageB16 *img,
42 | bool autoSize = false);
43 |
44 | void displayImageStitch(const char *windowName,
45 | const std::vector images, int cc = 0,
46 | int rc = 0);
47 | void displayImageStitch(const char *windowName,
48 | const std::vector images, int cc = 0,
49 | int rc = 0);
50 | void displayImageStitch(const char *windowName,
51 | const std::vector images, int cc = 0,
52 | int rc = 0);
53 | void displayImageStitch(const char *windowName,
54 | const std::vector images, int cc = 0,
55 | int rc = 0);
56 |
57 | int waitKey(int milliseconds);
58 | void closeAllWindows();
59 |
60 | } // namespace IOWrap
61 |
62 | } // namespace dso
63 |
--------------------------------------------------------------------------------
/src/FullSystem/Residuals.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 |
26 | #include "util/globalCalib.h"
27 | #include "vector"
28 |
29 | #include "OptimizationBackend/RawResidualJacobian.h"
30 | #include "util/NumType.h"
31 | #include "util/globalFuncs.h"
32 | #include
33 | #include
34 |
35 | namespace dso {
36 | class PointHessian;
37 | class FrameHessian;
38 | class CalibHessian;
39 |
40 | class EFResidual;
41 |
42 | enum ResLocation { ACTIVE = 0, LINEARIZED, MARGINALIZED, NONE };
43 | enum ResState { IN = 0, OOB, OUTLIER };
44 |
45 | struct FullJacRowT {
46 | Eigen::Vector2f projectedTo[MAX_RES_PER_POINT];
47 | };
48 |
49 | class PointFrameResidual {
50 | public:
51 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW
52 |
53 | EFResidual *efResidual;
54 |
55 | static int instanceCounter;
56 |
57 | ResState state_state;
58 | double state_energy;
59 | ResState state_NewState;
60 | double state_NewEnergy;
61 | double state_NewEnergyWithOutlier;
62 |
63 | void setState(ResState s) { state_state = s; }
64 |
65 | PointHessian *point;
66 | FrameHessian *host;
67 | FrameHessian *target;
68 | RawResidualJacobian *J;
69 |
70 | bool isNew;
71 |
72 | Eigen::Vector2f projectedTo[MAX_RES_PER_POINT];
73 | Vec3f centerProjectedTo;
74 |
75 | ~PointFrameResidual();
76 | PointFrameResidual();
77 | PointFrameResidual(PointHessian *point_, FrameHessian *host_,
78 | FrameHessian *target_);
79 | double linearize(CalibHessian *HCalib);
80 |
81 | void resetOOB() {
82 | state_NewEnergy = state_energy = 0;
83 | state_NewState = ResState::OUTLIER;
84 |
85 | setState(ResState::IN);
86 | };
87 | void applyRes(bool copyJacobians);
88 |
89 | void debugPlot();
90 |
91 | void printRows(std::vector &v, VecX &r, int nFrames, int nPoints, int M,
92 | int res);
93 | };
94 | } // namespace dso
95 |
--------------------------------------------------------------------------------
/thirdparty/Sophus/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | SET(PROJECT_NAME Sophus)
2 |
3 | PROJECT(${PROJECT_NAME})
4 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
5 |
6 | SET (CMAKE_VERBOSE_MAKEFILE ON)
7 |
8 | # Release by default
9 | # Turn on Debug with "-DCMAKE_BUILD_TYPE=Debug"
10 | IF( NOT CMAKE_BUILD_TYPE )
11 | SET( CMAKE_BUILD_TYPE Release )
12 | ENDIF()
13 |
14 | IF (CMAKE_COMPILER_IS_GNUCXX )
15 | SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
16 | SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG ")
17 |
18 | ADD_DEFINITIONS("-Wall -Werror -Wno-unused-variable
19 | -Wno-unused-but-set-variable -Wno-unknown-pragmas ")
20 | ENDIF()
21 |
22 | ################################################################################
23 | # Add local path for finding packages, set the local version first
24 | set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" )
25 | list( APPEND CMAKE_MODULE_PATH "${CMAKE_ROOT}/Modules" )
26 |
27 | ################################################################################
28 | # Create variables used for exporting in SophusConfig.cmake
29 | set( Sophus_LIBRARIES "" )
30 | set( Sophus_INCLUDE_DIR ${PROJECT_SOURCE_DIR} )
31 |
32 | ################################################################################
33 |
34 | include(FindEigen3.cmake)
35 | #find_package( Eigen3 REQUIRED )
36 | INCLUDE_DIRECTORIES( ${EIGEN3_INCLUDE_DIR} )
37 | SET( Sophus_INCLUDE_DIR ${Sophus_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIR} )
38 |
39 | SET (SOURCE_DIR "sophus")
40 |
41 | SET (TEMPLATES tests
42 | so2
43 | se2
44 | so3
45 | se3
46 | rxso3
47 | sim3
48 | )
49 |
50 | SET (SOURCES ${SOURCE_DIR}/sophus.hpp)
51 |
52 | FOREACH(templ ${TEMPLATES})
53 | LIST(APPEND SOURCES ${SOURCE_DIR}/${templ}.hpp)
54 | ENDFOREACH(templ)
55 |
56 |
57 | INCLUDE_DIRECTORIES(${INCLUDE_DIRS})
58 |
59 | # Added ${SOURCES} to executables so they show up in QtCreator (and possibly
60 | # other IDEs).
61 | # ADD_EXECUTABLE(test_so2 sophus/test_so2.cpp ${SOURCES})
62 | # ADD_EXECUTABLE(test_se2 sophus/test_se2.cpp ${SOURCES})
63 | # ADD_EXECUTABLE(test_so3 sophus/test_so3.cpp ${SOURCES})
64 | # ADD_EXECUTABLE(test_se3 sophus/test_se3.cpp ${SOURCES})
65 | # ADD_EXECUTABLE(test_rxso3 sophus/test_rxso3.cpp ${SOURCES})
66 | # ADD_EXECUTABLE(test_sim3 sophus/test_sim3.cpp ${SOURCES})
67 | # ENABLE_TESTING()
68 | #
69 | # ADD_TEST(test_so2 test_so2)
70 | # ADD_TEST(test_se2 test_se2)
71 | # ADD_TEST(test_so3 test_so3)
72 | # ADD_TEST(test_se3 test_se3)
73 | # ADD_TEST(test_rxso3 test_rxso3)
74 | # ADD_TEST(test_sim3 test_sim3)
75 |
76 | ################################################################################
77 | # Create the SophusConfig.cmake file for other cmake projects.
78 | CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/SophusConfig.cmake.in
79 | ${CMAKE_CURRENT_BINARY_DIR}/SophusConfig.cmake @ONLY IMMEDIATE )
80 | export( PACKAGE Sophus )
81 |
82 | INSTALL(DIRECTORY sophus DESTINATION ${CMAKE_INSTALL_PREFIX}/include
83 | FILES_MATCHING PATTERN "*.hpp" )
--------------------------------------------------------------------------------
/src/FullSystem/ResidualProjections.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 |
26 | #include "FullSystem.h"
27 | #include "HessianBlocks.h"
28 | #include "util/NumType.h"
29 | #include "util/settings.h"
30 |
31 | namespace dso {
32 |
33 | EIGEN_STRONG_INLINE float derive_idepth(const Vec3f &t, const float &u,
34 | const float &v, const int &dx,
35 | const int &dy, const float &dxInterp,
36 | const float &dyInterp,
37 | const float &drescale) {
38 | return (dxInterp * drescale * (t[0] - t[2] * u) +
39 | dyInterp * drescale * (t[1] - t[2] * v)) *
40 | SCALE_IDEPTH;
41 | }
42 |
43 | EIGEN_STRONG_INLINE bool projectPoint(const float &u_pt, const float &v_pt,
44 | const float &idepth, const Mat33f &KRKi,
45 | const Vec3f &Kt, float &Ku, float &Kv) {
46 | Vec3f ptp = KRKi * Vec3f(u_pt, v_pt, 1) + Kt * idepth;
47 | Ku = ptp[0] / ptp[2];
48 | Kv = ptp[1] / ptp[2];
49 | return Ku > 1.1f && Kv > 1.1f && Ku < wM3G && Kv < hM3G;
50 | }
51 |
52 | EIGEN_STRONG_INLINE bool
53 | projectPoint(const float &u_pt, const float &v_pt, const float &idepth,
54 | const int &dx, const int &dy, CalibHessian *const &HCalib,
55 | const Mat33f &R, const Vec3f &t, float &drescale, float &u,
56 | float &v, float &Ku, float &Kv, Vec3f &KliP, float &new_idepth) {
57 | KliP = Vec3f((u_pt + dx - HCalib->cxl()) * HCalib->fxli(),
58 | (v_pt + dy - HCalib->cyl()) * HCalib->fyli(), 1);
59 |
60 | Vec3f ptp = R * KliP + t * idepth;
61 | drescale = 1.0f / ptp[2];
62 | new_idepth = idepth * drescale;
63 |
64 | if (!(drescale > 0))
65 | return false;
66 |
67 | u = ptp[0] * drescale;
68 | v = ptp[1] * drescale;
69 | Ku = u * HCalib->fxl() + HCalib->cxl();
70 | Kv = v * HCalib->fyl() + HCalib->cyl();
71 |
72 | return Ku > 1.1f && Kv > 1.1f && Ku < wM3G && Kv < hM3G;
73 | }
74 |
75 | } // namespace dso
76 |
--------------------------------------------------------------------------------
/thirdparty/Sophus/sophus/test_so2.cpp:
--------------------------------------------------------------------------------
1 | // This file is part of Sophus.
2 | //
3 | // Copyright 2012-2013 Hauke Strasdat
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to
7 | // deal in the Software without restriction, including without limitation the
8 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 | // sell copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 | // IN THE SOFTWARE.
22 |
23 |
24 | #include
25 | #include
26 |
27 | #include "so2.hpp"
28 | #include "tests.hpp"
29 |
30 | using namespace Sophus;
31 | using namespace std;
32 |
33 | template
34 | void tests() {
35 |
36 | typedef SO2Group SO2Type;
37 | typedef typename SO2Group::Point Point;
38 | typedef typename SO2Group::Tangent Tangent;
39 |
40 | vector so2_vec;
41 | so2_vec.push_back(SO2Type::exp(0.0));
42 | so2_vec.push_back(SO2Type::exp(0.2));
43 | so2_vec.push_back(SO2Type::exp(10.));
44 | so2_vec.push_back(SO2Type::exp(0.00001));
45 | so2_vec.push_back(SO2Type::exp(M_PI));
46 | so2_vec.push_back(SO2Type::exp(0.2)
47 | *SO2Type::exp(M_PI)
48 | *SO2Type::exp(-0.2));
49 | so2_vec.push_back(SO2Type::exp(-0.3)
50 | *SO2Type::exp(M_PI)
51 | *SO2Type::exp(0.3));
52 |
53 | vector tangent_vec;
54 | tangent_vec.push_back(Tangent(0));
55 | tangent_vec.push_back(Tangent(1));
56 | tangent_vec.push_back(Tangent(M_PI_2));
57 | tangent_vec.push_back(Tangent(-1));
58 | tangent_vec.push_back(Tangent(20));
59 | tangent_vec.push_back(Tangent(M_PI_2+0.0001));
60 |
61 | vector point_vec;
62 | point_vec.push_back(Point(1,2));
63 |
64 | Tests tests;
65 | tests.setGroupElements(so2_vec);
66 | tests.setTangentVectors(tangent_vec);
67 | tests.setPoints(point_vec);
68 |
69 | tests.runAllTests();
70 |
71 | cerr << "Exception test: ";
72 | try {
73 | SO2Type so2(0., 0.);
74 | } catch(SophusException & e) {
75 | cerr << "passed." << endl << endl;
76 | return;
77 | }
78 | cerr << "failed!" << endl << endl;
79 | exit(-1);
80 | }
81 |
82 | int main() {
83 | cerr << "Test SO2" << endl << endl;
84 |
85 | cerr << "Double tests: " << endl;
86 | tests();
87 |
88 | cerr << "Float tests: " << endl;
89 | tests();
90 | return 0;
91 | }
92 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/thirdparty/Sophus/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 |
--------------------------------------------------------------------------------
/thirdparty/Sophus/sophus/test_so3.cpp:
--------------------------------------------------------------------------------
1 | // This file is part of Sophus.
2 | //
3 | // Copyright 2012-2013 Hauke Strasdat
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to
7 | // deal in the Software without restriction, including without limitation the
8 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 | // sell copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 | // IN THE SOFTWARE.
22 |
23 | #include
24 | #include
25 |
26 | #include "so3.hpp"
27 | #include "tests.hpp"
28 |
29 | using namespace Sophus;
30 | using namespace std;
31 |
32 | template
33 | void tests() {
34 |
35 | typedef SO3Group SO3Type;
36 | typedef typename SO3Group::Point Point;
37 | typedef typename SO3Group::Tangent Tangent;
38 |
39 | vector so3_vec;
40 |
41 | so3_vec.push_back(SO3Type(Quaternion(0.1e-11, 0., 1., 0.)));
42 | so3_vec.push_back(SO3Type(Quaternion(-1,0.00001,0.0,0.0)));
43 | so3_vec.push_back(SO3Type::exp(Point(0.2, 0.5, 0.0)));
44 | so3_vec.push_back(SO3Type::exp(Point(0.2, 0.5, -1.0)));
45 | so3_vec.push_back(SO3Type::exp(Point(0., 0., 0.)));
46 | so3_vec.push_back(SO3Type::exp(Point(0., 0., 0.00001)));
47 | so3_vec.push_back(SO3Type::exp(Point(M_PI, 0, 0)));
48 | so3_vec.push_back(SO3Type::exp(Point(0.2, 0.5, 0.0))
49 | *SO3Type::exp(Point(M_PI, 0, 0))
50 | *SO3Type::exp(Point(-0.2, -0.5, -0.0)));
51 | so3_vec.push_back(SO3Type::exp(Point(0.3, 0.5, 0.1))
52 | *SO3Type::exp(Point(M_PI, 0, 0))
53 | *SO3Type::exp(Point(-0.3, -0.5, -0.1)));
54 |
55 | vector tangent_vec;
56 | tangent_vec.push_back(Tangent(0,0,0));
57 | tangent_vec.push_back(Tangent(1,0,0));
58 | tangent_vec.push_back(Tangent(0,1,0));
59 | tangent_vec.push_back(Tangent(M_PI_2,M_PI_2,0.0));
60 | tangent_vec.push_back(Tangent(-1,1,0));
61 | tangent_vec.push_back(Tangent(20,-1,0));
62 | tangent_vec.push_back(Tangent(30,5,-1));
63 |
64 | vector point_vec;
65 | point_vec.push_back(Point(1,2,4));
66 |
67 | Tests tests;
68 | tests.setGroupElements(so3_vec);
69 | tests.setTangentVectors(tangent_vec);
70 | tests.setPoints(point_vec);
71 |
72 | tests.runAllTests();
73 | }
74 |
75 | int main() {
76 | cerr << "Test SO3" << endl << endl;
77 |
78 | cerr << "Double tests: " << endl;
79 | tests();
80 |
81 | cerr << "Float tests: " << endl;
82 | tests();
83 | return 0;
84 | }
85 |
--------------------------------------------------------------------------------
/thirdparty/Sophus/sophus/test_se2.cpp:
--------------------------------------------------------------------------------
1 | // This file is part of Sophus.
2 | //
3 | // Copyright 2012-2013 Hauke Strasdat
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to
7 | // deal in the Software without restriction, including without limitation the
8 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 | // sell copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 | // IN THE SOFTWARE.
22 |
23 | #include
24 | #include
25 |
26 | #include
27 | #include "se2.hpp"
28 | #include "tests.hpp"
29 |
30 | using namespace Sophus;
31 | using namespace std;
32 |
33 | template
34 | void tests() {
35 |
36 | typedef SO2Group SO2Type;
37 | typedef SE2Group SE2Type;
38 | typedef typename SE2Group::Point Point;
39 | typedef typename SE2Group::Tangent Tangent;
40 |
41 | vector se2_vec;
42 | se2_vec.push_back(SE2Type(SO2Type(0.0),Point(0,0)));
43 | se2_vec.push_back(SE2Type(SO2Type(0.2),Point(10,0)));
44 | se2_vec.push_back(SE2Type(SO2Type(0.),Point(0,100)));
45 | se2_vec.push_back(SE2Type(SO2Type(-1.),Point(20,-1)));
46 | se2_vec.push_back(SE2Type(SO2Type(0.00001),
47 | Point(-0.00000001,0.0000000001)));
48 | se2_vec.push_back(SE2Type(SO2Type(0.2),Point(0,0))
49 | *SE2Type(SO2Type(M_PI),Point(0,0))
50 | *SE2Type(SO2Type(-0.2),Point(0,0)));
51 | se2_vec.push_back(SE2Type(SO2Type(0.3),Point(2,0))
52 | *SE2Type(SO2Type(M_PI),Point(0,0))
53 | *SE2Type(SO2Type(-0.3),Point(0,6)));
54 |
55 | vector tangent_vec;
56 | Tangent tmp;
57 | tmp << 0,0,0;
58 | tangent_vec.push_back(tmp);
59 | tmp << 1,0,0;
60 | tangent_vec.push_back(tmp);
61 | tmp << 0,1,1;
62 | tangent_vec.push_back(tmp);
63 | tmp << -1,1,0;
64 | tangent_vec.push_back(tmp);
65 | tmp << 20,-1,-1;
66 | tangent_vec.push_back(tmp);
67 | tmp << 30,5,20;
68 | tangent_vec.push_back(tmp);
69 |
70 | vector point_vec;
71 | point_vec.push_back(Point(1,2));
72 |
73 | Tests tests;
74 | tests.setGroupElements(se2_vec);
75 | tests.setTangentVectors(tangent_vec);
76 | tests.setPoints(point_vec);
77 |
78 | tests.runAllTests();
79 | }
80 |
81 | int main() {
82 | cerr << "Test SE2" << endl << endl;
83 |
84 | cerr << "Double tests: " << endl;
85 | tests();
86 |
87 | cerr << "Float tests: " << endl;
88 | tests();
89 | return 0;
90 | }
91 |
--------------------------------------------------------------------------------
/src/FullSystem/ImmaturePoint.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 |
26 | #include "util/NumType.h"
27 |
28 | #include "HessianBlocks.h"
29 | namespace dso {
30 |
31 | struct ImmaturePointTemporaryResidual {
32 | public:
33 | ResState state_state;
34 | double state_energy;
35 | ResState state_NewState;
36 | double state_NewEnergy;
37 | FrameHessian *target;
38 | };
39 |
40 | enum ImmaturePointStatus {
41 | IPS_GOOD = 0, // traced well and good
42 | IPS_OOB, // OOB: end tracking & marginalize!
43 | IPS_OUTLIER, // energy too high: if happens again: outlier!
44 | IPS_SKIPPED, // traced well and good (but not actually traced).
45 | IPS_BADCONDITION, // not traced because of bad condition.
46 | IPS_UNINITIALIZED
47 | }; // not even traced once.
48 |
49 | class ImmaturePoint {
50 | public:
51 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
52 | // static values
53 | float color[MAX_RES_PER_POINT];
54 | float weights[MAX_RES_PER_POINT];
55 |
56 | Mat22f gradH;
57 | Vec2f gradH_ev;
58 | Mat22f gradH_eig;
59 | float energyTH;
60 | float u, v;
61 | FrameHessian *host;
62 | int idxInImmaturePoints;
63 |
64 | float quality;
65 |
66 | float my_type;
67 |
68 | float idepth_min;
69 | float idepth_max;
70 | ImmaturePoint(int u_, int v_, FrameHessian *host_, float type,
71 | CalibHessian *HCalib);
72 | ~ImmaturePoint();
73 |
74 | ImmaturePointStatus traceOn(FrameHessian *frame,
75 | const Mat33f &hostToFrame_KRKi,
76 | const Vec3f &hostToFrame_Kt,
77 | const Vec2f &hostToFrame_affine,
78 | CalibHessian *HCalib, bool debugPrint = false);
79 |
80 | ImmaturePointStatus lastTraceStatus;
81 | Vec2f lastTraceUV;
82 | float lastTracePixelInterval;
83 |
84 | float idepth_GT;
85 |
86 | double linearizeResidual(CalibHessian *HCalib, const float outlierTHSlack,
87 | ImmaturePointTemporaryResidual *tmpRes, float &Hdd,
88 | float &bd, float idepth);
89 | float getdPixdd(CalibHessian *HCalib, ImmaturePointTemporaryResidual *tmpRes,
90 | float idepth);
91 |
92 | float calcResidual(CalibHessian *HCalib, const float outlierTHSlack,
93 | ImmaturePointTemporaryResidual *tmpRes, float idepth);
94 |
95 | private:
96 | };
97 |
98 | } // namespace dso
99 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/src/util/globalCalib.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #include "globalCalib.h"
25 | #include "stdio.h"
26 | #include
27 |
28 | namespace dso {
29 | int wG[PYR_LEVELS], hG[PYR_LEVELS];
30 | float fxG[PYR_LEVELS], fyG[PYR_LEVELS], cxG[PYR_LEVELS], cyG[PYR_LEVELS];
31 |
32 | float fxiG[PYR_LEVELS], fyiG[PYR_LEVELS], cxiG[PYR_LEVELS], cyiG[PYR_LEVELS];
33 |
34 | Eigen::Matrix3f KG[PYR_LEVELS], KiG[PYR_LEVELS];
35 |
36 | float wM3G;
37 | float hM3G;
38 |
39 | void setGlobalCalib(int w, int h, const Eigen::Matrix3f &K) {
40 | int wlvl = w;
41 | int hlvl = h;
42 | pyrLevelsUsed = 1;
43 | while (wlvl % 2 == 0 && hlvl % 2 == 0 && wlvl * hlvl > 5000 &&
44 | pyrLevelsUsed < PYR_LEVELS) {
45 | wlvl /= 2;
46 | hlvl /= 2;
47 | pyrLevelsUsed++;
48 | }
49 | printf("using pyramid levels 0 to %d. coarsest resolution: %d x %d!\n",
50 | pyrLevelsUsed - 1, wlvl, hlvl);
51 | if (wlvl > 100 && hlvl > 100) {
52 | printf("\n\n===============WARNING!===================\n "
53 | "using not enough pyramid levels.\n"
54 | "Consider scaling to a resolution that is a multiple of a power of "
55 | "2.\n");
56 | }
57 | if (pyrLevelsUsed < 3) {
58 | printf("\n\n===============WARNING!===================\n "
59 | "I need higher resolution.\n"
60 | "I will probably segfault.\n");
61 | }
62 |
63 | wM3G = w - 3;
64 | hM3G = h - 3;
65 |
66 | wG[0] = w;
67 | hG[0] = h;
68 | KG[0] = K;
69 | fxG[0] = K(0, 0);
70 | fyG[0] = K(1, 1);
71 | cxG[0] = K(0, 2);
72 | cyG[0] = K(1, 2);
73 | KiG[0] = KG[0].inverse();
74 | fxiG[0] = KiG[0](0, 0);
75 | fyiG[0] = KiG[0](1, 1);
76 | cxiG[0] = KiG[0](0, 2);
77 | cyiG[0] = KiG[0](1, 2);
78 |
79 | for (int level = 1; level < pyrLevelsUsed; ++level) {
80 | wG[level] = w >> level;
81 | hG[level] = h >> level;
82 |
83 | fxG[level] = fxG[level - 1] * 0.5;
84 | fyG[level] = fyG[level - 1] * 0.5;
85 | cxG[level] = (cxG[0] + 0.5) / ((int)1 << level) - 0.5;
86 | cyG[level] = (cyG[0] + 0.5) / ((int)1 << level) - 0.5;
87 |
88 | KG[level] << fxG[level], 0.0, cxG[level], 0.0, fyG[level], cyG[level], 0.0,
89 | 0.0, 1.0; // synthetic
90 | KiG[level] = KG[level].inverse();
91 |
92 | fxiG[level] = KiG[level](0, 0);
93 | fyiG[level] = KiG[level](1, 1);
94 | cxiG[level] = KiG[level](0, 2);
95 | cyiG[level] = KiG[level](1, 2);
96 | }
97 | }
98 |
99 | } // namespace dso
100 |
--------------------------------------------------------------------------------
/thirdparty/Sophus/sophus/test_rxso3.cpp:
--------------------------------------------------------------------------------
1 | // This file is part of Sophus.
2 | //
3 | // Copyright 2012-2013 Hauke Strasdat
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to
7 | // deal in the Software without restriction, including without limitation the
8 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 | // sell copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 | // IN THE SOFTWARE.
22 |
23 | #include
24 | #include
25 |
26 |
27 | #include "rxso3.hpp"
28 | #include "tests.hpp"
29 |
30 | using namespace Sophus;
31 | using namespace std;
32 |
33 | template
34 | void tests() {
35 |
36 | typedef RxSO3Group RxSO3Type;
37 | typedef typename RxSO3Group::Point Point;
38 | typedef typename RxSO3Group::Tangent Tangent;
39 |
40 | vector rxso3_vec;
41 | rxso3_vec.push_back(RxSO3Type::exp(Tangent(0.2, 0.5, 0.0, 1.)));
42 | rxso3_vec.push_back(RxSO3Type::exp(Tangent(0.2, 0.5, -1.0, 1.1)));
43 | rxso3_vec.push_back(RxSO3Type::exp(Tangent(0., 0., 0., 1.1)));
44 | rxso3_vec.push_back(RxSO3Type::exp(Tangent(0., 0., 0.00001, 0.)));
45 | rxso3_vec.push_back(RxSO3Type::exp(Tangent(0., 0., 0.00001, 0.00001)));
46 | rxso3_vec.push_back(RxSO3Type::exp(Tangent(0., 0., 0.00001, 0)));
47 | rxso3_vec.push_back(RxSO3Type::exp(Tangent(M_PI, 0, 0, 0.9)));
48 | rxso3_vec.push_back(RxSO3Type::exp(Tangent(0.2, 0.5, 0.0,0))
49 | *RxSO3Type::exp(Tangent(M_PI, 0, 0,0.0))
50 | *RxSO3Type::exp(Tangent(-0.2, -0.5, -0.0,0)));
51 | rxso3_vec.push_back(RxSO3Type::exp(Tangent(0.3, 0.5, 0.1,0))
52 | *RxSO3Type::exp(Tangent(M_PI, 0, 0,0))
53 | *RxSO3Type::exp(Tangent(-0.3, -0.5, -0.1,0)));
54 |
55 | vector tangent_vec;
56 | Tangent tmp;
57 | tmp << 0,0,0,0;
58 | tangent_vec.push_back(tmp);
59 | tmp << 1,0,0,0;
60 | tangent_vec.push_back(tmp);
61 | tmp << 1,0,0,0.1;
62 | tangent_vec.push_back(tmp);
63 | tmp << 0,1,0,0.1;
64 | tangent_vec.push_back(tmp);
65 | tmp << 0,0,1,-0.1;
66 | tangent_vec.push_back(tmp);
67 | tmp << -1,1,0,-0.1;
68 | tangent_vec.push_back(tmp);
69 | tmp << 20,-1,0,2;
70 | tangent_vec.push_back(tmp);
71 |
72 | vector point_vec;
73 | point_vec.push_back(Point(1,2,4));
74 |
75 | Tests tests;
76 | tests.setGroupElements(rxso3_vec);
77 | tests.setTangentVectors(tangent_vec);
78 | tests.setPoints(point_vec);
79 |
80 | tests.runAllTests();
81 | }
82 |
83 | int main() {
84 | cerr << "Test RxSO3" << endl << endl;
85 |
86 | cerr << "Double tests: " << endl;
87 | tests();
88 |
89 | cerr << "Float tests: " << endl;
90 | tests();
91 | return 0;
92 | }
93 |
--------------------------------------------------------------------------------
/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 |
35 | namespace dso
36 | {
37 | class CalibHessian;
38 | class FrameHessian;
39 | class FrameShell;
40 |
41 | namespace IOWrap
42 | {
43 |
44 | template
45 | struct InputPointSparse
46 | {
47 | float u;
48 | float v;
49 | float idpeth;
50 | float idepth_hessian;
51 | float relObsBaseline;
52 | int numGoodRes;
53 | unsigned char color[ppp];
54 | unsigned char status;
55 | };
56 |
57 | struct MyVertex
58 | {
59 | float point[3];
60 | unsigned char color[4];
61 | };
62 |
63 | // stores a pointcloud associated to a Keyframe.
64 | class KeyFrameDisplay
65 | {
66 |
67 | public:
68 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
69 | KeyFrameDisplay();
70 | ~KeyFrameDisplay();
71 |
72 | // copies points from KF over to internal buffer,
73 | // keeping some additional information so we can render it differently.
74 | void setFromKF(FrameHessian* fh, CalibHessian* HCalib);
75 |
76 | // copies points from KF over to internal buffer,
77 | // keeping some additional information so we can render it differently.
78 | void setFromF(FrameShell* fs, CalibHessian* HCalib);
79 |
80 | // copies & filters internal data to GL buffer for rendering. if nothing to do: does nothing.
81 | bool refreshPC(bool canRefresh, float scaledTH, float absTH, int mode, float minBS, int sparsity);
82 |
83 | // renders cam & pointcloud.
84 | void drawCam(float lineWidth = 1, float* color = 0, float sizeFactor=1);
85 | void drawPC(float pointSize);
86 |
87 | int id;
88 | bool active;
89 | SE3 camToWorld;
90 |
91 | inline bool operator < (const KeyFrameDisplay& other) const
92 | {
93 | return (id < other.id);
94 | }
95 |
96 |
97 | private:
98 | float fx,fy,cx,cy;
99 | float fxi,fyi,cxi,cyi;
100 | int width, height;
101 |
102 | float my_scaledTH, my_absTH, my_scale;
103 | int my_sparsifyFactor;
104 | int my_displayMode;
105 | float my_minRelBS;
106 | bool needRefresh;
107 |
108 |
109 | int numSparsePoints;
110 | int numSparseBufferSize;
111 | InputPointSparse* originalInputSparse;
112 |
113 |
114 | bool bufferValid;
115 | int numGLBufferPoints;
116 | int numGLBufferGoodPoints;
117 | pangolin::GlBuffer vertexBuffer;
118 | pangolin::GlBuffer colorBuffer;
119 | };
120 |
121 | }
122 | }
123 |
124 |
--------------------------------------------------------------------------------
/src/util/MinimalImage.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 |
26 | #include "NumType.h"
27 | #include "algorithm"
28 |
29 | namespace dso {
30 |
31 | template class MinimalImage {
32 | public:
33 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW
34 | int w;
35 | int h;
36 | T *data;
37 |
38 | /*
39 | * creates minimal image with own memory
40 | */
41 | inline MinimalImage(int w_, int h_) : w(w_), h(h_) {
42 | data = new T[w * h];
43 | ownData = true;
44 | }
45 |
46 | /*
47 | * creates minimal image wrapping around existing memory
48 | */
49 | inline MinimalImage(int w_, int h_, T *data_) : w(w_), h(h_) {
50 | data = data_;
51 | ownData = false;
52 | }
53 |
54 | inline ~MinimalImage() {
55 | if (ownData)
56 | delete[] data;
57 | }
58 |
59 | inline MinimalImage *getClone() {
60 | MinimalImage *clone = new MinimalImage(w, h);
61 | memcpy(clone->data, data, sizeof(T) * w * h);
62 | return clone;
63 | }
64 |
65 | inline T &at(int x, int y) { return data[(int)x + ((int)y) * w]; }
66 | inline T &at(int i) { return data[i]; }
67 |
68 | inline void setBlack() { memset(data, 0, sizeof(T) * w * h); }
69 |
70 | inline void setConst(T val) {
71 | for (int i = 0; i < w * h; i++)
72 | data[i] = val;
73 | }
74 |
75 | inline void setPixel1(const float &u, const float &v, T val) {
76 | at(u + 0.5f, v + 0.5f) = val;
77 | }
78 |
79 | inline void setPixel4(const float &u, const float &v, T val) {
80 | at(u + 1.0f, v + 1.0f) = val;
81 | at(u + 1.0f, v) = val;
82 | at(u, v + 1.0f) = val;
83 | at(u, v) = val;
84 | }
85 |
86 | inline void setPixel9(const int &u, const int &v, T val) {
87 | at(u + 1, v - 1) = val;
88 | at(u + 1, v) = val;
89 | at(u + 1, v + 1) = val;
90 | at(u, v - 1) = val;
91 | at(u, v) = val;
92 | at(u, v + 1) = val;
93 | at(u - 1, v - 1) = val;
94 | at(u - 1, v) = val;
95 | at(u - 1, v + 1) = val;
96 | }
97 |
98 | inline void setPixelCirc(const int &u, const int &v, T val) {
99 | for (int i = -3; i <= 3; i++) {
100 | at(u + 3, v + i) = val;
101 | at(u - 3, v + i) = val;
102 | at(u + 2, v + i) = val;
103 | at(u - 2, v + i) = val;
104 |
105 | at(u + i, v - 3) = val;
106 | at(u + i, v + 3) = val;
107 | at(u + i, v - 2) = val;
108 | at(u + i, v + 2) = val;
109 | }
110 | }
111 |
112 | private:
113 | bool ownData;
114 | };
115 |
116 | typedef Eigen::Matrix Vec3b;
117 | typedef MinimalImage MinimalImageF;
118 | typedef MinimalImage MinimalImageF3;
119 | typedef MinimalImage MinimalImageB;
120 | typedef MinimalImage MinimalImageB3;
121 | typedef MinimalImage MinimalImageB16;
122 |
123 | } // namespace dso
124 |
--------------------------------------------------------------------------------
/src/OptimizationBackend/EnergyFunctionalStructs.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #pragma once
25 |
26 | #include "RawResidualJacobian.h"
27 | #include "util/NumType.h"
28 | #include "vector"
29 | #include
30 |
31 | namespace dso {
32 |
33 | class PointFrameResidual;
34 | class CalibHessian;
35 | class FrameHessian;
36 | class PointHessian;
37 |
38 | class EFResidual;
39 | class EFPoint;
40 | class EFFrame;
41 | class EnergyFunctional;
42 |
43 | class EFResidual {
44 | public:
45 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
46 |
47 | inline EFResidual(PointFrameResidual *org, EFPoint *point_, EFFrame *host_,
48 | EFFrame *target_)
49 | : data(org), point(point_), host(host_), target(target_) {
50 | isLinearized = false;
51 | isActiveAndIsGoodNEW = false;
52 | J = new RawResidualJacobian();
53 | assert(((long)this) % 16 == 0);
54 | assert(((long)J) % 16 == 0);
55 | }
56 | inline ~EFResidual() { delete J; }
57 |
58 | void takeDataF();
59 |
60 | void fixLinearizationF(EnergyFunctional *ef);
61 |
62 | // structural pointers
63 | PointFrameResidual *data;
64 | int hostIDX, targetIDX;
65 | EFPoint *point;
66 | EFFrame *host;
67 | EFFrame *target;
68 | int idxInAll;
69 |
70 | RawResidualJacobian *J;
71 |
72 | VecNRf res_toZeroF;
73 | Vec8f JpJdF;
74 |
75 | // status.
76 | bool isLinearized;
77 |
78 | // if residual is not OOB & not OUTLIER & should be used during accumulations
79 | bool isActiveAndIsGoodNEW;
80 | inline const bool &isActive() const { return isActiveAndIsGoodNEW; }
81 | };
82 |
83 | enum EFPointStatus { PS_GOOD = 0, PS_MARGINALIZE, PS_DROP };
84 |
85 | class EFPoint {
86 | public:
87 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
88 | EFPoint(PointHessian *d, EFFrame *host_) : data(d), host(host_) {
89 | takeData();
90 | stateFlag = EFPointStatus::PS_GOOD;
91 | }
92 | void takeData();
93 |
94 | PointHessian *data;
95 |
96 | float priorF;
97 | float deltaF;
98 |
99 | // constant info (never changes in-between).
100 | int idxInPoints;
101 | EFFrame *host;
102 |
103 | // contains all residuals.
104 | std::vector residualsAll;
105 |
106 | float bdSumF;
107 | float HdiF;
108 | float Hdd_accLF;
109 | VecCf Hcd_accLF;
110 | float bd_accLF;
111 | float Hdd_accAF;
112 | VecCf Hcd_accAF;
113 | float bd_accAF;
114 |
115 | EFPointStatus stateFlag;
116 | };
117 |
118 | class EFFrame {
119 | public:
120 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
121 | EFFrame(FrameHessian *d) : data(d) { takeData(); }
122 | void takeData();
123 |
124 | Vec8 prior; // prior hessian (diagonal)
125 | Vec8 delta_prior; // = state-state_prior (E_prior = (delta_prior)' *
126 | // diag(prior) * (delta_prior)
127 | Vec8 delta; // state - state_zero.
128 |
129 | std::vector points;
130 | FrameHessian *data;
131 | int idx; // idx in frames.
132 |
133 | int frameID;
134 | };
135 |
136 | } // namespace dso
137 |
--------------------------------------------------------------------------------
/src/OptimizationBackend/EnergyFunctionalStructs.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of DSO.
3 | *
4 | * Copyright 2016 Technical University of Munich and Intel.
5 | * Developed by Jakob Engel ,
6 | * for more information see .
7 | * If you use this code, please cite the respective publications as
8 | * listed on the above website.
9 | *
10 | * DSO is free software: you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation, either version 3 of the License, or
13 | * (at your option) any later version.
14 | *
15 | * DSO is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with DSO. If not, see .
22 | */
23 |
24 | #include "EnergyFunctionalStructs.h"
25 | #include "EnergyFunctional.h"
26 | #include "FullSystem/FullSystem.h"
27 | #include "FullSystem/HessianBlocks.h"
28 | #include "FullSystem/Residuals.h"
29 |
30 | #if !defined(__SSE3__) && !defined(__SSE2__) && !defined(__SSE1__)
31 | #include "SSE2NEON.h"
32 | #endif
33 |
34 | namespace dso {
35 |
36 | void EFResidual::takeDataF() {
37 | std::swap(J, data->J);
38 |
39 | Vec2f JI_JI_Jd = J->JIdx2 * J->Jpdd;
40 |
41 | for (int i = 0; i < 6; i++)
42 | JpJdF[i] = J->Jpdxi[0][i] * JI_JI_Jd[0] + J->Jpdxi[1][i] * JI_JI_Jd[1];
43 |
44 | JpJdF.segment<2>(6) = J->JabJIdx * J->Jpdd;
45 | }
46 |
47 | void EFFrame::takeData() {
48 | prior = data->getPrior().head<8>();
49 | delta = data->get_state_minus_stateZero().head<8>();
50 | delta_prior = (data->get_state() - data->getPriorZero()).head<8>();
51 |
52 | // Vec10 state_zero = data->get_state_zero();
53 | // state_zero.segment<3>(0) = SCALE_XI_TRANS * state_zero.segment<3>(0);
54 | // state_zero.segment<3>(3) = SCALE_XI_ROT * state_zero.segment<3>(3);
55 | // state_zero[6] = SCALE_A * state_zero[6];
56 | // state_zero[7] = SCALE_B * state_zero[7];
57 | // state_zero[8] = SCALE_A * state_zero[8];
58 | // state_zero[9] = SCALE_B * state_zero[9];
59 | //
60 | // std::cout << "state_zero: " << state_zero.transpose() << "\n";
61 |
62 | assert(data->frameID != -1);
63 |
64 | frameID = data->frameID;
65 | }
66 |
67 | void EFPoint::takeData() {
68 | priorF = data->hasDepthPrior
69 | ? setting_idepthFixPrior * SCALE_IDEPTH * SCALE_IDEPTH
70 | : 0;
71 |
72 | deltaF = data->idepth - data->idepth_zero;
73 | }
74 |
75 | void EFResidual::fixLinearizationF(EnergyFunctional *ef) {
76 | Vec8f dp = ef->adHTdeltaF[hostIDX + ef->nFrames * targetIDX];
77 |
78 | // compute Jp*delta
79 | __m128 Jp_delta_x =
80 | _mm_set1_ps(J->Jpdxi[0].dot(dp.head<6>()) + J->Jpdc[0].dot(ef->cDeltaF) +
81 | J->Jpdd[0] * point->deltaF);
82 | __m128 Jp_delta_y =
83 | _mm_set1_ps(J->Jpdxi[1].dot(dp.head<6>()) + J->Jpdc[1].dot(ef->cDeltaF) +
84 | J->Jpdd[1] * point->deltaF);
85 | __m128 delta_a = _mm_set1_ps((float)(dp[6]));
86 | __m128 delta_b = _mm_set1_ps((float)(dp[7]));
87 |
88 | for (int i = 0; i < patternNum; i += 4) {
89 | // PATTERN: rtz = resF - [JI*Jp Ja]*delta.
90 | __m128 rtz = _mm_load_ps(((float *)&J->resF) + i);
91 | rtz = _mm_sub_ps(
92 | rtz, _mm_mul_ps(_mm_load_ps(((float *)(J->JIdx)) + i), Jp_delta_x));
93 | rtz = _mm_sub_ps(
94 | rtz, _mm_mul_ps(_mm_load_ps(((float *)(J->JIdx + 1)) + i), Jp_delta_y));
95 | rtz = _mm_sub_ps(
96 | rtz, _mm_mul_ps(_mm_load_ps(((float *)(J->JabF)) + i), delta_a));
97 | rtz = _mm_sub_ps(
98 | rtz, _mm_mul_ps(_mm_load_ps(((float *)(J->JabF + 1)) + i), delta_b));
99 | _mm_store_ps(((float *)&res_toZeroF) + i, rtz);
100 | }
101 |
102 | isLinearized = true;
103 | }
104 |
105 | } // namespace dso
106 |
--------------------------------------------------------------------------------
/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 |
29 |
30 | namespace dso
31 | {
32 |
33 | namespace IOWrap
34 | {
35 | MinimalImageB* readImageBW_8U(std::string filename)
36 | {
37 | cv::Mat m = cv::imread(filename, cv::IMREAD_GRAYSCALE);
38 | if(m.rows*m.cols==0)
39 | {
40 | printf("cv::imread could not read image %s! this may segfault. \n", filename.c_str());
41 | return 0;
42 | }
43 | if(m.type() != CV_8U)
44 | {
45 | printf("cv::imread did something strange! this may segfault. \n");
46 | return 0;
47 | }
48 | MinimalImageB* img = new MinimalImageB(m.cols, m.rows);
49 | memcpy(img->data, m.data, m.rows*m.cols);
50 | return img;
51 | }
52 |
53 | MinimalImageB3* readImageRGB_8U(std::string filename)
54 | {
55 | cv::Mat m = cv::imread(filename, cv::IMREAD_COLOR);
56 | if(m.rows*m.cols==0)
57 | {
58 | printf("cv::imread could not read image %s! this may segfault. \n", filename.c_str());
59 | return 0;
60 | }
61 | if(m.type() != CV_8UC3)
62 | {
63 | printf("cv::imread did something strange! this may segfault. \n");
64 | return 0;
65 | }
66 | MinimalImageB3* img = new MinimalImageB3(m.cols, m.rows);
67 | memcpy(img->data, m.data, 3*m.rows*m.cols);
68 | return img;
69 | }
70 |
71 | MinimalImage* readImageBW_16U(std::string filename)
72 | {
73 | cv::Mat m = cv::imread(filename, cv::IMREAD_UNCHANGED);
74 | if(m.rows*m.cols==0)
75 | {
76 | printf("cv::imread could not read image %s! this may segfault. \n", filename.c_str());
77 | return 0;
78 | }
79 | if(m.type() != CV_16U)
80 | {
81 | printf("readImageBW_16U called on image that is not a 16bit grayscale image. this may segfault. \n");
82 | return 0;
83 | }
84 | MinimalImage* img = new MinimalImage(m.cols, m.rows);
85 | memcpy(img->data, m.data, 2*m.rows*m.cols);
86 | return img;
87 | }
88 |
89 | MinimalImageB* readStreamBW_8U(char* data, int numBytes)
90 | {
91 | cv::Mat m = cv::imdecode(cv::Mat(numBytes,1,CV_8U, data), cv::IMREAD_GRAYSCALE);
92 | if(m.rows*m.cols==0)
93 | {
94 | printf("cv::imdecode could not read stream (%d bytes)! this may segfault. \n", numBytes);
95 | return 0;
96 | }
97 | if(m.type() != CV_8U)
98 | {
99 | printf("cv::imdecode did something strange! this may segfault. \n");
100 | return 0;
101 | }
102 | MinimalImageB* img = new MinimalImageB(m.cols, m.rows);
103 | memcpy(img->data, m.data, m.rows*m.cols);
104 | return img;
105 | }
106 |
107 |
108 |
109 | void writeImage(std::string filename, MinimalImageB* img)
110 | {
111 | cv::imwrite(filename, cv::Mat(img->h, img->w, CV_8U, img->data));
112 | }
113 | void writeImage(std::string filename, MinimalImageB3* img)
114 | {
115 | cv::imwrite(filename, cv::Mat(img->h, img->w, CV_8UC3, img->data));
116 | }
117 | void writeImage(std::string filename, MinimalImageF* img)
118 | {
119 | cv::imwrite(filename, cv::Mat(img->h, img->w, CV_32F, img->data));
120 | }
121 | void writeImage(std::string filename, MinimalImageF3* img)
122 | {
123 | cv::imwrite(filename, cv::Mat(img->h, img->w, CV_32FC3, img->data));
124 | }
125 |
126 | }
127 |
128 | }
129 |
--------------------------------------------------------------------------------
/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