Skip to content

Commit

Permalink
Upgrade to the COLMAP head. Use FetchContent for PoseLib and COLMAP (#98
Browse files Browse the repository at this point in the history
)

* init migration.

* formatting.

* update.

* seems to be working

* skip copying to source

* fix. remove poselib include

* fix non void

* switch to official libigl

* use fetch content for poselib. update readme.

* fetch content for colmap

* update readme. no need for colmap installation

* update cmakelist

* fix install

* update readme

* update

* fix submodule

* try to disable cuda for colmap

* fix binding

* move CUDA_ENABLED to top level

* fix copy in pybind

* switch to clang-format 19.1.0 and use pip

* upgrade deeplsd

* use logging from pycolmap

* disable parallelization in fitnmerge

* fix formatting

* fix formatting

* E501

* fix scripts

* remove python json logger

* fix copy constructor for other classes

* Update to latest DeepLSD

---------

Co-authored-by: pautratrmi <[email protected]>
  • Loading branch information
B1ueber2y and pautratrmi authored Nov 28, 2024
1 parent f988271 commit 04987c4
Show file tree
Hide file tree
Showing 93 changed files with 734 additions and 582 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/format-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ jobs:
exit 0
fi
set +x -euo pipefail
sudo apt-get update && sudo apt-get install -y clang-format-14
python -m pip install ruff==0.6.7
python -m pip install ruff==0.6.7 clang-format==19.1.0
./scripts/format/clang_format.sh
./scripts/format/python.sh
git diff --name-only
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
[submodule "third-party/JLinkage"]
path = third-party/JLinkage
url = https://github.com/B1ueber2y/JLinkage
[submodule "third-party/libigl"]
path = third-party/libigl
url = https://github.com/B1ueber2y/libigl.git
[submodule "third-party/RansacLib"]
path = third-party/RansacLib
url = https://github.com/B1ueber2y/RansacLib.git
Expand All @@ -36,3 +33,6 @@
[submodule "third-party/GlueStick"]
path = third-party/GlueStick
url = https://github.com/cvg/GlueStick.git
[submodule "third-party/libigl"]
path = third-party/libigl
url = https://github.com/libigl/libigl.git
86 changes: 15 additions & 71 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ project(LIMAP)
# Include CMake dependencies
################################################################################
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.1)
message(FATAL_ERROR "GCC version needs to be at least 9.1")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -std=c++17 -std=gnu++17") # brute-force approach to make sure we are using C++17

# Include helper macros and commands, and allow the included file to override
# the CMake policies in this file
Expand All @@ -24,89 +23,34 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeHelper.cmake NO_POLICY_SCOPE)
################################################################################
option(OPENMP_ENABLED "Whether to enable OpenMP parallelization" ON)
option(INTERPOLATION_ENABLED "Whether to enable interpolation-based pixel-perfect optimization" OFF)
option(FETCH_POSELIB "Whether to use PoseLib with FetchContent or with self-installed software" ON)
option(FETCH_COLMAP "Whether to use COLMAP with FetchContent or with self-installed software" ON)
option(CUDA_ENABLED "Whether to use CUDA (only for the third-party COLMAP)" OFF)

################################################################################
# Compiler specific configuration
################################################################################

if(OPENMP_ENABLED)
find_package(OpenMP)
if(OPENMP_FOUND)
message(STATUS "Enabling OpenMP support")
add_definitions("-DOPENMP_ENABLED")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
endif()

if(INTERPOLATION_ENABLED)
message(STATUS "Enabling pixelwise optimization with ceres interpolation. This should be disabled for clang.")
add_definitions("-DINTERPOLATION_ENABLED")
else()
message(STATUS "Disabling pixelwise optimization with ceres interpolation.")
endif()

################################################################################
# Find packages
################################################################################
find_package(Eigen3 3.3 REQUIRED)
find_package(COLMAP REQUIRED)
if(${CERES_VERSION} VERSION_LESS "2.2.0")
# ceres 2.2.0 changes the interface of local parameterization
add_definitions("-DCERES_PARAMETERIZATION_ENABLED")
endif()
find_package(PoseLib REQUIRED)

################################################################################
# Add sources
################################################################################

set(LIMAP_INCLUDE_DIRS
${HDF5_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}
${FREEIMAGE_INCLUDE_DIRS}
${COLMAP_INCLUDE_DIRS}
)

