Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmake, travis, and others #109

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5784f4d
Fix declarations of aligned allocators.
NikolausDemmel Dec 1, 2017
f9cfd94
cmake: option to build static/dynamic library. include installation o…
Dec 12, 2016
e742361
cmake: use variable for the installation path
Dec 13, 2016
b68dee7
cmake: option for pkgconfig in the compilation process
Dec 13, 2016
4317d54
cmake: dso comes with its own version of Sophus. This makes the insta…
Dec 13, 2016
18a8d3f
cmake: install IOWrapper headers
Dec 13, 2016
733446b
Fix cmake default build type.
NikolausDemmel Nov 10, 2017
e02de65
update default compile flags
NikolausDemmel Nov 10, 2017
a63d387
Make build work with catkin (as plain cmake package)
NikolausDemmel Nov 10, 2017
ee26e23
cmake typo
NikolausDemmel Nov 10, 2017
920122f
remove unused dependency SuiteParse
NikolausDemmel Nov 10, 2017
0747250
Initial travis configuration for Linux.
NikolausDemmel Nov 10, 2017
ba53fad
Readme updates
NikolausDemmel Nov 14, 2017
a6db372
cmake: use DSO_BOOST_LIBRARIES everywhere
NikolausDemmel Nov 14, 2017
cdad2e7
Add compile check on OSX.
NikolausDemmel Nov 15, 2017
c2c6b0d
Add compile check with clang Release and Debug.
NikolausDemmel Nov 15, 2017
7d34144
travis on OSX: need brew update after all
NikolausDemmel Nov 15, 2017
2452a52
Fix Travis on OSX
NikolausDemmel Nov 15, 2017
ef0662c
typo
NikolausDemmel Nov 15, 2017
140afe5
Fix warnings in Sophus (no functional change).
NikolausDemmel Nov 15, 2017
5abc925
Fix compiler warnings
NikolausDemmel Nov 15, 2017
f0edcad
Fix Travis build.
NikolausDemmel Nov 20, 2017
b9a6011
Update readme. Includes instructions for OSX.
NikolausDemmel Nov 20, 2017
e23014e
cmake: simplify install rules
NikolausDemmel Nov 20, 2017
cc86b7b
travis: also test 'make install'
NikolausDemmel Nov 20, 2017
673e2e2
Fix OSX travis build (they upgraded their default image).
NikolausDemmel Dec 2, 2017
5c77bcc
Fix cmake warning and note on static vs dynamic so
NikolausDemmel Dec 4, 2017
0333335
Sophus: proper fix for deprecation warnings.
NikolausDemmel May 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# no xenial support from travis yet...
dist: trusty
sudo: enabled
language: cpp
cache: ccache

# get c++14 compatible gcc version
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-5
- g++-5

# 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
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
- compiler: gcc
os: linux
env:
- BUILD_TYPE=Debug
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
- 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:
- 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

script:
- mkdir build
- cd build
- cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..
- make
- sudo make install
# - make test
123 changes: 106 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,62 @@ PROJECT(${PROJECT_NAME})
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
#set(CMAKE_VERBOSE_MAKEFILE ON)


set(BUILD_TYPE Release)
#set(BUILD_TYPE RelWithDebInfo)
# 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)
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"
"MinSizeRel" "RelWithDebInfo")
endif()

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)

# avoid cmake policy warning by adopting new default
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
endif()

# required libraries
find_package(SuiteParse REQUIRED)
find_package(Eigen3 REQUIRED)
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)

# 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 ${CMAKE_CXX_FLAGS}"
# "-O3 -g -fno-omit-frame-pointer"
)

#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)
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
Expand All @@ -55,7 +82,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
Expand Down Expand Up @@ -109,24 +136,86 @@ 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})

#set_property( TARGET dso APPEND_STRING PROPERTY COMPILE_FLAGS -Wall )


if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") # OSX
set(BOOST_THREAD_LIBRARY boost_thread-mt)
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 ${LIBRARY_OUTPUT_PATH} COMPONENT libraries)
else()
set(BOOST_THREAD_LIBRARY boost_thread)
message("--- dso dynamic library selected.")
add_library(dso SHARED ${dso_SOURCE_FILES} ${dso_opencv_SOURCE_FILES} ${dso_pangolin_SOURCE_FILES})
target_link_libraries(dso ${DSO_BOOST_LIBRARIES})
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 ${LIBRARY_OUTPUT_PATH} COMPONENT libraries)
endif()
#set_property( TARGET dso APPEND_STRING PROPERTY COMPILE_FLAGS -Wall )

# 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 cxsparse ${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.")
endif()

# 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)
install(DIRECTORY thirdparty/Sophus/sophus DESTINATION ${INCLUDE_OUTPUT_PATH}
FILES_MATCHING PATTERN "*.hpp")


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)

34 changes: 28 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ Get some datasets from [https://vision.in.tum.de/mono-dataset](https://vision.in

#### 2.1 Required Dependencies

##### suitesparse and eigen3 (required).
Required. Install with

sudo apt-get install libsuitesparse-dev libeigen3-dev libboost-all-dev
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

#### 2.2 Optional Dependencies

Expand Down Expand Up @@ -52,6 +54,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, you need to compile it manually:

sudo apt-get install zlib1g-dev
cd dso/thirdparty
tar -zxvf libzip-1.1.1.tar.gz
Expand All @@ -64,6 +72,16 @@ to unzip the dataset image archives before loading them).
##### 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
Expand All @@ -72,9 +90,10 @@ 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 `cmake -DDSO_BUILD_STATIC_LIBRARY=ON`.
Note that with a static library, it seems you might get (slightly) better runtime performance.



Expand Down Expand Up @@ -172,6 +191,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`),
Expand Down
11 changes: 11 additions & 0 deletions dso.pc.in
Original file line number Diff line number Diff line change
@@ -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@
24 changes: 24 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<package format="2">
<name>dso</name>
<version>1.0.0</version>
<description>Direct Sparse Visual Odometry</description>
<maintainer email="[email protected]">Nikolaus Demmel</maintainer>
<maintainer email="[email protected]">Jakob Engel</maintainer>
<author email="[email protected]">Jakob Engel</author>
<license>GPLv3</license>
<url>http://vision.in.tum.de/dso</url>
<buildtool_depend>cmake</buildtool_depend>
<depend>eigen</depend>
<depend>pangolin</depend>
<depend>suitesparse</depend>
<depend>boost</depend>
<depend>libopencv-dev</depend>
<depend>zlib</depend>
<export>
<build_type>cmake</build_type>
</export>
<!-- todo: define rosdep keys for libzip -->
</package>


Loading