From 5784f4d6364bba92e2771e69049d407872f1ab96 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Fri, 1 Dec 2017 14:29:36 +0100 Subject: [PATCH 01/28] Fix declarations of aligned allocators. It seems like you might need a `const` for the first argument of `std::pair` in `aligned_allocator`, see #111. Added some `override` statements to Output3DWrapper's derived classes. --- src/IOWrapper/Output3DWrapper.h | 2 +- .../OutputWrapper/SampleOutputWrapper.h | 14 +++++++------- src/IOWrapper/Pangolin/PangolinDSOViewer.cpp | 2 +- src/IOWrapper/Pangolin/PangolinDSOViewer.h | 16 ++++++++-------- src/OptimizationBackend/EnergyFunctional.h | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/IOWrapper/Output3DWrapper.h b/src/IOWrapper/Output3DWrapper.h index d3ddf1531..897ab3ad1 100644 --- a/src/IOWrapper/Output3DWrapper.h +++ b/src/IOWrapper/Output3DWrapper.h @@ -127,7 +127,7 @@ class Output3DWrapper * Calling: * Always called, no overhead if not used. */ - virtual void publishGraph(const std::map, Eigen::aligned_allocator > > &connectivity) {} + virtual void publishGraph(const std::map, Eigen::aligned_allocator > > &connectivity) {} diff --git a/src/IOWrapper/OutputWrapper/SampleOutputWrapper.h b/src/IOWrapper/OutputWrapper/SampleOutputWrapper.h index 2d2e2415b..d7d1b1ab3 100644 --- a/src/IOWrapper/OutputWrapper/SampleOutputWrapper.h +++ b/src/IOWrapper/OutputWrapper/SampleOutputWrapper.h @@ -56,7 +56,7 @@ class SampleOutputWrapper : public Output3DWrapper printf("OUT: Destroyed SampleOutputWrapper\n"); } - virtual void publishGraph(const std::map &connectivity) + virtual void publishGraph(const std::map, Eigen::aligned_allocator>> &connectivity) override { printf("OUT: got graph with %d edges\n", (int)connectivity.size()); @@ -74,7 +74,7 @@ class SampleOutputWrapper : public Output3DWrapper - virtual void publishKeyframes( std::vector &frames, bool final, CalibHessian* HCalib) + virtual void publishKeyframes( std::vector &frames, bool final, CalibHessian* HCalib) override { for(FrameHessian* f : frames) { @@ -98,7 +98,7 @@ class SampleOutputWrapper : public Output3DWrapper } } - virtual void publishCamPose(FrameShell* frame, CalibHessian* HCalib) + virtual void publishCamPose(FrameShell* frame, CalibHessian* HCalib) override { printf("OUT: Current Frame %d (time %f, internal ID %d). CameraToWorld:\n", frame->incoming_id, @@ -108,21 +108,21 @@ class SampleOutputWrapper : public Output3DWrapper } - virtual void pushLiveFrame(FrameHessian* image) + virtual void pushLiveFrame(FrameHessian* image) override { // can be used to get the raw image / intensity pyramid. } - virtual void pushDepthImage(MinimalImageB3* image) + virtual void pushDepthImage(MinimalImageB3* image) override { // can be used to get the raw image with depth overlay. } - virtual bool needPushDepthImage() + virtual bool needPushDepthImage() override { return false; } - virtual void pushDepthImageFloat(MinimalImageF* image, FrameHessian* KF ) + virtual void pushDepthImageFloat(MinimalImageF* image, FrameHessian* KF ) override { printf("OUT: Predicted depth for KF %d (id %d, time %f, internal frame-ID %d). CameraToWorld:\n", KF->frameID, diff --git a/src/IOWrapper/Pangolin/PangolinDSOViewer.cpp b/src/IOWrapper/Pangolin/PangolinDSOViewer.cpp index a2fdc6009..b97aa7861 100644 --- a/src/IOWrapper/Pangolin/PangolinDSOViewer.cpp +++ b/src/IOWrapper/Pangolin/PangolinDSOViewer.cpp @@ -419,7 +419,7 @@ void PangolinDSOViewer::drawConstraints() -void PangolinDSOViewer::publishGraph(const std::map &connectivity) +void PangolinDSOViewer::publishGraph(const std::map, Eigen::aligned_allocator>> &connectivity) { if(!setting_render_display3D) return; if(disableAllDisplay) return; diff --git a/src/IOWrapper/Pangolin/PangolinDSOViewer.h b/src/IOWrapper/Pangolin/PangolinDSOViewer.h index c87936231..c10e7a2e7 100644 --- a/src/IOWrapper/Pangolin/PangolinDSOViewer.h +++ b/src/IOWrapper/Pangolin/PangolinDSOViewer.h @@ -67,18 +67,18 @@ class PangolinDSOViewer : public Output3DWrapper // ==================== Output3DWrapper Functionality ====================== - virtual void publishGraph(const std::map &connectivity); - virtual void publishKeyframes( std::vector &frames, bool final, CalibHessian* HCalib); - virtual void publishCamPose(FrameShell* frame, CalibHessian* HCalib); + virtual void publishGraph(const std::map, Eigen::aligned_allocator>> &connectivity) override; + virtual void publishKeyframes( std::vector &frames, bool final, CalibHessian* HCalib) override; + virtual void publishCamPose(FrameShell* frame, CalibHessian* HCalib) override; - virtual void pushLiveFrame(FrameHessian* image); - virtual void pushDepthImage(MinimalImageB3* image); - virtual bool needPushDepthImage(); + virtual void pushLiveFrame(FrameHessian* image) override; + virtual void pushDepthImage(MinimalImageB3* image) override; + virtual bool needPushDepthImage() override; - virtual void join(); + virtual void join() override; - virtual void reset(); + virtual void reset() override; private: bool needReset; diff --git a/src/OptimizationBackend/EnergyFunctional.h b/src/OptimizationBackend/EnergyFunctional.h index 16d8bb920..93e463089 100644 --- a/src/OptimizationBackend/EnergyFunctional.h +++ b/src/OptimizationBackend/EnergyFunctional.h @@ -117,7 +117,7 @@ class EnergyFunctional { std::map, - Eigen::aligned_allocator> + Eigen::aligned_allocator> > connectivityMap; private: From f9cfd9444e6992e5a5b70f488593b77408e2d497 Mon Sep 17 00:00:00 2001 From: Javier Hidalgo-Carrio Date: Mon, 12 Dec 2016 18:30:16 +0100 Subject: [PATCH 02/28] cmake: option to build static/dynamic library. include installation of files. --- CMakeLists.txt | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f137ecb1..26d5ed5ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ set(CMAKE_CXX_FLAGS "${SSE_FLAGS} -O3 -g -std=c++0x -march=native" # "${SSE_FLAGS} -O3 -g -std=c++0x -fno-omit-frame-pointer" ) +option(DSO_BUILD_STATIC_LIBRARY "Build a static dso library, instead of shared" ON) if (MSVC) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") @@ -109,9 +110,27 @@ endif() # compile main library. -include_directories( ${CSPARSE_INCLUDE_DIR} ${CHOLMOD_INCLUDE_DIR}) -add_library(dso ${dso_SOURCE_FILES} ${dso_opencv_SOURCE_FILES} ${dso_pangolin_SOURCE_FILES}) +include_directories( ${CSPARSE_INCLUDE_DIR} ${CHOLMOD_INCLUDE_DIR}) +if (DSO_BUILD_STATIC_LIBRARY) + message("--- dso static library selected.") + add_library(dso ${dso_SOURCE_FILES} ${dso_opencv_SOURCE_FILES} ${dso_pangolin_SOURCE_FILES}) + install (TARGETS dso ARCHIVE DESTINATION lib COMPONENT libraries) +else() + message("--- dso dynamic library selected.") + add_library(dso SHARED ${dso_SOURCE_FILES} ${dso_opencv_SOURCE_FILES} ${dso_pangolin_SOURCE_FILES}) + target_link_libraries(dso boost_system boost_thread cxsparse) + if (HAS_ZIPLIB) + target_link_libraries(dso ${LIBZIP_LIBRARY}) + endif() + if (HAS_PANGOLIN) + target_link_libraries(dso ${Pangolin_LIBRARIES}) + endif() + if (HAS_OPENCV) + target_link_libraries(dso ${OpenCV_LIBS}) + endif() + install (TARGETS dso LIBRARY DESTINATION lib COMPONENT libraries) +endif() #set_property( TARGET dso APPEND_STRING PROPERTY COMPILE_FLAGS -Wall ) @@ -130,3 +149,15 @@ else() message("--- not building dso_dataset, since either don't have openCV or Pangolin.") endif() +file(GLOB dso_HEADER_FILES "${PROJECT_SOURCE_DIR}/src/FullSystem/*.h") + +install (FILES ${dso_HEADER_FILES} DESTINATION include/dso/FullSystem) + +file(GLOB dso_HEADER_FILES "${PROJECT_SOURCE_DIR}/src/OptimizationBackend/*.h") + +install (FILES ${dso_HEADER_FILES} DESTINATION include/dso/OptimizationBackend) + +file(GLOB dso_HEADER_FILES "${PROJECT_SOURCE_DIR}/src/util/*.h") + +install (FILES ${dso_HEADER_FILES} DESTINATION include/dso/util) + From e7423617ab501e59d478b98ef4d85a9161ee21f5 Mon Sep 17 00:00:00 2001 From: Javier Hidalgo-Carrio Date: Tue, 13 Dec 2016 12:22:20 +0100 Subject: [PATCH 03/28] cmake: use variable for the installation path --- CMakeLists.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 26d5ed5ff..9232a6047 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,8 @@ set(BUILD_TYPE Release) set(EXECUTABLE_OUTPUT_PATH bin) set(LIBRARY_OUTPUT_PATH lib) +set(INCLUDE_OUTPUT_PATH include/dso) +set(CMAKE_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH}/cmake/dso) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # required libraries @@ -115,7 +117,7 @@ include_directories( ${CSPARSE_INCLUDE_DIR} ${CHOLMOD_INCLUDE_DIR}) if (DSO_BUILD_STATIC_LIBRARY) message("--- dso static library selected.") add_library(dso ${dso_SOURCE_FILES} ${dso_opencv_SOURCE_FILES} ${dso_pangolin_SOURCE_FILES}) - install (TARGETS dso ARCHIVE DESTINATION lib COMPONENT libraries) + install (TARGETS dso ARCHIVE DESTINATION ${LIBRARY_OUTPUT_PATH} COMPONENT libraries) else() message("--- dso dynamic library selected.") add_library(dso SHARED ${dso_SOURCE_FILES} ${dso_opencv_SOURCE_FILES} ${dso_pangolin_SOURCE_FILES}) @@ -129,7 +131,7 @@ else() if (HAS_OPENCV) target_link_libraries(dso ${OpenCV_LIBS}) endif() - install (TARGETS dso LIBRARY DESTINATION lib COMPONENT libraries) + install (TARGETS dso LIBRARY DESTINATION ${LIBRARY_OUTPUT_PATH} COMPONENT libraries) endif() #set_property( TARGET dso APPEND_STRING PROPERTY COMPILE_FLAGS -Wall ) @@ -151,13 +153,13 @@ endif() file(GLOB dso_HEADER_FILES "${PROJECT_SOURCE_DIR}/src/FullSystem/*.h") -install (FILES ${dso_HEADER_FILES} DESTINATION include/dso/FullSystem) +install (FILES ${dso_HEADER_FILES} DESTINATION ${INCLUDE_OUTPUT_PATH}/FullSystem) file(GLOB dso_HEADER_FILES "${PROJECT_SOURCE_DIR}/src/OptimizationBackend/*.h") -install (FILES ${dso_HEADER_FILES} DESTINATION include/dso/OptimizationBackend) +install (FILES ${dso_HEADER_FILES} DESTINATION ${INCLUDE_OUTPUT_PATH}/OptimizationBackend) file(GLOB dso_HEADER_FILES "${PROJECT_SOURCE_DIR}/src/util/*.h") -install (FILES ${dso_HEADER_FILES} DESTINATION include/dso/util) +install (FILES ${dso_HEADER_FILES} DESTINATION ${INCLUDE_OUTPUT_PATH}/util) From b68dee77272a224a71c74f3844552f471cd81ee2 Mon Sep 17 00:00:00 2001 From: Javier Hidalgo-Carrio Date: Tue, 13 Dec 2016 19:44:16 +0100 Subject: [PATCH 04/28] cmake: option for pkgconfig in the compilation process --- CMakeLists.txt | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- dso.pc.in | 11 +++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 dso.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 9232a6047..650e76180 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ set(EXECUTABLE_OUTPUT_PATH bin) set(LIBRARY_OUTPUT_PATH lib) set(INCLUDE_OUTPUT_PATH include/dso) set(CMAKE_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH}/cmake/dso) +set(PKGCONFIG_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH}/pkgconfig) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # required libraries @@ -36,6 +37,10 @@ if (MSVC) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") endif (MSVC) +if(NOT WIN32) + option(DSO_BUILD_PKGCONFIG "Build pkg-config .pc file for DSO" ON) +endif(NOT WIN32) + # Sources files set(dso_SOURCE_FILES ${PROJECT_SOURCE_DIR}/src/FullSystem/FullSystem.cpp @@ -58,7 +63,7 @@ set(dso_SOURCE_FILES ${PROJECT_SOURCE_DIR}/src/util/globalCalib.cpp ) - +set(DSO_BOOST_LIBRARIES ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY}) include_directories( ${PROJECT_SOURCE_DIR}/src @@ -163,3 +168,45 @@ file(GLOB dso_HEADER_FILES "${PROJECT_SOURCE_DIR}/src/util/*.h") install (FILES ${dso_HEADER_FILES} DESTINATION ${INCLUDE_OUTPUT_PATH}/util) +macro(libraries_for_pkgconfig VARNAME) + foreach(__lib ${ARGN}) + string(STRIP __lib ${__lib}) + string(SUBSTRING ${__lib} 0 1 __lib_is_absolute) + if (__lib_is_absolute STREQUAL "/") + get_filename_component(__lib_path ${__lib} PATH) + get_filename_component(__lib_name ${__lib} NAME_WE) + string(REGEX REPLACE "^lib" "" __lib_name "${__lib_name}") + set(${VARNAME} "${${VARNAME}} -L${__lib_path} -l${__lib_name}") + else() + set(${VARNAME} "${${VARNAME}} ${__lib}") + endif() + endforeach() +endmacro() + +# Generate pkgconfig pc file +if(DSO_BUILD_PKGCONFIG) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/dso.pc.in) + message("-- Found: ${CMAKE_CURRENT_SOURCE_DIR}/dso.pc.in") + + # Set the target name + set(TARGET_NAME dso) + + # Dependency for DSO + libraries_for_pkgconfig(${TARGET_NAME}_PKGCONFIG_LIBS + ${DSO_BOOST_LIBRARIES} ${LIBZIP_LIBRARY} ${Pangolin_LIBRARIES} + ${OpenCV_LIBS}) + + set(${TARGET_NAME}_PKGCONFIG_CFLAGS "${${TARGET_NAME}_PKGCONFIG_CFLAGS} ${BOOST_CFLAGS_OTHER}") + + set(PKGCONFIG_REQUIRES eigen3) + set(PKGCONFIG_CFLAGS ${${TARGET_NAME}_PKGCONFIG_CFLAGS}) + set(PKGCONFIG_LIBS ${${TARGET_NAME}_PKGCONFIG_LIBS}) + + configure_file(dso.pc.in dso.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dso.pc DESTINATION ${PKGCONFIG_OUTPUT_PATH}) + else() + message("-- pkg-config: ${CMAKE_CURRENT_SOURCE_DIR}/dso.pc.in is not available for configuration") + endif() + +endif(DSO_BUILD_PKGCONFIG) + diff --git a/dso.pc.in b/dso.pc.in new file mode 100644 index 000000000..e83c204b3 --- /dev/null +++ b/dso.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=${prefix}/@LIBRARY_OUTPUT_PATH@ +includedir=${prefix}/@INCLUDE_OUTPUT_PATH@ + +Name: @TARGET_NAME@ +Description: @TARGET_NAME@ +Version: @DSO_VERSION_STRING@ +Requires: @PKGCONFIG_REQUIRES@ +Libs: -L${libdir} -l@TARGET_NAME@ @PKGCONFIG_LIBS@ +Cflags: -I${includedir} @PKGCONFIG_CFLAGS@ From 4317d54ba25f141a8b50595f2e1af7f9a90a424f Mon Sep 17 00:00:00 2001 From: Javier Hidalgo-Carrio Date: Tue, 13 Dec 2016 19:53:29 +0100 Subject: [PATCH 05/28] cmake: dso comes with its own version of Sophus. This makes the installation of the required headers files. --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 650e76180..8338d4e70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,6 +168,10 @@ file(GLOB dso_HEADER_FILES "${PROJECT_SOURCE_DIR}/src/util/*.h") install (FILES ${dso_HEADER_FILES} DESTINATION ${INCLUDE_OUTPUT_PATH}/util) +#DSO comes with its own version of Sophus (TODO try to get the library from https://github.com/strasdat/Sophus) +file(GLOB SOPHUS_HEADER_FILES "${PROJECT_SOURCE_DIR}/thirdparty/Sophus/sophus/*.hpp") +install (FILES ${SOPHUS_HEADER_FILES} DESTINATION ${INCLUDE_OUTPUT_PATH}/sophus) + macro(libraries_for_pkgconfig VARNAME) foreach(__lib ${ARGN}) string(STRIP __lib ${__lib}) From 18a8d3f19855c9b3924e1b62a9691f4382739052 Mon Sep 17 00:00:00 2001 From: Javier Hidalgo-Carrio Date: Tue, 13 Dec 2016 19:56:40 +0100 Subject: [PATCH 06/28] cmake: install IOWrapper headers --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8338d4e70..1b7b0d0d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,6 +164,10 @@ file(GLOB dso_HEADER_FILES "${PROJECT_SOURCE_DIR}/src/OptimizationBackend/*.h") install (FILES ${dso_HEADER_FILES} DESTINATION ${INCLUDE_OUTPUT_PATH}/OptimizationBackend) +file(GLOB dso_HEADER_FILES "${PROJECT_SOURCE_DIR}/src/IOWrapper/*.h") + +install (FILES ${dso_HEADER_FILES} DESTINATION ${INCLUDE_OUTPUT_PATH}/IOWrapper) + file(GLOB dso_HEADER_FILES "${PROJECT_SOURCE_DIR}/src/util/*.h") install (FILES ${dso_HEADER_FILES} DESTINATION ${INCLUDE_OUTPUT_PATH}/util) From 733446b9a52f5a75a7063fb5365d6da90c308241 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Fri, 10 Nov 2017 13:21:39 +0100 Subject: [PATCH 07/28] Fix cmake default build type. --- CMakeLists.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b7b0d0d1..513c006b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,9 +4,15 @@ PROJECT(${PROJECT_NAME}) CMAKE_MINIMUM_REQUIRED(VERSION 2.6) #set(CMAKE_VERBOSE_MAKEFILE ON) - -set(BUILD_TYPE Release) -#set(BUILD_TYPE RelWithDebInfo) +# Set default build type if not specified otherwise. +# See https://cmake.org/pipermail/cmake/2012-May/050243.html +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORC) + message(STATUS "Setting build type to '${CMAKE_BUILD_TYPE}' as none was specified.") + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" + "MinSizeRel" "RelWithDebInfo") +endif() set(EXECUTABLE_OUTPUT_PATH bin) set(LIBRARY_OUTPUT_PATH lib) From e02de6586205752510bac0ea32bada3f1afa66f0 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Fri, 10 Nov 2017 13:23:07 +0100 Subject: [PATCH 08/28] update default compile flags - the sse related flags and defines seem to be unused --- CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 513c006b8..25f4f45e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,10 +32,9 @@ find_package(Pangolin 0.2 QUIET) find_package(OpenCV QUIET) # flags -add_definitions("-DENABLE_SSE") set(CMAKE_CXX_FLAGS - "${SSE_FLAGS} -O3 -g -std=c++0x -march=native" -# "${SSE_FLAGS} -O3 -g -std=c++0x -fno-omit-frame-pointer" + "-std=c++14 -march=native" +# "-O3 -g -std=c++14 -fno-omit-frame-pointer" ) option(DSO_BUILD_STATIC_LIBRARY "Build a static dso library, instead of shared" ON) From a63d3878cef817ec738756b7a18a7feb97699012 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Fri, 10 Nov 2017 13:25:02 +0100 Subject: [PATCH 09/28] Make build work with catkin (as plain cmake package) --- CMakeLists.txt | 12 +++++++++++- package.xml | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 package.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 25f4f45e7..6a60e938d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,10 @@ PROJECT(${PROJECT_NAME}) CMAKE_MINIMUM_REQUIRED(VERSION 2.6) #set(CMAKE_VERBOSE_MAKEFILE ON) +# TODO: make this work like a catkin package if it is built with +# catkin, otherwise plain cmake; change package.xml to catkin; check +# realsense_camera or librealsense for an example + # Set default build type if not specified otherwise. # See https://cmake.org/pipermail/cmake/2012-May/050243.html if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) @@ -28,6 +32,8 @@ find_package(Boost COMPONENTS system thread) # optional libraries find_package(LibZip QUIET) + +# TODO: make sure this works in general with catkin_tools, not just because of cmake package caching (~/.cmake/packages/Pangolin) find_package(Pangolin 0.2 QUIET) find_package(OpenCV QUIET) @@ -36,7 +42,10 @@ set(CMAKE_CXX_FLAGS "-std=c++14 -march=native" # "-O3 -g -std=c++14 -fno-omit-frame-pointer" ) -option(DSO_BUILD_STATIC_LIBRARY "Build a static dso library, instead of shared" ON) + +#message(" CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") + +option(DSO_BUILD_STATIC_LIBRARY "Build a static dso library, instead of shared" OFF) if (MSVC) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") @@ -157,6 +166,7 @@ if (OpenCV_FOUND AND Pangolin_FOUND) message("--- compiling dso_dataset.") add_executable(dso_dataset ${PROJECT_SOURCE_DIR}/src/main_dso_pangolin.cpp ) target_link_libraries(dso_dataset dso boost_system cxsparse ${BOOST_THREAD_LIBRARY} ${LIBZIP_LIBRARY} ${Pangolin_LIBRARIES} ${OpenCV_LIBS}) + install (TARGETS dso_dataset RUNTIME DESTINATION ${EXECUTABLE_OUTPUT_PATH}) else() message("--- not building dso_dataset, since either don't have openCV or Pangolin.") endif() diff --git a/package.xml b/package.xml new file mode 100644 index 000000000..7d953e61f --- /dev/null +++ b/package.xml @@ -0,0 +1,24 @@ + + + dso + 1.0.0 + Direct Sparse Visual Odometry + Nikolaus Demmel + Jakob Engel + Jakob Engel + GPLv3 + http://vision.in.tum.de/dso + cmake + eigen + pangolin + suitesparse + boost + libopencv-dev + zlib + + cmake + + + + + From ee26e231e9857925bbd686e24ebe15570949d554 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Fri, 10 Nov 2017 17:35:21 +0100 Subject: [PATCH 10/28] cmake typo --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a60e938d..38a212a36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) # Set default build type if not specified otherwise. # See https://cmake.org/pipermail/cmake/2012-May/050243.html if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORC) + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) message(STATUS "Setting build type to '${CMAKE_BUILD_TYPE}' as none was specified.") # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" From 920122f00ce2caba836e0afe33290b8b22cd8a26 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Fri, 10 Nov 2017 17:37:12 +0100 Subject: [PATCH 11/28] remove unused dependency SuiteParse --- CMakeLists.txt | 6 ++---- README.md | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38a212a36..67a81242d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,6 @@ set(PKGCONFIG_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH}/pkgconfig) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # required libraries -find_package(SuiteParse REQUIRED) find_package(Eigen3 REQUIRED) find_package(Boost COMPONENTS system thread) @@ -131,7 +130,6 @@ endif() # compile main library. -include_directories( ${CSPARSE_INCLUDE_DIR} ${CHOLMOD_INCLUDE_DIR}) if (DSO_BUILD_STATIC_LIBRARY) message("--- dso static library selected.") @@ -140,7 +138,7 @@ if (DSO_BUILD_STATIC_LIBRARY) else() message("--- dso dynamic library selected.") add_library(dso SHARED ${dso_SOURCE_FILES} ${dso_opencv_SOURCE_FILES} ${dso_pangolin_SOURCE_FILES}) - target_link_libraries(dso boost_system boost_thread cxsparse) + target_link_libraries(dso boost_system boost_thread) if (HAS_ZIPLIB) target_link_libraries(dso ${LIBZIP_LIBRARY}) endif() @@ -165,7 +163,7 @@ endif() if (OpenCV_FOUND AND Pangolin_FOUND) message("--- compiling dso_dataset.") add_executable(dso_dataset ${PROJECT_SOURCE_DIR}/src/main_dso_pangolin.cpp ) - target_link_libraries(dso_dataset dso boost_system cxsparse ${BOOST_THREAD_LIBRARY} ${LIBZIP_LIBRARY} ${Pangolin_LIBRARIES} ${OpenCV_LIBS}) + target_link_libraries(dso_dataset dso boost_system ${BOOST_THREAD_LIBRARY} ${LIBZIP_LIBRARY} ${Pangolin_LIBRARIES} ${OpenCV_LIBS}) install (TARGETS dso_dataset RUNTIME DESTINATION ${EXECUTABLE_OUTPUT_PATH}) else() message("--- not building dso_dataset, since either don't have openCV or Pangolin.") diff --git a/README.md b/README.md index 2ddc54bae..3f50cd9e3 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,10 @@ Get some datasets from [https://vision.in.tum.de/mono-dataset](https://vision.in #### 2.1 Required Dependencies -##### suitesparse and eigen3 (required). +##### eigen3 and boost (required). Required. Install with - sudo apt-get install libsuitesparse-dev libeigen3-dev libboost-all-dev + sudo apt-get install libeigen3-dev libboost-all-dev From 07472502603272ef195df35dd4323b2e7ac7535d Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Fri, 10 Nov 2017 17:40:47 +0100 Subject: [PATCH 12/28] Initial travis configuration for Linux. --- .travis.yml | 46 ++++++++++++++++++++++ scripts/ci-install-linux-deps.sh | 65 ++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 .travis.yml create mode 100755 scripts/ci-install-linux-deps.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..d5faeb14f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,46 @@ +# no xenial support from travis yet... +dist: trusty +sudo: enabled + +# get c++14 compatible gcc version +addons: + apt: + sources: + - sourceline: 'ppa:ubuntu-toolchain-r/test' + packages: + - gcc-5 + - g++-5 + +language: cpp + +cache: ccache + +matrix: + include: + - compiler: gcc + os: linux + env: BUILD_TYPE=Release +# - compiler: clang +# os: linux +# env: BUILD_TYPE=Debug +# - compiler: clang +# os: linux +# env: BUILD_TYPE=Release +# - compiler: clang +# os: osx +# env: BUILD_TYPE=Release + +env: + global: + - MAKEFLAGS="-j 2" + +before_install: + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then scripts/ci-install-linux-deps.sh ; fi +# - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then scripts/ci-install-osx-deps.sh ; fi + +script: + - mkdir build + - cd build + - cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. + - make +# - make test diff --git a/scripts/ci-install-linux-deps.sh b/scripts/ci-install-linux-deps.sh new file mode 100755 index 000000000..46f94ea23 --- /dev/null +++ b/scripts/ci-install-linux-deps.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +# Script to install dependencies, intended for CI builds, in particular for Travis + +set -x # echo on +set -e # exit on error + +ROOT_DIR="$PWD" + +sudo apt-get update -qq + +# basic dependencies (needed in minimalistic docker containers, but not travis) +#sudo apt-get install -qq build-essential git cmake + +# make recent gcc default (installed by travis "addon") +sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5 +gcc --version +g++ --version + +# get more recent cmake for e.g. CMAKE_CXX_COMPILER_LAUNCHER +cd "$ROOT_DIR" +wget https://cmake.org/files/v3.9/cmake-3.9.0-Linux-x86_64.sh +chmod +x cmake-3.9.0-Linux-x86_64.sh +set +x # echo off +sudo ./cmake-3.9.0-Linux-x86_64.sh --skip-license --prefix=/usr/local +set -x # echo on +sudo update-alternatives --install /usr/bin/cmake cmake /usr/local/bin/cmake 1 --force +cmake --version + +# get recent libeigen, since the one on 14.04 gives lots of warnings +cd "$ROOT_DIR" +wget http://bitbucket.org/eigen/eigen/get/3.3.4.tar.gz +tar -xf 3.3.4.tar.gz +cd eigen-eigen-* +mkdir build +cd build/ +cmake .. +sudo make install -j1 + +# install pangolin from source +cd "$ROOT_DIR" +# skip libeigen3-dev, since we installed manually above +sudo apt-get install -qq libglew-dev libc++-dev +git clone https://github.com/stevenlovegrove/Pangolin.git +cd Pangolin +mkdir build +cd build +cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. +make + + +# deps for DSO +# skip libeigen3-dev, since we installed manually above +sudo apt-get install -qq libboost-all-dev libopencv-dev + +# install libzip (for Ubuntu 16.04 and up, libzip-dev should be ok) +cd "$ROOT_DIR" +sudo apt-get install -qq zlib1g-dev +cd thirdparty +tar -zxvf libzip-1.1.1.tar.gz +cd libzip-1.1.1/ +./configure +make +sudo make install +sudo cp lib/zipconf.h /usr/local/include/zipconf.h # (no idea why that is needed). From ba53fad04169277d181008f9f43dfac2f11fb90c Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Tue, 14 Nov 2017 15:06:41 +0100 Subject: [PATCH 13/28] Readme updates - dynamic library is now default - libzip-dev should be fine from apt on 16.04 - hint on camera calibration and 0.5 offset for OpenCV and Kalibr --- README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3f50cd9e3..5d1a54343 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,12 @@ Used to read datasets with images as .zip, as e.g. in the TUM monoVO dataset. You can compile without this, however then you can only read images directly (i.e., have to unzip the dataset image archives before loading them). +On Ubuntu 16.04 and up, the version from apt should suffice: + + sudo apt-get install libzip-dev + +On Ubuntu 14.04: + sudo apt-get install zlib1g-dev cd dso/thirdparty tar -zxvf libzip-1.1.1.tar.gz @@ -72,9 +78,9 @@ After cloning, just run `git submodule update --init` to include this. It trans cmake .. make -j -this will compile a library `libdso.a`, which can be linked from external projects. +this will by default compile a dynamic library `libdso.so`, which can be linked from external projects. It will also build a binary `dso_dataset`, to run DSO on datasets. However, for this -OpenCV and Pangolin need to be installed. +OpenCV and Pangolin need to be installed. You can switch to building a static library with the `cmake -DDSO_BUILD_STATIC_LIBRARY=ON`. @@ -172,6 +178,9 @@ contains the integral over (0.5,0.5) to (1.5,1.5), or the integral over (1,1) to the given calibration in the calibration file uses the latter convention, and thus applies the -0.5 correction. Note that this also is taken into account when creating the scale-pyramid (see `globalCalib.cpp`). +It seems that Kalibr and OpenCV have the same internal representation as DSO, thus you should add an +0.5 offset to the +calibration results from those, to cancel out the -0.5 correction that DSO does when loading the calibration files. +See also [this discussion](https://github.com/ethz-asl/kalibr/issues/115) in the Kalibr issue tracker. **Rectification modes:** For image rectification, DSO either supports rectification to a user-defined pinhole model (`fx fy cx cy 0`), From a6db372b55198b0fb10374425d8d11648bed2568 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Tue, 14 Nov 2017 18:50:40 +0100 Subject: [PATCH 14/28] cmake: use DSO_BOOST_LIBRARIES everywhere --- CMakeLists.txt | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67a81242d..18c1adb9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,7 +138,7 @@ if (DSO_BUILD_STATIC_LIBRARY) else() message("--- dso dynamic library selected.") add_library(dso SHARED ${dso_SOURCE_FILES} ${dso_opencv_SOURCE_FILES} ${dso_pangolin_SOURCE_FILES}) - target_link_libraries(dso boost_system boost_thread) + target_link_libraries(dso ${DSO_BOOST_LIBRARIES}) if (HAS_ZIPLIB) target_link_libraries(dso ${LIBZIP_LIBRARY}) endif() @@ -152,18 +152,11 @@ else() endif() #set_property( TARGET dso APPEND_STRING PROPERTY COMPILE_FLAGS -Wall ) - -if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") # OSX - set(BOOST_THREAD_LIBRARY boost_thread-mt) -else() - set(BOOST_THREAD_LIBRARY boost_thread) -endif() - # build main executable (only if we have both OpenCV and Pangolin) if (OpenCV_FOUND AND Pangolin_FOUND) message("--- compiling dso_dataset.") add_executable(dso_dataset ${PROJECT_SOURCE_DIR}/src/main_dso_pangolin.cpp ) - target_link_libraries(dso_dataset dso boost_system ${BOOST_THREAD_LIBRARY} ${LIBZIP_LIBRARY} ${Pangolin_LIBRARIES} ${OpenCV_LIBS}) + target_link_libraries(dso_dataset dso ${DSO_BOOST_LIBRARIES} ${LIBZIP_LIBRARY} ${Pangolin_LIBRARIES} ${OpenCV_LIBS}) install (TARGETS dso_dataset RUNTIME DESTINATION ${EXECUTABLE_OUTPUT_PATH}) else() message("--- not building dso_dataset, since either don't have openCV or Pangolin.") From cdad2e702935e20747d4828107461b5233a88aac Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Wed, 15 Nov 2017 14:04:00 +0100 Subject: [PATCH 15/28] Add compile check on OSX. --- .travis.yml | 8 ++++---- scripts/ci-install-osx-deps.sh | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100755 scripts/ci-install-osx-deps.sh diff --git a/.travis.yml b/.travis.yml index d5faeb14f..9f78181a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,9 +26,9 @@ matrix: # - compiler: clang # os: linux # env: BUILD_TYPE=Release -# - compiler: clang -# os: osx -# env: BUILD_TYPE=Release + - compiler: clang + os: osx + env: BUILD_TYPE=Release env: global: @@ -36,7 +36,7 @@ env: before_install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then scripts/ci-install-linux-deps.sh ; fi -# - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then scripts/ci-install-osx-deps.sh ; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then scripts/ci-install-osx-deps.sh ; fi script: - mkdir build diff --git a/scripts/ci-install-osx-deps.sh b/scripts/ci-install-osx-deps.sh new file mode 100755 index 000000000..8b2f4c5f7 --- /dev/null +++ b/scripts/ci-install-osx-deps.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# Script to install dependencies, intended for CI builds, in particular for Travis + +set -x # echo on +set -e # exit on error + +# Travis suggests to not call brew update +brew install boost eigen glew opencv libzip cmake pkgconfig + +brew install ccache +export PATH="/usr/local/opt/ccache/libexec:$PATH" +whereis ccache + +git clone https://github.com/stevenlovegrove/Pangolin.git +mkdir Pangolin/build +cd Pangolin/build/ +cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_COMPILER_LAUNCHER=ccache .. +make +make install -j1 + From c2c6b0d92ba66e6a0a5632e6d8d660e489832593 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Wed, 15 Nov 2017 14:04:31 +0100 Subject: [PATCH 16/28] Add compile check with clang Release and Debug. --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9f78181a4..bef316916 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,12 +20,12 @@ matrix: - compiler: gcc os: linux env: BUILD_TYPE=Release -# - compiler: clang -# os: linux -# env: BUILD_TYPE=Debug -# - compiler: clang -# os: linux -# env: BUILD_TYPE=Release + - compiler: clang + os: linux + env: BUILD_TYPE=Debug + - compiler: clang + os: linux + env: BUILD_TYPE=Release - compiler: clang os: osx env: BUILD_TYPE=Release From 7d3414455a5009d41a65714ed94c799db374d5ee Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Wed, 15 Nov 2017 14:26:50 +0100 Subject: [PATCH 17/28] travis on OSX: need brew update after all --- scripts/ci-install-osx-deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci-install-osx-deps.sh b/scripts/ci-install-osx-deps.sh index 8b2f4c5f7..72edd667c 100755 --- a/scripts/ci-install-osx-deps.sh +++ b/scripts/ci-install-osx-deps.sh @@ -5,7 +5,7 @@ set -x # echo on set -e # exit on error -# Travis suggests to not call brew update +brew update brew install boost eigen glew opencv libzip cmake pkgconfig brew install ccache From 2452a52f8c8cedf0ba989ca1cb15cd14b3f2b018 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Wed, 15 Nov 2017 14:44:31 +0100 Subject: [PATCH 18/28] Fix Travis on OSX --- scripts/ci-install-osx-deps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/ci-install-osx-deps.sh b/scripts/ci-install-osx-deps.sh index 72edd667c..62d328710 100755 --- a/scripts/ci-install-osx-deps.sh +++ b/scripts/ci-install-osx-deps.sh @@ -6,7 +6,8 @@ set -x # echo on set -e # exit on error brew update -brew install boost eigen glew opencv libzip cmake pkgconfig +brew upgrad cmake pkgconfig # already present in the travis image +brew install boost eigen glew opencv libzip brew install ccache export PATH="/usr/local/opt/ccache/libexec:$PATH" From ef0662c1d0caa9ef55a3e532bb8095f02b73ebb9 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Wed, 15 Nov 2017 14:54:47 +0100 Subject: [PATCH 19/28] typo --- scripts/ci-install-osx-deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci-install-osx-deps.sh b/scripts/ci-install-osx-deps.sh index 62d328710..13c4f9c8a 100755 --- a/scripts/ci-install-osx-deps.sh +++ b/scripts/ci-install-osx-deps.sh @@ -6,7 +6,7 @@ set -x # echo on set -e # exit on error brew update -brew upgrad cmake pkgconfig # already present in the travis image +brew upgrade cmake pkgconfig # already present in the travis image brew install boost eigen glew opencv libzip brew install ccache From 140afe56bad2c55f5bd1925b2ecc4329d9851da9 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Wed, 15 Nov 2017 15:24:47 +0100 Subject: [PATCH 20/28] Fix warnings in Sophus (no functional change). --- thirdparty/Sophus/sophus/rxso3.hpp | 4 ++-- thirdparty/Sophus/sophus/sim3.hpp | 6 +++--- thirdparty/Sophus/sophus/so3.hpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/thirdparty/Sophus/sophus/rxso3.hpp b/thirdparty/Sophus/sophus/rxso3.hpp index a0262a090..5abd0b450 100644 --- a/thirdparty/Sophus/sophus/rxso3.hpp +++ b/thirdparty/Sophus/sophus/rxso3.hpp @@ -21,7 +21,7 @@ // IN THE SOFTWARE. #ifndef SOPHUS_RXSO3_HPP -#define RXSO3_HPP +#define SOPHUS_RXSO3_HPP #include "sophus.hpp" #include "so3.hpp" @@ -377,7 +377,7 @@ class RxSO3GroupBase { const Adjoint d_lieBracketab_by_d_a(const Tangent & b) { Adjoint res; res.setZero(); - res.template topLeftCorner<3,3>() = -SO3::hat(b.template head<3>()); + res.template topLeftCorner<3,3>() = -SO3d::hat(b.template head<3>()); return res; } diff --git a/thirdparty/Sophus/sophus/sim3.hpp b/thirdparty/Sophus/sophus/sim3.hpp index 97087c330..5ebb5f901 100644 --- a/thirdparty/Sophus/sophus/sim3.hpp +++ b/thirdparty/Sophus/sophus/sim3.hpp @@ -390,10 +390,10 @@ class Sim3GroupBase { Adjoint res; res.setZero(); res.template topLeftCorner<3,3>() - = -SO3::hat(omega2)-sigma2*Matrix3d::Identity(); - res.template block<3,3>(0,3) = -SO3::hat(upsilon2); + = -SO3d::hat(omega2)-sigma2*Matrix3d::Identity(); + res.template block<3,3>(0,3) = -SO3d::hat(upsilon2); res.template topRightCorner<3,1>() = upsilon2; - res.template block<3,3>(3,3) = -SO3::hat(omega2); + res.template block<3,3>(3,3) = -SO3d::hat(omega2); return res; } diff --git a/thirdparty/Sophus/sophus/so3.hpp b/thirdparty/Sophus/sophus/so3.hpp index 88a362e41..df851804c 100644 --- a/thirdparty/Sophus/sophus/so3.hpp +++ b/thirdparty/Sophus/sophus/so3.hpp @@ -798,7 +798,7 @@ class Map, _Options> * No direct write access is given to ensure the quaternion stays normalized. */ EIGEN_STRONG_INLINE - const ConstQuaternionReference unit_quaternion() const { + ConstQuaternionReference unit_quaternion() const { return unit_quaternion_; } From 5abc925030bfb30afaed2ba90e61c3cabbfaa83d Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Wed, 15 Nov 2017 15:28:24 +0100 Subject: [PATCH 21/28] Fix compiler warnings --- src/FullSystem/CoarseTracker.cpp | 8 ++++---- src/FullSystem/HessianBlocks.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/FullSystem/CoarseTracker.cpp b/src/FullSystem/CoarseTracker.cpp index e56662586..0f5afbfe9 100644 --- a/src/FullSystem/CoarseTracker.cpp +++ b/src/FullSystem/CoarseTracker.cpp @@ -699,14 +699,14 @@ bool CoarseTracker::trackNewestCoarse( aff_g2l_out = aff_g2l_current; - if((setting_affineOptModeA != 0 && (fabsf(aff_g2l_out.a) > 1.2)) - || (setting_affineOptModeB != 0 && (fabsf(aff_g2l_out.b) > 200))) + if((setting_affineOptModeA != 0 && (fabsf((float)aff_g2l_out.a) > 1.2f)) + || (setting_affineOptModeB != 0 && (fabsf((float)aff_g2l_out.b) > 200.f))) return false; Vec2f relAff = AffLight::fromToVecExposure(lastRef->ab_exposure, newFrame->ab_exposure, lastRef_aff_g2l, aff_g2l_out).cast(); - if((setting_affineOptModeA == 0 && (fabsf(logf((float)relAff[0])) > 1.5)) - || (setting_affineOptModeB == 0 && (fabsf((float)relAff[1]) > 200))) + if((setting_affineOptModeA == 0 && (fabsf(logf((float)relAff[0])) > 1.5f)) + || (setting_affineOptModeB == 0 && (fabsf((float)relAff[1]) > 200.f))) return false; diff --git a/src/FullSystem/HessianBlocks.cpp b/src/FullSystem/HessianBlocks.cpp index ef801b7ad..87c174d55 100644 --- a/src/FullSystem/HessianBlocks.cpp +++ b/src/FullSystem/HessianBlocks.cpp @@ -81,8 +81,8 @@ void FrameHessian::setStateZero(const Vec10 &state_zero) for(int i=0;i<6;i++) { Vec6 eps; eps.setZero(); eps[i] = 1e-3; - SE3 EepsP = Sophus::SE3::exp(eps); - SE3 EepsM = Sophus::SE3::exp(-eps); + SE3 EepsP = SE3::exp(eps); + SE3 EepsM = SE3::exp(-eps); SE3 w2c_leftEps_P_x0 = (get_worldToCam_evalPT() * EepsP) * get_worldToCam_evalPT().inverse(); SE3 w2c_leftEps_M_x0 = (get_worldToCam_evalPT() * EepsM) * get_worldToCam_evalPT().inverse(); nullspaces_pose.col(i) = (w2c_leftEps_P_x0.log() - w2c_leftEps_M_x0.log())/(2e-3); From f0edcad80948257d06a606b794ee6fbcf8829abf Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Mon, 20 Nov 2017 18:18:19 +0100 Subject: [PATCH 22/28] Fix Travis build. --- .travis.yml | 26 +++++++++++++++----------- CMakeLists.txt | 4 ++-- scripts/ci-install-linux-deps.sh | 13 +++---------- scripts/ci-install-osx-deps.sh | 13 +++++++++++-- 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index bef316916..5854c7b76 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,31 +1,34 @@ # no xenial support from travis yet... dist: trusty sudo: enabled +language: cpp +cache: ccache # get c++14 compatible gcc version addons: apt: sources: - - sourceline: 'ppa:ubuntu-toolchain-r/test' + - ubuntu-toolchain-r-test packages: - gcc-5 - g++-5 -language: cpp - -cache: ccache - +# See: https://docs.travis-ci.com/user/languages/c/ +# We don't include clang builds, since there are issues +# with C++11/14 and libc++ on Trusty, e.g. when including +# OpenCV headers. matrix: include: - compiler: gcc os: linux - env: BUILD_TYPE=Release - - compiler: clang - os: linux - env: BUILD_TYPE=Debug - - compiler: clang + env: + - BUILD_TYPE=Release + - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5" + - compiler: gcc os: linux - env: BUILD_TYPE=Release + env: + - BUILD_TYPE=Debug + - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5" - compiler: clang os: osx env: BUILD_TYPE=Release @@ -35,6 +38,7 @@ env: - MAKEFLAGS="-j 2" before_install: + - eval "${MATRIX_EVAL}" - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then scripts/ci-install-linux-deps.sh ; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then scripts/ci-install-osx-deps.sh ; fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 18c1adb9b..9e342e27e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,8 +38,8 @@ find_package(OpenCV QUIET) # flags set(CMAKE_CXX_FLAGS - "-std=c++14 -march=native" -# "-O3 -g -std=c++14 -fno-omit-frame-pointer" + "-std=c++14 -march=native ${CMAKE_CXX_FLAGS}" +# "-O3 -g -fno-omit-frame-pointer" ) #message(" CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") diff --git a/scripts/ci-install-linux-deps.sh b/scripts/ci-install-linux-deps.sh index 46f94ea23..3f3fb9151 100755 --- a/scripts/ci-install-linux-deps.sh +++ b/scripts/ci-install-linux-deps.sh @@ -10,12 +10,7 @@ ROOT_DIR="$PWD" sudo apt-get update -qq # basic dependencies (needed in minimalistic docker containers, but not travis) -#sudo apt-get install -qq build-essential git cmake - -# make recent gcc default (installed by travis "addon") -sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5 -gcc --version -g++ --version +#sudo apt-get install -qq build-essential git cmake wget pkg-config # get more recent cmake for e.g. CMAKE_CXX_COMPILER_LAUNCHER cd "$ROOT_DIR" @@ -42,13 +37,11 @@ cd "$ROOT_DIR" # skip libeigen3-dev, since we installed manually above sudo apt-get install -qq libglew-dev libc++-dev git clone https://github.com/stevenlovegrove/Pangolin.git -cd Pangolin -mkdir build -cd build +mkdir Pangolin/build +cd Pangolin/build cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. make - # deps for DSO # skip libeigen3-dev, since we installed manually above sudo apt-get install -qq libboost-all-dev libopencv-dev diff --git a/scripts/ci-install-osx-deps.sh b/scripts/ci-install-osx-deps.sh index 13c4f9c8a..d7e26ddd3 100755 --- a/scripts/ci-install-osx-deps.sh +++ b/scripts/ci-install-osx-deps.sh @@ -6,8 +6,17 @@ set -x # echo on set -e # exit on error brew update -brew upgrade cmake pkgconfig # already present in the travis image -brew install boost eigen glew opencv libzip + +# The following are already present in the travis image. +# We can probably live with slightly outdated formulas, so skip the upgrade +# which takes very long (in particular boost). +#brew upgrade cmake pkgconfig boost + +# remove numpy, which is present in the travis image. +# It will be installed from brew as opencv dependency, which fails if already present. +/usr/bin/yes | pip uninstall numpy > /dev/null 2>&1 + +brew install eigen glew opencv libzip brew install ccache export PATH="/usr/local/opt/ccache/libexec:$PATH" From b9a6011643e2d67af47f1c0b954ae54dffc1b170 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Mon, 20 Nov 2017 18:25:47 +0100 Subject: [PATCH 23/28] Update readme. Includes instructions for OSX. --- README.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5d1a54343..884453f21 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,14 @@ Get some datasets from [https://vision.in.tum.de/mono-dataset](https://vision.in #### 2.1 Required Dependencies +The following instructions are tested on Ubuntu 16.04. Ubuntu 14.04 +should also work. Other platforms might work with minor adjustments. +For Mac OS X, see below. + ##### eigen3 and boost (required). Required. Install with - sudo apt-get install libeigen3-dev libboost-all-dev - - + sudo apt-get install libeigen3-dev libboost-all-dev #### 2.2 Optional Dependencies @@ -56,7 +58,7 @@ On Ubuntu 16.04 and up, the version from apt should suffice: sudo apt-get install libzip-dev -On Ubuntu 14.04: +On Ubuntu 14.04, you need to compile it manually: sudo apt-get install zlib1g-dev cd dso/thirdparty @@ -70,6 +72,16 @@ On Ubuntu 14.04: ##### sse2neon (required for ARM builds). After cloning, just run `git submodule update --init` to include this. It translates Intel-native SSE functions to ARM-native NEON functions during the compilation process. +##### Mac OS X + +You can install the dependencies with Homebrew. + + brew install cmake pkgconfig boost eigen glew opencv libzip + +The install and build +[Pangolin](https://github.com/stevenlovegrove/Pangolin.git) as above, +and proceed below. + #### 2.3 Build cd dso @@ -80,7 +92,7 @@ After cloning, just run `git submodule update --init` to include this. It trans this will by default compile a dynamic library `libdso.so`, which can be linked from external projects. It will also build a binary `dso_dataset`, to run DSO on datasets. However, for this -OpenCV and Pangolin need to be installed. You can switch to building a static library with the `cmake -DDSO_BUILD_STATIC_LIBRARY=ON`. +OpenCV and Pangolin need to be installed. You can switch to building a static library with `cmake -DDSO_BUILD_STATIC_LIBRARY=ON`. From e23014ee3f57523ea8ca2a9e6e594d572958cb3f Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Mon, 20 Nov 2017 21:07:12 +0100 Subject: [PATCH 24/28] cmake: simplify install rules --- CMakeLists.txt | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e342e27e..522015d9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,25 +162,14 @@ else() message("--- not building dso_dataset, since either don't have openCV or Pangolin.") endif() -file(GLOB dso_HEADER_FILES "${PROJECT_SOURCE_DIR}/src/FullSystem/*.h") - -install (FILES ${dso_HEADER_FILES} DESTINATION ${INCLUDE_OUTPUT_PATH}/FullSystem) - -file(GLOB dso_HEADER_FILES "${PROJECT_SOURCE_DIR}/src/OptimizationBackend/*.h") - -install (FILES ${dso_HEADER_FILES} DESTINATION ${INCLUDE_OUTPUT_PATH}/OptimizationBackend) - -file(GLOB dso_HEADER_FILES "${PROJECT_SOURCE_DIR}/src/IOWrapper/*.h") - -install (FILES ${dso_HEADER_FILES} DESTINATION ${INCLUDE_OUTPUT_PATH}/IOWrapper) - -file(GLOB dso_HEADER_FILES "${PROJECT_SOURCE_DIR}/src/util/*.h") - -install (FILES ${dso_HEADER_FILES} DESTINATION ${INCLUDE_OUTPUT_PATH}/util) +# install all header files +install(DIRECTORY src/ DESTINATION ${INCLUDE_OUTPUT_PATH} + FILES_MATCHING PATTERN "*.h") #DSO comes with its own version of Sophus (TODO try to get the library from https://github.com/strasdat/Sophus) -file(GLOB SOPHUS_HEADER_FILES "${PROJECT_SOURCE_DIR}/thirdparty/Sophus/sophus/*.hpp") -install (FILES ${SOPHUS_HEADER_FILES} DESTINATION ${INCLUDE_OUTPUT_PATH}/sophus) +install(DIRECTORY thirdparty/Sophus/sophus DESTINATION ${INCLUDE_OUTPUT_PATH} + FILES_MATCHING PATTERN "*.hpp") + macro(libraries_for_pkgconfig VARNAME) foreach(__lib ${ARGN}) From cc86b7bc45e240c4856d5de9206c502c0bb8b714 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Mon, 20 Nov 2017 21:07:23 +0100 Subject: [PATCH 25/28] travis: also test 'make install' --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5854c7b76..af5d0f8d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,4 +47,5 @@ script: - cd build - cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. - make + - sudo make install # - make test From 673e2e2f10596dd3597e195160ef15c331a27794 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Sat, 2 Dec 2017 09:20:18 +0100 Subject: [PATCH 26/28] Fix OSX travis build (they upgraded their default image). --- .travis.yml | 6 ++++++ scripts/ci-install-osx-deps.sh | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index af5d0f8d6..28dd0e44d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,12 @@ matrix: - compiler: clang os: osx env: BUILD_TYPE=Release +# For now only run on xcode8.3, which is the default image, since OSX testing on Travis can take a long time. +# osx_image: xcode8.3 +# - compiler: clang +# os: osx +# env: BUILD_TYPE=Release +# osx_image: xcode7.3 env: global: diff --git a/scripts/ci-install-osx-deps.sh b/scripts/ci-install-osx-deps.sh index d7e26ddd3..ba43e97e1 100755 --- a/scripts/ci-install-osx-deps.sh +++ b/scripts/ci-install-osx-deps.sh @@ -14,7 +14,8 @@ brew update # remove numpy, which is present in the travis image. # It will be installed from brew as opencv dependency, which fails if already present. -/usr/bin/yes | pip uninstall numpy > /dev/null 2>&1 +PIP=`which pip` || PIP=pip2 # newer osx travis images don't have pip executable +/usr/bin/yes | $PIP uninstall numpy > /dev/null # 2>&1 brew install eigen glew opencv libzip From 5c77bcca3ca6b81abd6737f967f28442ec735317 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Mon, 4 Dec 2017 12:49:50 +0100 Subject: [PATCH 27/28] Fix cmake warning and note on static vs dynamic so --- CMakeLists.txt | 6 ++++++ README.md | 1 + 2 files changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 522015d9d..5404ffe5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,11 @@ set(CMAKE_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH}/cmake/dso) set(PKGCONFIG_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH}/pkgconfig) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) +# avoid cmake policy warning by adopting new default +if(APPLE) + set(CMAKE_MACOSX_RPATH ON) +endif() + # required libraries find_package(Eigen3 REQUIRED) find_package(Boost COMPONENTS system thread) @@ -44,6 +49,7 @@ set(CMAKE_CXX_FLAGS #message(" CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") +# Note that with a static library, it seems you might get (slightly) better runtime performence. option(DSO_BUILD_STATIC_LIBRARY "Build a static dso library, instead of shared" OFF) if (MSVC) diff --git a/README.md b/README.md index 884453f21..3a1bd6518 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ and proceed below. this will by default compile a dynamic library `libdso.so`, which can be linked from external projects. It will also build a binary `dso_dataset`, to run DSO on datasets. However, for this OpenCV and Pangolin need to be installed. You can switch to building a static library with `cmake -DDSO_BUILD_STATIC_LIBRARY=ON`. +Note that with a static library, it seems you might get (slightly) better runtime performance. From 03333350e6985383bf6b9574072eb09865de3330 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Tue, 19 May 2020 21:43:31 +0200 Subject: [PATCH 28/28] Sophus: proper fix for deprecation warnings. --- thirdparty/Sophus/sophus/rxso3.hpp | 2 +- thirdparty/Sophus/sophus/sim3.hpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/thirdparty/Sophus/sophus/rxso3.hpp b/thirdparty/Sophus/sophus/rxso3.hpp index 5abd0b450..76f4688d5 100644 --- a/thirdparty/Sophus/sophus/rxso3.hpp +++ b/thirdparty/Sophus/sophus/rxso3.hpp @@ -377,7 +377,7 @@ class RxSO3GroupBase { const Adjoint d_lieBracketab_by_d_a(const Tangent & b) { Adjoint res; res.setZero(); - res.template topLeftCorner<3,3>() = -SO3d::hat(b.template head<3>()); + res.template topLeftCorner<3,3>() = -SO3Group::hat(b.template head<3>()); return res; } diff --git a/thirdparty/Sophus/sophus/sim3.hpp b/thirdparty/Sophus/sophus/sim3.hpp index 5ebb5f901..72d431fd3 100644 --- a/thirdparty/Sophus/sophus/sim3.hpp +++ b/thirdparty/Sophus/sophus/sim3.hpp @@ -390,10 +390,10 @@ class Sim3GroupBase { Adjoint res; res.setZero(); res.template topLeftCorner<3,3>() - = -SO3d::hat(omega2)-sigma2*Matrix3d::Identity(); - res.template block<3,3>(0,3) = -SO3d::hat(upsilon2); + = -SO3Group::hat(omega2)-sigma2*Matrix3d::Identity(); + res.template block<3,3>(0,3) = -SO3Group::hat(upsilon2); res.template topRightCorner<3,1>() = upsilon2; - res.template block<3,3>(3,3) = -SO3d::hat(omega2); + res.template block<3,3>(3,3) = -SO3Group::hat(omega2); return res; }