set(LIMAP_LINK_DIRS
${COLMAP_LINK_DIRS}
)

set(LIMAP_EXTERNAL_LIBRARIES
${CERES_LIBRARIES}
${FREEIMAGE_LIBRARIES}
${COLMAP_LIBRARIES}
${HDF5_C_LIBRARIES}
${Boost_LIBRARIES}
PoseLib::PoseLib
)

if(OPENMP_FOUND)
list(APPEND LIMAP_EXTERNAL_LIBRARIES ${OpenMP_libomp_LIBRARY})
endif()

set(LIMAP_INTERNAL_LIBRARIES
HighFive
pybind11::module
JLinkage
igl::core
)
include(cmake/FindDependencies.cmake)
include(cmake/InitVariables.cmake)

# include directories
include_directories(
third-party
limap
${PROJECT_SOURCE_DIR}
${LIMAP_INCLUDE_DIRS}
)

link_directories(${LIMAP_LINK_DIRS})

# Add sources
add_subdirectory(third-party)
include_directories(${JLINKAGE_INCLUDE_DIRS})
include_directories(${POSELIB_INCLUDE_DIRS})
include_directories(${RANSACLIB_INCLUDE_DIRS})
add_subdirectory(limap)

# Install find_package scripts for dependencies.
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake
DESTINATION share/colmap
FILES_MATCHING PATTERN "Find*.cmake")

################################################################################
# Generate source groups for Visual Studio, XCode, etc.
################################################################################
Expand Down
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,38 @@ In this project, we provide interfaces for various geometric operations on 2D/3D

## Installation

**Note**: COLMAP has been under active development since summer 2023, so we currently only support COLMAP 3.8.

**Install the dependencies as follows:**
* CMake >= 3.17
* COLMAP 3.8 [[the official guide](https://colmap.github.io/install.html)] _make sure to use the tag 3.8_
* PoseLib [[Guide](misc/install/poselib.md)]
* All dependencies for third-party: COLMAP (will be installed with FetchContent). From [[official guide](https://colmap.github.io/install.html)]
```bash
sudo apt-get install \
git \
cmake \
ninja-build \
build-essential \
libboost-program-options-dev \
libboost-filesystem-dev \
libboost-graph-dev \
libboost-system-dev \
libeigen3-dev \
libflann-dev \
libfreeimage-dev \
libmetis-dev \
libgoogle-glog-dev \
libgtest-dev \
libgmock-dev \
libsqlite3-dev \
libglew-dev \
qtbase5-dev \
libqt5opengl5-dev \
libcgal-dev \
libceres-dev
```
* HDF5
```bash
sudo apt-get install libhdf5-dev
```
* Python 3.9 + required packages
* Python >= 3.9 + required packages
```bash
git submodule update --init --recursive

Expand Down
2 changes: 1 addition & 1 deletion cfgs/fitnmerge/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fitting:
var2d: -1.0 # depends on the detector
ransac_th: 0.75
min_percentage_inliers: 0.9
n_jobs: 4
n_jobs: 1

##############################
# merging config
Expand Down
69 changes: 69 additions & 0 deletions cmake/FindDependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
################################################################################
# Find packages
################################################################################
find_package(Eigen3 3.4 REQUIRED)
find_package(FreeImage REQUIRED)
find_package(Glog REQUIRED)
if(DEFINED glog_VERSION_MAJOR)
# Older versions of glog don't export version variables.
add_definitions("-DGLOG_VERSION_MAJOR=${glog_VERSION_MAJOR}")
add_definitions("-DGLOG_VERSION_MINOR=${glog_VERSION_MINOR}")
endif()
find_package(Boost REQUIRED COMPONENTS
graph
program_options
system)

# Ceres
find_package(Ceres REQUIRED COMPONENTS SuiteSparse)
if(${CERES_VERSION} VERSION_LESS "2.2.0")
# ceres 2.2.0 changes the interface of local parameterization
add_definitions("-DCERES_PARAMETERIZATION_ENABLED")
endif()
if(INTERPOLATION_ENABLED)
message(STATUS "Enabling pixelwise optimization with ceres interpolation. This should be disabled for clang.")
add_definitions("-DINTERPOLATION_ENABLED")
else()
message(STATUS "Disabling pixelwise optimization with ceres interpolation.")
endif()

# OpenMP
if(OPENMP_ENABLED)
find_package(OpenMP)
if(OPENMP_FOUND)
message(STATUS "Enabling OpenMP support")
add_definitions("-DOPENMP_ENABLED")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
endif()

# PoseLib
include(FetchContent)
FetchContent_Declare(PoseLib
GIT_REPOSITORY https://github.com/PoseLib/PoseLib.git
GIT_TAG a84c545a9895e46d12a3f5ccde2581c25e6a6953
EXCLUDE_FROM_ALL
)
message(STATUS "Configuring PoseLib...")
if (FETCH_POSELIB)
FetchContent_MakeAvailable(PoseLib)
else()
find_package(PoseLib REQUIRED)
endif()
message(STATUS "Configuring PoseLib... done")

# COLMAP
FetchContent_Declare(COLMAP
GIT_REPOSITORY https://github.com/colmap/colmap.git
GIT_TAG 63b2cc000de32dc697f45ef1576dec7e67abddbc
EXCLUDE_FROM_ALL
)
message(STATUS "Configuring COLMAP...")
if (FETCH_COLMAP)
FetchContent_MakeAvailable(COLMAP)
else()
find_package(COLMAP REQUIRED)
endif()
message(STATUS "Configuring COLMAP... done")

104 changes: 104 additions & 0 deletions cmake/FindFreeImage.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Copyright (c) 2023, ETH Zurich and UNC Chapel Hill.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the name of ETH Zurich and UNC Chapel Hill nor the names of
# its contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.


# Find package module for FreeImage library.
#
# The following variables are set by this module:
#
# FREEIMAGE_FOUND: TRUE if FreeImage is found.
# freeimage::FreeImage_limap: Imported target to link against.
#
# The following variables control the behavior of this module:
#
# FREEIMAGE_INCLUDE_DIR_HINTS: List of additional directories in which to
# search for FreeImage includes.
# FREEIMAGE_LIBRARY_DIR_HINTS: List of additional directories in which to
# search for FreeImage libraries.

set(FREEIMAGE_INCLUDE_DIR_HINTS "" CACHE PATH "FreeImage include directory")
set(FREEIMAGE_LIBRARY_DIR_HINTS "" CACHE PATH "FreeImage library directory")

unset(FREEIMAGE_FOUND)

find_package(FreeImage CONFIG QUIET)
if(FreeImage_FOUND)
if(TARGET freeimage::FreeImage_limap)
set(FREEIMAGE_FOUND TRUE)
message(STATUS "Found FreeImage")
message(STATUS " Target : freeimage::FreeImage_limap")
endif()
else()
list(APPEND FREEIMAGE_CHECK_INCLUDE_DIRS
${FREEIMAGE_INCLUDE_DIR_HINTS}
/usr/include
/usr/local/include
/opt/include
/opt/local/include
)

list(APPEND FREEIMAGE_CHECK_LIBRARY_DIRS
${FREEIMAGE_LIBRARY_DIR_HINTS}
/usr/lib
/usr/local/lib
/opt/lib
/opt/local/lib
)

find_path(FREEIMAGE_INCLUDE_DIRS
NAMES
FreeImage.h
PATHS
${FREEIMAGE_CHECK_INCLUDE_DIRS})
find_library(FREEIMAGE_LIBRARIES
NAMES
freeimage
PATHS
${FREEIMAGE_CHECK_LIBRARY_DIRS})

if(FREEIMAGE_INCLUDE_DIRS AND FREEIMAGE_LIBRARIES)
set(FREEIMAGE_FOUND TRUE)
endif()

if(FREEIMAGE_FOUND)
message(STATUS "Found FreeImage")
message(STATUS " Includes : ${FREEIMAGE_INCLUDE_DIRS}")
message(STATUS " Libraries : ${FREEIMAGE_LIBRARIES}")
endif()

add_library(freeimage::FreeImage_limap INTERFACE IMPORTED)
target_include_directories(
freeimage::FreeImage_limap INTERFACE ${FREEIMAGE_INCLUDE_DIRS})
target_link_libraries(
freeimage::FreeImage_limap INTERFACE ${FREEIMAGE_LIBRARIES})
endif()

if(NOT FREEIMAGE_FOUND AND FREEIMAGE_FIND_REQUIRED)
message(FATAL_ERROR "Could not find FreeImage")
endif()
Loading

0 comments on commit 04987c4

Please sign in to comment.