From 01c29b67831d9adf415d703853934fb0737a6edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 22 Jul 2023 15:28:12 +0200 Subject: [PATCH 01/38] Option manager moves to controllers to disentangle circular deps --- src/colmap/controllers/CMakeLists.txt | 1 + src/colmap/controllers/automatic_reconstruction.cc | 5 +++-- src/colmap/controllers/automatic_reconstruction.h | 2 +- src/colmap/controllers/bundle_adjustment.h | 2 +- src/colmap/{util => controllers}/option_manager.cc | 2 +- src/colmap/{util => controllers}/option_manager.h | 0 src/colmap/exe/database.cc | 2 +- src/colmap/exe/feature.cc | 2 +- src/colmap/exe/gui.cc | 2 +- src/colmap/exe/image.cc | 2 +- src/colmap/exe/model.cc | 2 +- src/colmap/exe/mvs.cc | 2 +- src/colmap/exe/sfm.cc | 5 +++-- src/colmap/exe/vocab_tree.cc | 2 +- src/colmap/mvs/meshing.cc | 1 - src/colmap/scene/reconstruction_manager.cc | 7 +------ src/colmap/scene/reconstruction_manager.h | 4 +--- src/colmap/tools/example.cc | 2 +- src/colmap/ui/bundle_adjustment_widget.h | 2 +- src/colmap/ui/database_management_widget.h | 2 +- src/colmap/ui/dense_reconstruction_widget.h | 2 +- src/colmap/ui/feature_extraction_widget.h | 2 +- src/colmap/ui/feature_matching_widget.h | 2 +- src/colmap/ui/image_viewer_widget.h | 2 +- src/colmap/ui/log_widget.h | 2 +- src/colmap/ui/main_window.cc | 3 ++- src/colmap/ui/match_matrix_widget.h | 2 +- src/colmap/ui/model_viewer_widget.h | 2 +- src/colmap/ui/point_viewer_widget.h | 2 +- src/colmap/ui/project_widget.h | 2 +- src/colmap/ui/reconstruction_options_widget.h | 2 +- src/colmap/ui/undistortion_widget.h | 2 +- src/colmap/util/CMakeLists.txt | 1 - 33 files changed, 35 insertions(+), 40 deletions(-) rename src/colmap/{util => controllers}/option_manager.cc (99%) rename src/colmap/{util => controllers}/option_manager.h (100%) diff --git a/src/colmap/controllers/CMakeLists.txt b/src/colmap/controllers/CMakeLists.txt index 849534304f..9b3127a2da 100644 --- a/src/colmap/controllers/CMakeLists.txt +++ b/src/colmap/controllers/CMakeLists.txt @@ -36,6 +36,7 @@ COLMAP_ADD_SOURCES( bundle_adjustment.h bundle_adjustment.cc hierarchical_mapper.h hierarchical_mapper.cc incremental_mapper.h incremental_mapper.cc + option_manager.h option_manager.cc ) COLMAP_ADD_TEST(hierarchical_mapper_test hierarchical_mapper_test.cc) diff --git a/src/colmap/controllers/automatic_reconstruction.cc b/src/colmap/controllers/automatic_reconstruction.cc index 9b98649082..cd648e7036 100644 --- a/src/colmap/controllers/automatic_reconstruction.cc +++ b/src/colmap/controllers/automatic_reconstruction.cc @@ -32,6 +32,7 @@ #include "colmap/controllers/automatic_reconstruction.h" #include "colmap/controllers/incremental_mapper.h" +#include "colmap/controllers/option_manager.h" #include "colmap/feature/extraction.h" #include "colmap/feature/matching.h" #include "colmap/image/undistortion.h" @@ -39,7 +40,6 @@ #include "colmap/mvs/meshing.h" #include "colmap/mvs/patch_match.h" #include "colmap/util/misc.h" -#include "colmap/util/option_manager.h" namespace colmap { @@ -233,7 +233,8 @@ void AutomaticReconstructionController::RunSparseMapper() { active_thread_ = nullptr; CreateDirIfNotExists(sparse_path); - reconstruction_manager_->Write(sparse_path, &option_manager_); + reconstruction_manager_->Write(sparse_path); + option_manager_.Write(JoinPaths(sparse_path, "project.ini")); } void AutomaticReconstructionController::RunDenseMapper() { diff --git a/src/colmap/controllers/automatic_reconstruction.h b/src/colmap/controllers/automatic_reconstruction.h index a9f35d6f53..deac350f70 100644 --- a/src/colmap/controllers/automatic_reconstruction.h +++ b/src/colmap/controllers/automatic_reconstruction.h @@ -31,8 +31,8 @@ #pragma once +#include "colmap/controllers/option_manager.h" #include "colmap/scene/reconstruction_manager.h" -#include "colmap/util/option_manager.h" #include "colmap/util/threading.h" #include diff --git a/src/colmap/controllers/bundle_adjustment.h b/src/colmap/controllers/bundle_adjustment.h index e9d31f60f1..5cb3976542 100644 --- a/src/colmap/controllers/bundle_adjustment.h +++ b/src/colmap/controllers/bundle_adjustment.h @@ -31,8 +31,8 @@ #pragma once +#include "colmap/controllers/option_manager.h" #include "colmap/scene/reconstruction.h" -#include "colmap/util/option_manager.h" #include "colmap/util/threading.h" namespace colmap { diff --git a/src/colmap/util/option_manager.cc b/src/colmap/controllers/option_manager.cc similarity index 99% rename from src/colmap/util/option_manager.cc rename to src/colmap/controllers/option_manager.cc index 3e093f2680..b5fda26268 100644 --- a/src/colmap/util/option_manager.cc +++ b/src/colmap/controllers/option_manager.cc @@ -29,7 +29,7 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -#include "colmap/util/option_manager.h" +#include "colmap/controllers/option_manager.h" #include "colmap/controllers/incremental_mapper.h" #include "colmap/estimators/bundle_adjustment.h" diff --git a/src/colmap/util/option_manager.h b/src/colmap/controllers/option_manager.h similarity index 100% rename from src/colmap/util/option_manager.h rename to src/colmap/controllers/option_manager.h diff --git a/src/colmap/exe/database.cc b/src/colmap/exe/database.cc index 410a69a5cb..4409dfe9f6 100644 --- a/src/colmap/exe/database.cc +++ b/src/colmap/exe/database.cc @@ -31,9 +31,9 @@ #include "colmap/exe/database.h" +#include "colmap/controllers/option_manager.h" #include "colmap/scene/database.h" #include "colmap/util/misc.h" -#include "colmap/util/option_manager.h" namespace colmap { diff --git a/src/colmap/exe/feature.cc b/src/colmap/exe/feature.cc index 021888b1a6..586924cb21 100644 --- a/src/colmap/exe/feature.cc +++ b/src/colmap/exe/feature.cc @@ -32,13 +32,13 @@ #include "colmap/exe/feature.h" #include "colmap/camera/models.h" +#include "colmap/controllers/option_manager.h" #include "colmap/exe/gui.h" #include "colmap/feature/extraction.h" #include "colmap/feature/matching.h" #include "colmap/image/reader.h" #include "colmap/util/misc.h" #include "colmap/util/opengl_utils.h" -#include "colmap/util/option_manager.h" namespace colmap { namespace { diff --git a/src/colmap/exe/gui.cc b/src/colmap/exe/gui.cc index c3946d0f5e..ebe1ace412 100644 --- a/src/colmap/exe/gui.cc +++ b/src/colmap/exe/gui.cc @@ -31,8 +31,8 @@ #include "colmap/exe/gui.h" +#include "colmap/controllers/option_manager.h" #include "colmap/util/opengl_utils.h" -#include "colmap/util/option_manager.h" namespace colmap { diff --git a/src/colmap/exe/image.cc b/src/colmap/exe/image.cc index 82fd8511a4..ad6c90df24 100644 --- a/src/colmap/exe/image.cc +++ b/src/colmap/exe/image.cc @@ -32,11 +32,11 @@ #include "colmap/exe/image.h" #include "colmap/controllers/incremental_mapper.h" +#include "colmap/controllers/option_manager.h" #include "colmap/image/undistortion.h" #include "colmap/scene/reconstruction.h" #include "colmap/sfm/incremental_mapper.h" #include "colmap/util/misc.h" -#include "colmap/util/option_manager.h" namespace colmap { namespace { diff --git a/src/colmap/exe/model.cc b/src/colmap/exe/model.cc index 458b53a5dc..ac3b937a04 100644 --- a/src/colmap/exe/model.cc +++ b/src/colmap/exe/model.cc @@ -31,12 +31,12 @@ #include "colmap/exe/model.h" +#include "colmap/controllers/option_manager.h" #include "colmap/estimators/coordinate_frame.h" #include "colmap/geometry/gps.h" #include "colmap/geometry/pose.h" #include "colmap/scene/alignment.h" #include "colmap/util/misc.h" -#include "colmap/util/option_manager.h" #include "colmap/util/threading.h" namespace colmap { diff --git a/src/colmap/exe/mvs.cc b/src/colmap/exe/mvs.cc index 860a488756..fd0f694efb 100644 --- a/src/colmap/exe/mvs.cc +++ b/src/colmap/exe/mvs.cc @@ -31,12 +31,12 @@ #include "colmap/exe/mvs.h" +#include "colmap/controllers/option_manager.h" #include "colmap/mvs/fusion.h" #include "colmap/mvs/meshing.h" #include "colmap/mvs/patch_match.h" #include "colmap/scene/reconstruction.h" #include "colmap/util/misc.h" -#include "colmap/util/option_manager.h" namespace colmap { diff --git a/src/colmap/exe/sfm.cc b/src/colmap/exe/sfm.cc index 614c4239b8..8b07189918 100644 --- a/src/colmap/exe/sfm.cc +++ b/src/colmap/exe/sfm.cc @@ -34,11 +34,11 @@ #include "colmap/controllers/automatic_reconstruction.h" #include "colmap/controllers/bundle_adjustment.h" #include "colmap/controllers/hierarchical_mapper.h" +#include "colmap/controllers/option_manager.h" #include "colmap/exe/gui.h" #include "colmap/scene/reconstruction.h" #include "colmap/util/misc.h" #include "colmap/util/opengl_utils.h" -#include "colmap/util/option_manager.h" #include #include @@ -295,7 +295,8 @@ int RunHierarchicalMapper(int argc, char** argv) { return EXIT_FAILURE; } - reconstruction_manager->Write(output_path, &options); + reconstruction_manager->Write(output_path); + options.Write(JoinPaths(output_path, "project.ini")); return EXIT_SUCCESS; } diff --git a/src/colmap/exe/vocab_tree.cc b/src/colmap/exe/vocab_tree.cc index 217f9f3e6a..5138f8f9ef 100644 --- a/src/colmap/exe/vocab_tree.cc +++ b/src/colmap/exe/vocab_tree.cc @@ -31,6 +31,7 @@ #include "colmap/exe/vocab_tree.h" +#include "colmap/controllers/option_manager.h" #include "colmap/exe/gui.h" #include "colmap/feature/matching.h" #include "colmap/feature/sift.h" @@ -39,7 +40,6 @@ #include "colmap/scene/database.h" #include "colmap/util/misc.h" #include "colmap/util/opengl_utils.h" -#include "colmap/util/option_manager.h" #include diff --git a/src/colmap/mvs/meshing.cc b/src/colmap/mvs/meshing.cc index a83660441b..23cf944caf 100644 --- a/src/colmap/mvs/meshing.cc +++ b/src/colmap/mvs/meshing.cc @@ -46,7 +46,6 @@ #include "colmap/util/endian.h" #include "colmap/util/logging.h" #include "colmap/util/misc.h" -#include "colmap/util/option_manager.h" #include "colmap/util/ply.h" #include "colmap/util/threading.h" #include "colmap/util/timer.h" diff --git a/src/colmap/scene/reconstruction_manager.cc b/src/colmap/scene/reconstruction_manager.cc index 2d45e27902..b1d3f820dc 100644 --- a/src/colmap/scene/reconstruction_manager.cc +++ b/src/colmap/scene/reconstruction_manager.cc @@ -32,7 +32,6 @@ #include "colmap/scene/reconstruction_manager.h" #include "colmap/util/misc.h" -#include "colmap/util/option_manager.h" namespace colmap { @@ -66,8 +65,7 @@ size_t ReconstructionManager::Read(const std::string& path) { return idx; } -void ReconstructionManager::Write(const std::string& path, - const OptionManager* options) const { +void ReconstructionManager::Write(const std::string& path) const { std::vector> recon_sizes(reconstructions_.size()); for (size_t i = 0; i < reconstructions_.size(); ++i) { recon_sizes[i] = std::make_pair(i, reconstructions_[i]->NumPoints3D()); @@ -83,9 +81,6 @@ void ReconstructionManager::Write(const std::string& path, const std::string reconstruction_path = JoinPaths(path, std::to_string(i)); CreateDirIfNotExists(reconstruction_path); reconstructions_[recon_sizes[i].first]->Write(reconstruction_path); - if (options != nullptr) { - options->Write(JoinPaths(reconstruction_path, "project.ini")); - } } } diff --git a/src/colmap/scene/reconstruction_manager.h b/src/colmap/scene/reconstruction_manager.h index f5b9fee1e5..5ba29d03d8 100644 --- a/src/colmap/scene/reconstruction_manager.h +++ b/src/colmap/scene/reconstruction_manager.h @@ -61,9 +61,7 @@ class ReconstructionManager { size_t Read(const std::string& path); // Write all managed reconstructions into sub-folders "0", "1", "2", ... - // If the option manager object is not null, the options are written - // to each respective reconstruction folder as well. - void Write(const std::string& path, const OptionManager* options) const; + void Write(const std::string& path) const; private: std::vector> reconstructions_; diff --git a/src/colmap/tools/example.cc b/src/colmap/tools/example.cc index 05ce6824ce..4248047244 100644 --- a/src/colmap/tools/example.cc +++ b/src/colmap/tools/example.cc @@ -29,9 +29,9 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) +#include "colmap/controllers/option_manager.h" #include "colmap/scene/reconstruction.h" #include "colmap/util/logging.h" -#include "colmap/util/option_manager.h" // Simple example that reads and writes a reconstruction. int main(int argc, char** argv) { diff --git a/src/colmap/ui/bundle_adjustment_widget.h b/src/colmap/ui/bundle_adjustment_widget.h index fc2a2df2be..e3354a5309 100644 --- a/src/colmap/ui/bundle_adjustment_widget.h +++ b/src/colmap/ui/bundle_adjustment_widget.h @@ -31,10 +31,10 @@ #pragma once +#include "colmap/controllers/option_manager.h" #include "colmap/scene/reconstruction.h" #include "colmap/ui/options_widget.h" #include "colmap/ui/thread_control_widget.h" -#include "colmap/util/option_manager.h" #include #include diff --git a/src/colmap/ui/database_management_widget.h b/src/colmap/ui/database_management_widget.h index ac9a47cfa7..443e016334 100644 --- a/src/colmap/ui/database_management_widget.h +++ b/src/colmap/ui/database_management_widget.h @@ -31,10 +31,10 @@ #pragma once +#include "colmap/controllers/option_manager.h" #include "colmap/scene/database.h" #include "colmap/ui/image_viewer_widget.h" #include "colmap/util/misc.h" -#include "colmap/util/option_manager.h" #include #include diff --git a/src/colmap/ui/dense_reconstruction_widget.h b/src/colmap/ui/dense_reconstruction_widget.h index d243e15e1f..2d28aaad2d 100644 --- a/src/colmap/ui/dense_reconstruction_widget.h +++ b/src/colmap/ui/dense_reconstruction_widget.h @@ -31,11 +31,11 @@ #pragma once +#include "colmap/controllers/option_manager.h" #include "colmap/mvs/fusion.h" #include "colmap/ui/image_viewer_widget.h" #include "colmap/ui/options_widget.h" #include "colmap/ui/thread_control_widget.h" -#include "colmap/util/option_manager.h" #include #include diff --git a/src/colmap/ui/feature_extraction_widget.h b/src/colmap/ui/feature_extraction_widget.h index b98be005ea..f4be07b99f 100644 --- a/src/colmap/ui/feature_extraction_widget.h +++ b/src/colmap/ui/feature_extraction_widget.h @@ -31,8 +31,8 @@ #pragma once +#include "colmap/controllers/option_manager.h" #include "colmap/util/misc.h" -#include "colmap/util/option_manager.h" #include #include diff --git a/src/colmap/ui/feature_matching_widget.h b/src/colmap/ui/feature_matching_widget.h index fb9136d1b5..da86ce44cb 100644 --- a/src/colmap/ui/feature_matching_widget.h +++ b/src/colmap/ui/feature_matching_widget.h @@ -31,8 +31,8 @@ #pragma once +#include "colmap/controllers/option_manager.h" #include "colmap/util/misc.h" -#include "colmap/util/option_manager.h" #include #include diff --git a/src/colmap/ui/image_viewer_widget.h b/src/colmap/ui/image_viewer_widget.h index 863eed50fc..a6fb24a8b5 100644 --- a/src/colmap/ui/image_viewer_widget.h +++ b/src/colmap/ui/image_viewer_widget.h @@ -31,11 +31,11 @@ #pragma once +#include "colmap/controllers/option_manager.h" #include "colmap/geometry/projection.h" #include "colmap/scene/database.h" #include "colmap/scene/reconstruction.h" #include "colmap/ui/qt_utils.h" -#include "colmap/util/option_manager.h" #include #include diff --git a/src/colmap/ui/log_widget.h b/src/colmap/ui/log_widget.h index b39a0637f7..d6002d0974 100644 --- a/src/colmap/ui/log_widget.h +++ b/src/colmap/ui/log_widget.h @@ -31,7 +31,7 @@ #pragma once -#include "colmap/util/option_manager.h" +#include "colmap/controllers/option_manager.h" #include #include diff --git a/src/colmap/ui/main_window.cc b/src/colmap/ui/main_window.cc index e203f30025..53872c930b 100644 --- a/src/colmap/ui/main_window.cc +++ b/src/colmap/ui/main_window.cc @@ -887,7 +887,8 @@ void MainWindow::ExportAll() { } thread_control_widget_->StartFunction("Exporting...", [this, export_path]() { - reconstruction_manager_->Write(export_path, &options_); + reconstruction_manager_->Write(export_path); + options_.Write(JoinPaths(export_path, "project.ini")); }); } diff --git a/src/colmap/ui/match_matrix_widget.h b/src/colmap/ui/match_matrix_widget.h index 335bd6d691..29126149bd 100644 --- a/src/colmap/ui/match_matrix_widget.h +++ b/src/colmap/ui/match_matrix_widget.h @@ -31,8 +31,8 @@ #pragma once +#include "colmap/controllers/option_manager.h" #include "colmap/ui/image_viewer_widget.h" -#include "colmap/util/option_manager.h" namespace colmap { diff --git a/src/colmap/ui/model_viewer_widget.h b/src/colmap/ui/model_viewer_widget.h index ab3d407d11..1ee68070b4 100644 --- a/src/colmap/ui/model_viewer_widget.h +++ b/src/colmap/ui/model_viewer_widget.h @@ -31,6 +31,7 @@ #pragma once +#include "colmap/controllers/option_manager.h" #include "colmap/scene/database.h" #include "colmap/scene/reconstruction.h" #include "colmap/ui/colormaps.h" @@ -41,7 +42,6 @@ #include "colmap/ui/point_viewer_widget.h" #include "colmap/ui/render_options.h" #include "colmap/ui/triangle_painter.h" -#include "colmap/util/option_manager.h" #include #include diff --git a/src/colmap/ui/point_viewer_widget.h b/src/colmap/ui/point_viewer_widget.h index 84e5100858..58bd3d55b2 100644 --- a/src/colmap/ui/point_viewer_widget.h +++ b/src/colmap/ui/point_viewer_widget.h @@ -31,8 +31,8 @@ #pragma once +#include "colmap/controllers/option_manager.h" #include "colmap/scene/reconstruction.h" -#include "colmap/util/option_manager.h" #include #include diff --git a/src/colmap/ui/project_widget.h b/src/colmap/ui/project_widget.h index 63391e46b3..8e9aee69f1 100644 --- a/src/colmap/ui/project_widget.h +++ b/src/colmap/ui/project_widget.h @@ -31,8 +31,8 @@ #pragma once +#include "colmap/controllers/option_manager.h" #include "colmap/util/misc.h" -#include "colmap/util/option_manager.h" #include #include diff --git a/src/colmap/ui/reconstruction_options_widget.h b/src/colmap/ui/reconstruction_options_widget.h index 0316d06696..875e23c0e1 100644 --- a/src/colmap/ui/reconstruction_options_widget.h +++ b/src/colmap/ui/reconstruction_options_widget.h @@ -31,8 +31,8 @@ #pragma once +#include "colmap/controllers/option_manager.h" #include "colmap/ui/options_widget.h" -#include "colmap/util/option_manager.h" #include #include diff --git a/src/colmap/ui/undistortion_widget.h b/src/colmap/ui/undistortion_widget.h index 4e7c225935..30670382ef 100644 --- a/src/colmap/ui/undistortion_widget.h +++ b/src/colmap/ui/undistortion_widget.h @@ -31,12 +31,12 @@ #pragma once +#include "colmap/controllers/option_manager.h" #include "colmap/image/undistortion.h" #include "colmap/scene/reconstruction.h" #include "colmap/ui/options_widget.h" #include "colmap/ui/thread_control_widget.h" #include "colmap/util/misc.h" -#include "colmap/util/option_manager.h" #include #include diff --git a/src/colmap/util/CMakeLists.txt b/src/colmap/util/CMakeLists.txt index d707fd47e0..7d9253850e 100644 --- a/src/colmap/util/CMakeLists.txt +++ b/src/colmap/util/CMakeLists.txt @@ -36,7 +36,6 @@ COLMAP_ADD_SOURCES( logging.h logging.cc misc.h misc.cc opengl_utils.h opengl_utils.cc - option_manager.h option_manager.cc ply.h ply.cc sqlite3_utils.h string.h string.cc From ed9e642ea28045d8f05ccde3c528cf4baf70e650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 22 Jul 2023 22:13:30 +0200 Subject: [PATCH 02/38] Granular CMake module targets --- CMakeLists.txt | 40 +++++- cmake/CMakeHelper.cmake | 78 +++++------ cmake/FindFLANN.cmake | 6 + cmake/FindFreeImage.cmake | 6 + cmake/FindGlew.cmake | 6 + cmake/FindLZ4.cmake | 6 + cmake/FindMetis.cmake | 6 + src/colmap/CMakeLists.txt | 23 ++-- src/colmap/camera/CMakeLists.txt | 27 +++- src/colmap/camera/models.h | 2 +- src/colmap/controllers/CMakeLists.txt | 39 ++++-- src/colmap/estimators/CMakeLists.txt | 130 +++++++++++++----- .../estimators/generalized_relative_pose.cc | 29 +--- src/colmap/estimators/pose.cc | 61 ++++++++ src/colmap/estimators/pose.h | 18 +++ src/colmap/estimators/pose_test.cc | 79 +++++++++++ src/colmap/exe/CMakeLists.txt | 53 +++++-- src/colmap/exe/vocab_tree.cc | 1 - src/colmap/feature/CMakeLists.txt | 41 ++++-- src/colmap/geometry/CMakeLists.txt | 75 +++++++--- src/colmap/geometry/essential_matrix.cc | 64 +-------- src/colmap/geometry/essential_matrix.h | 19 --- src/colmap/geometry/essential_matrix_test.cc | 38 ----- src/colmap/geometry/triangulation.cc | 2 + src/colmap/image/CMakeLists.txt | 45 ++++-- src/colmap/math/CMakeLists.txt | 50 +++++-- src/colmap/mvs/CMakeLists.txt | 74 +++++++--- src/colmap/optim/CMakeLists.txt | 62 +++++++-- src/colmap/retrieval/CMakeLists.txt | 50 +++++-- src/colmap/retrieval/visual_index.h | 2 +- src/colmap/scene/CMakeLists.txt | 128 ++++++++++++----- src/colmap/scene/database_cache.h | 1 + src/colmap/sfm/CMakeLists.txt | 14 +- src/colmap/ui/CMakeLists.txt | 70 ++++++---- src/colmap/util/CMakeLists.txt | 91 ++++++++---- src/colmap/util/ply.h | 4 +- src/colmap/util/version.cc | 4 +- src/lib/LSD/CMakeLists.txt | 7 +- src/lib/PoissonRecon/CMakeLists.txt | 89 ++++++------ src/lib/SiftGPU/CMakeLists.txt | 18 ++- src/lib/VLFeat/CMakeLists.txt | 2 +- 41 files changed, 1058 insertions(+), 502 deletions(-) create mode 100644 src/colmap/estimators/pose_test.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 58285cb421..c71d86e1a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,6 +178,26 @@ if(CGAL_FOUND) message(STATUS "Found CGAL") message(STATUS " Includes : ${CGAL_INCLUDE_DIRS}") message(STATUS " Libraries : ${CGAL_LIBRARY}") + if(NOT TARGET CGAL) + add_library(CGAL INTERFACE IMPORTED) + target_include_directories( + CGAL INTERFACE ${CGAL_INCLUDE_DIRS} ${GMP_INCLUDE_DIR}) + target_link_libraries( + CGAL INTERFACE ${CGAL_LIBRARY} ${GMP_LIBRARIES}) + endif() +endif() + +add_library(OpenGL INTERFACE IMPORTED) +target_link_libraries( + OpenGL INTERFACE ${OPENGL_LIBRARIES}) + +# For backwards compatibility with older Ceres versions, define the interface. +if(NOT TARGET Ceres::ceres) + add_library(Ceres::ceres INTERFACE IMPORTED) + target_include_directories( + Ceres::ceres INTERFACE ${CERES_INCLUDE_DIRS}) + target_link_libraries( + Ceres::ceres INTERFACE ${CERES_LIBRARIES}) endif() @@ -352,10 +372,8 @@ endif() include(GenerateVersionDefinitions) set(COLMAP_INCLUDE_DIRS - ${FLANN_INCLUDE_DIRS} ${LZ4_INCLUDE_DIRS} ${FREEIMAGE_INCLUDE_DIRS} - ${CERES_INCLUDE_DIRS} ${METIS_INCLUDE_DIRS} ${GLEW_INCLUDE_DIRS} ) @@ -366,16 +384,15 @@ set(COLMAP_LINK_DIRS set(COLMAP_EXTERNAL_LIBRARIES ${CMAKE_DL_LIBS} - ${FLANN_LIBRARIES} ${LZ4_LIBRARIES} ${FREEIMAGE_LIBRARIES} ${METIS_LIBRARIES} - ${CERES_LIBRARIES} ${OPENGL_LIBRARIES} Boost::program_options Boost::filesystem Boost::graph Boost::system + Ceres::ceres Eigen3::Eigen glog::glog SQLite::SQLite3 @@ -391,6 +408,7 @@ if(Qt5_FOUND) endif() if(CGAL_FOUND) + list(APPEND COLMAP_INCLUDE_DIRS ${CGAL_INCLUDE_DIRS} ${GMP_INCLUDE_DIR}) list(APPEND COLMAP_EXTERNAL_LIBRARIES ${CGAL_LIBRARY} ${GMP_LIBRARIES}) list(APPEND COLMAP_LINK_DIRS ${CGAL_LIBRARIES_DIR}) @@ -401,6 +419,20 @@ if(UNIX) endif() set(COLMAP_INTERNAL_LIBRARIES + colmap_util + colmap_math + colmap_camera + colmap_image + colmap_feature + colmap_geometry + colmap_scene + colmap_estimators + colmap_optim + colmap_mvs + colmap_retrieval + colmap_sfm + colmap_controllers + colmap_ui lsd poisson_recon sift_gpu diff --git a/cmake/CMakeHelper.cmake b/cmake/CMakeHelper.cmake index b36a457d32..a4f51e667a 100644 --- a/cmake/CMakeHelper.cmake +++ b/cmake/CMakeHelper.cmake @@ -109,73 +109,70 @@ endmacro(COLMAP_ADD_CUDA_SOURCES) # Replacement for the normal add_library() command. The syntax remains the same # in that the first argument is the target name, and the following arguments # are the source files to use when building the target. -macro(COLMAP_ADD_LIBRARY TARGET_NAME) - # ${ARGN} will store the list of source files passed to this function. - add_library(${TARGET_NAME} STATIC ${ARGN}) - set_target_properties(${TARGET_NAME} PROPERTIES FOLDER +macro(COLMAP_ADD_LIBRARY) + set(options) + set(oneValueArgs) + set(multiValueArgs NAME SRCS PRIVATE_DEPS PUBLIC_DEPS) + cmake_parse_arguments(COLMAP_ADD_LIBRARY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + add_library(${COLMAP_ADD_LIBRARY_NAME} STATIC ${COLMAP_ADD_LIBRARY_SRCS}) + set_target_properties(${COLMAP_ADD_LIBRARY_NAME} PROPERTIES FOLDER ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) if(CLANG_TIDY_EXE) - set_target_properties(${TARGET_NAME} + set_target_properties(${COLMAP_ADD_LIBRARY_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") endif() - install(TARGETS ${TARGET_NAME} DESTINATION lib/colmap) + target_link_libraries(${COLMAP_ADD_LIBRARY_NAME} + PRIVATE ${COLMAP_ADD_LIBRARY_PRIVATE_DEPS} + PUBLIC ${COLMAP_ADD_LIBRARY_PUBLIC_DEPS}) + install(TARGETS ${COLMAP_ADD_LIBRARY_NAME} DESTINATION lib/colmap) endmacro(COLMAP_ADD_LIBRARY) -# Replacement for the normal cuda_add_library() command. The syntax remains the -# same in that the first argument is the target name, and the following -# arguments are the source files to use when building the target. -macro(COLMAP_ADD_CUDA_LIBRARY TARGET_NAME) - # ${ARGN} will store the list of source files passed to this function. - add_library(${TARGET_NAME} STATIC ${ARGN}) - target_link_libraries(${TARGET_NAME} CUDA::cudart CUDA::curand) - set_target_properties(${TARGET_NAME} PROPERTIES FOLDER - ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) - if(CLANG_TIDY_EXE) - set_target_properties(${TARGET_NAME} - PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") - endif() - install(TARGETS ${TARGET_NAME} DESTINATION lib/colmap/) -endmacro(COLMAP_ADD_CUDA_LIBRARY) - # Replacement for the normal add_executable() command. The syntax remains the # same in that the first argument is the target name, and the following # arguments are the source files to use when building the target. -macro(COLMAP_ADD_EXECUTABLE TARGET_NAME) - # ${ARGN} will store the list of source files passed to this function. - add_executable(${TARGET_NAME} ${ARGN}) - set_target_properties(${TARGET_NAME} PROPERTIES FOLDER +macro(COLMAP_ADD_EXECUTABLE) +set(options) +set(oneValueArgs) +set(multiValueArgs NAME SRCS DEPS) +cmake_parse_arguments(COLMAP_ADD_EXECUTABLE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + add_executable(${COLMAP_ADD_EXECUTABLE_NAME} ${COLMAP_ADD_EXECUTABLE_SRCS}) + set_target_properties(${COLMAP_ADD_EXECUTABLE_NAME} PROPERTIES FOLDER ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) - target_link_libraries(${TARGET_NAME} colmap) + target_link_libraries(${COLMAP_ADD_EXECUTABLE_NAME} ${COLMAP_ADD_EXECUTABLE_DEPS}) if(VCPKG_BUILD) - install(TARGETS ${TARGET_NAME} DESTINATION tools/) + install(TARGETS ${COLMAP_ADD_EXECUTABLE_NAME} DESTINATION tools/) else() - install(TARGETS ${TARGET_NAME} DESTINATION bin/) + install(TARGETS ${COLMAP_ADD_EXECUTABLE_NAME} DESTINATION bin/) endif() if(CLANG_TIDY_EXE) - set_target_properties(${TARGET_NAME} + set_target_properties(${COLMAP_ADD_EXECUTABLE_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") endif() endmacro(COLMAP_ADD_EXECUTABLE) # Wrapper for test executables. -macro(COLMAP_ADD_TEST TEST_NAME) +macro(COLMAP_ADD_TEST) + set(options) + set(oneValueArgs) + set(multiValueArgs NAME SRCS DEPS) + cmake_parse_arguments(COLMAP_ADD_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if(TESTS_ENABLED) - # ${ARGN} will store the list of source files passed to this function. - set(TARGET_NAME "colmap_${FOLDER_NAME}_${TEST_NAME}") - add_executable(${TARGET_NAME} ${ARGN}) - set_target_properties(${TARGET_NAME} PROPERTIES FOLDER + # ${ARGN} will store the list of link libraries. + set(COLMAP_ADD_TEST_NAME "colmap_${FOLDER_NAME}_${COLMAP_ADD_TEST_NAME}") + add_executable(${COLMAP_ADD_TEST_NAME} ${COLMAP_ADD_TEST_SRCS}) + set_target_properties(${COLMAP_ADD_TEST_NAME} PROPERTIES FOLDER ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) if(CLANG_TIDY_EXE) - set_target_properties(${TARGET_NAME} + set_target_properties(${COLMAP_ADD_TEST_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") endif() - target_link_libraries(${TARGET_NAME} - colmap + target_link_libraries(${COLMAP_ADD_TEST_NAME} + ${COLMAP_ADD_TEST_DEPS} GTest::gtest GTest::gtest_main) - add_test("${FOLDER_NAME}/${TARGET_NAME}" ${TARGET_NAME}) + add_test("${FOLDER_NAME}/${COLMAP_ADD_TEST_NAME}" ${COLMAP_ADD_TEST_NAME}) if(IS_MSVC) - install(TARGETS ${TARGET_NAME} DESTINATION bin/) + install(TARGETS ${COLMAP_ADD_TEST_NAME} DESTINATION bin/) endif() endif() endmacro(COLMAP_ADD_TEST) @@ -183,7 +180,6 @@ endmacro(COLMAP_ADD_TEST) # Wrapper for CUDA test executables. macro(COLMAP_ADD_CUDA_TEST TEST_NAME) if(TESTS_ENABLED) - # ${ARGN} will store the list of source files passed to this function. set(TARGET_NAME "colmap_${FOLDER_NAME}_${TEST_NAME}") add_executable(${TARGET_NAME} ${ARGN}) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER diff --git a/cmake/FindFLANN.cmake b/cmake/FindFLANN.cmake index 5ec113c740..c22524ee6b 100644 --- a/cmake/FindFLANN.cmake +++ b/cmake/FindFLANN.cmake @@ -91,3 +91,9 @@ else() message(FATAL_ERROR "Could not find FLANN") endif() endif() + +add_library(flann INTERFACE IMPORTED) +target_include_directories( + flann INTERFACE ${FLANN_INCLUDE_DIRS}) +target_link_libraries( + flann INTERFACE ${FLANN_LIBRARIES}) diff --git a/cmake/FindFreeImage.cmake b/cmake/FindFreeImage.cmake index 7939893caa..0447399053 100644 --- a/cmake/FindFreeImage.cmake +++ b/cmake/FindFreeImage.cmake @@ -91,3 +91,9 @@ else() message(FATAL_ERROR "Could not find FreeImage") endif() endif() + +add_library(freeimage INTERFACE IMPORTED) +target_include_directories( + freeimage INTERFACE ${FREEIMAGE_INCLUDE_DIRS}) +target_link_libraries( + freeimage INTERFACE ${FREEIMAGE_LIBRARIES}) diff --git a/cmake/FindGlew.cmake b/cmake/FindGlew.cmake index 43800fe2d6..45c3de5eed 100644 --- a/cmake/FindGlew.cmake +++ b/cmake/FindGlew.cmake @@ -88,3 +88,9 @@ else() message(FATAL_ERROR "Could not find Glew") endif() endif() + +add_library(glew INTERFACE IMPORTED) +target_include_directories( + glew INTERFACE ${GLEW_INCLUDE_DIRS}) +target_link_libraries( + glew INTERFACE ${GLEW_LIBRARIES}) diff --git a/cmake/FindLZ4.cmake b/cmake/FindLZ4.cmake index a83392121c..0a0e14059b 100644 --- a/cmake/FindLZ4.cmake +++ b/cmake/FindLZ4.cmake @@ -92,3 +92,9 @@ else() message(FATAL_ERROR "Could not find LZ4") endif() endif() + +add_library(lz4 INTERFACE IMPORTED) +target_include_directories( + lz4 INTERFACE ${LZ4_INCLUDE_DIRS}) +target_link_libraries( + lz4 INTERFACE ${LZ4_LIBRARIES}) diff --git a/cmake/FindMetis.cmake b/cmake/FindMetis.cmake index a94b6d3fab..7460ee0fde 100644 --- a/cmake/FindMetis.cmake +++ b/cmake/FindMetis.cmake @@ -102,3 +102,9 @@ endif() if(NOT METIS_FOUND AND METIS_FIND_REQUIRED) message(FATAL_ERROR "Could not find Metis") endif() + +add_library(metis INTERFACE IMPORTED) +target_include_directories( + metis INTERFACE ${METIS_INCLUDE_DIRS}) +target_link_libraries( + metis INTERFACE ${METIS_LIBRARIES}) diff --git a/src/colmap/CMakeLists.txt b/src/colmap/CMakeLists.txt index 779a148128..aa8a7f12ac 100644 --- a/src/colmap/CMakeLists.txt +++ b/src/colmap/CMakeLists.txt @@ -66,7 +66,9 @@ if (GUI_ENABLED) add_subdirectory(ui) endif() -COLMAP_ADD_LIBRARY(colmap ${COLMAP_SOURCES}) +# COLMAP_ADD_LIBRARY( +# NAME colmap +# SRCS colmap_lib.cc) if(CUDA_ENABLED) set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --use_fast_math") @@ -87,12 +89,17 @@ if(CUDA_ENABLED) add_definitions("-DWIN32_LEAN_AND_MEAN") endif() - COLMAP_ADD_CUDA_LIBRARY(colmap_cuda ${COLMAP_CUDA_SOURCES}) - target_link_libraries(colmap_cuda colmap) - - target_link_libraries(colmap - colmap_cuda ${COLMAP_INTERNAL_LIBRARIES} ${COLMAP_EXTERNAL_LIBRARIES}) + # COLMAP_ADD_LIBRARY( + # NAME colmap_cuda + # SRCS ${COLMAP_CUDA_SOURCES} + # PRIVATE_DEPS + # CUDA::cudart + # CUDA::curand + # colmap + # ) + # target_link_libraries(colmap + # colmap_cuda ${COLMAP_INTERNAL_LIBRARIES} ${COLMAP_EXTERNAL_LIBRARIES}) else() - target_link_libraries(colmap - ${COLMAP_INTERNAL_LIBRARIES} ${COLMAP_EXTERNAL_LIBRARIES}) + # target_link_libraries(colmap + # ${COLMAP_INTERNAL_LIBRARIES} ${COLMAP_EXTERNAL_LIBRARIES}) endif() diff --git a/src/colmap/camera/CMakeLists.txt b/src/colmap/camera/CMakeLists.txt index d952bb1476..35a554c119 100644 --- a/src/colmap/camera/CMakeLists.txt +++ b/src/colmap/camera/CMakeLists.txt @@ -31,11 +31,26 @@ set(FOLDER_NAME "camera") -COLMAP_ADD_SOURCES( - database.h database.cc - models.h models.cc - specs.h specs.cc +COLMAP_ADD_LIBRARY( + NAME colmap_camera + SRCS + database.h database.cc + models.h models.cc + specs.h specs.cc + PUBLIC_DEPS + Eigen3::Eigen + Ceres::ceres + PRIVATE_DEPS + colmap_util ) -COLMAP_ADD_TEST(database_test database_test.cc) -COLMAP_ADD_TEST(models_test models_test.cc) +COLMAP_ADD_TEST( + NAME database_test + SRCS database_test.cc + DEPS colmap_camera +) +COLMAP_ADD_TEST( + NAME models_test + SRCS models_test.cc + DEPS colmap_camera +) diff --git a/src/colmap/camera/models.h b/src/colmap/camera/models.h index 387965c049..d881dff483 100644 --- a/src/colmap/camera/models.h +++ b/src/colmap/camera/models.h @@ -37,7 +37,7 @@ #include #include -#include +#include namespace colmap { diff --git a/src/colmap/controllers/CMakeLists.txt b/src/colmap/controllers/CMakeLists.txt index 9b3127a2da..91aa88f447 100644 --- a/src/colmap/controllers/CMakeLists.txt +++ b/src/colmap/controllers/CMakeLists.txt @@ -31,13 +31,36 @@ set(FOLDER_NAME "controllers") -COLMAP_ADD_SOURCES( - automatic_reconstruction.h automatic_reconstruction.cc - bundle_adjustment.h bundle_adjustment.cc - hierarchical_mapper.h hierarchical_mapper.cc - incremental_mapper.h incremental_mapper.cc - option_manager.h option_manager.cc +COLMAP_ADD_LIBRARY( + NAME colmap_controllers + SRCS + automatic_reconstruction.h automatic_reconstruction.cc + bundle_adjustment.h bundle_adjustment.cc + hierarchical_mapper.h hierarchical_mapper.cc + incremental_mapper.h incremental_mapper.cc + option_manager.h option_manager.cc + PUBLIC_DEPS + colmap_scene + colmap_util + Eigen3::Eigen + PRIVATE_DEPS + colmap_math + colmap_estimators + colmap_feature + colmap_image + colmap_sfm + colmap_mvs + Ceres::ceres + Boost::program_options ) -COLMAP_ADD_TEST(hierarchical_mapper_test hierarchical_mapper_test.cc) -COLMAP_ADD_TEST(incremental_mapper_test incremental_mapper_test.cc) +COLMAP_ADD_TEST( + NAME hierarchical_mapper_test + SRCS hierarchical_mapper_test.cc + DEPS colmap_controllers +) +COLMAP_ADD_TEST( + NAME incremental_mapper_test + SRCS incremental_mapper_test.cc + DEPS colmap_controllers +) diff --git a/src/colmap/estimators/CMakeLists.txt b/src/colmap/estimators/CMakeLists.txt index b274a80852..5381d0d75f 100644 --- a/src/colmap/estimators/CMakeLists.txt +++ b/src/colmap/estimators/CMakeLists.txt @@ -31,37 +31,103 @@ set(FOLDER_NAME "estimators") -COLMAP_ADD_SOURCES( - absolute_pose.h absolute_pose.cc - affine_transform.h affine_transform.cc - bundle_adjustment.h bundle_adjustment.cc - coordinate_frame.h coordinate_frame.cc - cost_functions.h - essential_matrix.h essential_matrix.cc - euclidean_transform.h - fundamental_matrix.h fundamental_matrix.cc - generalized_absolute_pose.h generalized_absolute_pose.cc - generalized_absolute_pose_coeffs.h generalized_absolute_pose_coeffs.cc - generalized_relative_pose.h generalized_relative_pose.cc - homography_matrix.h homography_matrix.cc - pose.h pose.cc - similarity_transform.h - translation_transform.h - triangulation.h triangulation.cc - two_view_geometry.h two_view_geometry.cc - utils.h utils.cc +COLMAP_ADD_LIBRARY( + NAME colmap_estimators + SRCS + absolute_pose.h absolute_pose.cc + affine_transform.h affine_transform.cc + bundle_adjustment.h bundle_adjustment.cc + coordinate_frame.h coordinate_frame.cc + cost_functions.h + essential_matrix.h essential_matrix.cc + euclidean_transform.h + fundamental_matrix.h fundamental_matrix.cc + generalized_absolute_pose.h generalized_absolute_pose.cc + generalized_absolute_pose_coeffs.h generalized_absolute_pose_coeffs.cc + generalized_relative_pose.h generalized_relative_pose.cc + homography_matrix.h homography_matrix.cc + pose.h pose.cc + similarity_transform.h + translation_transform.h + triangulation.h triangulation.cc + two_view_geometry.h two_view_geometry.cc + utils.h utils.cc + PUBLIC_DEPS + colmap_util + colmap_math + colmap_feature + colmap_geometry + Eigen3::Eigen + Ceres::ceres ) -COLMAP_ADD_TEST(absolute_pose_test absolute_pose_test.cc) -COLMAP_ADD_TEST(affine_transform_test affine_transform_test.cc) -COLMAP_ADD_TEST(bundle_adjustment_test bundle_adjustment_test.cc) -COLMAP_ADD_TEST(coordinate_frame_test coordinate_frame_test.cc) -COLMAP_ADD_TEST(cost_functions_test cost_functions_test.cc) -COLMAP_ADD_TEST(essential_matrix_test essential_matrix_test.cc) -COLMAP_ADD_TEST(estimators_utils_test utils_test.cc) -COLMAP_ADD_TEST(fundamental_matrix_test fundamental_matrix_test.cc) -COLMAP_ADD_TEST(generalized_absolute_pose_test generalized_absolute_pose_test.cc) -COLMAP_ADD_TEST(generalized_relative_pose_test generalized_relative_pose_test.cc) -COLMAP_ADD_TEST(homography_matrix_test homography_matrix_test.cc) -COLMAP_ADD_TEST(translation_transform_test translation_transform_test.cc) -COLMAP_ADD_TEST(two_view_geometry_test two_view_geometry_test.cc) +COLMAP_ADD_TEST( + NAME absolute_pose_test + SRCS absolute_pose_test.cc + DEPS colmap_estimators +) +COLMAP_ADD_TEST( + NAME affine_transform_test + SRCS affine_transform_test.cc + DEPS colmap_estimators +) +COLMAP_ADD_TEST( + NAME bundle_adjustment_test + SRCS bundle_adjustment_test.cc + DEPS colmap_estimators +) +COLMAP_ADD_TEST( + NAME coordinate_frame_test + SRCS coordinate_frame_test.cc + DEPS colmap_estimators +) +COLMAP_ADD_TEST( + NAME cost_functions_test + SRCS cost_functions_test.cc + DEPS colmap_estimators +) +COLMAP_ADD_TEST( + NAME essential_matrix_test + SRCS essential_matrix_test.cc + DEPS colmap_estimators +) +COLMAP_ADD_TEST( + NAME estimators_utils_test + SRCS utils_test.cc + DEPS colmap_estimators +) +COLMAP_ADD_TEST( + NAME fundamental_matrix_test + SRCS fundamental_matrix_test.cc + DEPS colmap_estimators +) +COLMAP_ADD_TEST( + NAME generalized_absolute_pose_test + SRCS generalized_absolute_pose_test.cc + DEPS colmap_estimators +) +COLMAP_ADD_TEST( + NAME generalized_relative_pose_test + SRCS generalized_relative_pose_test.cc + DEPS colmap_estimators +) +COLMAP_ADD_TEST( + NAME homography_matrix_test + SRCS homography_matrix_test.cc + DEPS colmap_estimators +) +COLMAP_ADD_TEST( + NAME pose_test + SRCS pose_test.cc + DEPS colmap_estimators +) +COLMAP_ADD_TEST( + NAME translation_transform_test + SRCS translation_transform_test.cc + DEPS colmap_estimators +) +COLMAP_ADD_TEST( + NAME two_view_geometry_test + SRCS two_view_geometry_test.cc + DEPS colmap_estimators +) diff --git a/src/colmap/estimators/generalized_relative_pose.cc b/src/colmap/estimators/generalized_relative_pose.cc index d3b7caca6c..df01dddccc 100644 --- a/src/colmap/estimators/generalized_relative_pose.cc +++ b/src/colmap/estimators/generalized_relative_pose.cc @@ -29,33 +29,6 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -// Note that part of this code is licensed under the following conditions. -// Author: Laurent Kneip -// Contact: kneip.laurent@gmail.com -// License: Copyright (c) 2013 Laurent Kneip, ANU. 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 ANU 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 ANU OR THE 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. - #include "colmap/estimators/generalized_relative_pose.h" #include "colmap/geometry/essential_matrix.h" @@ -65,6 +38,8 @@ #include "colmap/math/random.h" #include "colmap/util/logging.h" +#include + namespace colmap { namespace { diff --git a/src/colmap/estimators/pose.cc b/src/colmap/estimators/pose.cc index 7db92fda0c..4d35da68a5 100644 --- a/src/colmap/estimators/pose.cc +++ b/src/colmap/estimators/pose.cc @@ -537,4 +537,65 @@ bool RefineGeneralizedAbsolutePose(const AbsolutePoseRefinementOptions& options, return summary.IsSolutionUsable(); } +bool RefineEssentialMatrix(const ceres::Solver::Options& options, + const std::vector& points1, + const std::vector& points2, + const std::vector& inlier_mask, + Eigen::Matrix3d* E) { + CHECK_EQ(points1.size(), points2.size()); + CHECK_EQ(points1.size(), inlier_mask.size()); + + // Extract inlier points for decomposing the essential matrix into + // rotation and translation components. + + size_t num_inliers = 0; + for (const auto inlier : inlier_mask) { + if (inlier) { + num_inliers += 1; + } + } + + std::vector inlier_points1(num_inliers); + std::vector inlier_points2(num_inliers); + size_t j = 0; + for (size_t i = 0; i < inlier_mask.size(); ++i) { + if (inlier_mask[i]) { + inlier_points1[j] = points1[i]; + inlier_points2[j] = points2[i]; + j += 1; + } + } + + // Extract relative pose from essential matrix. + + Rigid3d cam2_from_cam1; + Eigen::Matrix3d cam2_from_cam1_rot_mat; + std::vector points3D; + PoseFromEssentialMatrix(*E, + inlier_points1, + inlier_points2, + &cam2_from_cam1_rot_mat, + &cam2_from_cam1.translation, + &points3D); + cam2_from_cam1.rotation = Eigen::Quaterniond(cam2_from_cam1_rot_mat); + + if (points3D.size() == 0) { + return false; + } + + // Refine essential matrix, use all points so that refinement is able to + // consider points as inliers that were originally outliers. + + const bool refinement_success = RefineRelativePose( + options, inlier_points1, inlier_points2, &cam2_from_cam1); + + if (!refinement_success) { + return false; + } + + *E = EssentialMatrixFromPose(cam2_from_cam1); + + return true; +} + } // namespace colmap diff --git a/src/colmap/estimators/pose.h b/src/colmap/estimators/pose.h index 430503448b..46c172aa41 100644 --- a/src/colmap/estimators/pose.h +++ b/src/colmap/estimators/pose.h @@ -217,4 +217,22 @@ bool RefineGeneralizedAbsolutePose( std::vector* cameras, Eigen::Matrix6d* rig_from_world_cov = nullptr); +// Refine essential matrix. +// +// Decomposes the essential matrix into rotation and translation components +// and refines the relative pose using the function `RefineRelativePose`. +// +// @param E 3x3 essential matrix. +// @param points1 First set of corresponding points. +// @param points2 Second set of corresponding points. +// @param inlier_mask Inlier mask for corresponding points. +// @param options Solver options. +// +// @return Flag indicating if solution is usable. +bool RefineEssentialMatrix(const ceres::Solver::Options& options, + const std::vector& points1, + const std::vector& points2, + const std::vector& inlier_mask, + Eigen::Matrix3d* E); + } // namespace colmap diff --git a/src/colmap/estimators/pose_test.cc b/src/colmap/estimators/pose_test.cc new file mode 100644 index 0000000000..1be90ea5ec --- /dev/null +++ b/src/colmap/estimators/pose_test.cc @@ -0,0 +1,79 @@ +// 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. +// +// Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) + +#include "colmap/estimators/pose.h" + +#include "colmap/geometry/essential_matrix.h" +#include "colmap/geometry/rigid3.h" + +#include + +namespace colmap { + +TEST(RefineEssentialMatrix, Nominal) { + const Rigid3d cam1_from_world; + const Rigid3d cam2_from_world(Eigen::Quaterniond::Identity(), + Eigen::Vector3d(1, 0, 0).normalized()); + const Eigen::Matrix3d E = + EssentialMatrixFromPose(cam2_from_world * Inverse(cam1_from_world)); + + std::vector points3D(150); + for (size_t i = 0; i < points3D.size() / 3; ++i) { + points3D[3 * i + 0] = Eigen::Vector3d(i * 0.01, 0, 1); + points3D[3 * i + 1] = Eigen::Vector3d(0, i * 0.01, 1); + points3D[3 * i + 2] = Eigen::Vector3d(i * 0.01, i * 0.01, 1); + } + + std::vector points1(points3D.size()); + std::vector points2(points3D.size()); + for (size_t i = 0; i < points3D.size(); ++i) { + points1[i] = (cam1_from_world * points3D[i]).hnormalized(); + points2[i] = (cam2_from_world * points3D[i]).hnormalized(); + } + + const Rigid3d cam2_from_world_perturbed( + Eigen::Quaterniond::Identity(), + Eigen::Vector3d(1.02, 0.02, 0.01).normalized()); + const Eigen::Matrix3d E_pertubated = + EssentialMatrixFromPose(cam2_from_world * Inverse(cam1_from_world)); + + Eigen::Matrix3d E_refined = E_pertubated; + ceres::Solver::Options options; + RefineEssentialMatrix(options, + points1, + points2, + std::vector(points1.size(), true), + &E_refined); + + EXPECT_LE((E - E_refined).norm(), (E - E_pertubated).norm()); +} + +} // namespace colmap diff --git a/src/colmap/exe/CMakeLists.txt b/src/colmap/exe/CMakeLists.txt index 5b5037d463..038550e871 100644 --- a/src/colmap/exe/CMakeLists.txt +++ b/src/colmap/exe/CMakeLists.txt @@ -35,19 +35,44 @@ if(IS_MSVC) add_compile_options("/bigobj") endif() -COLMAP_ADD_EXECUTABLE(colmap_exe - colmap.cc - database.cc - feature.cc - gui.cc - image.cc - model.cc - mvs.cc - sfm.cc - vocab_tree.cc) +COLMAP_ADD_LIBRARY( + NAME colmap_exe_helpers + SRCS + feature.h feature.cc + sfm.h sfm.cc + PUBLIC_DEPS + colmap_controllers + colmap_image + colmap_feature +) + +COLMAP_ADD_EXECUTABLE( + NAME colmap_exe + SRCS + colmap.cc + database.cc + feature.cc + gui.cc + image.cc + model.cc + mvs.cc + sfm.cc + vocab_tree.cc + DEPS + colmap_util + colmap_math + colmap_camera + colmap_image + colmap_feature + colmap_geometry + colmap_scene + colmap_estimators + colmap_optim + colmap_mvs + colmap_retrieval + colmap_sfm + colmap_controllers + colmap_ui + colmap_exe_helpers) set_target_properties(colmap_exe PROPERTIES OUTPUT_NAME colmap) -COLMAP_ADD_SOURCES( - feature.h feature.cc - sfm.h sfm.cc -) diff --git a/src/colmap/exe/vocab_tree.cc b/src/colmap/exe/vocab_tree.cc index 5138f8f9ef..e641c85589 100644 --- a/src/colmap/exe/vocab_tree.cc +++ b/src/colmap/exe/vocab_tree.cc @@ -32,7 +32,6 @@ #include "colmap/exe/vocab_tree.h" #include "colmap/controllers/option_manager.h" -#include "colmap/exe/gui.h" #include "colmap/feature/matching.h" #include "colmap/feature/sift.h" #include "colmap/feature/utils.h" diff --git a/src/colmap/feature/CMakeLists.txt b/src/colmap/feature/CMakeLists.txt index ee23a9183f..7c703007fe 100644 --- a/src/colmap/feature/CMakeLists.txt +++ b/src/colmap/feature/CMakeLists.txt @@ -31,14 +31,37 @@ set(FOLDER_NAME "feature") -COLMAP_ADD_SOURCES( - extraction.h extraction.cc - matching.h matching.cc - sift.h sift.cc - types.h types.cc - utils.h utils.cc +COLMAP_ADD_LIBRARY( + NAME colmap_feature + SRCS + extraction.h extraction.cc + matching.h matching.cc + sift.h sift.cc + types.h types.cc + utils.h utils.cc + PUBLIC_DEPS + Eigen3::Eigen + PRIVATE_DEPS + colmap_util + colmap_image + flann + lz4 + sift_gpu + vlfeat ) -COLMAP_ADD_TEST(feature_utils_test utils_test.cc) -COLMAP_ADD_TEST(sift_test sift_test.cc) -COLMAP_ADD_TEST(types_test types_test.cc) +COLMAP_ADD_TEST( + NAME feature_utils_test + SRCS utils_test.cc + DEPS colmap_feature +) +COLMAP_ADD_TEST( + NAME sift_test + SRCS sift_test.cc + DEPS colmap_feature +) +COLMAP_ADD_TEST( + NAME types_test + SRCS types_test.cc + DEPS colmap_feature +) diff --git a/src/colmap/geometry/CMakeLists.txt b/src/colmap/geometry/CMakeLists.txt index f7188bb91c..ad0fabb319 100644 --- a/src/colmap/geometry/CMakeLists.txt +++ b/src/colmap/geometry/CMakeLists.txt @@ -31,22 +31,63 @@ set(FOLDER_NAME "geometry") -COLMAP_ADD_SOURCES( - essential_matrix.h essential_matrix.cc - gps.h gps.cc - homography_matrix.h homography_matrix.cc - pose.h pose.cc - projection.h projection.cc - rigid3.h - sim3.h sim3.cc - triangulation.h triangulation.cc +COLMAP_ADD_LIBRARY( + NAME colmap_geometry + SRCS + essential_matrix.h essential_matrix.cc + gps.h gps.cc + homography_matrix.h homography_matrix.cc + pose.h pose.cc + projection.h projection.cc + rigid3.h + sim3.h sim3.cc + triangulation.h triangulation.cc + PUBLIC_DEPS + colmap_util + colmap_math + Eigen3::Eigen + PRIVATE_DEPS + colmap_scene + colmap_optim ) -COLMAP_ADD_TEST(essential_matrix_utils_test essential_matrix_test.cc) -COLMAP_ADD_TEST(gps_test gps_test.cc) -COLMAP_ADD_TEST(homography_matrix_utils_test homography_matrix_test.cc) -COLMAP_ADD_TEST(pose_test pose_test.cc) -COLMAP_ADD_TEST(projection_test projection_test.cc) -COLMAP_ADD_TEST(rigid3_test rigid3_test.cc) -COLMAP_ADD_TEST(sim3_test sim3_test.cc) -COLMAP_ADD_TEST(triangulation_test triangulation_test.cc) +COLMAP_ADD_TEST( + NAME essential_matrix_utils_test + SRCS essential_matrix_test.cc + DEPS colmap_geometry +) +COLMAP_ADD_TEST( + NAME gps_test + SRCS gps_test.cc + DEPS colmap_geometry +) +COLMAP_ADD_TEST( + NAME homography_matrix_utils_test + SRCS homography_matrix_test.cc + DEPS colmap_geometry +) +COLMAP_ADD_TEST( + NAME pose_test + SRCS pose_test.cc + DEPS colmap_geometry +) +COLMAP_ADD_TEST( + NAME projection_test + SRCS projection_test.cc + DEPS colmap_geometry +) +COLMAP_ADD_TEST( + NAME rigid3_test + SRCS rigid3_test.cc + DEPS colmap_geometry +) +COLMAP_ADD_TEST( + NAME sim3_test + SRCS sim3_test.cc + DEPS colmap_geometry +) +COLMAP_ADD_TEST( + NAME triangulation_test + SRCS triangulation_test.cc + DEPS colmap_geometry +) diff --git a/src/colmap/geometry/essential_matrix.cc b/src/colmap/geometry/essential_matrix.cc index 00f396751d..46d3405225 100644 --- a/src/colmap/geometry/essential_matrix.cc +++ b/src/colmap/geometry/essential_matrix.cc @@ -31,11 +31,12 @@ #include "colmap/geometry/essential_matrix.h" -#include "colmap/estimators/pose.h" #include "colmap/geometry/pose.h" #include +#include + namespace colmap { void DecomposeEssentialMatrix(const Eigen::Matrix3d& E, @@ -144,65 +145,4 @@ Eigen::Matrix3d InvertEssentialMatrix(const Eigen::Matrix3d& E) { return E.transpose(); } -bool RefineEssentialMatrix(const ceres::Solver::Options& options, - const std::vector& points1, - const std::vector& points2, - const std::vector& inlier_mask, - Eigen::Matrix3d* E) { - CHECK_EQ(points1.size(), points2.size()); - CHECK_EQ(points1.size(), inlier_mask.size()); - - // Extract inlier points for decomposing the essential matrix into - // rotation and translation components. - - size_t num_inliers = 0; - for (const auto inlier : inlier_mask) { - if (inlier) { - num_inliers += 1; - } - } - - std::vector inlier_points1(num_inliers); - std::vector inlier_points2(num_inliers); - size_t j = 0; - for (size_t i = 0; i < inlier_mask.size(); ++i) { - if (inlier_mask[i]) { - inlier_points1[j] = points1[i]; - inlier_points2[j] = points2[i]; - j += 1; - } - } - - // Extract relative pose from essential matrix. - - Rigid3d cam2_from_cam1; - Eigen::Matrix3d cam2_from_cam1_rot_mat; - std::vector points3D; - PoseFromEssentialMatrix(*E, - inlier_points1, - inlier_points2, - &cam2_from_cam1_rot_mat, - &cam2_from_cam1.translation, - &points3D); - cam2_from_cam1.rotation = Eigen::Quaterniond(cam2_from_cam1_rot_mat); - - if (points3D.size() == 0) { - return false; - } - - // Refine essential matrix, use all points so that refinement is able to - // consider points as inliers that were originally outliers. - - const bool refinement_success = RefineRelativePose( - options, inlier_points1, inlier_points2, &cam2_from_cam1); - - if (!refinement_success) { - return false; - } - - *E = EssentialMatrixFromPose(cam2_from_cam1); - - return true; -} - } // namespace colmap diff --git a/src/colmap/geometry/essential_matrix.h b/src/colmap/geometry/essential_matrix.h index 5d7c73c8a2..9aee1e6897 100644 --- a/src/colmap/geometry/essential_matrix.h +++ b/src/colmap/geometry/essential_matrix.h @@ -37,7 +37,6 @@ #include #include -#include namespace colmap { @@ -127,22 +126,4 @@ Eigen::Vector3d EpipoleFromEssentialMatrix(const Eigen::Matrix3d& E, // @return Inverted essential matrix. Eigen::Matrix3d InvertEssentialMatrix(const Eigen::Matrix3d& matrix); -// Refine essential matrix. -// -// Decomposes the essential matrix into rotation and translation components -// and refines the relative pose using the function `RefineRelativePose`. -// -// @param E 3x3 essential matrix. -// @param points1 First set of corresponding points. -// @param points2 Second set of corresponding points. -// @param inlier_mask Inlier mask for corresponding points. -// @param options Solver options. -// -// @return Flag indicating if solution is usable. -bool RefineEssentialMatrix(const ceres::Solver::Options& options, - const std::vector& points1, - const std::vector& points2, - const std::vector& inlier_mask, - Eigen::Matrix3d* E); - } // namespace colmap diff --git a/src/colmap/geometry/essential_matrix_test.cc b/src/colmap/geometry/essential_matrix_test.cc index 432dd4d7e6..7a9fe87fd9 100644 --- a/src/colmap/geometry/essential_matrix_test.cc +++ b/src/colmap/geometry/essential_matrix_test.cc @@ -149,42 +149,4 @@ TEST(InvertEssentialMatrix, Nominal) { } } -TEST(RefineEssentialMatrix, Nominal) { - const Rigid3d cam1_from_world; - const Rigid3d cam2_from_world(Eigen::Quaterniond::Identity(), - Eigen::Vector3d(1, 0, 0).normalized()); - const Eigen::Matrix3d E = - EssentialMatrixFromPose(cam2_from_world * Inverse(cam1_from_world)); - - std::vector points3D(150); - for (size_t i = 0; i < points3D.size() / 3; ++i) { - points3D[3 * i + 0] = Eigen::Vector3d(i * 0.01, 0, 1); - points3D[3 * i + 1] = Eigen::Vector3d(0, i * 0.01, 1); - points3D[3 * i + 2] = Eigen::Vector3d(i * 0.01, i * 0.01, 1); - } - - std::vector points1(points3D.size()); - std::vector points2(points3D.size()); - for (size_t i = 0; i < points3D.size(); ++i) { - points1[i] = (cam1_from_world * points3D[i]).hnormalized(); - points2[i] = (cam2_from_world * points3D[i]).hnormalized(); - } - - const Rigid3d cam2_from_world_perturbed( - Eigen::Quaterniond::Identity(), - Eigen::Vector3d(1.02, 0.02, 0.01).normalized()); - const Eigen::Matrix3d E_pertubated = - EssentialMatrixFromPose(cam2_from_world * Inverse(cam1_from_world)); - - Eigen::Matrix3d E_refined = E_pertubated; - ceres::Solver::Options options; - RefineEssentialMatrix(options, - points1, - points2, - std::vector(points1.size(), true), - &E_refined); - - EXPECT_LE((E - E_refined).norm(), (E - E_pertubated).norm()); -} - } // namespace colmap diff --git a/src/colmap/geometry/triangulation.cc b/src/colmap/geometry/triangulation.cc index 4785bde5dd..b5fb34924b 100644 --- a/src/colmap/geometry/triangulation.cc +++ b/src/colmap/geometry/triangulation.cc @@ -34,6 +34,8 @@ #include "colmap/geometry/essential_matrix.h" #include "colmap/geometry/pose.h" +#include + namespace colmap { Eigen::Vector3d TriangulatePoint(const Eigen::Matrix3x4d& cam1_from_world, diff --git a/src/colmap/image/CMakeLists.txt b/src/colmap/image/CMakeLists.txt index 8a95067d7d..3f22cc4e5b 100644 --- a/src/colmap/image/CMakeLists.txt +++ b/src/colmap/image/CMakeLists.txt @@ -31,15 +31,40 @@ set(FOLDER_NAME "image") -COLMAP_ADD_SOURCES( - bitmap.h bitmap.cc - reader.h reader.cc - line.h line.cc - undistortion.h undistortion.cc - warp.h warp.cc +COLMAP_ADD_LIBRARY( + NAME colmap_image + SRCS + bitmap.h bitmap.cc + reader.h reader.cc + line.h line.cc + undistortion.h undistortion.cc + warp.h warp.cc + PUBLIC_DEPS + colmap_scene + Eigen3::Eigen + freeimage + PRIVATE_DEPS + lsd + vlfeat ) -COLMAP_ADD_TEST(bitmap_test bitmap_test.cc) -COLMAP_ADD_TEST(line_test line_test.cc) -COLMAP_ADD_TEST(undistortion_test undistortion_test.cc) -COLMAP_ADD_TEST(warp_test warp_test.cc) +COLMAP_ADD_TEST( + NAME bitmap_test + SRCS bitmap_test.cc + DEPS colmap_image +) +COLMAP_ADD_TEST( + NAME line_test + SRCS line_test.cc + DEPS colmap_image +) +COLMAP_ADD_TEST( + NAME undistortion_test + SRCS undistortion_test.cc + DEPS colmap_image +) +COLMAP_ADD_TEST( + NAME warp_test + SRCS warp_test.cc + DEPS colmap_image +) diff --git a/src/colmap/math/CMakeLists.txt b/src/colmap/math/CMakeLists.txt index 2f3216c4eb..e0ef6f50e6 100644 --- a/src/colmap/math/CMakeLists.txt +++ b/src/colmap/math/CMakeLists.txt @@ -31,16 +31,44 @@ set(FOLDER_NAME "math") -COLMAP_ADD_SOURCES( - graph_cut.h graph_cut.cc - math.h math.cc - matrix.h - polynomial.h polynomial.cc - random.h random.cc +COLMAP_ADD_LIBRARY( + NAME colmap_math + SRCS + graph_cut.h graph_cut.cc + math.h math.cc + matrix.h + polynomial.h polynomial.cc + random.h random.cc + PUBLIC_DEPS + colmap_util + Boost::graph + Eigen3::Eigen + PRIVATE_DEPS + metis ) -COLMAP_ADD_TEST(graph_cut_test graph_cut_test.cc) -COLMAP_ADD_TEST(math_test math_test.cc) -COLMAP_ADD_TEST(matrix_test matrix_test.cc) -COLMAP_ADD_TEST(polynomial_test polynomial_test.cc) -COLMAP_ADD_TEST(random_test random_test.cc) +COLMAP_ADD_TEST( + NAME graph_cut_test + SRCS graph_cut_test.cc + DEPS colmap_math +) +COLMAP_ADD_TEST( + NAME math_test + SRCS math_test.cc + DEPS colmap_math +) +COLMAP_ADD_TEST( + NAME matrix_test + SRCS matrix_test.cc + DEPS colmap_math +) +COLMAP_ADD_TEST( + NAME polynomial_test + SRCS polynomial_test.cc + DEPS colmap_math +) +COLMAP_ADD_TEST( + NAME random_test + SRCS random_test.cc + DEPS colmap_math +) diff --git a/src/colmap/mvs/CMakeLists.txt b/src/colmap/mvs/CMakeLists.txt index 59e98207fb..a506da8921 100644 --- a/src/colmap/mvs/CMakeLists.txt +++ b/src/colmap/mvs/CMakeLists.txt @@ -31,29 +31,65 @@ set(FOLDER_NAME "mvs") -COLMAP_ADD_SOURCES( - consistency_graph.h consistency_graph.cc - depth_map.h depth_map.cc - fusion.h fusion.cc - image.h image.cc - meshing.h meshing.cc - model.h model.cc - normal_map.h normal_map.cc - workspace.h workspace.cc +COLMAP_ADD_LIBRARY( + NAME colmap_mvs + SRCS + consistency_graph.h consistency_graph.cc + depth_map.h depth_map.cc + fusion.h fusion.cc + image.h image.cc + meshing.h meshing.cc + model.h model.cc + normal_map.h normal_map.cc + workspace.h workspace.cc + PUBLIC_DEPS + colmap_util + colmap_scene + PRIVATE_DEPS + poisson_recon + Eigen3::Eigen + CGAL ) -COLMAP_ADD_TEST(consistency_graph_test consistency_graph_test.cc) -COLMAP_ADD_TEST(depth_map_test depth_map_test.cc) -COLMAP_ADD_TEST(mat_test mat_test.cc) -COLMAP_ADD_TEST(normal_map_test normal_map_test.cc) +COLMAP_ADD_TEST( + NAME consistency_graph_test + SRCS consistency_graph_test.cc + DEPS colmap_mvs +) +COLMAP_ADD_TEST( + NAME depth_map_test + SRCS depth_map_test.cc + DEPS colmap_mvs +) +COLMAP_ADD_TEST( + NAME mat_test + SRCS mat_test.cc + DEPS colmap_mvs +) +COLMAP_ADD_TEST( + NAME normal_map_test + SRCS normal_map_test.cc + DEPS colmap_mvs +) if(CUDA_ENABLED) - COLMAP_ADD_CUDA_SOURCES( - gpu_mat_prng.h gpu_mat_prng.cu - gpu_mat_ref_image.h gpu_mat_ref_image.cu - patch_match.h patch_match.cc - patch_match_cuda.h patch_match_cuda.cu + COLMAP_ADD__LIBRARY( + NAME colmap_mvs_cuda + SRCS + gpu_mat_prng.h gpu_mat_prng.cu + gpu_mat_ref_image.h gpu_mat_ref_image.cu + patch_match.h patch_match.cc + patch_match_cuda.h patch_match_cuda.cu + PUBLIC_DEPS + colmap_mvs + Cuda::cudart + Cuda::curand ) + target_link_libraries(colmap_mvs PRIVATE colmap_mvs_cuda) - COLMAP_ADD_CUDA_TEST(gpu_mat_test gpu_mat_test.cu) + COLMAP_ADD_TEST( + NAME gpu_mat_test + SRCS gpu_mat_test.cu + DEPS colmap_mvs + ) endif() diff --git a/src/colmap/optim/CMakeLists.txt b/src/colmap/optim/CMakeLists.txt index 4e5269b05e..6c809152d7 100644 --- a/src/colmap/optim/CMakeLists.txt +++ b/src/colmap/optim/CMakeLists.txt @@ -31,20 +31,52 @@ set(FOLDER_NAME "optim") -COLMAP_ADD_SOURCES( - combination_sampler.h combination_sampler.cc - least_absolute_deviations.h least_absolute_deviations.cc - progressive_sampler.h progressive_sampler.cc - random_sampler.h random_sampler.cc - sprt.h sprt.cc - support_measurement.h support_measurement.cc +COLMAP_ADD_LIBRARY( + NAME colmap_optim + SRCS + combination_sampler.h combination_sampler.cc + least_absolute_deviations.h least_absolute_deviations.cc + progressive_sampler.h progressive_sampler.cc + random_sampler.h random_sampler.cc + sprt.h sprt.cc + support_measurement.h support_measurement.cc + PUBLIC_DEPS + colmap_math + Eigen3::Eigen ) -COLMAP_ADD_TEST(combination_sampler_test combination_sampler_test.cc) -COLMAP_ADD_TEST(least_absolute_deviations_test - least_absolute_deviations_test.cc) -COLMAP_ADD_TEST(loransac_test loransac_test.cc) -COLMAP_ADD_TEST(progressive_sampler_test progressive_sampler_test.cc) -COLMAP_ADD_TEST(random_sampler_test random_sampler_test.cc) -COLMAP_ADD_TEST(ransac_test ransac_test.cc) -COLMAP_ADD_TEST(support_measurement_test support_measurement_test.cc) +COLMAP_ADD_TEST( + NAME combination_sampler_test + SRCS combination_sampler_test.cc + DEPS colmap_optim +) +COLMAP_ADD_TEST( + NAME least_absolute_deviations_test + SRCS least_absolute_deviations_test.cc + DEPS colmap_optim +) +COLMAP_ADD_TEST( + NAME loransac_test + SRCS loransac_test.cc + DEPS colmap_optim +) +COLMAP_ADD_TEST( + NAME progressive_sampler_test + SRCS progressive_sampler_test.cc + DEPS colmap_optim +) +COLMAP_ADD_TEST( + NAME random_sampler_test + SRCS random_sampler_test.cc + DEPS colmap_optim +) +COLMAP_ADD_TEST( + NAME ransac_test + SRCS ransac_test.cc + DEPS colmap_optim +) +COLMAP_ADD_TEST( + NAME support_measurement_test + SRCS support_measurement_test.cc + DEPS colmap_optim +) diff --git a/src/colmap/retrieval/CMakeLists.txt b/src/colmap/retrieval/CMakeLists.txt index 54315159ea..2e3d1e495a 100644 --- a/src/colmap/retrieval/CMakeLists.txt +++ b/src/colmap/retrieval/CMakeLists.txt @@ -31,17 +31,43 @@ set(FOLDER_NAME "retrieval") -COLMAP_ADD_SOURCES( - geometry.h geometry.cc - inverted_file.h - inverted_file_entry.h - inverted_index.h - utils.h - visual_index.h - vote_and_verify.h vote_and_verify.cc +COLMAP_ADD_LIBRARY( + NAME colmap_retrieval + SRCS + geometry.h geometry.cc + inverted_file.h + inverted_file_entry.h + inverted_index.h + utils.h + visual_index.h + vote_and_verify.h vote_and_verify.cc + PUBLIC_DEPS + Boost::graph + Eigen3::Eigen + flann + lz4 + PRIVATE_DEPS + colmap_math + colmap_estimators ) -COLMAP_ADD_TEST(geometry_test geometry_test.cc) -COLMAP_ADD_TEST(inverted_file_entry_test inverted_file_entry_test.cc) -COLMAP_ADD_TEST(visual_index_test visual_index_test.cc) -COLMAP_ADD_TEST(vote_and_verify_test vote_and_verify_test.cc) +COLMAP_ADD_TEST( + NAME geometry_test + SRCS geometry_test.cc + DEPS colmap_retrieval +) +COLMAP_ADD_TEST( + NAME inverted_file_entry_test + SRCS inverted_file_entry_test.cc + DEPS colmap_retrieval +) +COLMAP_ADD_TEST( + NAME visual_index_test + SRCS visual_index_test.cc + DEPS colmap_retrieval +) +COLMAP_ADD_TEST( + NAME vote_and_verify_test + SRCS vote_and_verify_test.cc + DEPS colmap_retrieval +) diff --git a/src/colmap/retrieval/visual_index.h b/src/colmap/retrieval/visual_index.h index 48afe2c2aa..b6351ae9ed 100644 --- a/src/colmap/retrieval/visual_index.h +++ b/src/colmap/retrieval/visual_index.h @@ -39,9 +39,9 @@ #include "colmap/util/endian.h" #include "colmap/util/logging.h" -#include "flann/flann.hpp" #include #include +#include namespace colmap { namespace retrieval { diff --git a/src/colmap/scene/CMakeLists.txt b/src/colmap/scene/CMakeLists.txt index 878e7beae6..d36d90c683 100644 --- a/src/colmap/scene/CMakeLists.txt +++ b/src/colmap/scene/CMakeLists.txt @@ -29,37 +29,103 @@ # # Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -set(FOLDER_NAME "base") +set(FOLDER_NAME "scene") -COLMAP_ADD_SOURCES( - alignment.h alignment.cc - camera.h camera.cc - camera_rig.h camera_rig.cc - correspondence_graph.h correspondence_graph.cc - database.h database.cc - database_cache.h database_cache.cc - image.h image.cc - point2d.h - point3d.h point3d.cc - reconstruction.h reconstruction.cc - reconstruction_manager.h reconstruction_manager.cc - scene_clustering.h scene_clustering.cc - synthetic.h synthetic.cc - track.h track.cc - visibility_pyramid.h visibility_pyramid.cc +COLMAP_ADD_LIBRARY( + NAME colmap_scene + SRCS + alignment.h alignment.cc + camera.h camera.cc + camera_rig.h camera_rig.cc + correspondence_graph.h correspondence_graph.cc + database.h database.cc + database_cache.h database_cache.cc + image.h image.cc + point2d.h + point3d.h point3d.cc + reconstruction.h reconstruction.cc + reconstruction_manager.h reconstruction_manager.cc + scene_clustering.h scene_clustering.cc + synthetic.h synthetic.cc + track.h track.cc + visibility_pyramid.h visibility_pyramid.cc + PUBLIC_DEPS + colmap_camera + colmap_image + colmap_feature + colmap_geometry + colmap_estimators + Eigen3::Eigen + SQLite::SQLite3 ) -COLMAP_ADD_TEST(camera_rig_test camera_rig_test.cc) -COLMAP_ADD_TEST(camera_test camera_test.cc) -COLMAP_ADD_TEST(correspondence_graph_test correspondence_graph_test.cc) -COLMAP_ADD_TEST(database_cache_test database_cache_test.cc) -COLMAP_ADD_TEST(database_test database_test.cc) -COLMAP_ADD_TEST(image_test image_test.cc) -COLMAP_ADD_TEST(point2d_test point2d_test.cc) -COLMAP_ADD_TEST(point3d_test point3d_test.cc) -COLMAP_ADD_TEST(reconstruction_test reconstruction_test.cc) -COLMAP_ADD_TEST(reconstruction_manager_test reconstruction_manager_test.cc) -COLMAP_ADD_TEST(scene_clustering_test scene_clustering_test.cc) -COLMAP_ADD_TEST(synthetic_test synthetic_test.cc) -COLMAP_ADD_TEST(track_test track_test.cc) -COLMAP_ADD_TEST(visibility_pyramid_test visibility_pyramid_test.cc) +COLMAP_ADD_TEST( + NAME camera_rig_test + SRCS camera_rig_test.cc + DEPS colmap_scene +) +COLMAP_ADD_TEST( + NAME camera_test + SRCS camera_test.cc + DEPS colmap_scene +) +COLMAP_ADD_TEST( + NAME correspondence_graph_test + SRCS correspondence_graph_test.cc + DEPS colmap_scene +) +COLMAP_ADD_TEST( + NAME database_cache_test + SRCS database_cache_test.cc + DEPS colmap_scene +) +COLMAP_ADD_TEST( + NAME database_test + SRCS database_test.cc + DEPS colmap_scene +) +COLMAP_ADD_TEST( + NAME image_test + SRCS image_test.cc + DEPS colmap_scene +) +COLMAP_ADD_TEST( + NAME point2d_test + SRCS point2d_test.cc + DEPS colmap_scene +) +COLMAP_ADD_TEST( + NAME point3d_test + SRCS point3d_test.cc + DEPS colmap_scene +) +COLMAP_ADD_TEST( + NAME reconstruction_test + SRCS reconstruction_test.cc + DEPS colmap_scene +) +COLMAP_ADD_TEST( + NAME reconstruction_manager_test + SRCS reconstruction_manager_test.cc + DEPS colmap_scene +) +COLMAP_ADD_TEST( + NAME scene_clustering_test + SRCS scene_clustering_test.cc + DEPS colmap_scene +) +COLMAP_ADD_TEST( + NAME synthetic_test + SRCS synthetic_test.cc + DEPS colmap_scene +) +COLMAP_ADD_TEST( + NAME track_test + SRCS track_test.cc + DEPS colmap_scene +) +COLMAP_ADD_TEST( + NAME visibility_pyramid_test + SRCS visibility_pyramid_test.cc + DEPS colmap_scene +) diff --git a/src/colmap/scene/database_cache.h b/src/colmap/scene/database_cache.h index 65edc00903..d2b606ec4a 100644 --- a/src/colmap/scene/database_cache.h +++ b/src/colmap/scene/database_cache.h @@ -38,6 +38,7 @@ #include "colmap/scene/image.h" #include "colmap/util/types.h" +#include #include #include #include diff --git a/src/colmap/sfm/CMakeLists.txt b/src/colmap/sfm/CMakeLists.txt index d69fdfea9b..e264995024 100644 --- a/src/colmap/sfm/CMakeLists.txt +++ b/src/colmap/sfm/CMakeLists.txt @@ -31,7 +31,15 @@ set(FOLDER_NAME "sfm") -COLMAP_ADD_SOURCES( - incremental_mapper.h incremental_mapper.cc - incremental_triangulator.h incremental_triangulator.cc +COLMAP_ADD_LIBRARY( + NAME colmap_sfm + SRCS + incremental_mapper.h incremental_mapper.cc + incremental_triangulator.h incremental_triangulator.cc + PUBLIC_DEPS + colmap_scene + colmap_estimators + PRIVATE_DEPS + colmap_geometry + colmap_image ) diff --git a/src/colmap/ui/CMakeLists.txt b/src/colmap/ui/CMakeLists.txt index 9ee2c73ee1..80b992a21d 100644 --- a/src/colmap/ui/CMakeLists.txt +++ b/src/colmap/ui/CMakeLists.txt @@ -31,34 +31,44 @@ set(FOLDER_NAME "ui") -COLMAP_ADD_SOURCES( - automatic_reconstruction_widget.h automatic_reconstruction_widget.cc - bundle_adjustment_widget.h bundle_adjustment_widget.cc - colormaps.h colormaps.cc - database_management_widget.h database_management_widget.cc - dense_reconstruction_widget.h dense_reconstruction_widget.cc - feature_extraction_widget.h feature_extraction_widget.cc - feature_matching_widget.h feature_matching_widget.cc - image_viewer_widget.h image_viewer_widget.cc - license_widget.h license_widget.cc - line_painter.h line_painter.cc - log_widget.h log_widget.cc - main_window.h main_window.cc - match_matrix_widget.h match_matrix_widget.cc - model_viewer_widget.h model_viewer_widget.cc - movie_grabber_widget.h movie_grabber_widget.cc - options_widget.h options_widget.cc - point_painter.h point_painter.cc - point_viewer_widget.h point_viewer_widget.cc - project_widget.h project_widget.cc - qt_utils.h qt_utils.cc - reconstruction_manager_widget.h reconstruction_manager_widget.cc - reconstruction_options_widget.h reconstruction_options_widget.cc - reconstruction_stats_widget.h reconstruction_stats_widget.cc - render_options.h render_options.cc - render_options_widget.h render_options_widget.cc - thread_control_widget.h thread_control_widget.cc - triangle_painter.h triangle_painter.cc - undistortion_widget.h undistortion_widget.cc - resources.qrc +COLMAP_ADD_LIBRARY( + NAME colmap_ui + SRCS + automatic_reconstruction_widget.h automatic_reconstruction_widget.cc + bundle_adjustment_widget.h bundle_adjustment_widget.cc + colormaps.h colormaps.cc + database_management_widget.h database_management_widget.cc + dense_reconstruction_widget.h dense_reconstruction_widget.cc + feature_extraction_widget.h feature_extraction_widget.cc + feature_matching_widget.h feature_matching_widget.cc + image_viewer_widget.h image_viewer_widget.cc + license_widget.h license_widget.cc + line_painter.h line_painter.cc + log_widget.h log_widget.cc + main_window.h main_window.cc + match_matrix_widget.h match_matrix_widget.cc + model_viewer_widget.h model_viewer_widget.cc + movie_grabber_widget.h movie_grabber_widget.cc + options_widget.h options_widget.cc + point_painter.h point_painter.cc + point_viewer_widget.h point_viewer_widget.cc + project_widget.h project_widget.cc + qt_utils.h qt_utils.cc + reconstruction_manager_widget.h reconstruction_manager_widget.cc + reconstruction_options_widget.h reconstruction_options_widget.cc + reconstruction_stats_widget.h reconstruction_stats_widget.cc + render_options.h render_options.cc + render_options_widget.h render_options_widget.cc + thread_control_widget.h thread_control_widget.cc + triangle_painter.h triangle_painter.cc + undistortion_widget.h undistortion_widget.cc + resources.qrc + PUBLIC_DEPS + colmap_util + colmap_image + colmap_scene + colmap_controllers + Qt5::Core + Qt5::OpenGL + Qt5::Widgets ) diff --git a/src/colmap/util/CMakeLists.txt b/src/colmap/util/CMakeLists.txt index 7d9253850e..4093c02a78 100644 --- a/src/colmap/util/CMakeLists.txt +++ b/src/colmap/util/CMakeLists.txt @@ -31,34 +31,79 @@ set(FOLDER_NAME "util") -COLMAP_ADD_SOURCES( - cache.h - logging.h logging.cc - misc.h misc.cc - opengl_utils.h opengl_utils.cc - ply.h ply.cc - sqlite3_utils.h - string.h string.cc - testing.h testing.cc - threading.h threading.cc - timer.h timer.cc - types.h - version.h version.cc +COLMAP_ADD_LIBRARY( + NAME colmap_util + SRCS + cache.h + logging.h logging.cc + misc.h misc.cc + opengl_utils.h opengl_utils.cc + ply.h ply.cc + sqlite3_utils.h + string.h string.cc + testing.h testing.cc + threading.h threading.cc + timer.h timer.cc + types.h + version.h version.cc + PUBLIC_DEPS + Boost::filesystem + Eigen3::Eigen + glog::glog + OpenGL + Qt5::Core + Qt5::OpenGL + SQLite::SQLite3 + PRIVATE_DEPS + colmap_math ) if(CUDA_ENABLED) - COLMAP_ADD_CUDA_SOURCES( - cuda.h cuda.cc - cudacc.h cudacc.cc + COLMAP_ADD_LIBRARY( + NAME colmap_util_cuda + SRCS + cuda.h cuda.cc + cudacc.h cudacc.cc + PUBLIC_DEPS + Cuda::cudart ) + target_link_libraries(colmap_util PUBLIC_DEPS colmap_util_cuda) endif() -COLMAP_ADD_TEST(cache_test cache_test.cc) -COLMAP_ADD_TEST(endian_test endian_test.cc) -COLMAP_ADD_TEST(misc_test misc_test.cc) -COLMAP_ADD_TEST(string_test string_test.cc) -COLMAP_ADD_TEST(threading_test threading_test.cc) -COLMAP_ADD_TEST(timer_test timer_test.cc) +COLMAP_ADD_TEST( + NAME cache_test + SRCS cache_test.cc + DEPS colmap_util +) +COLMAP_ADD_TEST( + NAME endian_test + SRCS endian_test.cc + DEPS colmap_util +) +COLMAP_ADD_TEST( + NAME misc_test + SRCS misc_test.cc + DEPS colmap_util +) +COLMAP_ADD_TEST( + NAME string_test + SRCS string_test.cc + DEPS colmap_util +) +COLMAP_ADD_TEST( + NAME threading_test + SRCS threading_test.cc + DEPS colmap_util +) +COLMAP_ADD_TEST( + NAME timer_test + SRCS timer_test.cc + DEPS colmap_util +) if(GUI_ENABLED) - COLMAP_ADD_TEST(opengl_utils_test opengl_utils_test.cc) + COLMAP_ADD_TEST( + NAME opengl_utils_test + SRCS opengl_utils_test.cc + DEPS colmap_util + ) endif() diff --git a/src/colmap/util/ply.h b/src/colmap/util/ply.h index 267729dddc..8f7a2c5584 100644 --- a/src/colmap/util/ply.h +++ b/src/colmap/util/ply.h @@ -31,11 +31,11 @@ #pragma once +#include "colmap/util/types.h" + #include #include -#include "types.h" - namespace colmap { struct PlyPoint { diff --git a/src/colmap/util/version.cc b/src/colmap/util/version.cc index 7ec4a702f3..4c75603697 100644 --- a/src/colmap/util/version.cc +++ b/src/colmap/util/version.cc @@ -38,8 +38,8 @@ namespace { const std::string COLMAP_VERSION = "3.9"; const int COLMAP_VERSION_NUMBER = 3900; -const std::string COLMAP_COMMIT_ID = "93af740"; -const std::string COLMAP_COMMIT_DATE = "2023-07-23"; +const std::string COLMAP_COMMIT_ID = "01c29b6"; +const std::string COLMAP_COMMIT_DATE = "2023-07-22"; } // namespace diff --git a/src/lib/LSD/CMakeLists.txt b/src/lib/LSD/CMakeLists.txt index c205a899eb..ddc9bada38 100644 --- a/src/lib/LSD/CMakeLists.txt +++ b/src/lib/LSD/CMakeLists.txt @@ -1,4 +1,5 @@ -COLMAP_ADD_LIBRARY(lsd - lsd.h - lsd.c +COLMAP_ADD_LIBRARY( + NAME lsd + SRCS + lsd.h lsd.c ) diff --git a/src/lib/PoissonRecon/CMakeLists.txt b/src/lib/PoissonRecon/CMakeLists.txt index cedb751518..50fdc3ab35 100644 --- a/src/lib/PoissonRecon/CMakeLists.txt +++ b/src/lib/PoissonRecon/CMakeLists.txt @@ -4,51 +4,46 @@ endif() add_definitions("-DRELEASE") -COLMAP_ADD_LIBRARY(poisson_recon - Allocator.h - Array.h - Array.inl - BSplineData.h - BSplineData.inl - BinaryNode.h - CmdLineParser.cpp - CmdLineParser.h - CmdLineParser.inl - Factor.cpp - Factor.h - FunctionData.h - FunctionData.inl - Geometry.cpp - Geometry.h - Geometry.inl - Hash.h - MAT.h - MAT.inl - MarchingCubes.cpp - MarchingCubes.h - MemoryUsage.h - MultiGridOctreeData.Evaluation.inl - MultiGridOctreeData.IsoSurface.inl - MultiGridOctreeData.SortedTreeNodes.inl - MultiGridOctreeData.System.inl - MultiGridOctreeData.WeightedSamples.inl - MultiGridOctreeData.h - MultiGridOctreeData.inl - MyTime.h - Octree.h - Octree.inl - PPolynomial.h - PPolynomial.inl - Ply.h - PlyFile.cpp - PointStream.h - PointStream.inl - PoissonRecon.cpp - PoissonRecon.h - Polynomial.h - Polynomial.inl - SparseMatrix.h - SparseMatrix.inl - SurfaceTrimmer.cpp - SurfaceTrimmer.h +COLMAP_ADD_LIBRARY( + NAME poisson_recon + SRCS + Allocator.h + Array.h + Array.inl + BSplineData.h + BSplineData.inl + BinaryNode.h + CmdLineParser.h CmdLineParser.cpp + CmdLineParser.inl + Factor.h Factor.cpp + FunctionData.h + FunctionData.inl + Geometry.h Geometry.cpp + Geometry.inl + Hash.h + MAT.h + MAT.inl + MarchingCubes.h MarchingCubes.cpp + MemoryUsage.h + MultiGridOctreeData.Evaluation.inl + MultiGridOctreeData.IsoSurface.inl + MultiGridOctreeData.SortedTreeNodes.inl + MultiGridOctreeData.System.inl + MultiGridOctreeData.WeightedSamples.inl + MultiGridOctreeData.h + MultiGridOctreeData.inl + MyTime.h + Octree.h + Octree.inl + PPolynomial.h + PPolynomial.inl + Ply.h + PointStream.h PlyFile.cpp + PointStream.inl + PoissonRecon.h PoissonRecon.cpp + Polynomial.h + Polynomial.inl + SparseMatrix.h + SparseMatrix.inl + SurfaceTrimmer.h SurfaceTrimmer.cpp ) diff --git a/src/lib/SiftGPU/CMakeLists.txt b/src/lib/SiftGPU/CMakeLists.txt index bcfb1465cf..a651be27e2 100644 --- a/src/lib/SiftGPU/CMakeLists.txt +++ b/src/lib/SiftGPU/CMakeLists.txt @@ -37,14 +37,22 @@ if(CUDA_ENABLED) SiftMatchCU.h ) - COLMAP_ADD_CUDA_LIBRARY(sift_gpu ${SIFT_GPU_SOURCE_FILES}) + COLMAP_ADD_CUDA_LIBRARY( + NAME sift_gpu + SRCS ${SIFT_GPU_SOURCE_FILES} + PRIVATE_DEPS + CUDA::cudart + CUDA::curand + ) else() - COLMAP_ADD_LIBRARY(sift_gpu ${SIFT_GPU_SOURCE_FILES}) + COLMAP_ADD_LIBRARY( + NAME sift_gpu + SRCS ${SIFT_GPU_SOURCE_FILES} + ) endif() target_link_libraries(sift_gpu ${SIFT_GPU_LIBRARIES} - ${GLEW_LIBRARIES} - ${OPENGL_gl_LIBRARY} - ${OPENGL_glu_LIBRARY} + OpenGL + glew ) diff --git a/src/lib/VLFeat/CMakeLists.txt b/src/lib/VLFeat/CMakeLists.txt index f65f0c486c..5831123be0 100644 --- a/src/lib/VLFeat/CMakeLists.txt +++ b/src/lib/VLFeat/CMakeLists.txt @@ -107,4 +107,4 @@ if(NOT OPENMP_ENABLED OR NOT OPENMP_FOUND) add_definitions("-DVL_DISABLE_OPENMP") endif() -COLMAP_ADD_LIBRARY(vlfeat ${VLFEAT_SOURCE_FILES}) +COLMAP_ADD_LIBRARY(NAME vlfeat SRCS ${VLFEAT_SOURCE_FILES}) From a9769350e1ed8ee82448984f6d1364238d8decbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 22 Jul 2023 22:21:03 +0200 Subject: [PATCH 03/38] d --- CMakeLists.txt | 75 ++----------------------------- src/colmap/feature/CMakeLists.txt | 4 +- 2 files changed, 6 insertions(+), 73 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c71d86e1a8..820c0270ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,6 +185,7 @@ if(CGAL_FOUND) target_link_libraries( CGAL INTERFACE ${CGAL_LIBRARY} ${GMP_LIBRARIES}) endif() + list(APPEND COLMAP_LINK_DIRS ${CGAL_LIBRARIES_DIR}) endif() add_library(OpenGL INTERFACE IMPORTED) @@ -371,79 +372,9 @@ endif() # Generate source file with version definitions. include(GenerateVersionDefinitions) -set(COLMAP_INCLUDE_DIRS - ${LZ4_INCLUDE_DIRS} - ${FREEIMAGE_INCLUDE_DIRS} - ${METIS_INCLUDE_DIRS} - ${GLEW_INCLUDE_DIRS} -) - -set(COLMAP_LINK_DIRS - ${Boost_LIBRARY_DIRS} -) - -set(COLMAP_EXTERNAL_LIBRARIES - ${CMAKE_DL_LIBS} - ${LZ4_LIBRARIES} - ${FREEIMAGE_LIBRARIES} - ${METIS_LIBRARIES} - ${OPENGL_LIBRARIES} - Boost::program_options - Boost::filesystem - Boost::graph - Boost::system - Ceres::ceres - Eigen3::Eigen - glog::glog - SQLite::SQLite3 -) - -if(OPENMP_FOUND) - list(APPEND COLMAP_EXTERNAL_LIBRARIES ${OpenMP_libomp_LIBRARY}) -endif() - -if(Qt5_FOUND) - list(APPEND COLMAP_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5OpenGL_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}) - list(APPEND COLMAP_EXTERNAL_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5OpenGL_LIBRARIES} ${Qt5Widgets_LIBRARIES}) -endif() - -if(CGAL_FOUND) - - list(APPEND COLMAP_INCLUDE_DIRS ${CGAL_INCLUDE_DIRS} ${GMP_INCLUDE_DIR}) - list(APPEND COLMAP_EXTERNAL_LIBRARIES ${CGAL_LIBRARY} ${GMP_LIBRARIES}) - list(APPEND COLMAP_LINK_DIRS ${CGAL_LIBRARIES_DIR}) -endif() - -if(UNIX) - list(APPEND COLMAP_EXTERNAL_LIBRARIES pthread) -endif() - -set(COLMAP_INTERNAL_LIBRARIES - colmap_util - colmap_math - colmap_camera - colmap_image - colmap_feature - colmap_geometry - colmap_scene - colmap_estimators - colmap_optim - colmap_mvs - colmap_retrieval - colmap_sfm - colmap_controllers - colmap_ui - lsd - poisson_recon - sift_gpu - vlfeat -) - -include_directories( - src - ${COLMAP_INCLUDE_DIRS} -) +list(APPEND COLMAP_LINK_DIRS ${Boost_LIBRARY_DIRS}) +include_directories(src) link_directories(${COLMAP_LINK_DIRS}) add_subdirectory(src/lib) diff --git a/src/colmap/feature/CMakeLists.txt b/src/colmap/feature/CMakeLists.txt index 7c703007fe..4f4ee949b4 100644 --- a/src/colmap/feature/CMakeLists.txt +++ b/src/colmap/feature/CMakeLists.txt @@ -58,7 +58,9 @@ COLMAP_ADD_TEST( COLMAP_ADD_TEST( NAME sift_test SRCS sift_test.cc - DEPS colmap_feature + DEPS + colmap_feature + Qt5::Widgets ) COLMAP_ADD_TEST( NAME types_test From 94da8269b236ee9ef24e09713166bb0d4d8fff41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 22 Jul 2023 22:24:31 +0200 Subject: [PATCH 04/38] d --- CMakeLists.txt | 12 +++++-- cmake/CMakeHelper.cmake | 64 +++----------------------------------- src/colmap/util/version.cc | 2 +- 3 files changed, 15 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 820c0270ea..87b8c6a45f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -390,14 +390,18 @@ COLMAP_ADD_SOURCE_DIR(src/lib/PoissonRecon LIB_POISSON_RECON_SRCS *.h *.cpp *.in COLMAP_ADD_SOURCE_DIR(src/lib/SiftGPU LIB_SIFT_GPU_SRCS *.h *.cpp *.cu) COLMAP_ADD_SOURCE_DIR(src/lib/VLFeat LIB_VLFEAT_SRCS *.h *.c *.tc) +COLMAP_ADD_SOURCE_DIR(src/colmap/camera CAMERA_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/controllers CONTROLLERS_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/estimators ESTIMATORS_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/exe EXE_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/feature FEATURE_SRCS *.h *.cc) +COLMAP_ADD_SOURCE_DIR(src/colmap/geometry GEOMETRY_SRCS *.h *.cc) +COLMAP_ADD_SOURCE_DIR(src/colmap/image IMAGE_SRCS *.h *.cc) +COLMAP_ADD_SOURCE_DIR(src/colmap/math MATH_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/mvs MVS_SRCS *.h *.cc *.cu) COLMAP_ADD_SOURCE_DIR(src/colmap/optim OPTIM_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/retrieval RETRIEVAL_SRCS *.h *.cc) -COLMAP_ADD_SOURCE_DIR(src/colmap/scene BASE_SRCS *.h *.cc) +COLMAP_ADD_SOURCE_DIR(src/colmap/scene SCENE_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/sfm SFM_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/tools TOOLS_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/ui UI_SRCS *.h *.cc) @@ -412,14 +416,18 @@ add_library( ${LIB_POISSON_RECON_SRCS} ${LIB_SIFT_GPU_SRCS} ${LIB_VLFEAT_SRCS} - ${BASE_SRCS} + ${CAMERA_SRCS} ${CONTROLLERS_SRCS} ${ESTIMATORS_SRCS} ${EXE_SRCS} ${FEATURE_SRCS} + ${GEOMETRY_SRCS} + ${IMAGE_SRCS} + ${MATH_SRCS} ${MVS_SRCS} ${OPTIM_SRCS} ${RETRIEVAL_SRCS} + ${SCENE_SRCS} ${SFM_SRCS} ${TOOLS_SRCS} ${UI_SRCS} diff --git a/cmake/CMakeHelper.cmake b/cmake/CMakeHelper.cmake index a4f51e667a..0750a08e79 100644 --- a/cmake/CMakeHelper.cmake +++ b/cmake/CMakeHelper.cmake @@ -72,40 +72,6 @@ macro(COLMAP_ADD_SOURCE_DIR SRC_DIR SRC_VAR) unset(GROUP_NAME) endmacro(COLMAP_ADD_SOURCE_DIR) -# Macro to add source files to COLMAP library. -macro(COLMAP_ADD_SOURCES) - set(SOURCE_FILES "") - foreach(SOURCE_FILE ${ARGN}) - if(SOURCE_FILE MATCHES "^/.*") - list(APPEND SOURCE_FILES ${SOURCE_FILE}) - else() - list(APPEND SOURCE_FILES - "${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE}") - endif() - endforeach() - set(COLMAP_SOURCES ${COLMAP_SOURCES} ${SOURCE_FILES} PARENT_SCOPE) -endmacro(COLMAP_ADD_SOURCES) - -# Macro to add CUDA source files to COLMAP library. -macro(COLMAP_ADD_CUDA_SOURCES) - set(SOURCE_FILES "") - foreach(SOURCE_FILE ${ARGN}) - if(SOURCE_FILE MATCHES "^/.*") - # Absolute path. - list(APPEND SOURCE_FILES ${SOURCE_FILE}) - else() - # Relative path. - list(APPEND SOURCE_FILES - "${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE}") - endif() - endforeach() - - set(COLMAP_CUDA_SOURCES - ${COLMAP_CUDA_SOURCES} - ${SOURCE_FILES} - PARENT_SCOPE) -endmacro(COLMAP_ADD_CUDA_SOURCES) - # Replacement for the normal add_library() command. The syntax remains the same # in that the first argument is the target name, and the following arguments # are the source files to use when building the target. @@ -131,10 +97,10 @@ endmacro(COLMAP_ADD_LIBRARY) # same in that the first argument is the target name, and the following # arguments are the source files to use when building the target. macro(COLMAP_ADD_EXECUTABLE) -set(options) -set(oneValueArgs) -set(multiValueArgs NAME SRCS DEPS) -cmake_parse_arguments(COLMAP_ADD_EXECUTABLE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + set(options) + set(oneValueArgs) + set(multiValueArgs NAME SRCS DEPS) + cmake_parse_arguments(COLMAP_ADD_EXECUTABLE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) add_executable(${COLMAP_ADD_EXECUTABLE_NAME} ${COLMAP_ADD_EXECUTABLE_SRCS}) set_target_properties(${COLMAP_ADD_EXECUTABLE_NAME} PROPERTIES FOLDER ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) @@ -176,25 +142,3 @@ macro(COLMAP_ADD_TEST) endif() endif() endmacro(COLMAP_ADD_TEST) - -# Wrapper for CUDA test executables. -macro(COLMAP_ADD_CUDA_TEST TEST_NAME) - if(TESTS_ENABLED) - set(TARGET_NAME "colmap_${FOLDER_NAME}_${TEST_NAME}") - add_executable(${TARGET_NAME} ${ARGN}) - set_target_properties(${TARGET_NAME} PROPERTIES FOLDER - ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) - if(CLANG_TIDY_EXE) - set_target_properties(${TARGET_NAME} - PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") - endif() - target_link_libraries(${TARGET_NAME} - colmap - GTest::gtest - GTest::gtest_main) - add_test("${FOLDER_NAME}/${TARGET_NAME}" ${TARGET_NAME}) - if(IS_MSVC) - install(TARGETS ${TARGET_NAME} DESTINATION bin/) - endif() - endif() -endmacro(COLMAP_ADD_CUDA_TEST) diff --git a/src/colmap/util/version.cc b/src/colmap/util/version.cc index 4c75603697..b83a90407c 100644 --- a/src/colmap/util/version.cc +++ b/src/colmap/util/version.cc @@ -38,7 +38,7 @@ namespace { const std::string COLMAP_VERSION = "3.9"; const int COLMAP_VERSION_NUMBER = 3900; -const std::string COLMAP_COMMIT_ID = "01c29b6"; +const std::string COLMAP_COMMIT_ID = "a976935"; const std::string COLMAP_COMMIT_DATE = "2023-07-22"; } // namespace From c5d8e30d70ac1f4f8a95d10a505c2d6ca8b923ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 22 Jul 2023 22:25:05 +0200 Subject: [PATCH 05/38] d --- src/colmap/util/version.cc | 64 -------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 src/colmap/util/version.cc diff --git a/src/colmap/util/version.cc b/src/colmap/util/version.cc deleted file mode 100644 index b83a90407c..0000000000 --- a/src/colmap/util/version.cc +++ /dev/null @@ -1,64 +0,0 @@ -// 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. -// -// Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) - -#include "colmap/util/version.h" - -#include "colmap/util/misc.h" - -namespace colmap { -namespace { - -const std::string COLMAP_VERSION = "3.9"; -const int COLMAP_VERSION_NUMBER = 3900; -const std::string COLMAP_COMMIT_ID = "a976935"; -const std::string COLMAP_COMMIT_DATE = "2023-07-22"; - -} // namespace - -int GetVersionNumber() { return COLMAP_VERSION_NUMBER; } - -std::string GetVersionInfo() { - return StringPrintf("COLMAP %s", COLMAP_VERSION.c_str()); -} - -std::string GetBuildInfo() { -#ifdef CUDA_ENABLED - const std::string cuda_info = "with CUDA"; -#else - const std::string cuda_info = "without CUDA"; -#endif - return StringPrintf("Commit %s on %s %s", - COLMAP_COMMIT_ID.c_str(), - COLMAP_COMMIT_DATE.c_str(), - cuda_info.c_str()); -} - -} // namespace colmap From 8e3feb4b2c303f19a9edc560de1a0154f95bcc1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 24 Jul 2023 08:43:53 +0200 Subject: [PATCH 06/38] d --- cmake/CMakeHelper.cmake | 14 ++++++------- src/colmap/CMakeLists.txt | 2 +- src/colmap/camera/CMakeLists.txt | 8 +++---- src/colmap/controllers/CMakeLists.txt | 8 +++---- src/colmap/estimators/CMakeLists.txt | 30 +++++++++++++-------------- src/colmap/exe/CMakeLists.txt | 4 ++-- src/colmap/feature/CMakeLists.txt | 10 ++++----- src/colmap/geometry/CMakeLists.txt | 20 +++++++++--------- src/colmap/image/CMakeLists.txt | 12 +++++------ src/colmap/math/CMakeLists.txt | 14 ++++++------- src/colmap/mvs/CMakeLists.txt | 16 +++++++------- src/colmap/optim/CMakeLists.txt | 16 +++++++------- src/colmap/retrieval/CMakeLists.txt | 12 +++++------ src/colmap/scene/CMakeLists.txt | 30 +++++++++++++-------------- src/colmap/sfm/CMakeLists.txt | 4 ++-- src/colmap/ui/CMakeLists.txt | 2 +- src/colmap/util/CMakeLists.txt | 22 ++++++++++---------- src/lib/SiftGPU/CMakeLists.txt | 2 +- 18 files changed, 113 insertions(+), 113 deletions(-) diff --git a/cmake/CMakeHelper.cmake b/cmake/CMakeHelper.cmake index 0750a08e79..f7c28a8222 100644 --- a/cmake/CMakeHelper.cmake +++ b/cmake/CMakeHelper.cmake @@ -78,7 +78,7 @@ endmacro(COLMAP_ADD_SOURCE_DIR) macro(COLMAP_ADD_LIBRARY) set(options) set(oneValueArgs) - set(multiValueArgs NAME SRCS PRIVATE_DEPS PUBLIC_DEPS) + set(multiValueArgs NAME SRCS PRIVATE_LINK_LIBS PUBLIC_LINK_LIBS) cmake_parse_arguments(COLMAP_ADD_LIBRARY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) add_library(${COLMAP_ADD_LIBRARY_NAME} STATIC ${COLMAP_ADD_LIBRARY_SRCS}) set_target_properties(${COLMAP_ADD_LIBRARY_NAME} PROPERTIES FOLDER @@ -88,8 +88,8 @@ macro(COLMAP_ADD_LIBRARY) PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") endif() target_link_libraries(${COLMAP_ADD_LIBRARY_NAME} - PRIVATE ${COLMAP_ADD_LIBRARY_PRIVATE_DEPS} - PUBLIC ${COLMAP_ADD_LIBRARY_PUBLIC_DEPS}) + PRIVATE ${COLMAP_ADD_LIBRARY_PRIVATE_LINK_LIBS} + PUBLIC ${COLMAP_ADD_LIBRARY_PUBLIC_LINK_LIBS}) install(TARGETS ${COLMAP_ADD_LIBRARY_NAME} DESTINATION lib/colmap) endmacro(COLMAP_ADD_LIBRARY) @@ -99,12 +99,12 @@ endmacro(COLMAP_ADD_LIBRARY) macro(COLMAP_ADD_EXECUTABLE) set(options) set(oneValueArgs) - set(multiValueArgs NAME SRCS DEPS) + set(multiValueArgs NAME SRCS LINK_LIBS) cmake_parse_arguments(COLMAP_ADD_EXECUTABLE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) add_executable(${COLMAP_ADD_EXECUTABLE_NAME} ${COLMAP_ADD_EXECUTABLE_SRCS}) set_target_properties(${COLMAP_ADD_EXECUTABLE_NAME} PROPERTIES FOLDER ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) - target_link_libraries(${COLMAP_ADD_EXECUTABLE_NAME} ${COLMAP_ADD_EXECUTABLE_DEPS}) + target_link_libraries(${COLMAP_ADD_EXECUTABLE_NAME} ${COLMAP_ADD_EXECUTABLE_LINK_LIBS}) if(VCPKG_BUILD) install(TARGETS ${COLMAP_ADD_EXECUTABLE_NAME} DESTINATION tools/) else() @@ -120,7 +120,7 @@ endmacro(COLMAP_ADD_EXECUTABLE) macro(COLMAP_ADD_TEST) set(options) set(oneValueArgs) - set(multiValueArgs NAME SRCS DEPS) + set(multiValueArgs NAME SRCS LINK_LIBS) cmake_parse_arguments(COLMAP_ADD_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if(TESTS_ENABLED) # ${ARGN} will store the list of link libraries. @@ -133,7 +133,7 @@ macro(COLMAP_ADD_TEST) PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=.*") endif() target_link_libraries(${COLMAP_ADD_TEST_NAME} - ${COLMAP_ADD_TEST_DEPS} + ${COLMAP_ADD_TEST_LINK_LIBS} GTest::gtest GTest::gtest_main) add_test("${FOLDER_NAME}/${COLMAP_ADD_TEST_NAME}" ${COLMAP_ADD_TEST_NAME}) diff --git a/src/colmap/CMakeLists.txt b/src/colmap/CMakeLists.txt index aa8a7f12ac..d355543106 100644 --- a/src/colmap/CMakeLists.txt +++ b/src/colmap/CMakeLists.txt @@ -92,7 +92,7 @@ if(CUDA_ENABLED) # COLMAP_ADD_LIBRARY( # NAME colmap_cuda # SRCS ${COLMAP_CUDA_SOURCES} - # PRIVATE_DEPS + # PRIVATE_LINK_LIBS # CUDA::cudart # CUDA::curand # colmap diff --git a/src/colmap/camera/CMakeLists.txt b/src/colmap/camera/CMakeLists.txt index 35a554c119..b45c4884b2 100644 --- a/src/colmap/camera/CMakeLists.txt +++ b/src/colmap/camera/CMakeLists.txt @@ -37,20 +37,20 @@ COLMAP_ADD_LIBRARY( database.h database.cc models.h models.cc specs.h specs.cc - PUBLIC_DEPS + PUBLIC_LINK_LIBS Eigen3::Eigen Ceres::ceres - PRIVATE_DEPS + PRIVATE_LINK_LIBS colmap_util ) COLMAP_ADD_TEST( NAME database_test SRCS database_test.cc - DEPS colmap_camera + LINK_LIBS colmap_camera ) COLMAP_ADD_TEST( NAME models_test SRCS models_test.cc - DEPS colmap_camera + LINK_LIBS colmap_camera ) diff --git a/src/colmap/controllers/CMakeLists.txt b/src/colmap/controllers/CMakeLists.txt index 91aa88f447..43b5c2043b 100644 --- a/src/colmap/controllers/CMakeLists.txt +++ b/src/colmap/controllers/CMakeLists.txt @@ -39,11 +39,11 @@ COLMAP_ADD_LIBRARY( hierarchical_mapper.h hierarchical_mapper.cc incremental_mapper.h incremental_mapper.cc option_manager.h option_manager.cc - PUBLIC_DEPS + PUBLIC_LINK_LIBS colmap_scene colmap_util Eigen3::Eigen - PRIVATE_DEPS + PRIVATE_LINK_LIBS colmap_math colmap_estimators colmap_feature @@ -57,10 +57,10 @@ COLMAP_ADD_LIBRARY( COLMAP_ADD_TEST( NAME hierarchical_mapper_test SRCS hierarchical_mapper_test.cc - DEPS colmap_controllers + LINK_LIBS colmap_controllers ) COLMAP_ADD_TEST( NAME incremental_mapper_test SRCS incremental_mapper_test.cc - DEPS colmap_controllers + LINK_LIBS colmap_controllers ) diff --git a/src/colmap/estimators/CMakeLists.txt b/src/colmap/estimators/CMakeLists.txt index 5381d0d75f..e261d0a19f 100644 --- a/src/colmap/estimators/CMakeLists.txt +++ b/src/colmap/estimators/CMakeLists.txt @@ -52,7 +52,7 @@ COLMAP_ADD_LIBRARY( triangulation.h triangulation.cc two_view_geometry.h two_view_geometry.cc utils.h utils.cc - PUBLIC_DEPS + PUBLIC_LINK_LIBS colmap_util colmap_math colmap_feature @@ -64,70 +64,70 @@ COLMAP_ADD_LIBRARY( COLMAP_ADD_TEST( NAME absolute_pose_test SRCS absolute_pose_test.cc - DEPS colmap_estimators + LINK_LIBS colmap_estimators ) COLMAP_ADD_TEST( NAME affine_transform_test SRCS affine_transform_test.cc - DEPS colmap_estimators + LINK_LIBS colmap_estimators ) COLMAP_ADD_TEST( NAME bundle_adjustment_test SRCS bundle_adjustment_test.cc - DEPS colmap_estimators + LINK_LIBS colmap_estimators ) COLMAP_ADD_TEST( NAME coordinate_frame_test SRCS coordinate_frame_test.cc - DEPS colmap_estimators + LINK_LIBS colmap_estimators ) COLMAP_ADD_TEST( NAME cost_functions_test SRCS cost_functions_test.cc - DEPS colmap_estimators + LINK_LIBS colmap_estimators ) COLMAP_ADD_TEST( NAME essential_matrix_test SRCS essential_matrix_test.cc - DEPS colmap_estimators + LINK_LIBS colmap_estimators ) COLMAP_ADD_TEST( NAME estimators_utils_test SRCS utils_test.cc - DEPS colmap_estimators + LINK_LIBS colmap_estimators ) COLMAP_ADD_TEST( NAME fundamental_matrix_test SRCS fundamental_matrix_test.cc - DEPS colmap_estimators + LINK_LIBS colmap_estimators ) COLMAP_ADD_TEST( NAME generalized_absolute_pose_test SRCS generalized_absolute_pose_test.cc - DEPS colmap_estimators + LINK_LIBS colmap_estimators ) COLMAP_ADD_TEST( NAME generalized_relative_pose_test SRCS generalized_relative_pose_test.cc - DEPS colmap_estimators + LINK_LIBS colmap_estimators ) COLMAP_ADD_TEST( NAME homography_matrix_test SRCS homography_matrix_test.cc - DEPS colmap_estimators + LINK_LIBS colmap_estimators ) COLMAP_ADD_TEST( NAME pose_test SRCS pose_test.cc - DEPS colmap_estimators + LINK_LIBS colmap_estimators ) COLMAP_ADD_TEST( NAME translation_transform_test SRCS translation_transform_test.cc - DEPS colmap_estimators + LINK_LIBS colmap_estimators ) COLMAP_ADD_TEST( NAME two_view_geometry_test SRCS two_view_geometry_test.cc - DEPS colmap_estimators + LINK_LIBS colmap_estimators ) diff --git a/src/colmap/exe/CMakeLists.txt b/src/colmap/exe/CMakeLists.txt index 038550e871..28b7352637 100644 --- a/src/colmap/exe/CMakeLists.txt +++ b/src/colmap/exe/CMakeLists.txt @@ -40,7 +40,7 @@ COLMAP_ADD_LIBRARY( SRCS feature.h feature.cc sfm.h sfm.cc - PUBLIC_DEPS + PUBLIC_LINK_LIBS colmap_controllers colmap_image colmap_feature @@ -58,7 +58,7 @@ COLMAP_ADD_EXECUTABLE( mvs.cc sfm.cc vocab_tree.cc - DEPS + LINK_LIBS colmap_util colmap_math colmap_camera diff --git a/src/colmap/feature/CMakeLists.txt b/src/colmap/feature/CMakeLists.txt index 4f4ee949b4..ae5f93acad 100644 --- a/src/colmap/feature/CMakeLists.txt +++ b/src/colmap/feature/CMakeLists.txt @@ -39,9 +39,9 @@ COLMAP_ADD_LIBRARY( sift.h sift.cc types.h types.cc utils.h utils.cc - PUBLIC_DEPS + PUBLIC_LINK_LIBS Eigen3::Eigen - PRIVATE_DEPS + PRIVATE_LINK_LIBS colmap_util colmap_image flann @@ -53,17 +53,17 @@ COLMAP_ADD_LIBRARY( COLMAP_ADD_TEST( NAME feature_utils_test SRCS utils_test.cc - DEPS colmap_feature + LINK_LIBS colmap_feature ) COLMAP_ADD_TEST( NAME sift_test SRCS sift_test.cc - DEPS + LINK_LIBS colmap_feature Qt5::Widgets ) COLMAP_ADD_TEST( NAME types_test SRCS types_test.cc - DEPS colmap_feature + LINK_LIBS colmap_feature ) diff --git a/src/colmap/geometry/CMakeLists.txt b/src/colmap/geometry/CMakeLists.txt index ad0fabb319..e9e5444ef5 100644 --- a/src/colmap/geometry/CMakeLists.txt +++ b/src/colmap/geometry/CMakeLists.txt @@ -42,11 +42,11 @@ COLMAP_ADD_LIBRARY( rigid3.h sim3.h sim3.cc triangulation.h triangulation.cc - PUBLIC_DEPS + PUBLIC_LINK_LIBS colmap_util colmap_math Eigen3::Eigen - PRIVATE_DEPS + PRIVATE_LINK_LIBS colmap_scene colmap_optim ) @@ -54,40 +54,40 @@ COLMAP_ADD_LIBRARY( COLMAP_ADD_TEST( NAME essential_matrix_utils_test SRCS essential_matrix_test.cc - DEPS colmap_geometry + LINK_LIBS colmap_geometry ) COLMAP_ADD_TEST( NAME gps_test SRCS gps_test.cc - DEPS colmap_geometry + LINK_LIBS colmap_geometry ) COLMAP_ADD_TEST( NAME homography_matrix_utils_test SRCS homography_matrix_test.cc - DEPS colmap_geometry + LINK_LIBS colmap_geometry ) COLMAP_ADD_TEST( NAME pose_test SRCS pose_test.cc - DEPS colmap_geometry + LINK_LIBS colmap_geometry ) COLMAP_ADD_TEST( NAME projection_test SRCS projection_test.cc - DEPS colmap_geometry + LINK_LIBS colmap_geometry ) COLMAP_ADD_TEST( NAME rigid3_test SRCS rigid3_test.cc - DEPS colmap_geometry + LINK_LIBS colmap_geometry ) COLMAP_ADD_TEST( NAME sim3_test SRCS sim3_test.cc - DEPS colmap_geometry + LINK_LIBS colmap_geometry ) COLMAP_ADD_TEST( NAME triangulation_test SRCS triangulation_test.cc - DEPS colmap_geometry + LINK_LIBS colmap_geometry ) diff --git a/src/colmap/image/CMakeLists.txt b/src/colmap/image/CMakeLists.txt index 3f22cc4e5b..cc8733fed5 100644 --- a/src/colmap/image/CMakeLists.txt +++ b/src/colmap/image/CMakeLists.txt @@ -39,11 +39,11 @@ COLMAP_ADD_LIBRARY( line.h line.cc undistortion.h undistortion.cc warp.h warp.cc - PUBLIC_DEPS + PUBLIC_LINK_LIBS colmap_scene Eigen3::Eigen freeimage - PRIVATE_DEPS + PRIVATE_LINK_LIBS lsd vlfeat ) @@ -51,20 +51,20 @@ COLMAP_ADD_LIBRARY( COLMAP_ADD_TEST( NAME bitmap_test SRCS bitmap_test.cc - DEPS colmap_image + LINK_LIBS colmap_image ) COLMAP_ADD_TEST( NAME line_test SRCS line_test.cc - DEPS colmap_image + LINK_LIBS colmap_image ) COLMAP_ADD_TEST( NAME undistortion_test SRCS undistortion_test.cc - DEPS colmap_image + LINK_LIBS colmap_image ) COLMAP_ADD_TEST( NAME warp_test SRCS warp_test.cc - DEPS colmap_image + LINK_LIBS colmap_image ) diff --git a/src/colmap/math/CMakeLists.txt b/src/colmap/math/CMakeLists.txt index e0ef6f50e6..addfce4de4 100644 --- a/src/colmap/math/CMakeLists.txt +++ b/src/colmap/math/CMakeLists.txt @@ -39,36 +39,36 @@ COLMAP_ADD_LIBRARY( matrix.h polynomial.h polynomial.cc random.h random.cc - PUBLIC_DEPS + PUBLIC_LINK_LIBS colmap_util Boost::graph Eigen3::Eigen - PRIVATE_DEPS + PRIVATE_LINK_LIBS metis ) COLMAP_ADD_TEST( NAME graph_cut_test SRCS graph_cut_test.cc - DEPS colmap_math + LINK_LIBS colmap_math ) COLMAP_ADD_TEST( NAME math_test SRCS math_test.cc - DEPS colmap_math + LINK_LIBS colmap_math ) COLMAP_ADD_TEST( NAME matrix_test SRCS matrix_test.cc - DEPS colmap_math + LINK_LIBS colmap_math ) COLMAP_ADD_TEST( NAME polynomial_test SRCS polynomial_test.cc - DEPS colmap_math + LINK_LIBS colmap_math ) COLMAP_ADD_TEST( NAME random_test SRCS random_test.cc - DEPS colmap_math + LINK_LIBS colmap_math ) diff --git a/src/colmap/mvs/CMakeLists.txt b/src/colmap/mvs/CMakeLists.txt index a506da8921..ae99062bf2 100644 --- a/src/colmap/mvs/CMakeLists.txt +++ b/src/colmap/mvs/CMakeLists.txt @@ -42,10 +42,10 @@ COLMAP_ADD_LIBRARY( model.h model.cc normal_map.h normal_map.cc workspace.h workspace.cc - PUBLIC_DEPS + PUBLIC_LINK_LIBS colmap_util colmap_scene - PRIVATE_DEPS + PRIVATE_LINK_LIBS poisson_recon Eigen3::Eigen CGAL @@ -54,22 +54,22 @@ COLMAP_ADD_LIBRARY( COLMAP_ADD_TEST( NAME consistency_graph_test SRCS consistency_graph_test.cc - DEPS colmap_mvs + LINK_LIBS colmap_mvs ) COLMAP_ADD_TEST( NAME depth_map_test SRCS depth_map_test.cc - DEPS colmap_mvs + LINK_LIBS colmap_mvs ) COLMAP_ADD_TEST( NAME mat_test SRCS mat_test.cc - DEPS colmap_mvs + LINK_LIBS colmap_mvs ) COLMAP_ADD_TEST( NAME normal_map_test SRCS normal_map_test.cc - DEPS colmap_mvs + LINK_LIBS colmap_mvs ) if(CUDA_ENABLED) @@ -80,7 +80,7 @@ if(CUDA_ENABLED) gpu_mat_ref_image.h gpu_mat_ref_image.cu patch_match.h patch_match.cc patch_match_cuda.h patch_match_cuda.cu - PUBLIC_DEPS + PUBLIC_LINK_LIBS colmap_mvs Cuda::cudart Cuda::curand @@ -90,6 +90,6 @@ if(CUDA_ENABLED) COLMAP_ADD_TEST( NAME gpu_mat_test SRCS gpu_mat_test.cu - DEPS colmap_mvs + LINK_LIBS colmap_mvs ) endif() diff --git a/src/colmap/optim/CMakeLists.txt b/src/colmap/optim/CMakeLists.txt index 6c809152d7..1aef864f94 100644 --- a/src/colmap/optim/CMakeLists.txt +++ b/src/colmap/optim/CMakeLists.txt @@ -40,7 +40,7 @@ COLMAP_ADD_LIBRARY( random_sampler.h random_sampler.cc sprt.h sprt.cc support_measurement.h support_measurement.cc - PUBLIC_DEPS + PUBLIC_LINK_LIBS colmap_math Eigen3::Eigen ) @@ -48,35 +48,35 @@ COLMAP_ADD_LIBRARY( COLMAP_ADD_TEST( NAME combination_sampler_test SRCS combination_sampler_test.cc - DEPS colmap_optim + LINK_LIBS colmap_optim ) COLMAP_ADD_TEST( NAME least_absolute_deviations_test SRCS least_absolute_deviations_test.cc - DEPS colmap_optim + LINK_LIBS colmap_optim ) COLMAP_ADD_TEST( NAME loransac_test SRCS loransac_test.cc - DEPS colmap_optim + LINK_LIBS colmap_optim ) COLMAP_ADD_TEST( NAME progressive_sampler_test SRCS progressive_sampler_test.cc - DEPS colmap_optim + LINK_LIBS colmap_optim ) COLMAP_ADD_TEST( NAME random_sampler_test SRCS random_sampler_test.cc - DEPS colmap_optim + LINK_LIBS colmap_optim ) COLMAP_ADD_TEST( NAME ransac_test SRCS ransac_test.cc - DEPS colmap_optim + LINK_LIBS colmap_optim ) COLMAP_ADD_TEST( NAME support_measurement_test SRCS support_measurement_test.cc - DEPS colmap_optim + LINK_LIBS colmap_optim ) diff --git a/src/colmap/retrieval/CMakeLists.txt b/src/colmap/retrieval/CMakeLists.txt index 2e3d1e495a..37be79c497 100644 --- a/src/colmap/retrieval/CMakeLists.txt +++ b/src/colmap/retrieval/CMakeLists.txt @@ -41,12 +41,12 @@ COLMAP_ADD_LIBRARY( utils.h visual_index.h vote_and_verify.h vote_and_verify.cc - PUBLIC_DEPS + PUBLIC_LINK_LIBS Boost::graph Eigen3::Eigen flann lz4 - PRIVATE_DEPS + PRIVATE_LINK_LIBS colmap_math colmap_estimators ) @@ -54,20 +54,20 @@ COLMAP_ADD_LIBRARY( COLMAP_ADD_TEST( NAME geometry_test SRCS geometry_test.cc - DEPS colmap_retrieval + LINK_LIBS colmap_retrieval ) COLMAP_ADD_TEST( NAME inverted_file_entry_test SRCS inverted_file_entry_test.cc - DEPS colmap_retrieval + LINK_LIBS colmap_retrieval ) COLMAP_ADD_TEST( NAME visual_index_test SRCS visual_index_test.cc - DEPS colmap_retrieval + LINK_LIBS colmap_retrieval ) COLMAP_ADD_TEST( NAME vote_and_verify_test SRCS vote_and_verify_test.cc - DEPS colmap_retrieval + LINK_LIBS colmap_retrieval ) diff --git a/src/colmap/scene/CMakeLists.txt b/src/colmap/scene/CMakeLists.txt index d36d90c683..a73d51b936 100644 --- a/src/colmap/scene/CMakeLists.txt +++ b/src/colmap/scene/CMakeLists.txt @@ -49,7 +49,7 @@ COLMAP_ADD_LIBRARY( synthetic.h synthetic.cc track.h track.cc visibility_pyramid.h visibility_pyramid.cc - PUBLIC_DEPS + PUBLIC_LINK_LIBS colmap_camera colmap_image colmap_feature @@ -62,70 +62,70 @@ COLMAP_ADD_LIBRARY( COLMAP_ADD_TEST( NAME camera_rig_test SRCS camera_rig_test.cc - DEPS colmap_scene + LINK_LIBS colmap_scene ) COLMAP_ADD_TEST( NAME camera_test SRCS camera_test.cc - DEPS colmap_scene + LINK_LIBS colmap_scene ) COLMAP_ADD_TEST( NAME correspondence_graph_test SRCS correspondence_graph_test.cc - DEPS colmap_scene + LINK_LIBS colmap_scene ) COLMAP_ADD_TEST( NAME database_cache_test SRCS database_cache_test.cc - DEPS colmap_scene + LINK_LIBS colmap_scene ) COLMAP_ADD_TEST( NAME database_test SRCS database_test.cc - DEPS colmap_scene + LINK_LIBS colmap_scene ) COLMAP_ADD_TEST( NAME image_test SRCS image_test.cc - DEPS colmap_scene + LINK_LIBS colmap_scene ) COLMAP_ADD_TEST( NAME point2d_test SRCS point2d_test.cc - DEPS colmap_scene + LINK_LIBS colmap_scene ) COLMAP_ADD_TEST( NAME point3d_test SRCS point3d_test.cc - DEPS colmap_scene + LINK_LIBS colmap_scene ) COLMAP_ADD_TEST( NAME reconstruction_test SRCS reconstruction_test.cc - DEPS colmap_scene + LINK_LIBS colmap_scene ) COLMAP_ADD_TEST( NAME reconstruction_manager_test SRCS reconstruction_manager_test.cc - DEPS colmap_scene + LINK_LIBS colmap_scene ) COLMAP_ADD_TEST( NAME scene_clustering_test SRCS scene_clustering_test.cc - DEPS colmap_scene + LINK_LIBS colmap_scene ) COLMAP_ADD_TEST( NAME synthetic_test SRCS synthetic_test.cc - DEPS colmap_scene + LINK_LIBS colmap_scene ) COLMAP_ADD_TEST( NAME track_test SRCS track_test.cc - DEPS colmap_scene + LINK_LIBS colmap_scene ) COLMAP_ADD_TEST( NAME visibility_pyramid_test SRCS visibility_pyramid_test.cc - DEPS colmap_scene + LINK_LIBS colmap_scene ) diff --git a/src/colmap/sfm/CMakeLists.txt b/src/colmap/sfm/CMakeLists.txt index e264995024..f46937f1f8 100644 --- a/src/colmap/sfm/CMakeLists.txt +++ b/src/colmap/sfm/CMakeLists.txt @@ -36,10 +36,10 @@ COLMAP_ADD_LIBRARY( SRCS incremental_mapper.h incremental_mapper.cc incremental_triangulator.h incremental_triangulator.cc - PUBLIC_DEPS + PUBLIC_LINK_LIBS colmap_scene colmap_estimators - PRIVATE_DEPS + PRIVATE_LINK_LIBS colmap_geometry colmap_image ) diff --git a/src/colmap/ui/CMakeLists.txt b/src/colmap/ui/CMakeLists.txt index 80b992a21d..d3c490e681 100644 --- a/src/colmap/ui/CMakeLists.txt +++ b/src/colmap/ui/CMakeLists.txt @@ -63,7 +63,7 @@ COLMAP_ADD_LIBRARY( triangle_painter.h triangle_painter.cc undistortion_widget.h undistortion_widget.cc resources.qrc - PUBLIC_DEPS + PUBLIC_LINK_LIBS colmap_util colmap_image colmap_scene diff --git a/src/colmap/util/CMakeLists.txt b/src/colmap/util/CMakeLists.txt index 4093c02a78..d6d9b05d01 100644 --- a/src/colmap/util/CMakeLists.txt +++ b/src/colmap/util/CMakeLists.txt @@ -46,7 +46,7 @@ COLMAP_ADD_LIBRARY( timer.h timer.cc types.h version.h version.cc - PUBLIC_DEPS + PUBLIC_LINK_LIBS Boost::filesystem Eigen3::Eigen glog::glog @@ -54,7 +54,7 @@ COLMAP_ADD_LIBRARY( Qt5::Core Qt5::OpenGL SQLite::SQLite3 - PRIVATE_DEPS + PRIVATE_LINK_LIBS colmap_math ) @@ -64,46 +64,46 @@ if(CUDA_ENABLED) SRCS cuda.h cuda.cc cudacc.h cudacc.cc - PUBLIC_DEPS + PUBLIC_LINK_LIBS Cuda::cudart ) - target_link_libraries(colmap_util PUBLIC_DEPS colmap_util_cuda) + target_link_libraries(colmap_util PUBLIC_LINK_LIBS colmap_util_cuda) endif() COLMAP_ADD_TEST( NAME cache_test SRCS cache_test.cc - DEPS colmap_util + LINK_LIBS colmap_util ) COLMAP_ADD_TEST( NAME endian_test SRCS endian_test.cc - DEPS colmap_util + LINK_LIBS colmap_util ) COLMAP_ADD_TEST( NAME misc_test SRCS misc_test.cc - DEPS colmap_util + LINK_LIBS colmap_util ) COLMAP_ADD_TEST( NAME string_test SRCS string_test.cc - DEPS colmap_util + LINK_LIBS colmap_util ) COLMAP_ADD_TEST( NAME threading_test SRCS threading_test.cc - DEPS colmap_util + LINK_LIBS colmap_util ) COLMAP_ADD_TEST( NAME timer_test SRCS timer_test.cc - DEPS colmap_util + LINK_LIBS colmap_util ) if(GUI_ENABLED) COLMAP_ADD_TEST( NAME opengl_utils_test SRCS opengl_utils_test.cc - DEPS colmap_util + LINK_LIBS colmap_util ) endif() diff --git a/src/lib/SiftGPU/CMakeLists.txt b/src/lib/SiftGPU/CMakeLists.txt index a651be27e2..860e2a4474 100644 --- a/src/lib/SiftGPU/CMakeLists.txt +++ b/src/lib/SiftGPU/CMakeLists.txt @@ -40,7 +40,7 @@ if(CUDA_ENABLED) COLMAP_ADD_CUDA_LIBRARY( NAME sift_gpu SRCS ${SIFT_GPU_SOURCE_FILES} - PRIVATE_DEPS + PRIVATE_LINK_LIBS CUDA::cudart CUDA::curand ) From 399b6a46576ce413d0a226963aded85ef250e3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 24 Jul 2023 08:46:44 +0200 Subject: [PATCH 07/38] d --- src/lib/SiftGPU/CMakeLists.txt | 72 ++++++++++++---------------------- 1 file changed, 26 insertions(+), 46 deletions(-) diff --git a/src/lib/SiftGPU/CMakeLists.txt b/src/lib/SiftGPU/CMakeLists.txt index 860e2a4474..b1e338e0ad 100644 --- a/src/lib/SiftGPU/CMakeLists.txt +++ b/src/lib/SiftGPU/CMakeLists.txt @@ -1,58 +1,38 @@ add_definitions("-DSIFTGPU_NO_DEVIL") -set(SIFT_GPU_SOURCE_FILES - FrameBufferObject.cpp - FrameBufferObject.h - GlobalUtil.cpp - GlobalUtil.h - GLTexImage.cpp - GLTexImage.h - ProgramGLSL.cpp - ProgramGLSL.h - ProgramGPU.h - PyramidGL.cpp - PyramidGL.h - ShaderMan.cpp - ShaderMan.h - SiftGPU.cpp - SiftGPU.h - SiftMatch.cpp - SiftMatch.h - SiftPyramid.cpp - SiftPyramid.h +COLMAP_ADD_LIBRARY( + NAME sift_gpu + SRCS + FrameBufferObject.h FrameBufferObject.cpp + GlobalUtil.h GlobalUtil.cpp + GLTexImage.h GLTexImage.cpp + ProgramGLSL.h ProgramGLSL.cpp + ProgramGPU.h + PyramidGL.h PyramidGL.cpp + ShaderMan.h ShaderMan.cpp + SiftGPU.h SiftGPU.cpp + SiftMatch.h SiftMatch.cpp + SiftPyramid.h SiftPyramid.cpp + PRIVATE_LINK_LIBS + OpenGL + glew ) if(CUDA_ENABLED) add_definitions("-DCUDA_SIFTGPU_ENABLED") - set(SIFT_GPU_SOURCE_FILES - ${SIFT_GPU_SOURCE_FILES} - CuTexImage.cpp - CuTexImage.h - ProgramCU.cu - ProgramCU.h - PyramidCU.cpp - PyramidCU.h - SiftMatchCU.cpp - SiftMatchCU.h - ) - - COLMAP_ADD_CUDA_LIBRARY( - NAME sift_gpu - SRCS ${SIFT_GPU_SOURCE_FILES} + COLMAP_ADD_LIBRARY( + NAME sift_gpu_cuda + SRCS + CuTexImage.h CuTexImage.cpp + ProgramCU.cu + ProgramCU.h + PyramidCU.h PyramidCU.cpp + SiftMatchCU.h SiftMatchCU.cpp PRIVATE_LINK_LIBS CUDA::cudart CUDA::curand ) -else() - COLMAP_ADD_LIBRARY( - NAME sift_gpu - SRCS ${SIFT_GPU_SOURCE_FILES} - ) -endif() -target_link_libraries(sift_gpu - ${SIFT_GPU_LIBRARIES} - OpenGL - glew -) + target_link_libraries(sift_gpu PRIVATE sift_gpu_cuda) +endif() From cb23c5d75f603b234c8db2b89f875c41a3e03767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 24 Jul 2023 08:51:35 +0200 Subject: [PATCH 08/38] d --- CMakeLists.txt | 13 ++++++++----- cmake/FindMetis.cmake | 14 +++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87b8c6a45f..0e6ed9bce3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -173,12 +173,19 @@ if(OPENGL_ENABLED AND NOT GUI_ENABLED) set(OPENGL_ENABLED OFF) endif() +if(OPENGL_ENABLED) + add_library(OpenGL INTERFACE IMPORTED) + target_link_libraries( + OpenGL INTERFACE ${OPENGL_LIBRARIES}) +endif() + if(CGAL_FOUND) list(APPEND CGAL_LIBRARY ${CGAL_LIBRARIES}) message(STATUS "Found CGAL") message(STATUS " Includes : ${CGAL_INCLUDE_DIRS}") message(STATUS " Libraries : ${CGAL_LIBRARY}") if(NOT TARGET CGAL) + # Older CGAL versions don't come with an imported interface target. add_library(CGAL INTERFACE IMPORTED) target_include_directories( CGAL INTERFACE ${CGAL_INCLUDE_DIRS} ${GMP_INCLUDE_DIR}) @@ -188,12 +195,8 @@ if(CGAL_FOUND) list(APPEND COLMAP_LINK_DIRS ${CGAL_LIBRARIES_DIR}) endif() -add_library(OpenGL INTERFACE IMPORTED) -target_link_libraries( - OpenGL INTERFACE ${OPENGL_LIBRARIES}) - -# For backwards compatibility with older Ceres versions, define the interface. if(NOT TARGET Ceres::ceres) + # Older Ceres versions don't come with an imported interface target. add_library(Ceres::ceres INTERFACE IMPORTED) target_include_directories( Ceres::ceres INTERFACE ${CERES_INCLUDE_DIRS}) diff --git a/cmake/FindMetis.cmake b/cmake/FindMetis.cmake index 7460ee0fde..b9639cd21a 100644 --- a/cmake/FindMetis.cmake +++ b/cmake/FindMetis.cmake @@ -103,8 +103,12 @@ if(NOT METIS_FOUND AND METIS_FIND_REQUIRED) message(FATAL_ERROR "Could not find Metis") endif() -add_library(metis INTERFACE IMPORTED) -target_include_directories( - metis INTERFACE ${METIS_INCLUDE_DIRS}) -target_link_libraries( - metis INTERFACE ${METIS_LIBRARIES}) +if(NOT TARGET metis) + # vcpkg's metis CMake config defines an imported interface target. + # Only define it here, if it doesn't already exist. + add_library(metis INTERFACE IMPORTED) + target_include_directories( + metis INTERFACE ${METIS_INCLUDE_DIRS}) + target_link_libraries( + metis INTERFACE ${METIS_LIBRARIES}) +endif() From e825e92b4250c3522669c32772b1158c7795a46b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 24 Jul 2023 09:51:21 +0200 Subject: [PATCH 09/38] d --- cmake/FindGlew.cmake | 6 ------ src/colmap/mvs/CMakeLists.txt | 2 +- src/lib/SiftGPU/CMakeLists.txt | 4 ++-- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/cmake/FindGlew.cmake b/cmake/FindGlew.cmake index 45c3de5eed..43800fe2d6 100644 --- a/cmake/FindGlew.cmake +++ b/cmake/FindGlew.cmake @@ -88,9 +88,3 @@ else() message(FATAL_ERROR "Could not find Glew") endif() endif() - -add_library(glew INTERFACE IMPORTED) -target_include_directories( - glew INTERFACE ${GLEW_INCLUDE_DIRS}) -target_link_libraries( - glew INTERFACE ${GLEW_LIBRARIES}) diff --git a/src/colmap/mvs/CMakeLists.txt b/src/colmap/mvs/CMakeLists.txt index ae99062bf2..6fb06f12fc 100644 --- a/src/colmap/mvs/CMakeLists.txt +++ b/src/colmap/mvs/CMakeLists.txt @@ -73,7 +73,7 @@ COLMAP_ADD_TEST( ) if(CUDA_ENABLED) - COLMAP_ADD__LIBRARY( + COLMAP_ADD_LIBRARY( NAME colmap_mvs_cuda SRCS gpu_mat_prng.h gpu_mat_prng.cu diff --git a/src/lib/SiftGPU/CMakeLists.txt b/src/lib/SiftGPU/CMakeLists.txt index b1e338e0ad..5566caf019 100644 --- a/src/lib/SiftGPU/CMakeLists.txt +++ b/src/lib/SiftGPU/CMakeLists.txt @@ -14,8 +14,8 @@ COLMAP_ADD_LIBRARY( SiftMatch.h SiftMatch.cpp SiftPyramid.h SiftPyramid.cpp PRIVATE_LINK_LIBS - OpenGL - glew + OpenGL::GL + GLEW::GLEW ) if(CUDA_ENABLED) From 885453f215c9cf98e5db0727059cd8c86531ba80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 24 Jul 2023 09:51:26 +0200 Subject: [PATCH 10/38] d --- CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e6ed9bce3..c9abdd35e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ # # Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.10) project(COLMAP LANGUAGES C CXX) @@ -173,10 +173,12 @@ if(OPENGL_ENABLED AND NOT GUI_ENABLED) set(OPENGL_ENABLED OFF) endif() -if(OPENGL_ENABLED) - add_library(OpenGL INTERFACE IMPORTED) +if(NOT TARGET GLEW::GLEW) + add_library(GLEW::GLEW INTERFACE IMPORTED) + target_include_directories( + GLEW::GLEW INTERFACE ${GLEW_INCLUDE_DIRS}) target_link_libraries( - OpenGL INTERFACE ${OPENGL_LIBRARIES}) + GLEW::GLEW INTERFACE ${GLEW_LIBRARIES}) endif() if(CGAL_FOUND) From b0f16b3756f1d76eefe20cfdb1496d5134947cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 24 Jul 2023 09:55:29 +0200 Subject: [PATCH 11/38] d --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9abdd35e7..71d9d3538e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,6 +174,8 @@ if(OPENGL_ENABLED AND NOT GUI_ENABLED) endif() if(NOT TARGET GLEW::GLEW) + # vcpkg's glew CMake config defines an imported interface target. + # Only define it here, if it doesn't already exist. add_library(GLEW::GLEW INTERFACE IMPORTED) target_include_directories( GLEW::GLEW INTERFACE ${GLEW_INCLUDE_DIRS}) From 6b6729b63a2d2676fb5dbdabb093a91336ba7565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 24 Jul 2023 14:10:51 +0200 Subject: [PATCH 12/38] d --- CMakeLists.txt | 315 +++++------------- cmake/CMakeConfig.cmake.in | 245 -------------- cmake/CMakeHelper.cmake | 1 - cmake/FindCOLMAPDependencies.cmake | 196 +++++++++++ ...make.in => colmap-config-version.cmake.in} | 0 cmake/colmap-config.cmake.in | 84 +++++ doc/install.rst | 27 +- .../controllers/automatic_reconstruction.cc | 4 +- .../controllers/automatic_reconstruction.h | 2 +- src/colmap/controllers/option_manager.cc | 2 +- src/colmap/estimators/bundle_adjustment.cc | 2 +- src/colmap/exe/CMakeLists.txt | 18 +- src/colmap/exe/{colmap.cc => colmap_exe.cc} | 2 +- src/colmap/exe/colmap_lib.cc | 32 ++ src/colmap/exe/feature.cc | 2 +- src/colmap/exe/gui.cc | 2 +- src/colmap/exe/gui.h | 4 +- src/colmap/exe/mvs.cc | 4 +- src/colmap/feature/CMakeLists.txt | 4 +- src/colmap/feature/extraction.cc | 6 +- src/colmap/feature/matching.cc | 10 +- src/colmap/feature/sift.cc | 8 +- src/colmap/feature/sift_test.cc | 4 +- src/colmap/image/CMakeLists.txt | 4 +- src/colmap/mvs/CMakeLists.txt | 2 +- src/colmap/mvs/meshing.cc | 8 +- src/colmap/mvs/meshing.h | 2 +- src/colmap/ui/dense_reconstruction_widget.cc | 4 +- src/colmap/util/CMakeLists.txt | 2 +- src/colmap/util/opengl_utils.cc | 2 +- src/colmap/util/opengl_utils.h | 4 +- src/colmap/util/version.cc.in | 2 +- src/lib/LSD/CMakeLists.txt | 2 +- src/lib/PoissonRecon/CMakeLists.txt | 4 +- src/lib/SiftGPU/CMakeLists.txt | 6 +- src/lib/VLFeat/CMakeLists.txt | 7 +- 36 files changed, 463 insertions(+), 560 deletions(-) delete mode 100644 cmake/CMakeConfig.cmake.in create mode 100644 cmake/FindCOLMAPDependencies.cmake rename cmake/{CMakeConfigVersion.cmake.in => colmap-config-version.cmake.in} (100%) create mode 100644 cmake/colmap-config.cmake.in rename src/colmap/exe/{colmap.cc => colmap_exe.cc} (99%) create mode 100644 src/colmap/exe/colmap_lib.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 71d9d3538e..56b44b04bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,9 @@ include(CheckCXXCompilerFlag) # the CMake policies in this file include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeHelper.cmake NO_POLICY_SCOPE) +# Build position-independent code, so that shared libraries can link against +# COLMAP's static libraries. +set(CMAKE_POSITION_INDEPENDENT_CODE ON) ################################################################################ # Options @@ -67,147 +70,18 @@ option(ASAN_ENABLED "Whether to enable AddressSanitizer flags" OFF) option(PROFILING_ENABLED "Whether to enable google-perftools linker flags" OFF) option(CCACHE_ENABLED "Whether to enable compiler caching, if available" ON) option(CGAL_ENABLED "Whether to enable the CGAL library" ON) +option(LIBRARY_ENABLED "Whether to build and install COLMAP as a shared/static library" OFF) if(TESTS_ENABLED) enable_testing() endif() -# Build position-independent code, so that shared libraries can link against -# COLMAP's static libraries. -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - ################################################################################ -# Find packages +# Dependency configuration ################################################################################ -find_package(Ceres REQUIRED) - -find_package(Boost REQUIRED COMPONENTS - program_options - filesystem - graph - system) - -find_package(Eigen3 REQUIRED) - -find_package(FreeImage REQUIRED) - -find_package(FLANN REQUIRED) -find_package(LZ4 REQUIRED) - -find_package(Metis REQUIRED) - -find_package(Glog REQUIRED) - -find_package(SQLite3 REQUIRED) - -set(OpenGL_GL_PREFERENCE GLVND) -find_package(OpenGL REQUIRED) -find_package(Glew REQUIRED) -find_package(Git) - -if(TESTS_ENABLED) - find_package(GTest REQUIRED) -endif() - -if(OPENMP_ENABLED) - find_package(OpenMP QUIET) -endif() - -if(CGAL_ENABLED) - set(CGAL_DO_NOT_WARN_ABOUT_CMAKE_BUILD_TYPE TRUE) - # We do not use CGAL data. This prevents an unnecessary warning by CMake. - set(CGAL_DATA_DIR "unused") - find_package(CGAL QUIET) -endif() - -set(CUDA_MIN_VERSION "7.0") -if(CUDA_ENABLED) - if(CMAKE_VERSION VERSION_LESS 3.17) - find_package(CUDA QUIET) - if(CUDA_FOUND) - message(STATUS "Found CUDA version ${CUDA_VERSION} installed in " - "${CUDA_TOOLKIT_ROOT_DIR} via legacy CMake (<3.17) module. " - "Using the legacy CMake module means that any installation of " - "COLMAP will require that the CUDA libraries are " - "available under LD_LIBRARY_PATH.") - enable_language(CUDA) - - macro(declare_imported_cuda_target module) - add_library(CUDA::${module} INTERFACE IMPORTED) - target_include_directories( - CUDA::${module} INTERFACE ${CUDA_INCLUDE_DIRS}) - target_link_libraries( - CUDA::${module} INTERFACE ${CUDA_${module}_LIBRARY} ${ARGN}) - endmacro() - - declare_imported_cuda_target(cudart ${CUDA_LIBRARIES}) - declare_imported_cuda_target(curand ${CUDA_LIBRARIES}) - - set(CUDAToolkit_VERSION "${CUDA_VERSION_STRING}") - set(CUDAToolkit_BIN_DIR "${CUDA_TOOLKIT_ROOT_DIR}/bin") - endif() - else() - find_package(CUDAToolkit QUIET) - if(CUDAToolkit_FOUND) - set(CUDA_FOUND ON) - enable_language(CUDA) - endif() - endif() -endif() - -if(GUI_ENABLED) - find_package(Qt5 5.4 COMPONENTS Core OpenGL Widgets) - if(Qt5_FOUND) - message(STATUS "Found Qt") - message(STATUS " Module : ${Qt5Core_DIR}") - message(STATUS " Module : ${Qt5OpenGL_DIR}") - message(STATUS " Module : ${Qt5Widgets_DIR}") - else() - set(GUI_ENABLED OFF) - endif() -endif() - -if(OPENGL_ENABLED AND NOT GUI_ENABLED) - message(STATUS "Disabling GUI will also disable OpenGL") - set(OPENGL_ENABLED OFF) -endif() - -if(NOT TARGET GLEW::GLEW) - # vcpkg's glew CMake config defines an imported interface target. - # Only define it here, if it doesn't already exist. - add_library(GLEW::GLEW INTERFACE IMPORTED) - target_include_directories( - GLEW::GLEW INTERFACE ${GLEW_INCLUDE_DIRS}) - target_link_libraries( - GLEW::GLEW INTERFACE ${GLEW_LIBRARIES}) -endif() - -if(CGAL_FOUND) - list(APPEND CGAL_LIBRARY ${CGAL_LIBRARIES}) - message(STATUS "Found CGAL") - message(STATUS " Includes : ${CGAL_INCLUDE_DIRS}") - message(STATUS " Libraries : ${CGAL_LIBRARY}") - if(NOT TARGET CGAL) - # Older CGAL versions don't come with an imported interface target. - add_library(CGAL INTERFACE IMPORTED) - target_include_directories( - CGAL INTERFACE ${CGAL_INCLUDE_DIRS} ${GMP_INCLUDE_DIR}) - target_link_libraries( - CGAL INTERFACE ${CGAL_LIBRARY} ${GMP_LIBRARIES}) - endif() - list(APPEND COLMAP_LINK_DIRS ${CGAL_LIBRARIES_DIR}) -endif() - -if(NOT TARGET Ceres::ceres) - # Older Ceres versions don't come with an imported interface target. - add_library(Ceres::ceres INTERFACE IMPORTED) - target_include_directories( - Ceres::ceres INTERFACE ${CERES_INCLUDE_DIRS}) - target_link_libraries( - Ceres::ceres INTERFACE ${CERES_LIBRARIES}) -endif() - +set(COLMAP_FIND_QUIETLY FALSE) +include(cmake/FindCOLMAPDependencies.cmake) ################################################################################ # Compiler specific configuration @@ -258,15 +132,6 @@ else() message(STATUS "Disabling SIMD support") endif() -if(OPENMP_ENABLED AND 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}") -else() - message(STATUS "Disabling OpenMP support") -endif() - if(IPO_ENABLED AND NOT IS_DEBUG AND NOT IS_GNU) message(STATUS "Enabling interprocedural optimization") set_property(DIRECTORY PROPERTY INTERPROCEDURAL_OPTIMIZATION 1) @@ -284,45 +149,6 @@ if(ASAN_ENABLED) endif() endif() -if(CUDA_ENABLED AND CUDA_FOUND) - if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) - message( - FATAL_ERROR "You must set CMAKE_CUDA_ARCHITECTURES to e.g. 'native', 'all-major', '70', etc. " - "More information at https://cmake.org/cmake/help/latest/prop_tgt/CUDA_ARCHITECTURES.html") - endif() - - add_definitions("-DCUDA_ENABLED") - - # Fix for some combinations of CUDA and GCC (e.g. under Ubuntu 16.04). - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D_FORCE_INLINES") - # Do not show warnings if the architectures are deprecated. - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets") - # Explicitly set PIC flags for CUDA targets. - if(NOT IS_MSVC) - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --compiler-options -fPIC") - endif() - - message(STATUS "Enabling CUDA support (version: ${CUDAToolkit_VERSION}, " - "archs: ${CMAKE_CUDA_ARCHITECTURES})") -else() - set(CUDA_ENABLED OFF) - message(STATUS "Disabling CUDA support") -endif() - -if(GUI_ENABLED AND Qt5_FOUND) - add_definitions("-DGUI_ENABLED") - message(STATUS "Enabling GUI support") -else() - message(STATUS "Disabling GUI support") -endif() - -if(OPENGL_ENABLED) - add_definitions("-DOPENGL_ENABLED") - message(STATUS "Enabling OpenGL support") -else() - message(STATUS "Disabling OpenGL support") -endif() - if(CCACHE_ENABLED) find_program(CCACHE ccache) if(CCACHE) @@ -344,34 +170,6 @@ else() message(STATUS "Disabling profiling support") endif() -if(CGAL_FOUND AND CGAL_ENABLED) - message(STATUS "Enabling CGAL support") - add_definitions("-DCGAL_ENABLED") -else() - message(STATUS "Disabling CGAL support") - set(CGAL_ENABLED OFF) -endif() - -if(Qt5_FOUND) - # Qt5 was built with -reduce-relocations. - if(Qt5_POSITION_INDEPENDENT_CODE) - set(CMAKE_POSITION_INDEPENDENT_CODE ON) - # Workaround for Qt5 CMake config bug under Ubuntu 20.04: https://gitlab.kitware.com/cmake/cmake/-/issues/16915 - if(TARGET Qt5::Core) - get_property(core_options TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_OPTIONS) - string(REPLACE "-fPIC" "" new_qt5_core_options "${core_options}") - set_property(TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_OPTIONS ${new_qt5_core_options}) - set_property(TARGET Qt5::Core PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE "ON") - if(NOT IS_MSVC) - set(CMAKE_CXX_COMPILE_OPTIONS_PIE "-fPIC") - endif() - endif() - endif() - - # Enable automatic compilation of Qt resource files. - set(CMAKE_AUTORCC ON) -endif() - ################################################################################ # Add sources ################################################################################ @@ -379,11 +177,26 @@ endif() # Generate source file with version definitions. include(GenerateVersionDefinitions) -list(APPEND COLMAP_LINK_DIRS ${Boost_LIBRARY_DIRS}) - include_directories(src) link_directories(${COLMAP_LINK_DIRS}) +set(COLMAP_LIBS + colmap_util + colmap_math + colmap_camera + colmap_image + colmap_feature + colmap_geometry + colmap_scene + colmap_estimators + colmap_optim + colmap_mvs + colmap_retrieval + colmap_sfm + colmap_controllers + colmap_ui +) + add_subdirectory(src/lib) add_subdirectory(src/colmap) @@ -452,29 +265,6 @@ set_target_properties( # Install and uninstall scripts ################################################################################ -# Install header files. -install(DIRECTORY src/colmap - DESTINATION include - FILES_MATCHING PATTERN "*.h") -install(DIRECTORY src/lib - DESTINATION include/colmap - FILES_MATCHING REGEX ".*[.]h|.*[.]hpp|.*[.]inl") - -# Generate and install CMake configuration. -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeConfig.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/COLMAPConfig.cmake" @ONLY) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/COLMAPConfig.cmake" - DESTINATION "share/colmap") -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeConfigVersion.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/COLMAPConfigVersion.cmake" @ONLY) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/COLMAPConfigVersion.cmake" - DESTINATION "share/colmap") - -# Install find_package scripts for dependencies. -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake - DESTINATION share/colmap - FILES_MATCHING PATTERN "Find*.cmake") - # Install batch scripts under Windows. if(IS_MSVC) install(FILES "scripts/shell/COLMAP.bat" "scripts/shell/RUN_TESTS.bat" @@ -494,3 +284,60 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeUninstall.cmake.in" IMMEDIATE @ONLY) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/CMakeUninstall.cmake) set_target_properties(uninstall PROPERTIES FOLDER ${CMAKE_TARGETS_ROOT_FOLDER}) + + +if(LIBRARY_ENABLED) + add_library(colmap INTERFACE) + target_link_libraries(colmap INTERFACE ${COLMAP_LIBS}) + set(INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include") + target_include_directories( + colmap INTERFACE $) + + install( + TARGETS + colmap + ${COLMAP_LIBS} + colmap_lsd + colmap_poisson_recon + colmap_vlfeat + colmap_sift_gpu + EXPORT colmap-targets + LIBRARY DESTINATION lib/) + + # Generate config and version. + include(CMakePackageConfigHelpers) + set(PACKAGE_CONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/colmap-config.cmake") + set(INSTALL_CONFIG_DIR "share/colmap") + configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/colmap-config.cmake.in ${PACKAGE_CONFIG_FILE} + INSTALL_DESTINATION ${INSTALL_CONFIG_DIR}) + install(FILES ${PACKAGE_CONFIG_FILE} DESTINATION ${INSTALL_CONFIG_DIR}) + + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/colmap-config-version.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/colmap-config-version.cmake" @ONLY) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/colmap-config-version.cmake" + DESTINATION "share/colmap") + + # Install targets. + install( + EXPORT colmap-targets + FILE colmap-targets.cmake + NAMESPACE colmap:: + DESTINATION ${INSTALL_CONFIG_DIR}) + + # Install header files. + install( + DIRECTORY src/colmap + DESTINATION include + FILES_MATCHING PATTERN "*.h") + install( + DIRECTORY src/lib + DESTINATION include/colmap + FILES_MATCHING REGEX ".*[.]h|.*[.]hpp|.*[.]inl") + + # Install find_package scripts for dependencies. + install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake + DESTINATION share/colmap + FILES_MATCHING PATTERN "Find*.cmake") +endif() diff --git a/cmake/CMakeConfig.cmake.in b/cmake/CMakeConfig.cmake.in deleted file mode 100644 index 9ed2ed7bbf..0000000000 --- a/cmake/CMakeConfig.cmake.in +++ /dev/null @@ -1,245 +0,0 @@ -# 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. -# -# Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) - -# Find package module for COLMAP library. -# -# The following variables are set by this module: -# -# COLMAP_FOUND: TRUE if COLMAP is found. -# COLMAP_VERSION: COLMAP version. -# COLMAP_INCLUDE_DIRS: Include directories for COLMAP. -# COLMAP_LINK_DIRS: Link directories for COLMAP. -# COLMAP_LIBRARIES: Libraries required to link COLMAP. -# COLMAP_CUDA_ENABLED: Whether COLMAP was compiled with CUDA support. -# COLMAP_GUI_ENABLED: Whether COLMAP was compiled with the graphical UI. -# COLMAP_CGAL_ENABLED: Whether COLMAP was compiled with CGAL dependencies. - -get_filename_component(COLMAP_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_FILE} PATH) -set(COLMAP_INSTALL_PREFIX "${COLMAP_INSTALL_PREFIX}/../..") - -set(COLMAP_FOUND FALSE) - -# Set hints for finding dependency packages. - -set(FLANN_INCLUDE_DIR_HINTS @FLANN_INCLUDE_DIR_HINTS@) -set(FLANN_LIBRARY_DIR_HINTS @FLANN_LIBRARY_DIR_HINTS@) - -set(LZ4_INCLUDE_DIR_HINTS @LZ4_INCLUDE_DIR_HINTS@) -set(LZ4_LIBRARY_DIR_HINTS @LZ4_LIBRARY_DIR_HINTS@) - -set(FREEIMAGE_INCLUDE_DIR_HINTS @FREEIMAGE_INCLUDE_DIR_HINTS@) -set(FREEIMAGE_LIBRARY_DIR_HINTS @FREEIMAGE_LIBRARY_DIR_HINTS@) - -set(METIS_INCLUDE_DIR_HINTS @METIS_INCLUDE_DIR_HINTS@) -set(METIS_LIBRARY_DIR_HINTS @METIS_LIBRARY_DIR_HINTS@) - -set(GLEW_INCLUDE_DIR_HINTS @GLEW_INCLUDE_DIR_HINTS@) -set(GLEW_LIBRARY_DIR_HINTS @GLEW_LIBRARY_DIR_HINTS@) - -# Find dependency packages. - -set(TEMP_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) -set(CMAKE_MODULE_PATH ${COLMAP_INSTALL_PREFIX}/share/colmap/cmake) - -if(COLMAP_FIND_QUIETLY) - find_package(Ceres QUIET) - - find_package(Boost COMPONENTS - program_options - filesystem - system - graph - unit_test_framework - QUIET) - - find_package(Eigen3 QUIET) - - find_package(FLANN QUIET) - find_package(LZ4 QUIET) - - find_package(FreeImage QUIET) - - find_package(Metis QUIET) - - find_package(Glog QUIET) - - find_package(SQLite3 QUIET) - - find_package(OpenGL QUIET) - find_package(Glew QUIET) -else() - find_package(Ceres REQUIRED) - - find_package(Boost COMPONENTS - program_options - filesystem - system - graph - unit_test_framework - REQUIRED) - - find_package(Eigen3 REQUIRED) - - find_package(FLANN REQUIRED) - find_package(LZ4 REQUIRED) - - find_package(FreeImage REQUIRED) - - find_package(Metis REQUIRED) - - find_package(Glog REQUIRED) - - find_package(SQLite3 REQUIRED) - - find_package(OpenGL REQUIRED) - find_package(Glew REQUIRED) -endif() - -# Set the exported variables. - -set(COLMAP_FOUND TRUE) - -set(COLMAP_VERSION @COLMAP_VERSION@) - -set(COLMAP_OPENMP_ENABLED @OPENMP_ENABLED@) - -set(COLMAP_CUDA_ENABLED @CUDA_ENABLED@) -set(COLMAP_CUDA_MIN_VERSION @CUDA_MIN_VERSION@) - -set(COLMAP_GUI_ENABLED @GUI_ENABLED@) - -set(COLMAP_CGAL_ENABLED @CGAL_ENABLED@) - -set(COLMAP_INCLUDE_DIRS - ${COLMAP_INSTALL_PREFIX}/include/ - ${COLMAP_INSTALL_PREFIX}/include/colmap - ${COLMAP_INSTALL_PREFIX}/include/colmap/lib - ${FLANN_INCLUDE_DIRS} - ${LZ4_INCLUDE_DIRS} - ${FREEIMAGE_INCLUDE_DIRS} - ${METIS_INCLUDE_DIRS} - ${CERES_INCLUDE_DIRS} - ${GLEW_INCLUDE_DIRS} -) - -set(COLMAP_LINK_DIRS - ${COLMAP_INSTALL_PREFIX}/lib/colmap - ${Boost_LIBRARY_DIRS} -) - -set(COLMAP_INTERNAL_LIBRARIES - lsd - poisson_recon - sqlite3 - sift_gpu - vlfeat -) - -set(COLMAP_EXTERNAL_LIBRARIES - ${CMAKE_DL_LIBS} - ${FLANN_LIBRARIES} - ${LZ4_LIBRARIES} - ${FREEIMAGE_LIBRARIES} - ${METIS_LIBRARIES} - ${CERES_LIBRARIES} - ${OPENGL_LIBRARIES} - ${GLEW_LIBRARIES} - Boost::program_options - Boost::filesystem - Boost::graph - Boost::system - Eigen3::Eigen - glog::glog - SQLite::SQLite3 -) - -if(UNIX) - list(APPEND COLMAP_EXTERNAL_LIBRARIES - ${Boost_FILESYSTEM_LIBRARY} - ${Boost_PROGRAM_OPTIONS_LIBRARY} - ${Boost_SYSTEM_LIBRARY} - ${Boost_GRAPH_LIBRARY} - pthread) -endif() - -if(COLMAP_OPENMP_ENABLED) - find_package(OpenMP QUIET) - add_definitions("-DOPENMP_ENABLED") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - list(APPEND COLMAP_EXTERNAL_LIBRARIES ${OpenMP_libomp_LIBRARY}) -endif() - -if(COLMAP_CUDA_ENABLED) - find_package(CUDA ${COLMAP_CUDA_MIN_VERSION} QUIET) - list(APPEND COLMAP_EXTERNAL_LIBRARIES ${CUDA_LIBRARIES}) - list(APPEND COLMAP_INTERNAL_LIBRARIES colmap_cuda) -endif() - -if(COLMAP_GUI_ENABLED) - find_package(Qt5 5.4 REQUIRED COMPONENTS Core OpenGL Widgets) - list(APPEND COLMAP_EXTERNAL_LIBRARIES - ${Qt5Core_LIBRARIES} - ${Qt5OpenGL_LIBRARIES} - ${Qt5Widgets_LIBRARIES}) - list(APPEND COLMAP_INCLUDE_DIRS - ${Qt5Core_INCLUDE_DIRS} - ${Qt5OpenGL_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS}) -endif() - -if(COLMAP_CGAL_ENABLED) - find_package(CGAL REQUIRED) - list(APPEND COLMAP_EXTERNAL_LIBRARIES ${CGAL_LIBRARY} ${GMP_LIBRARIES}) -endif() - -set(COLMAP_LIBRARIES - colmap - ${COLMAP_INTERNAL_LIBRARIES} - ${COLMAP_EXTERNAL_LIBRARIES} -) - -# Cleanup of configuration variables. - -set(CMAKE_MODULE_PATH ${TEMP_CMAKE_MODULE_PATH}) - -unset(COLMAP_INSTALL_PREFIX) -unset(FLANN_INCLUDE_DIR_HINTS) -unset(FLANN_LIBRARY_DIR_HINTS) -unset(LZ4_INCLUDE_DIR_HINTS) -unset(LZ4_LIBRARY_DIR_HINTS) -unset(FREEIMAGE_INCLUDE_DIR_HINTS) -unset(FREEIMAGE_LIBRARY_DIR_HINTS) -unset(METIS_INCLUDE_DIR_HINTS) -unset(METIS_LIBRARY_DIR_HINTS) -unset(GLEW_INCLUDE_DIR_HINTS) -unset(GLEW_LIBRARY_DIR_HINTS) -unset(QT5_CMAKE_CONFIG_DIR_HINTS) diff --git a/cmake/CMakeHelper.cmake b/cmake/CMakeHelper.cmake index f7c28a8222..475c7fab48 100644 --- a/cmake/CMakeHelper.cmake +++ b/cmake/CMakeHelper.cmake @@ -90,7 +90,6 @@ macro(COLMAP_ADD_LIBRARY) target_link_libraries(${COLMAP_ADD_LIBRARY_NAME} PRIVATE ${COLMAP_ADD_LIBRARY_PRIVATE_LINK_LIBS} PUBLIC ${COLMAP_ADD_LIBRARY_PUBLIC_LINK_LIBS}) - install(TARGETS ${COLMAP_ADD_LIBRARY_NAME} DESTINATION lib/colmap) endmacro(COLMAP_ADD_LIBRARY) # Replacement for the normal add_executable() command. The syntax remains the diff --git a/cmake/FindCOLMAPDependencies.cmake b/cmake/FindCOLMAPDependencies.cmake new file mode 100644 index 0000000000..d91c956e48 --- /dev/null +++ b/cmake/FindCOLMAPDependencies.cmake @@ -0,0 +1,196 @@ +if(COLMAP_FIND_QUIETLY) + set(COLMAP_FIND_TYPE QUIET) +else() + set(COLMAP_FIND_TYPE REQUIRED) +endif() + +find_package(Boost ${COLMAP_FIND_TYPE} COMPONENTS + program_options + filesystem + graph + system) + +find_package(Eigen3 ${COLMAP_FIND_TYPE}) + +find_package(FreeImage ${COLMAP_FIND_TYPE}) + +find_package(FLANN ${COLMAP_FIND_TYPE}) +find_package(LZ4 ${COLMAP_FIND_TYPE}) + +find_package(Metis ${COLMAP_FIND_TYPE}) + +find_package(Glog ${COLMAP_FIND_TYPE}) + +find_package(SQLite3 ${COLMAP_FIND_TYPE}) + +set(OpenGL_GL_PREFERENCE GLVND) +find_package(OpenGL ${COLMAP_FIND_TYPE}) + +find_package(Glew ${COLMAP_FIND_TYPE}) +if(NOT TARGET GLEW::GLEW) + # vcpkg's glew CMake config defines an imported interface target. + # Only define it here, if it doesn't already exist. + add_library(GLEW::GLEW INTERFACE IMPORTED) + target_include_directories( + GLEW::GLEW INTERFACE ${GLEW_INCLUDE_DIRS}) + target_link_libraries( + GLEW::GLEW INTERFACE ${GLEW_LIBRARIES}) +endif() + +find_package(Git) + +find_package(Ceres ${COLMAP_FIND_TYPE}) +if(NOT TARGET Ceres::ceres) + # Older Ceres versions don't come with an imported interface target. + add_library(Ceres::ceres INTERFACE IMPORTED) + target_include_directories( + Ceres::ceres INTERFACE ${CERES_INCLUDE_DIRS}) + target_link_libraries( + Ceres::ceres INTERFACE ${CERES_LIBRARIES}) +endif() + +if(TESTS_ENABLED) + find_package(GTest ${COLMAP_FIND_TYPE}) +endif() + +if(OPENMP_ENABLED) + find_package(OpenMP ${COLMAP_FIND_TYPE}) +endif() + +if(OPENMP_ENABLED AND OPENMP_FOUND) + message(STATUS "Enabling OpenMP support") + add_definitions("-DCOLMAP_OPENMP_ENABLED") +else() + message(STATUS "Disabling OpenMP support") +endif() + +if(CGAL_ENABLED) + set(CGAL_DO_NOT_WARN_ABOUT_CMAKE_BUILD_TYPE TRUE) + # We do not use CGAL data. This prevents an unnecessary warning by CMake. + set(CGAL_DATA_DIR "unused") + find_package(CGAL ${COLMAP_FIND_TYPE}) +endif() + +if(CGAL_FOUND) + list(APPEND CGAL_LIBRARY ${CGAL_LIBRARIES}) + message(STATUS "Found CGAL") + message(STATUS " Includes : ${CGAL_INCLUDE_DIRS}") + message(STATUS " Libraries : ${CGAL_LIBRARY}") + if(NOT TARGET CGAL) + # Older CGAL versions don't come with an imported interface target. + add_library(CGAL INTERFACE IMPORTED) + target_include_directories( + CGAL INTERFACE ${CGAL_INCLUDE_DIRS} ${GMP_INCLUDE_DIR}) + target_link_libraries( + CGAL INTERFACE ${CGAL_LIBRARY} ${GMP_LIBRARIES}) + endif() + list(APPEND COLMAP_LINK_DIRS ${CGAL_LIBRARIES_DIR}) +endif() + +set(COLMAP_LINK_DIRS ${Boost_LIBRARY_DIRS}) + +set(CUDA_MIN_VERSION "7.0") +if(CUDA_ENABLED) + if(CMAKE_VERSION VERSION_LESS 3.17) + find_package(CUDA QUIET) + if(CUDA_FOUND) + message(STATUS "Found CUDA version ${CUDA_VERSION} installed in " + "${CUDA_TOOLKIT_ROOT_DIR} via legacy CMake (<3.17) module. " + "Using the legacy CMake module means that any installation of " + "COLMAP will require that the CUDA libraries are " + "available under LD_LIBRARY_PATH.") + enable_language(CUDA) + + macro(declare_imported_cuda_target module) + add_library(CUDA::${module} INTERFACE IMPORTED) + target_include_directories( + CUDA::${module} INTERFACE ${CUDA_INCLUDE_DIRS}) + target_link_libraries( + CUDA::${module} INTERFACE ${CUDA_${module}_LIBRARY} ${ARGN}) + endmacro() + + declare_imported_cuda_target(cudart ${CUDA_LIBRARIES}) + declare_imported_cuda_target(curand ${CUDA_LIBRARIES}) + + set(CUDAToolkit_VERSION "${CUDA_VERSION_STRING}") + set(CUDAToolkit_BIN_DIR "${CUDA_TOOLKIT_ROOT_DIR}/bin") + endif() + else() + find_package(CUDAToolkit QUIET) + if(CUDAToolkit_FOUND) + set(CUDA_FOUND ON) + enable_language(CUDA) + endif() + endif() +endif() + +if(CUDA_ENABLED AND CUDA_FOUND) + if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) + message( + FATAL_ERROR "You must set CMAKE_CUDA_ARCHITECTURES to e.g. 'native', 'all-major', '70', etc. " + "More information at https://cmake.org/cmake/help/latest/prop_tgt/CUDA_ARCHITECTURES.html") + endif() + + add_definitions("-DCOLMAP_CUDA_ENABLED") + + # Fix for some combinations of CUDA and GCC (e.g. under Ubuntu 16.04). + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D_FORCE_INLINES") + # Do not show warnings if the architectures are deprecated. + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets") + # Explicitly set PIC flags for CUDA targets. + if(NOT IS_MSVC) + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --compiler-options -fPIC") + endif() + + message(STATUS "Enabling CUDA support (version: ${CUDAToolkit_VERSION}, " + "archs: ${CMAKE_CUDA_ARCHITECTURES})") +else() + set(CUDA_ENABLED OFF) + message(STATUS "Disabling CUDA support") +endif() + +if(GUI_ENABLED) + find_package(Qt5 5.4 ${COLMAP_FIND_TYPE} COMPONENTS Core OpenGL Widgets) + message(STATUS "Found Qt") + message(STATUS " Module : ${Qt5Core_DIR}") + message(STATUS " Module : ${Qt5OpenGL_DIR}") + message(STATUS " Module : ${Qt5Widgets_DIR}") + if(Qt5_FOUND) + # Qt5 was built with -reduce-relocations. + if(Qt5_POSITION_INDEPENDENT_CODE) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + # Workaround for Qt5 CMake config bug under Ubuntu 20.04: https://gitlab.kitware.com/cmake/cmake/-/issues/16915 + if(TARGET Qt5::Core) + get_property(core_options TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_OPTIONS) + string(REPLACE "-fPIC" "" new_qt5_core_options "${core_options}") + set_property(TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_OPTIONS ${new_qt5_core_options}) + set_property(TARGET Qt5::Core PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE "ON") + if(NOT IS_MSVC) + set(CMAKE_CXX_COMPILE_OPTIONS_PIE "-fPIC") + endif() + endif() + endif() + + # Enable automatic compilation of Qt resource files. + set(CMAKE_AUTORCC ON) + endif() +endif() + +if(GUI_ENABLED AND Qt5_FOUND) + add_definitions("-DCOLMAP_GUI_ENABLED") + message(STATUS "Enabling GUI support") +else() + message(STATUS "Disabling GUI support") +endif() + +if(OPENGL_ENABLED) + if(NOT GUI_ENABLED) + message(STATUS "Disabling GUI also disables OpenGL") + set(OPENGL_ENABLED OFF) + else() + add_definitions("-DCOLMAP_OPENGL_ENABLED") + message(STATUS "Enabling OpenGL support") + endif() +else() + message(STATUS "Disabling OpenGL support") +endif() diff --git a/cmake/CMakeConfigVersion.cmake.in b/cmake/colmap-config-version.cmake.in similarity index 100% rename from cmake/CMakeConfigVersion.cmake.in rename to cmake/colmap-config-version.cmake.in diff --git a/cmake/colmap-config.cmake.in b/cmake/colmap-config.cmake.in new file mode 100644 index 0000000000..c05d1f5f94 --- /dev/null +++ b/cmake/colmap-config.cmake.in @@ -0,0 +1,84 @@ +# 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. +# +# Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) + +# Find package config for COLMAP library. +# +# The following variables are set by this config: +# +# COLMAP_FOUND: TRUE if COLMAP is found. +# COLMAP_VERSION: COLMAP version. +# +# The colmap::colmap imported interface target is defined. + +@PACKAGE_INIT@ + +set(COLMAP_FOUND FALSE) + +# Set hints for finding dependency packages. + +set(FLANN_INCLUDE_DIR_HINTS @FLANN_INCLUDE_DIR_HINTS@) +set(FLANN_LIBRARY_DIR_HINTS @FLANN_LIBRARY_DIR_HINTS@) + +set(LZ4_INCLUDE_DIR_HINTS @LZ4_INCLUDE_DIR_HINTS@) +set(LZ4_LIBRARY_DIR_HINTS @LZ4_LIBRARY_DIR_HINTS@) + +set(FREEIMAGE_INCLUDE_DIR_HINTS @FREEIMAGE_INCLUDE_DIR_HINTS@) +set(FREEIMAGE_LIBRARY_DIR_HINTS @FREEIMAGE_LIBRARY_DIR_HINTS@) + +set(METIS_INCLUDE_DIR_HINTS @METIS_INCLUDE_DIR_HINTS@) +set(METIS_LIBRARY_DIR_HINTS @METIS_LIBRARY_DIR_HINTS@) + +set(GLEW_INCLUDE_DIR_HINTS @GLEW_INCLUDE_DIR_HINTS@) +set(GLEW_LIBRARY_DIR_HINTS @GLEW_LIBRARY_DIR_HINTS@) + +# Find dependency packages. + +set(TEMP_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) +set(CMAKE_MODULE_PATH ${PACKAGE_PREFIX_DIR}/share/colmap/cmake) + +# Set the exported variables. + +set(COLMAP_FOUND TRUE) + +set(COLMAP_VERSION @COLMAP_VERSION@) + +set(OPENMP_ENABLED @OPENMP_ENABLED@) + +set(CUDA_ENABLED @CUDA_ENABLED@) +set(CUDA_MIN_VERSION @CUDA_MIN_VERSION@) + +set(GUI_ENABLED @GUI_ENABLED@) + +set(CGAL_ENABLED @CGAL_ENABLED@) + +include(${PACKAGE_PREFIX_DIR}/share/colmap/cmake/FindCOLMAPDependencies.cmake) +include(${PACKAGE_PREFIX_DIR}/share/colmap/colmap-targets.cmake) +check_required_components(colmap) diff --git a/doc/install.rst b/doc/install.rst index 8d9ec45fd6..a44d6e046e 100755 --- a/doc/install.rst +++ b/doc/install.rst @@ -281,36 +281,33 @@ To see the full list of command-line options, pass the ``--help`` argument. Library ------- -If you want to include and link COLMAP against your own library, the easiest -way is to use CMake as a build configuration tool. COLMAP automatically installs -all headers to ``${CMAKE_INSTALL_PREFIX}/include/colmap``, all libraries to +If you want to include and link COLMAP against your own library, the easiest way +is to use CMake as a build configuration tool. By setting `-DLIBRARY_ENABLED` +when configuring the COLMAP build and then running `ninja/make install`, COLMAP +automatically installs all headers to +``${CMAKE_INSTALL_PREFIX}/include/colmap``, all libraries to ``${CMAKE_INSTALL_PREFIX}/lib/colmap``, and the CMake configuration to ``${CMAKE_INSTALL_PREFIX}/share/colmap``. For example, compiling your own source code against COLMAP is as simple as using the following ``CMakeLists.txt``:: - cmake_minimum_required(VERSION 2.8.11) + cmake_minimum_required(VERSION 3.10) project(TestProject) - find_package(COLMAP REQUIRED) - # or to require a specific version: find_package(COLMAP 3.4 REQUIRED) - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - - include_directories(${COLMAP_INCLUDE_DIRS}) - link_directories(${COLMAP_LINK_DIRS}) + find_package(colmap REQUIRED) + # or to require a specific version: find_package(colmap 3.4 REQUIRED) add_executable(hello_world hello_world.cc) - target_link_libraries(hello_world ${COLMAP_LIBRARIES}) + target_link_libraries(hello_world colmap::colmap) with the source code ``hello_world.cc``:: #include #include - #include + #include #include int main(int argc, char** argv) { @@ -333,8 +330,8 @@ Then compile and run your code as:: mkdir build cd build - COLMAP_DIR=${CMAKE_INSTALL_PREFIX}/share/colmap cmake .. - make + cmake .. -GNinja -Dcolmap_DIR=${CMAKE_INSTALL_PREFIX}/share/colmap + ninja ./hello_world ---------------- diff --git a/src/colmap/controllers/automatic_reconstruction.cc b/src/colmap/controllers/automatic_reconstruction.cc index cd648e7036..b66de674ea 100644 --- a/src/colmap/controllers/automatic_reconstruction.cc +++ b/src/colmap/controllers/automatic_reconstruction.cc @@ -284,7 +284,7 @@ void AutomaticReconstructionController::RunDenseMapper() { // Patch match stereo. -#ifdef CUDA_ENABLED +#if defined(COLMAP_CUDA_ENABLED) { mvs::PatchMatchController patch_match_controller( *option_manager_.patch_match_stereo, dense_path, "COLMAP", ""); @@ -341,7 +341,7 @@ void AutomaticReconstructionController::RunDenseMapper() { mvs::PoissonMeshing( *option_manager_.poisson_meshing, fused_path, meshing_path); } else if (options_.mesher == Mesher::DELAUNAY) { -#ifdef CGAL_ENABLED +#if defined(COLMAP_CGAL_ENABLED) mvs::DenseDelaunayMeshing( *option_manager_.delaunay_meshing, dense_path, meshing_path); #else // CGAL_ENABLED diff --git a/src/colmap/controllers/automatic_reconstruction.h b/src/colmap/controllers/automatic_reconstruction.h index deac350f70..0c359b172a 100644 --- a/src/colmap/controllers/automatic_reconstruction.h +++ b/src/colmap/controllers/automatic_reconstruction.h @@ -82,7 +82,7 @@ class AutomaticReconstructionController : public Thread { bool sparse = true; // Whether to perform dense mapping. -#ifdef CUDA_ENABLED +#if defined(COLMAP_CUDA_ENABLED) bool dense = true; #else bool dense = false; diff --git a/src/colmap/controllers/option_manager.cc b/src/colmap/controllers/option_manager.cc index b5fda26268..2b5b3bf629 100644 --- a/src/colmap/controllers/option_manager.cc +++ b/src/colmap/controllers/option_manager.cc @@ -832,7 +832,7 @@ bool OptionManager::Check() { if (poisson_meshing) success = success && poisson_meshing->Check(); if (delaunay_meshing) success = success && delaunay_meshing->Check(); -#ifdef GUI_ENABLED +#if defined(COLMAP_GUI_ENABLED) if (render) success = success && render->Check(); #endif diff --git a/src/colmap/estimators/bundle_adjustment.cc b/src/colmap/estimators/bundle_adjustment.cc index 6a26b93e46..a1ae34d575 100644 --- a/src/colmap/estimators/bundle_adjustment.cc +++ b/src/colmap/estimators/bundle_adjustment.cc @@ -33,7 +33,7 @@ #include -#ifdef OPENMP_ENABLED +#if defined(COLMAP_OPENMP_ENABLED) #include #endif diff --git a/src/colmap/exe/CMakeLists.txt b/src/colmap/exe/CMakeLists.txt index 28b7352637..e029cf5f0c 100644 --- a/src/colmap/exe/CMakeLists.txt +++ b/src/colmap/exe/CMakeLists.txt @@ -49,7 +49,7 @@ COLMAP_ADD_LIBRARY( COLMAP_ADD_EXECUTABLE( NAME colmap_exe SRCS - colmap.cc + colmap_exe.cc database.cc feature.cc gui.cc @@ -59,20 +59,6 @@ COLMAP_ADD_EXECUTABLE( sfm.cc vocab_tree.cc LINK_LIBS - colmap_util - colmap_math - colmap_camera - colmap_image - colmap_feature - colmap_geometry - colmap_scene - colmap_estimators - colmap_optim - colmap_mvs - colmap_retrieval - colmap_sfm - colmap_controllers - colmap_ui + ${COLMAP_LIBS} colmap_exe_helpers) set_target_properties(colmap_exe PROPERTIES OUTPUT_NAME colmap) - diff --git a/src/colmap/exe/colmap.cc b/src/colmap/exe/colmap_exe.cc similarity index 99% rename from src/colmap/exe/colmap.cc rename to src/colmap/exe/colmap_exe.cc index 3b21d8c412..f237e3bf7b 100644 --- a/src/colmap/exe/colmap.cc +++ b/src/colmap/exe/colmap_exe.cc @@ -91,7 +91,7 @@ int ShowHelp( int main(int argc, char** argv) { colmap::InitializeGlog(argv); -#ifdef GUI_ENABLED +#if defined(COLMAP_GUI_ENABLED) Q_INIT_RESOURCE(resources); #endif diff --git a/src/colmap/exe/colmap_lib.cc b/src/colmap/exe/colmap_lib.cc new file mode 100644 index 0000000000..6a6113e2c9 --- /dev/null +++ b/src/colmap/exe/colmap_lib.cc @@ -0,0 +1,32 @@ +// 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. +// +// Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) + +// Empty source file to create single library for all colmap modules. diff --git a/src/colmap/exe/feature.cc b/src/colmap/exe/feature.cc index 586924cb21..361a29bb09 100644 --- a/src/colmap/exe/feature.cc +++ b/src/colmap/exe/feature.cc @@ -62,7 +62,7 @@ bool VerifyCameraParams(const std::string& camera_model, } bool VerifySiftGPUParams(const bool use_gpu) { -#if !defined(CUDA_ENABLED) && !defined(OPENGL_ENABLED) +#if !defined(COLMAP_CUDA_ENABLED) && !defined(COLMAP_OPENGL_ENABLED) if (use_gpu) { std::cerr << "ERROR: Cannot use Sift GPU without CUDA or OpenGL support; " "set SiftExtraction.use_gpu or SiftMatching.use_gpu to false." diff --git a/src/colmap/exe/gui.cc b/src/colmap/exe/gui.cc index ebe1ace412..212f40fedc 100644 --- a/src/colmap/exe/gui.cc +++ b/src/colmap/exe/gui.cc @@ -37,7 +37,7 @@ namespace colmap { int RunGraphicalUserInterface(int argc, char** argv) { -#ifndef GUI_ENABLED +#if !defined(COLMAP_GUI_ENABLED) std::cerr << "ERROR: Cannot start colmap GUI; colmap was built without GUI " "support or QT dependency is missing." << std::endl; diff --git a/src/colmap/exe/gui.h b/src/colmap/exe/gui.h index bcc4965012..ea2cce0829 100644 --- a/src/colmap/exe/gui.h +++ b/src/colmap/exe/gui.h @@ -31,7 +31,7 @@ #include -#ifdef GUI_ENABLED +#if defined(COLMAP_GUI_ENABLED) #include "colmap/ui/main_window.h" #include @@ -45,7 +45,7 @@ class QApplication { namespace colmap { -#if defined(CUDA_ENABLED) || !defined(OPENGL_ENABLED) +#if defined(COLMAP_CUDA_ENABLED) || !defined(COLMAP_OPENGL_ENABLED) const bool kUseOpenGL = false; #else const bool kUseOpenGL = true; diff --git a/src/colmap/exe/mvs.cc b/src/colmap/exe/mvs.cc index fd0f694efb..d4ae8570a0 100644 --- a/src/colmap/exe/mvs.cc +++ b/src/colmap/exe/mvs.cc @@ -41,7 +41,7 @@ namespace colmap { int RunDelaunayMesher(int argc, char** argv) { -#ifndef CGAL_ENABLED +#if !defined(COLMAP_CGAL_ENABLED) std::cerr << "ERROR: Delaunay meshing requires CGAL, which is not " "available on your system." << std::endl; @@ -80,7 +80,7 @@ int RunDelaunayMesher(int argc, char** argv) { } int RunPatchMatchStereo(int argc, char** argv) { -#ifndef CUDA_ENABLED +#if !defined(COLMAP_CUDA_ENABLED) std::cerr << "ERROR: Dense stereo reconstruction requires CUDA, which is not " "available on your system." << std::endl; diff --git a/src/colmap/feature/CMakeLists.txt b/src/colmap/feature/CMakeLists.txt index ae5f93acad..a1487e501a 100644 --- a/src/colmap/feature/CMakeLists.txt +++ b/src/colmap/feature/CMakeLists.txt @@ -44,10 +44,10 @@ COLMAP_ADD_LIBRARY( PRIVATE_LINK_LIBS colmap_util colmap_image + colmap_sift_gpu + colmap_vlfeat flann lz4 - sift_gpu - vlfeat ) COLMAP_ADD_TEST( diff --git a/src/colmap/feature/extraction.cc b/src/colmap/feature/extraction.cc index bda47363d5..0c1ac0bec5 100644 --- a/src/colmap/feature/extraction.cc +++ b/src/colmap/feature/extraction.cc @@ -132,7 +132,7 @@ SiftFeatureExtractor::SiftFeatureExtractor( std::vector gpu_indices = CSVToVector(sift_options_.gpu_index); CHECK_GT(gpu_indices.size(), 0); -#ifdef CUDA_ENABLED +#if defined(COLMAP_CUDA_ENABLED) if (gpu_indices.size() == 1 && gpu_indices[0] == -1) { const int num_cuda_devices = GetNumCudaDevices(); CHECK_GT(num_cuda_devices, 0); @@ -364,7 +364,7 @@ SiftFeatureExtractorThread::SiftFeatureExtractorThread( output_queue_(output_queue) { CHECK(sift_options_.Check()); -#ifndef CUDA_ENABLED +#if !defined(COLMAP_CUDA_ENABLED) if (sift_options_.use_gpu) { opengl_context_ = std::make_unique(); } @@ -374,7 +374,7 @@ SiftFeatureExtractorThread::SiftFeatureExtractorThread( void SiftFeatureExtractorThread::Run() { std::unique_ptr sift_gpu; if (sift_options_.use_gpu) { -#ifndef CUDA_ENABLED +#if !defined(COLMAP_CUDA_ENABLED) CHECK(opengl_context_); CHECK(opengl_context_->MakeCurrent()); #endif diff --git a/src/colmap/feature/matching.cc b/src/colmap/feature/matching.cc index da6f79039d..2f368f9fc7 100644 --- a/src/colmap/feature/matching.cc +++ b/src/colmap/feature/matching.cc @@ -404,13 +404,13 @@ SiftGPUFeatureMatcher::SiftGPUFeatureMatcher(const SiftMatchingOptions& options, prev_uploaded_image_ids_[0] = kInvalidImageId; prev_uploaded_image_ids_[1] = kInvalidImageId; -#ifndef CUDA_ENABLED +#if !defined(COLMAP_CUDA_ENABLED) opengl_context_ = std::make_unique(); #endif } void SiftGPUFeatureMatcher::Run() { -#ifndef CUDA_ENABLED +#if !defined(COLMAP_CUDA_ENABLED) CHECK(opengl_context_); CHECK(opengl_context_->MakeCurrent()); #endif @@ -535,13 +535,13 @@ GuidedSiftGPUFeatureMatcher::GuidedSiftGPUFeatureMatcher( prev_uploaded_image_ids_[0] = kInvalidImageId; prev_uploaded_image_ids_[1] = kInvalidImageId; -#ifndef CUDA_ENABLED +#if !defined(COLMAP_CUDA_ENABLED) opengl_context_ = std::make_unique(); #endif } void GuidedSiftGPUFeatureMatcher::Run() { -#ifndef CUDA_ENABLED +#if !defined(COLMAP_CUDA_ENABLED) CHECK(opengl_context_); CHECK(opengl_context_->MakeCurrent()); #endif @@ -700,7 +700,7 @@ SiftFeatureMatcher::SiftFeatureMatcher(const SiftMatchingOptions& options, std::vector gpu_indices = CSVToVector(options_.gpu_index); CHECK_GT(gpu_indices.size(), 0); -#ifdef CUDA_ENABLED +#if defined(COLMAP_CUDA_ENABLED) if (options_.use_gpu && gpu_indices.size() == 1 && gpu_indices[0] == -1) { const int num_cuda_devices = GetNumCudaDevices(); CHECK_GT(num_cuda_devices, 0); diff --git a/src/colmap/feature/sift.cc b/src/colmap/feature/sift.cc index 7a1a862220..7b2133d778 100644 --- a/src/colmap/feature/sift.cc +++ b/src/colmap/feature/sift.cc @@ -31,7 +31,7 @@ #include "colmap/feature/sift.h" -#if !defined(GUI_ENABLED) && !defined(CUDA_ENABLED) +#if !defined(COLMAP_GUI_ENABLED) && !defined(COLMAP_CUDA_ENABLED) #include #endif @@ -803,7 +803,7 @@ bool CreateSiftGPUExtractor(const SiftExtractionOptions& options, sift_gpu_args.push_back("./sift_gpu"); -#ifdef CUDA_ENABLED +#if defined(COLMAP_CUDA_ENABLED) // Use CUDA version by default if darkness adaptivity is disabled. if (!options.darkness_adaptivity && gpu_indices[0] < 0) { gpu_indices[0] = 0; @@ -1162,7 +1162,7 @@ bool CreateSiftGPUMatcher(const SiftMatchingOptions& match_options, *sift_match_gpu = SiftMatchGPU(match_options.max_num_matches); -#ifdef CUDA_ENABLED +#if defined(COLMAP_CUDA_ENABLED) if (gpu_indices[0] >= 0) { sift_match_gpu->SetLanguage(SiftMatchGPU::SIFTMATCH_CUDA_DEVICE0 + gpu_indices[0]); @@ -1187,7 +1187,7 @@ bool CreateSiftGPUMatcher(const SiftMatchingOptions& match_options, return false; } -#ifndef CUDA_ENABLED +#if !defined(COLMAP_CUDA_ENABLED) if (sift_match_gpu->GetMaxSift() < match_options.max_num_matches) { std::cout << StringPrintf( "WARNING: OpenGL version of SiftGPU only supports a " diff --git a/src/colmap/feature/sift_test.cc b/src/colmap/feature/sift_test.cc index d104dfb775..fa7a041e2e 100644 --- a/src/colmap/feature/sift_test.cc +++ b/src/colmap/feature/sift_test.cc @@ -31,7 +31,7 @@ #include -#ifdef GUI_ENABLED +#if defined(COLMAP_GUI_ENABLED) #include #else #include "colmap/exe/gui.h" @@ -286,7 +286,7 @@ TEST(CreateSiftGPUMatcherOpenGL, Nominal) { } TEST(CreateSiftGPUMatcherCUDA, Nominal) { -#ifdef CUDA_ENABLED +#if defined(COLMAP_CUDA_ENABLED) SiftMatchGPU sift_match_gpu; SiftMatchingOptions create_options; create_options.gpu_index = "0"; diff --git a/src/colmap/image/CMakeLists.txt b/src/colmap/image/CMakeLists.txt index cc8733fed5..516e82cca2 100644 --- a/src/colmap/image/CMakeLists.txt +++ b/src/colmap/image/CMakeLists.txt @@ -44,8 +44,8 @@ COLMAP_ADD_LIBRARY( Eigen3::Eigen freeimage PRIVATE_LINK_LIBS - lsd - vlfeat + colmap_lsd + colmap_vlfeat ) COLMAP_ADD_TEST( diff --git a/src/colmap/mvs/CMakeLists.txt b/src/colmap/mvs/CMakeLists.txt index 6fb06f12fc..f713b924e9 100644 --- a/src/colmap/mvs/CMakeLists.txt +++ b/src/colmap/mvs/CMakeLists.txt @@ -46,7 +46,7 @@ COLMAP_ADD_LIBRARY( colmap_util colmap_scene PRIVATE_LINK_LIBS - poisson_recon + colmap_poisson_recon Eigen3::Eigen CGAL ) diff --git a/src/colmap/mvs/meshing.cc b/src/colmap/mvs/meshing.cc index 23cf944caf..69ac74708f 100644 --- a/src/colmap/mvs/meshing.cc +++ b/src/colmap/mvs/meshing.cc @@ -35,7 +35,7 @@ #include #include -#ifdef CGAL_ENABLED +#if defined(COLMAP_CGAL_ENABLED) #include #include #endif // CGAL_ENABLED @@ -53,7 +53,7 @@ #include "lib/PoissonRecon/PoissonRecon.h" #include "lib/PoissonRecon/SurfaceTrimmer.h" -#ifdef CGAL_ENABLED +#if defined(COLMAP_CGAL_ENABLED) typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Delaunay_triangulation_3 Delaunay; @@ -146,7 +146,7 @@ bool PoissonMeshing(const PoissonMeshingOptions& options, args.push_back(std::to_string(options.color)); } -#ifdef OPENMP_ENABLED +#if defined(COLMAP_OPENMP_ENABLED) if (options.num_threads > 0) { args.push_back("--threads"); args.push_back(std::to_string(options.num_threads)); @@ -195,7 +195,7 @@ bool PoissonMeshing(const PoissonMeshingOptions& options, const_cast(args_cstr.data())) == EXIT_SUCCESS; } -#ifdef CGAL_ENABLED +#if defined(COLMAP_CGAL_ENABLED) K::Point_3 EigenToCGAL(const Eigen::Vector3f& point) { return K::Point_3(point.x(), point.y(), point.z()); diff --git a/src/colmap/mvs/meshing.h b/src/colmap/mvs/meshing.h index c75065ab77..9fe32ac63a 100644 --- a/src/colmap/mvs/meshing.h +++ b/src/colmap/mvs/meshing.h @@ -106,7 +106,7 @@ bool PoissonMeshing(const PoissonMeshingOptions& options, const std::string& input_path, const std::string& output_path); -#ifdef CGAL_ENABLED +#if defined(COLMAP_CGAL_ENABLED) // Delaunay meshing of sparse and dense COLMAP reconstructions. This is an // implementation of the approach described in: diff --git a/src/colmap/ui/dense_reconstruction_widget.cc b/src/colmap/ui/dense_reconstruction_widget.cc index 7933d438b7..fa004f6c07 100644 --- a/src/colmap/ui/dense_reconstruction_widget.cc +++ b/src/colmap/ui/dense_reconstruction_widget.cc @@ -380,7 +380,7 @@ void DenseReconstructionWidget::Stereo() { return; } -#ifdef CUDA_ENABLED +#if defined(COLMAP_CUDA_ENABLED) auto processor = std::make_unique( *options_->patch_match_stereo, workspace_path, "COLMAP", ""); processor->AddCallback(Thread::FINISHED_CALLBACK, @@ -439,7 +439,7 @@ void DenseReconstructionWidget::PoissonMeshing() { } void DenseReconstructionWidget::DelaunayMeshing() { -#ifdef CGAL_ENABLED +#if defined(COLMAP_CGAL_ENABLED) const std::string workspace_path = GetWorkspacePath(); if (workspace_path.empty()) { return; diff --git a/src/colmap/util/CMakeLists.txt b/src/colmap/util/CMakeLists.txt index d6d9b05d01..237b29ca00 100644 --- a/src/colmap/util/CMakeLists.txt +++ b/src/colmap/util/CMakeLists.txt @@ -67,7 +67,7 @@ if(CUDA_ENABLED) PUBLIC_LINK_LIBS Cuda::cudart ) - target_link_libraries(colmap_util PUBLIC_LINK_LIBS colmap_util_cuda) + target_link_libraries(colmap_util PUBLIC colmap_util_cuda) endif() COLMAP_ADD_TEST( diff --git a/src/colmap/util/opengl_utils.cc b/src/colmap/util/opengl_utils.cc index 69b75a3a7d..745e9d39e0 100644 --- a/src/colmap/util/opengl_utils.cc +++ b/src/colmap/util/opengl_utils.cc @@ -35,7 +35,7 @@ namespace colmap { -#ifdef GUI_ENABLED +#if defined(COLMAP_GUI_ENABLED) OpenGLContextManager::OpenGLContextManager(int opengl_major_version, int opengl_minor_version) : parent_thread_(QThread::currentThread()), diff --git a/src/colmap/util/opengl_utils.h b/src/colmap/util/opengl_utils.h index 63c2ac1648..301b8a5fdc 100644 --- a/src/colmap/util/opengl_utils.h +++ b/src/colmap/util/opengl_utils.h @@ -31,7 +31,7 @@ #pragma once -#ifdef GUI_ENABLED +#if defined(COLMAP_GUI_ENABLED) #include #include #include @@ -50,7 +50,7 @@ namespace colmap { #define glDebugLog() #endif -#ifdef GUI_ENABLED +#if defined(COLMAP_GUI_ENABLED) // This class manages a thread-safe OpenGL context. Note that this class must be // instantiated in the main Qt thread, since an OpenGL context must be created diff --git a/src/colmap/util/version.cc.in b/src/colmap/util/version.cc.in index edd6b24332..ccc95eee0f 100644 --- a/src/colmap/util/version.cc.in +++ b/src/colmap/util/version.cc.in @@ -50,7 +50,7 @@ std::string GetVersionInfo() { } std::string GetBuildInfo() { -#ifdef CUDA_ENABLED +#if defined(COLMAP_CUDA_ENABLED) const std::string cuda_info = "with CUDA"; #else const std::string cuda_info = "without CUDA"; diff --git a/src/lib/LSD/CMakeLists.txt b/src/lib/LSD/CMakeLists.txt index ddc9bada38..d5b9f925df 100644 --- a/src/lib/LSD/CMakeLists.txt +++ b/src/lib/LSD/CMakeLists.txt @@ -1,5 +1,5 @@ COLMAP_ADD_LIBRARY( - NAME lsd + NAME colmap_lsd SRCS lsd.h lsd.c ) diff --git a/src/lib/PoissonRecon/CMakeLists.txt b/src/lib/PoissonRecon/CMakeLists.txt index 50fdc3ab35..62bde852e2 100644 --- a/src/lib/PoissonRecon/CMakeLists.txt +++ b/src/lib/PoissonRecon/CMakeLists.txt @@ -5,7 +5,7 @@ endif() add_definitions("-DRELEASE") COLMAP_ADD_LIBRARY( - NAME poisson_recon + NAME colmap_poisson_recon SRCS Allocator.h Array.h @@ -46,4 +46,6 @@ COLMAP_ADD_LIBRARY( SparseMatrix.h SparseMatrix.inl SurfaceTrimmer.h SurfaceTrimmer.cpp + PUBLIC_LINK_LIBS + OpenMP::OpenMP_CXX ) diff --git a/src/lib/SiftGPU/CMakeLists.txt b/src/lib/SiftGPU/CMakeLists.txt index 5566caf019..a415b52363 100644 --- a/src/lib/SiftGPU/CMakeLists.txt +++ b/src/lib/SiftGPU/CMakeLists.txt @@ -1,7 +1,7 @@ add_definitions("-DSIFTGPU_NO_DEVIL") COLMAP_ADD_LIBRARY( - NAME sift_gpu + NAME colmap_sift_gpu SRCS FrameBufferObject.h FrameBufferObject.cpp GlobalUtil.h GlobalUtil.cpp @@ -22,7 +22,7 @@ if(CUDA_ENABLED) add_definitions("-DCUDA_SIFTGPU_ENABLED") COLMAP_ADD_LIBRARY( - NAME sift_gpu_cuda + NAME colmap_sift_gpu_cuda SRCS CuTexImage.h CuTexImage.cpp ProgramCU.cu @@ -34,5 +34,5 @@ if(CUDA_ENABLED) CUDA::curand ) - target_link_libraries(sift_gpu PRIVATE sift_gpu_cuda) + target_link_libraries(colmap_sift_gpu PRIVATE colmap_sift_gpu_cuda) endif() diff --git a/src/lib/VLFeat/CMakeLists.txt b/src/lib/VLFeat/CMakeLists.txt index 5831123be0..d59fba85b0 100644 --- a/src/lib/VLFeat/CMakeLists.txt +++ b/src/lib/VLFeat/CMakeLists.txt @@ -107,4 +107,9 @@ if(NOT OPENMP_ENABLED OR NOT OPENMP_FOUND) add_definitions("-DVL_DISABLE_OPENMP") endif() -COLMAP_ADD_LIBRARY(NAME vlfeat SRCS ${VLFEAT_SOURCE_FILES}) +COLMAP_ADD_LIBRARY( + NAME colmap_vlfeat + SRCS ${VLFEAT_SOURCE_FILES} + PUBLIC_LINK_LIBS + OpenMP::OpenMP_C +) From f8dceb816e0dc7102ef6c82f8e0ec1bdd38e3173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 24 Jul 2023 16:49:51 +0200 Subject: [PATCH 13/38] f --- cmake/colmap-config.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/colmap-config.cmake.in b/cmake/colmap-config.cmake.in index c05d1f5f94..5d47ca4b9a 100644 --- a/cmake/colmap-config.cmake.in +++ b/cmake/colmap-config.cmake.in @@ -79,6 +79,6 @@ set(GUI_ENABLED @GUI_ENABLED@) set(CGAL_ENABLED @CGAL_ENABLED@) -include(${PACKAGE_PREFIX_DIR}/share/colmap/cmake/FindCOLMAPDependencies.cmake) include(${PACKAGE_PREFIX_DIR}/share/colmap/colmap-targets.cmake) +include(${PACKAGE_PREFIX_DIR}/share/colmap/cmake/FindCOLMAPDependencies.cmake) check_required_components(colmap) From ec005de11476e4c22059eb4b913ef779e8487cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 24 Jul 2023 16:52:33 +0200 Subject: [PATCH 14/38] f --- src/colmap/exe/CMakeLists.txt | 18 +++--------- src/colmap/exe/{colmap_exe.cc => colmap.cc} | 0 src/colmap/exe/colmap_lib.cc | 32 --------------------- 3 files changed, 4 insertions(+), 46 deletions(-) rename src/colmap/exe/{colmap_exe.cc => colmap.cc} (100%) delete mode 100644 src/colmap/exe/colmap_lib.cc diff --git a/src/colmap/exe/CMakeLists.txt b/src/colmap/exe/CMakeLists.txt index e029cf5f0c..f75f4e9a33 100644 --- a/src/colmap/exe/CMakeLists.txt +++ b/src/colmap/exe/CMakeLists.txt @@ -35,21 +35,12 @@ if(IS_MSVC) add_compile_options("/bigobj") endif() -COLMAP_ADD_LIBRARY( - NAME colmap_exe_helpers - SRCS - feature.h feature.cc - sfm.h sfm.cc - PUBLIC_LINK_LIBS - colmap_controllers - colmap_image - colmap_feature -) - COLMAP_ADD_EXECUTABLE( NAME colmap_exe SRCS - colmap_exe.cc + feature.h feature.cc + sfm.h sfm.cc + colmap.cc database.cc feature.cc gui.cc @@ -59,6 +50,5 @@ COLMAP_ADD_EXECUTABLE( sfm.cc vocab_tree.cc LINK_LIBS - ${COLMAP_LIBS} - colmap_exe_helpers) + ${COLMAP_LIBS}) set_target_properties(colmap_exe PROPERTIES OUTPUT_NAME colmap) diff --git a/src/colmap/exe/colmap_exe.cc b/src/colmap/exe/colmap.cc similarity index 100% rename from src/colmap/exe/colmap_exe.cc rename to src/colmap/exe/colmap.cc diff --git a/src/colmap/exe/colmap_lib.cc b/src/colmap/exe/colmap_lib.cc deleted file mode 100644 index 6a6113e2c9..0000000000 --- a/src/colmap/exe/colmap_lib.cc +++ /dev/null @@ -1,32 +0,0 @@ -// 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. -// -// Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) - -// Empty source file to create single library for all colmap modules. From 3dee7137d715a48b859d7447fc99c248d6ac0693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 24 Jul 2023 16:59:35 +0200 Subject: [PATCH 15/38] remove cycles --- CMakeLists.txt | 6 +- src/colmap/util/CMakeLists.txt | 2 - src/colmap/util/endian_test.cc | 112 +++++++++++++++++++-------------- 3 files changed, 69 insertions(+), 51 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56b44b04bd..cf524a8ae2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,11 +33,13 @@ cmake_minimum_required(VERSION 3.10) project(COLMAP LANGUAGES C CXX) +set(COLMAP_VERSION "3.9") +set(COLMAP_VERSION_NUMBER "3900") + set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(COLMAP_VERSION "3.9") -set(COLMAP_VERSION_NUMBER "3900") +set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_NO_CYCLES ON) ################################################################################ # Include CMake dependencies diff --git a/src/colmap/util/CMakeLists.txt b/src/colmap/util/CMakeLists.txt index 237b29ca00..a7a928ede2 100644 --- a/src/colmap/util/CMakeLists.txt +++ b/src/colmap/util/CMakeLists.txt @@ -54,8 +54,6 @@ COLMAP_ADD_LIBRARY( Qt5::Core Qt5::OpenGL SQLite::SQLite3 - PRIVATE_LINK_LIBS - colmap_math ) if(CUDA_ENABLED) diff --git a/src/colmap/util/endian_test.cc b/src/colmap/util/endian_test.cc index e269d56478..8358238c30 100644 --- a/src/colmap/util/endian_test.cc +++ b/src/colmap/util/endian_test.cc @@ -31,7 +31,7 @@ #include "colmap/util/endian.h" -#include "colmap/math/random.h" +#include #include @@ -96,20 +96,30 @@ TEST(IsLittleBigEndian, Nominal) { EXPECT_NE(IsLittleEndian(), IsBigEndian()); } template void TestIntNativeToLitteBigEndian() { - const T x = RandomUniformInteger(std::numeric_limits::lowest(), - std::numeric_limits::max()); - EXPECT_EQ(LittleEndianToNative(NativeToLittleEndian(x)), x); - EXPECT_EQ(BigEndianToNative(NativeToBigEndian(x)), x); + std::default_random_engine prng; + std::uniform_int_distribution distribution( + std::numeric_limits::lowest(), std::numeric_limits::max()); + constexpr int kNumTrials = 100; + for (int i = 0; i < kNumTrials; ++i) { + const T x = distribution(prng); + EXPECT_EQ(LittleEndianToNative(NativeToLittleEndian(x)), x); + EXPECT_EQ(BigEndianToNative(NativeToBigEndian(x)), x); + } } template void TestRealNativeToLitteBigEndian() { - const T x = RandomUniformReal(std::numeric_limits::lowest(), - std::numeric_limits::max()); - EXPECT_EQ(LittleEndianToNative(NativeToLittleEndian(x)), x); - EXPECT_EQ(BigEndianToNative(NativeToBigEndian(x)), x); - EXPECT_EQ(NativeToLittleEndian(LittleEndianToNative(x)), x); - EXPECT_EQ(NativeToBigEndian(BigEndianToNative(x)), x); + std::default_random_engine prng; + std::uniform_real_distribution distribution( + std::numeric_limits::lowest(), std::numeric_limits::max()); + constexpr int kNumTrials = 100; + for (int i = 0; i < kNumTrials; ++i) { + const T x = distribution(prng); + EXPECT_EQ(LittleEndianToNative(NativeToLittleEndian(x)), x); + EXPECT_EQ(BigEndianToNative(NativeToBigEndian(x)), x); + EXPECT_EQ(NativeToLittleEndian(LittleEndianToNative(x)), x); + EXPECT_EQ(NativeToBigEndian(BigEndianToNative(x)), x); + } } TEST(NativeToLitteBigEndian, Nominal) { @@ -131,47 +141,55 @@ TEST(NativeToLitteBigEndian, Nominal) { template void TestIntReadWriteBinaryLittleEndian() { - std::stringstream file; - const T orig_value = RandomUniformInteger(std::numeric_limits::lowest(), - std::numeric_limits::max()); - WriteBinaryLittleEndian(&file, orig_value); - const T read_value = ReadBinaryLittleEndian(&file); - EXPECT_EQ(orig_value, read_value); - - std::stringstream file_vector; - std::vector orig_vector(100); - std::generate(orig_vector.begin(), orig_vector.end(), []() { - return RandomUniformInteger(std::numeric_limits::lowest(), - std::numeric_limits::max()); - }); - WriteBinaryLittleEndian(&file_vector, orig_vector); - std::vector read_vector(orig_vector.size()); - ReadBinaryLittleEndian(&file_vector, &read_vector); - for (size_t i = 0; i < orig_vector.size(); ++i) { - EXPECT_EQ(orig_vector[i], read_vector[i]); + std::default_random_engine prng; + std::uniform_int_distribution distribution( + std::numeric_limits::lowest(), std::numeric_limits::max()); + constexpr int kNumTrials = 100; + for (int i = 0; i < kNumTrials; ++i) { + std::stringstream file; + const T orig_value = distribution(prng); + WriteBinaryLittleEndian(&file, orig_value); + const T read_value = ReadBinaryLittleEndian(&file); + EXPECT_EQ(orig_value, read_value); + + std::stringstream file_vector; + std::vector orig_vector(100); + std::generate(orig_vector.begin(), orig_vector.end(), [&distribution]() { + return distribution(prng); + }); + WriteBinaryLittleEndian(&file_vector, orig_vector); + std::vector read_vector(orig_vector.size()); + ReadBinaryLittleEndian(&file_vector, &read_vector); + for (size_t i = 0; i < orig_vector.size(); ++i) { + EXPECT_EQ(orig_vector[i], read_vector[i]); + } } } template void TestFloatReadWriteBinaryLittleEndian() { - std::stringstream file; - const T orig_value = RandomUniformReal(std::numeric_limits::lowest(), - std::numeric_limits::max()); - WriteBinaryLittleEndian(&file, orig_value); - const T read_value = ReadBinaryLittleEndian(&file); - EXPECT_EQ(orig_value, read_value); - - std::stringstream file_vector; - std::vector orig_vector(100); - std::generate(orig_vector.begin(), orig_vector.end(), []() { - return RandomUniformReal(std::numeric_limits::lowest(), - std::numeric_limits::max()); - }); - WriteBinaryLittleEndian(&file_vector, orig_vector); - std::vector read_vector(orig_vector.size()); - ReadBinaryLittleEndian(&file_vector, &read_vector); - for (size_t i = 0; i < orig_vector.size(); ++i) { - EXPECT_EQ(orig_vector[i], read_vector[i]); + std::default_random_engine prng; + std::uniform_real_distribution distribution( + std::numeric_limits::lowest(), std::numeric_limits::max()); + constexpr int kNumTrials = 100; + for (int i = 0; i < kNumTrials; ++i) { + std::stringstream file; + const T orig_value = distribution(prng); + WriteBinaryLittleEndian(&file, orig_value); + const T read_value = ReadBinaryLittleEndian(&file); + EXPECT_EQ(orig_value, read_value); + + std::stringstream file_vector; + std::vector orig_vector(100); + std::generate(orig_vector.begin(), orig_vector.end(), [&distribution]() { + return distribution(prng); + }); + WriteBinaryLittleEndian(&file_vector, orig_vector); + std::vector read_vector(orig_vector.size()); + ReadBinaryLittleEndian(&file_vector, &read_vector); + for (size_t i = 0; i < orig_vector.size(); ++i) { + EXPECT_EQ(orig_vector[i], read_vector[i]); + } } } From 5cb71c4f925062272ddb7d6ec9aba56654bb164e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 24 Jul 2023 17:31:13 +0200 Subject: [PATCH 16/38] d --- src/colmap/estimators/bundle_adjustment.cc | 2 +- .../estimators/bundle_adjustment_test.cc | 2 +- .../estimators/coordinate_frame_test.cc | 2 +- .../estimators/essential_matrix_test.cc | 2 +- .../estimators/generalized_absolute_pose.cc | 2 +- .../generalized_absolute_pose_test.cc | 2 +- .../estimators/generalized_relative_pose.cc | 2 +- .../generalized_relative_pose_test.cc | 2 +- src/colmap/estimators/homography_matrix.cc | 2 +- src/colmap/estimators/similarity_transform.h | 2 +- src/colmap/estimators/triangulation.cc | 2 +- src/colmap/estimators/two_view_geometry.cc | 2 +- src/colmap/geometry/CMakeLists.txt | 7 --- src/colmap/geometry/essential_matrix_test.cc | 2 +- src/colmap/geometry/pose.cc | 46 ++++++++++++++++++- src/colmap/geometry/pose.h | 11 +++++ src/colmap/geometry/pose_test.cc | 26 ++++++++++- src/colmap/geometry/sim3.cc | 2 +- src/colmap/geometry/triangulation.h | 1 - src/colmap/mvs/image.cc | 2 +- src/colmap/mvs/model.cc | 2 +- src/colmap/scene/CMakeLists.txt | 7 ++- src/colmap/scene/alignment.cc | 2 +- src/colmap/scene/image.cc | 2 +- src/colmap/{geometry => scene}/projection.cc | 46 +------------------ src/colmap/{geometry => scene}/projection.h | 11 ----- .../{geometry => scene}/projection_test.cc | 26 +---------- src/colmap/scene/reconstruction.cc | 3 +- src/colmap/scene/synthetic.cc | 2 +- src/colmap/sfm/incremental_mapper.cc | 2 +- src/colmap/sfm/incremental_triangulator.cc | 2 +- src/colmap/ui/image_viewer_widget.h | 2 +- src/colmap/ui/movie_grabber_widget.cc | 2 +- 33 files changed, 113 insertions(+), 117 deletions(-) rename src/colmap/{geometry => scene}/projection.cc (82%) rename src/colmap/{geometry => scene}/projection.h (89%) rename src/colmap/{geometry => scene}/projection_test.cc (89%) diff --git a/src/colmap/estimators/bundle_adjustment.cc b/src/colmap/estimators/bundle_adjustment.cc index a1ae34d575..f640346058 100644 --- a/src/colmap/estimators/bundle_adjustment.cc +++ b/src/colmap/estimators/bundle_adjustment.cc @@ -39,7 +39,7 @@ #include "colmap/camera/models.h" #include "colmap/estimators/cost_functions.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/util/misc.h" #include "colmap/util/threading.h" #include "colmap/util/timer.h" diff --git a/src/colmap/estimators/bundle_adjustment_test.cc b/src/colmap/estimators/bundle_adjustment_test.cc index ff309d857f..2c91b74697 100644 --- a/src/colmap/estimators/bundle_adjustment_test.cc +++ b/src/colmap/estimators/bundle_adjustment_test.cc @@ -32,7 +32,7 @@ #include "colmap/estimators/bundle_adjustment.h" #include "colmap/camera/models.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/math/random.h" #include "colmap/scene/correspondence_graph.h" diff --git a/src/colmap/estimators/coordinate_frame_test.cc b/src/colmap/estimators/coordinate_frame_test.cc index ad7acd7ba9..cfea4a3f92 100644 --- a/src/colmap/estimators/coordinate_frame_test.cc +++ b/src/colmap/estimators/coordinate_frame_test.cc @@ -32,7 +32,7 @@ #include "colmap/estimators/coordinate_frame.h" #include "colmap/geometry/gps.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include diff --git a/src/colmap/estimators/essential_matrix_test.cc b/src/colmap/estimators/essential_matrix_test.cc index fe6c304dbc..a4e48cf424 100644 --- a/src/colmap/estimators/essential_matrix_test.cc +++ b/src/colmap/estimators/essential_matrix_test.cc @@ -34,7 +34,7 @@ #include "colmap/camera/models.h" #include "colmap/estimators/essential_matrix.h" #include "colmap/geometry/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/math/random.h" #include "colmap/optim/ransac.h" diff --git a/src/colmap/estimators/generalized_absolute_pose.cc b/src/colmap/estimators/generalized_absolute_pose.cc index 3d14a33f44..c6ad7411dd 100644 --- a/src/colmap/estimators/generalized_absolute_pose.cc +++ b/src/colmap/estimators/generalized_absolute_pose.cc @@ -32,7 +32,7 @@ #include "colmap/estimators/generalized_absolute_pose.h" #include "colmap/estimators/generalized_absolute_pose_coeffs.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/math/polynomial.h" #include "colmap/util/logging.h" diff --git a/src/colmap/estimators/generalized_absolute_pose_test.cc b/src/colmap/estimators/generalized_absolute_pose_test.cc index 15d8de2f33..b22476f3e4 100644 --- a/src/colmap/estimators/generalized_absolute_pose_test.cc +++ b/src/colmap/estimators/generalized_absolute_pose_test.cc @@ -32,7 +32,7 @@ #include "colmap/estimators/generalized_absolute_pose.h" #include "colmap/geometry/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/geometry/rigid3.h" #include "colmap/optim/ransac.h" diff --git a/src/colmap/estimators/generalized_relative_pose.cc b/src/colmap/estimators/generalized_relative_pose.cc index df01dddccc..455371e403 100644 --- a/src/colmap/estimators/generalized_relative_pose.cc +++ b/src/colmap/estimators/generalized_relative_pose.cc @@ -33,7 +33,7 @@ #include "colmap/geometry/essential_matrix.h" #include "colmap/geometry/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/geometry/triangulation.h" #include "colmap/math/random.h" #include "colmap/util/logging.h" diff --git a/src/colmap/estimators/generalized_relative_pose_test.cc b/src/colmap/estimators/generalized_relative_pose_test.cc index 0b575c3539..8783400a1e 100644 --- a/src/colmap/estimators/generalized_relative_pose_test.cc +++ b/src/colmap/estimators/generalized_relative_pose_test.cc @@ -32,7 +32,7 @@ #include "colmap/estimators/generalized_relative_pose.h" #include "colmap/geometry/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/geometry/rigid3.h" #include "colmap/optim/loransac.h" diff --git a/src/colmap/estimators/homography_matrix.cc b/src/colmap/estimators/homography_matrix.cc index aa866d59ca..df86a7aea2 100644 --- a/src/colmap/estimators/homography_matrix.cc +++ b/src/colmap/estimators/homography_matrix.cc @@ -32,7 +32,7 @@ #include "colmap/estimators/homography_matrix.h" #include "colmap/estimators/utils.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/util/logging.h" #include diff --git a/src/colmap/estimators/similarity_transform.h b/src/colmap/estimators/similarity_transform.h index 328d9e96f7..16daf5a47d 100644 --- a/src/colmap/estimators/similarity_transform.h +++ b/src/colmap/estimators/similarity_transform.h @@ -31,7 +31,7 @@ #pragma once -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/util/logging.h" #include "colmap/util/types.h" diff --git a/src/colmap/estimators/triangulation.cc b/src/colmap/estimators/triangulation.cc index 42c2c9e031..59e953895b 100644 --- a/src/colmap/estimators/triangulation.cc +++ b/src/colmap/estimators/triangulation.cc @@ -32,7 +32,7 @@ #include "colmap/estimators/triangulation.h" #include "colmap/estimators/essential_matrix.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/geometry/triangulation.h" #include "colmap/math/math.h" #include "colmap/optim/combination_sampler.h" diff --git a/src/colmap/estimators/two_view_geometry.cc b/src/colmap/estimators/two_view_geometry.cc index 7669e90978..c371be4a02 100644 --- a/src/colmap/estimators/two_view_geometry.cc +++ b/src/colmap/estimators/two_view_geometry.cc @@ -38,7 +38,7 @@ #include "colmap/geometry/essential_matrix.h" #include "colmap/geometry/homography_matrix.h" #include "colmap/geometry/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/geometry/triangulation.h" #include "colmap/math/random.h" #include "colmap/optim/loransac.h" diff --git a/src/colmap/geometry/CMakeLists.txt b/src/colmap/geometry/CMakeLists.txt index e9e5444ef5..17f9cc6491 100644 --- a/src/colmap/geometry/CMakeLists.txt +++ b/src/colmap/geometry/CMakeLists.txt @@ -38,7 +38,6 @@ COLMAP_ADD_LIBRARY( gps.h gps.cc homography_matrix.h homography_matrix.cc pose.h pose.cc - projection.h projection.cc rigid3.h sim3.h sim3.cc triangulation.h triangulation.cc @@ -47,7 +46,6 @@ COLMAP_ADD_LIBRARY( colmap_math Eigen3::Eigen PRIVATE_LINK_LIBS - colmap_scene colmap_optim ) @@ -71,11 +69,6 @@ COLMAP_ADD_TEST( SRCS pose_test.cc LINK_LIBS colmap_geometry ) -COLMAP_ADD_TEST( - NAME projection_test - SRCS projection_test.cc - LINK_LIBS colmap_geometry -) COLMAP_ADD_TEST( NAME rigid3_test SRCS rigid3_test.cc diff --git a/src/colmap/geometry/essential_matrix_test.cc b/src/colmap/geometry/essential_matrix_test.cc index 7a9fe87fd9..7db0996dc4 100644 --- a/src/colmap/geometry/essential_matrix_test.cc +++ b/src/colmap/geometry/essential_matrix_test.cc @@ -32,7 +32,7 @@ #include "colmap/geometry/essential_matrix.h" #include "colmap/geometry/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include #include diff --git a/src/colmap/geometry/pose.cc b/src/colmap/geometry/pose.cc index a9d341889c..1c183dd3d2 100644 --- a/src/colmap/geometry/pose.cc +++ b/src/colmap/geometry/pose.cc @@ -31,13 +31,57 @@ #include "colmap/geometry/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/geometry/triangulation.h" #include namespace colmap { +Eigen::Matrix3d ComputeClosestRotationMatrix(const Eigen::Matrix3d& matrix) { + const Eigen::JacobiSVD svd( + matrix, Eigen::ComputeFullU | Eigen::ComputeFullV); + Eigen::Matrix3d R = svd.matrixU() * (svd.matrixV().transpose()); + if (R.determinant() < 0.0) { + R *= -1.0; + } + return R; +} + +bool DecomposeProjectionMatrix(const Eigen::Matrix3x4d& P, + Eigen::Matrix3d* K, + Eigen::Matrix3d* R, + Eigen::Vector3d* T) { + Eigen::Matrix3d RR; + Eigen::Matrix3d QQ; + DecomposeMatrixRQ(P.leftCols<3>().eval(), &RR, &QQ); + + *R = ComputeClosestRotationMatrix(QQ); + + const double det_K = RR.determinant(); + if (det_K == 0) { + return false; + } else if (det_K > 0) { + *K = RR; + } else { + *K = -RR; + } + + for (int i = 0; i < 3; ++i) { + if ((*K)(i, i) < 0.0) { + K->col(i) = -K->col(i); + R->row(i) = -R->row(i); + } + } + + *T = K->triangularView().solve(P.col(3)); + if (det_K < 0) { + *T = -(*T); + } + + return true; +} + Eigen::Matrix3d CrossProductMatrix(const Eigen::Vector3d& vector) { Eigen::Matrix3d matrix; matrix << 0, -vector(2), vector(1), vector(2), 0, -vector(0), -vector(1), diff --git a/src/colmap/geometry/pose.h b/src/colmap/geometry/pose.h index e30e971f12..cb5bc634d9 100644 --- a/src/colmap/geometry/pose.h +++ b/src/colmap/geometry/pose.h @@ -41,6 +41,17 @@ namespace colmap { +// Compute the closes rotation matrix with the closest Frobenius norm by setting +// the singular values of the given matrix to 1. +Eigen::Matrix3d ComputeClosestRotationMatrix(const Eigen::Matrix3d& matrix); + +// Decompose projection matrix into intrinsic camera matrix, rotation matrix and +// translation vector. Returns false if decomposition fails. +bool DecomposeProjectionMatrix(const Eigen::Matrix3x4d& proj_matrix, + Eigen::Matrix3d* K, + Eigen::Matrix3d* R, + Eigen::Vector3d* T); + // Compose the skew symmetric cross product matrix from a vector. Eigen::Matrix3d CrossProductMatrix(const Eigen::Vector3d& vector); diff --git a/src/colmap/geometry/pose_test.cc b/src/colmap/geometry/pose_test.cc index 5026b3149b..957a671dab 100644 --- a/src/colmap/geometry/pose_test.cc +++ b/src/colmap/geometry/pose_test.cc @@ -31,7 +31,7 @@ #include "colmap/geometry/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/math/math.h" #include @@ -39,6 +39,30 @@ namespace colmap { +TEST(ComputeClosestRotationMatrix, Nominal) { + const Eigen::Matrix3d A = Eigen::Matrix3d::Identity(); + EXPECT_LT((ComputeClosestRotationMatrix(A) - A).norm(), 1e-6); + EXPECT_LT((ComputeClosestRotationMatrix(2 * A) - A).norm(), 1e-6); +} + +TEST(DecomposeProjectionMatrix, Nominal) { + for (int i = 1; i < 100; ++i) { + Eigen::Matrix3d ref_K = i * Eigen::Matrix3d::Identity(); + ref_K(0, 2) = i; + ref_K(1, 2) = 2 * i; + const Rigid3d cam_from_world(Eigen::Quaterniond::UnitRandom(), + Eigen::Vector3d::Random()); + const Eigen::Matrix3x4d P = ref_K * cam_from_world.ToMatrix(); + Eigen::Matrix3d K; + Eigen::Matrix3d R; + Eigen::Vector3d T; + DecomposeProjectionMatrix(P, &K, &R, &T); + EXPECT_TRUE(ref_K.isApprox(K, 1e-6)); + EXPECT_TRUE(cam_from_world.rotation.toRotationMatrix().isApprox(R, 1e-6)); + EXPECT_TRUE(cam_from_world.translation.isApprox(T, 1e-6)); + } +} + TEST(CrossProductMatrix, Nominal) { EXPECT_EQ(CrossProductMatrix(Eigen::Vector3d(0, 0, 0)), Eigen::Matrix3d::Zero()); diff --git a/src/colmap/geometry/sim3.cc b/src/colmap/geometry/sim3.cc index 5cebf4ebfe..8eb8fea591 100644 --- a/src/colmap/geometry/sim3.cc +++ b/src/colmap/geometry/sim3.cc @@ -33,7 +33,7 @@ #include "colmap/estimators/similarity_transform.h" #include "colmap/geometry/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include diff --git a/src/colmap/geometry/triangulation.h b/src/colmap/geometry/triangulation.h index 4baf071620..c93ebef9aa 100644 --- a/src/colmap/geometry/triangulation.h +++ b/src/colmap/geometry/triangulation.h @@ -32,7 +32,6 @@ #pragma once #include "colmap/math/math.h" -#include "colmap/scene/camera.h" #include "colmap/util/types.h" #include diff --git a/src/colmap/mvs/image.cc b/src/colmap/mvs/image.cc index 9d3ad919d2..52c9956ca5 100644 --- a/src/colmap/mvs/image.cc +++ b/src/colmap/mvs/image.cc @@ -31,7 +31,7 @@ #include "colmap/mvs/image.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/util/logging.h" #include diff --git a/src/colmap/mvs/model.cc b/src/colmap/mvs/model.cc index d917953817..87ea1af1af 100644 --- a/src/colmap/mvs/model.cc +++ b/src/colmap/mvs/model.cc @@ -33,7 +33,7 @@ #include "colmap/camera/models.h" #include "colmap/geometry/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/geometry/triangulation.h" #include "colmap/scene/reconstruction.h" #include "colmap/util/misc.h" diff --git a/src/colmap/scene/CMakeLists.txt b/src/colmap/scene/CMakeLists.txt index a73d51b936..146d9c2952 100644 --- a/src/colmap/scene/CMakeLists.txt +++ b/src/colmap/scene/CMakeLists.txt @@ -43,6 +43,7 @@ COLMAP_ADD_LIBRARY( image.h image.cc point2d.h point3d.h point3d.cc + projection.h projection.cc reconstruction.h reconstruction.cc reconstruction_manager.h reconstruction_manager.cc scene_clustering.h scene_clustering.cc @@ -54,7 +55,6 @@ COLMAP_ADD_LIBRARY( colmap_image colmap_feature colmap_geometry - colmap_estimators Eigen3::Eigen SQLite::SQLite3 ) @@ -99,6 +99,11 @@ COLMAP_ADD_TEST( SRCS point3d_test.cc LINK_LIBS colmap_scene ) +COLMAP_ADD_TEST( + NAME projection_test + SRCS projection_test.cc + LINK_LIBS colmap_scene +) COLMAP_ADD_TEST( NAME reconstruction_test SRCS reconstruction_test.cc diff --git a/src/colmap/scene/alignment.cc b/src/colmap/scene/alignment.cc index dfa0014fa8..41ee9d4ec9 100644 --- a/src/colmap/scene/alignment.cc +++ b/src/colmap/scene/alignment.cc @@ -33,7 +33,7 @@ #include "colmap/estimators/similarity_transform.h" #include "colmap/geometry/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/optim/loransac.h" namespace colmap { diff --git a/src/colmap/scene/image.cc b/src/colmap/scene/image.cc index 0a40096b34..646cd2813d 100644 --- a/src/colmap/scene/image.cc +++ b/src/colmap/scene/image.cc @@ -32,7 +32,7 @@ #include "colmap/scene/image.h" #include "colmap/geometry/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" namespace colmap { namespace { diff --git a/src/colmap/geometry/projection.cc b/src/colmap/scene/projection.cc similarity index 82% rename from src/colmap/geometry/projection.cc rename to src/colmap/scene/projection.cc index f2aa62703d..7a7caeec0f 100644 --- a/src/colmap/geometry/projection.cc +++ b/src/colmap/scene/projection.cc @@ -29,57 +29,13 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/geometry/pose.h" #include "colmap/math/matrix.h" namespace colmap { -Eigen::Matrix3d ComputeClosestRotationMatrix(const Eigen::Matrix3d& matrix) { - const Eigen::JacobiSVD svd( - matrix, Eigen::ComputeFullU | Eigen::ComputeFullV); - Eigen::Matrix3d R = svd.matrixU() * (svd.matrixV().transpose()); - if (R.determinant() < 0.0) { - R *= -1.0; - } - return R; -} - -bool DecomposeProjectionMatrix(const Eigen::Matrix3x4d& P, - Eigen::Matrix3d* K, - Eigen::Matrix3d* R, - Eigen::Vector3d* T) { - Eigen::Matrix3d RR; - Eigen::Matrix3d QQ; - DecomposeMatrixRQ(P.leftCols<3>().eval(), &RR, &QQ); - - *R = ComputeClosestRotationMatrix(QQ); - - const double det_K = RR.determinant(); - if (det_K == 0) { - return false; - } else if (det_K > 0) { - *K = RR; - } else { - *K = -RR; - } - - for (int i = 0; i < 3; ++i) { - if ((*K)(i, i) < 0.0) { - K->col(i) = -K->col(i); - R->row(i) = -R->row(i); - } - } - - *T = K->triangularView().solve(P.col(3)); - if (det_K < 0) { - *T = -(*T); - } - - return true; -} - double CalculateSquaredReprojectionError(const Eigen::Vector2d& point2D, const Eigen::Vector3d& point3D, const Rigid3d& cam_from_world, diff --git a/src/colmap/geometry/projection.h b/src/colmap/scene/projection.h similarity index 89% rename from src/colmap/geometry/projection.h rename to src/colmap/scene/projection.h index 85d8dff8ae..9044de0567 100644 --- a/src/colmap/geometry/projection.h +++ b/src/colmap/scene/projection.h @@ -42,17 +42,6 @@ namespace colmap { -// Compute the closes rotation matrix with the closest Frobenius norm by setting -// the singular values of the given matrix to 1. -Eigen::Matrix3d ComputeClosestRotationMatrix(const Eigen::Matrix3d& matrix); - -// Decompose projection matrix into intrinsic camera matrix, rotation matrix and -// translation vector. Returns false if decomposition fails. -bool DecomposeProjectionMatrix(const Eigen::Matrix3x4d& proj_matrix, - Eigen::Matrix3d* K, - Eigen::Matrix3d* R, - Eigen::Vector3d* T); - // Calculate the reprojection error. // // The reprojection error is the Euclidean distance between the observation diff --git a/src/colmap/geometry/projection_test.cc b/src/colmap/scene/projection_test.cc similarity index 89% rename from src/colmap/geometry/projection_test.cc rename to src/colmap/scene/projection_test.cc index 9e9f96fa4f..c2b2ddbd18 100644 --- a/src/colmap/geometry/projection_test.cc +++ b/src/colmap/scene/projection_test.cc @@ -29,7 +29,7 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/camera/models.h" #include "colmap/geometry/pose.h" @@ -40,30 +40,6 @@ namespace colmap { -TEST(ComputeClosestRotationMatrix, Nominal) { - const Eigen::Matrix3d A = Eigen::Matrix3d::Identity(); - EXPECT_LT((ComputeClosestRotationMatrix(A) - A).norm(), 1e-6); - EXPECT_LT((ComputeClosestRotationMatrix(2 * A) - A).norm(), 1e-6); -} - -TEST(DecomposeProjectionMatrix, Nominal) { - for (int i = 1; i < 100; ++i) { - Eigen::Matrix3d ref_K = i * Eigen::Matrix3d::Identity(); - ref_K(0, 2) = i; - ref_K(1, 2) = 2 * i; - const Rigid3d cam_from_world(Eigen::Quaterniond::UnitRandom(), - Eigen::Vector3d::Random()); - const Eigen::Matrix3x4d P = ref_K * cam_from_world.ToMatrix(); - Eigen::Matrix3d K; - Eigen::Matrix3d R; - Eigen::Vector3d T; - DecomposeProjectionMatrix(P, &K, &R, &T); - EXPECT_TRUE(ref_K.isApprox(K, 1e-6)); - EXPECT_TRUE(cam_from_world.rotation.toRotationMatrix().isApprox(R, 1e-6)); - EXPECT_TRUE(cam_from_world.translation.isApprox(T, 1e-6)); - } -} - TEST(CalculateSquaredReprojectionError, Nominal) { const Rigid3d cam_from_world(Eigen::Quaterniond::Identity(), Eigen::Vector3d::Zero()); diff --git a/src/colmap/scene/reconstruction.cc b/src/colmap/scene/reconstruction.cc index c54711ef94..c39fc1140c 100644 --- a/src/colmap/scene/reconstruction.cc +++ b/src/colmap/scene/reconstruction.cc @@ -31,10 +31,9 @@ #include "colmap/scene/reconstruction.h" -#include "colmap/estimators/similarity_transform.h" #include "colmap/geometry/gps.h" #include "colmap/geometry/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/geometry/triangulation.h" #include "colmap/image/bitmap.h" #include "colmap/optim/loransac.h" diff --git a/src/colmap/scene/synthetic.cc b/src/colmap/scene/synthetic.cc index f097a0cefc..3e84c52428 100644 --- a/src/colmap/scene/synthetic.cc +++ b/src/colmap/scene/synthetic.cc @@ -33,7 +33,7 @@ #include "colmap/geometry/essential_matrix.h" #include "colmap/geometry/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/math/random.h" #include diff --git a/src/colmap/sfm/incremental_mapper.cc b/src/colmap/sfm/incremental_mapper.cc index ee8f8e1410..bfedcb885d 100644 --- a/src/colmap/sfm/incremental_mapper.cc +++ b/src/colmap/sfm/incremental_mapper.cc @@ -32,7 +32,7 @@ #include "colmap/sfm/incremental_mapper.h" #include "colmap/estimators/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/geometry/triangulation.h" #include "colmap/image/bitmap.h" #include "colmap/util/misc.h" diff --git a/src/colmap/sfm/incremental_triangulator.cc b/src/colmap/sfm/incremental_triangulator.cc index 7dfff86c95..8c51be5b39 100644 --- a/src/colmap/sfm/incremental_triangulator.cc +++ b/src/colmap/sfm/incremental_triangulator.cc @@ -32,7 +32,7 @@ #include "colmap/sfm/incremental_triangulator.h" #include "colmap/estimators/triangulation.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/util/misc.h" namespace colmap { diff --git a/src/colmap/ui/image_viewer_widget.h b/src/colmap/ui/image_viewer_widget.h index a6fb24a8b5..3c43984819 100644 --- a/src/colmap/ui/image_viewer_widget.h +++ b/src/colmap/ui/image_viewer_widget.h @@ -32,7 +32,7 @@ #pragma once #include "colmap/controllers/option_manager.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/scene/database.h" #include "colmap/scene/reconstruction.h" #include "colmap/ui/qt_utils.h" diff --git a/src/colmap/ui/movie_grabber_widget.cc b/src/colmap/ui/movie_grabber_widget.cc index a6a1a1d4d8..392c53b67b 100644 --- a/src/colmap/ui/movie_grabber_widget.cc +++ b/src/colmap/ui/movie_grabber_widget.cc @@ -32,7 +32,7 @@ #include "colmap/ui/movie_grabber_widget.h" #include "colmap/geometry/pose.h" -#include "colmap/geometry/projection.h" +#include "colmap/scene/projection.h" #include "colmap/ui/model_viewer_widget.h" namespace colmap { From 4ad63dd9bffcef6a42dd8d4b66c7b67395c49634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 24 Jul 2023 17:47:36 +0200 Subject: [PATCH 17/38] d --- src/colmap/estimators/bundle_adjustment_test.cc | 2 +- src/colmap/estimators/essential_matrix_test.cc | 2 +- src/colmap/estimators/generalized_absolute_pose.cc | 2 +- src/colmap/estimators/generalized_absolute_pose_test.cc | 2 +- src/colmap/estimators/generalized_relative_pose.cc | 2 +- src/colmap/estimators/generalized_relative_pose_test.cc | 2 +- src/colmap/estimators/triangulation.cc | 2 +- src/colmap/estimators/two_view_geometry.cc | 2 +- src/colmap/geometry/pose.cc | 2 +- src/colmap/geometry/pose_test.cc | 2 +- src/colmap/mvs/model.cc | 2 +- src/colmap/scene/alignment.cc | 2 +- src/colmap/scene/reconstruction.cc | 2 +- src/colmap/scene/synthetic.cc | 2 +- src/colmap/sfm/incremental_mapper.cc | 2 +- src/colmap/ui/image_viewer_widget.h | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/colmap/estimators/bundle_adjustment_test.cc b/src/colmap/estimators/bundle_adjustment_test.cc index 2c91b74697..e3c7bf389d 100644 --- a/src/colmap/estimators/bundle_adjustment_test.cc +++ b/src/colmap/estimators/bundle_adjustment_test.cc @@ -32,9 +32,9 @@ #include "colmap/estimators/bundle_adjustment.h" #include "colmap/camera/models.h" -#include "colmap/scene/projection.h" #include "colmap/math/random.h" #include "colmap/scene/correspondence_graph.h" +#include "colmap/scene/projection.h" #include diff --git a/src/colmap/estimators/essential_matrix_test.cc b/src/colmap/estimators/essential_matrix_test.cc index a4e48cf424..a557e97c9a 100644 --- a/src/colmap/estimators/essential_matrix_test.cc +++ b/src/colmap/estimators/essential_matrix_test.cc @@ -34,9 +34,9 @@ #include "colmap/camera/models.h" #include "colmap/estimators/essential_matrix.h" #include "colmap/geometry/pose.h" -#include "colmap/scene/projection.h" #include "colmap/math/random.h" #include "colmap/optim/ransac.h" +#include "colmap/scene/projection.h" #include #include diff --git a/src/colmap/estimators/generalized_absolute_pose.cc b/src/colmap/estimators/generalized_absolute_pose.cc index c6ad7411dd..39bb2a9a57 100644 --- a/src/colmap/estimators/generalized_absolute_pose.cc +++ b/src/colmap/estimators/generalized_absolute_pose.cc @@ -32,8 +32,8 @@ #include "colmap/estimators/generalized_absolute_pose.h" #include "colmap/estimators/generalized_absolute_pose_coeffs.h" -#include "colmap/scene/projection.h" #include "colmap/math/polynomial.h" +#include "colmap/scene/projection.h" #include "colmap/util/logging.h" #include diff --git a/src/colmap/estimators/generalized_absolute_pose_test.cc b/src/colmap/estimators/generalized_absolute_pose_test.cc index b22476f3e4..c215f09c79 100644 --- a/src/colmap/estimators/generalized_absolute_pose_test.cc +++ b/src/colmap/estimators/generalized_absolute_pose_test.cc @@ -32,9 +32,9 @@ #include "colmap/estimators/generalized_absolute_pose.h" #include "colmap/geometry/pose.h" -#include "colmap/scene/projection.h" #include "colmap/geometry/rigid3.h" #include "colmap/optim/ransac.h" +#include "colmap/scene/projection.h" #include diff --git a/src/colmap/estimators/generalized_relative_pose.cc b/src/colmap/estimators/generalized_relative_pose.cc index 455371e403..dea2f5a50c 100644 --- a/src/colmap/estimators/generalized_relative_pose.cc +++ b/src/colmap/estimators/generalized_relative_pose.cc @@ -33,9 +33,9 @@ #include "colmap/geometry/essential_matrix.h" #include "colmap/geometry/pose.h" -#include "colmap/scene/projection.h" #include "colmap/geometry/triangulation.h" #include "colmap/math/random.h" +#include "colmap/scene/projection.h" #include "colmap/util/logging.h" #include diff --git a/src/colmap/estimators/generalized_relative_pose_test.cc b/src/colmap/estimators/generalized_relative_pose_test.cc index 8783400a1e..23033d2b08 100644 --- a/src/colmap/estimators/generalized_relative_pose_test.cc +++ b/src/colmap/estimators/generalized_relative_pose_test.cc @@ -32,9 +32,9 @@ #include "colmap/estimators/generalized_relative_pose.h" #include "colmap/geometry/pose.h" -#include "colmap/scene/projection.h" #include "colmap/geometry/rigid3.h" #include "colmap/optim/loransac.h" +#include "colmap/scene/projection.h" #include diff --git a/src/colmap/estimators/triangulation.cc b/src/colmap/estimators/triangulation.cc index 59e953895b..e644f72e66 100644 --- a/src/colmap/estimators/triangulation.cc +++ b/src/colmap/estimators/triangulation.cc @@ -32,11 +32,11 @@ #include "colmap/estimators/triangulation.h" #include "colmap/estimators/essential_matrix.h" -#include "colmap/scene/projection.h" #include "colmap/geometry/triangulation.h" #include "colmap/math/math.h" #include "colmap/optim/combination_sampler.h" #include "colmap/optim/loransac.h" +#include "colmap/scene/projection.h" #include "colmap/util/logging.h" #include diff --git a/src/colmap/estimators/two_view_geometry.cc b/src/colmap/estimators/two_view_geometry.cc index c371be4a02..dd1ceb1f0e 100644 --- a/src/colmap/estimators/two_view_geometry.cc +++ b/src/colmap/estimators/two_view_geometry.cc @@ -38,12 +38,12 @@ #include "colmap/geometry/essential_matrix.h" #include "colmap/geometry/homography_matrix.h" #include "colmap/geometry/pose.h" -#include "colmap/scene/projection.h" #include "colmap/geometry/triangulation.h" #include "colmap/math/random.h" #include "colmap/optim/loransac.h" #include "colmap/optim/ransac.h" #include "colmap/scene/camera.h" +#include "colmap/scene/projection.h" #include diff --git a/src/colmap/geometry/pose.cc b/src/colmap/geometry/pose.cc index 1c183dd3d2..4ac5247324 100644 --- a/src/colmap/geometry/pose.cc +++ b/src/colmap/geometry/pose.cc @@ -31,8 +31,8 @@ #include "colmap/geometry/pose.h" -#include "colmap/scene/projection.h" #include "colmap/geometry/triangulation.h" +#include "colmap/scene/projection.h" #include diff --git a/src/colmap/geometry/pose_test.cc b/src/colmap/geometry/pose_test.cc index 957a671dab..68ab25ea81 100644 --- a/src/colmap/geometry/pose_test.cc +++ b/src/colmap/geometry/pose_test.cc @@ -31,8 +31,8 @@ #include "colmap/geometry/pose.h" -#include "colmap/scene/projection.h" #include "colmap/math/math.h" +#include "colmap/scene/projection.h" #include #include diff --git a/src/colmap/mvs/model.cc b/src/colmap/mvs/model.cc index 87ea1af1af..980678478f 100644 --- a/src/colmap/mvs/model.cc +++ b/src/colmap/mvs/model.cc @@ -33,8 +33,8 @@ #include "colmap/camera/models.h" #include "colmap/geometry/pose.h" -#include "colmap/scene/projection.h" #include "colmap/geometry/triangulation.h" +#include "colmap/scene/projection.h" #include "colmap/scene/reconstruction.h" #include "colmap/util/misc.h" diff --git a/src/colmap/scene/alignment.cc b/src/colmap/scene/alignment.cc index 41ee9d4ec9..b0776d223a 100644 --- a/src/colmap/scene/alignment.cc +++ b/src/colmap/scene/alignment.cc @@ -33,8 +33,8 @@ #include "colmap/estimators/similarity_transform.h" #include "colmap/geometry/pose.h" -#include "colmap/scene/projection.h" #include "colmap/optim/loransac.h" +#include "colmap/scene/projection.h" namespace colmap { namespace { diff --git a/src/colmap/scene/reconstruction.cc b/src/colmap/scene/reconstruction.cc index c39fc1140c..316c3b308e 100644 --- a/src/colmap/scene/reconstruction.cc +++ b/src/colmap/scene/reconstruction.cc @@ -33,11 +33,11 @@ #include "colmap/geometry/gps.h" #include "colmap/geometry/pose.h" -#include "colmap/scene/projection.h" #include "colmap/geometry/triangulation.h" #include "colmap/image/bitmap.h" #include "colmap/optim/loransac.h" #include "colmap/scene/database_cache.h" +#include "colmap/scene/projection.h" #include "colmap/util/misc.h" #include "colmap/util/ply.h" diff --git a/src/colmap/scene/synthetic.cc b/src/colmap/scene/synthetic.cc index 3e84c52428..128bb7ebfa 100644 --- a/src/colmap/scene/synthetic.cc +++ b/src/colmap/scene/synthetic.cc @@ -33,8 +33,8 @@ #include "colmap/geometry/essential_matrix.h" #include "colmap/geometry/pose.h" -#include "colmap/scene/projection.h" #include "colmap/math/random.h" +#include "colmap/scene/projection.h" #include diff --git a/src/colmap/sfm/incremental_mapper.cc b/src/colmap/sfm/incremental_mapper.cc index bfedcb885d..cc79329ab5 100644 --- a/src/colmap/sfm/incremental_mapper.cc +++ b/src/colmap/sfm/incremental_mapper.cc @@ -32,9 +32,9 @@ #include "colmap/sfm/incremental_mapper.h" #include "colmap/estimators/pose.h" -#include "colmap/scene/projection.h" #include "colmap/geometry/triangulation.h" #include "colmap/image/bitmap.h" +#include "colmap/scene/projection.h" #include "colmap/util/misc.h" #include diff --git a/src/colmap/ui/image_viewer_widget.h b/src/colmap/ui/image_viewer_widget.h index 3c43984819..20baaf8cbc 100644 --- a/src/colmap/ui/image_viewer_widget.h +++ b/src/colmap/ui/image_viewer_widget.h @@ -32,8 +32,8 @@ #pragma once #include "colmap/controllers/option_manager.h" -#include "colmap/scene/projection.h" #include "colmap/scene/database.h" +#include "colmap/scene/projection.h" #include "colmap/scene/reconstruction.h" #include "colmap/ui/qt_utils.h" From 4588010303cfca6a322714801d26566d9faa92a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Tue, 25 Jul 2023 15:57:48 +0200 Subject: [PATCH 18/38] Finished removing all cycles --- CMakeLists.txt | 8 +- src/colmap/CMakeLists.txt | 2 +- src/colmap/controllers/CMakeLists.txt | 3 + .../controllers/automatic_reconstruction.cc | 4 +- .../feature_extraction.cc} | 2 +- .../feature_extraction.h} | 2 +- .../feature_matching.cc} | 44 +- .../feature_matching.h} | 2 +- src/colmap/controllers/hierarchical_mapper.cc | 2 +- .../controllers/hierarchical_mapper_test.cc | 2 +- .../reader.cc => controllers/image_reader.cc} | 4 +- .../reader.h => controllers/image_reader.h} | 2 +- .../controllers/incremental_mapper_test.cc | 2 +- src/colmap/controllers/option_manager.cc | 6 +- src/colmap/estimators/CMakeLists.txt | 9 +- src/colmap/{scene => estimators}/alignment.cc | 2 +- src/colmap/{scene => estimators}/alignment.h | 0 src/colmap/estimators/bundle_adjustment.cc | 2 +- .../estimators/bundle_adjustment_test.cc | 2 +- src/colmap/estimators/cost_functions_test.cc | 2 +- .../estimators/essential_matrix_test.cc | 2 +- src/colmap/estimators/pose.cc | 2 +- src/colmap/estimators/pose.h | 2 +- src/colmap/estimators/two_view_geometry.cc | 472 +++++++++--------- src/colmap/estimators/two_view_geometry.h | 367 ++++++-------- src/colmap/exe/feature.cc | 8 +- src/colmap/exe/feature.h | 2 +- src/colmap/exe/model.cc | 3 +- src/colmap/exe/vocab_tree.cc | 2 +- src/colmap/feature/CMakeLists.txt | 5 +- src/colmap/feature/sift.h | 2 +- src/colmap/geometry/pose.cc | 12 +- src/colmap/image/CMakeLists.txt | 13 +- src/colmap/image/line.h | 2 +- src/colmap/image/undistortion.cc | 2 +- src/colmap/image/undistortion.h | 2 +- src/colmap/image/warp.h | 2 +- src/colmap/mvs/CMakeLists.txt | 2 + src/colmap/mvs/depth_map.h | 2 +- src/colmap/mvs/image.h | 2 +- src/colmap/mvs/model.cc | 2 +- src/colmap/mvs/normal_map.h | 2 +- src/colmap/mvs/workspace.h | 2 +- src/colmap/scene/CMakeLists.txt | 10 +- src/colmap/scene/camera.cc | 2 +- src/colmap/scene/camera_test.cc | 2 +- src/colmap/scene/database.h | 2 +- src/colmap/scene/database_cache.h | 2 +- src/colmap/scene/projection.cc | 6 - src/colmap/scene/projection.h | 13 - src/colmap/scene/projection_test.cc | 26 +- src/colmap/scene/reconstruction.cc | 2 +- src/colmap/scene/reconstruction_test.cc | 2 +- src/colmap/scene/synthetic.h | 2 +- src/colmap/scene/two_view_geometry.cc | 46 ++ src/colmap/scene/two_view_geometry.h | 86 ++++ .../two_view_geometry_test.cc | 2 +- src/colmap/{camera => sensor}/CMakeLists.txt | 18 +- src/colmap/{image => sensor}/bitmap.cc | 4 +- src/colmap/{image => sensor}/bitmap.h | 0 src/colmap/{image => sensor}/bitmap_test.cc | 2 +- src/colmap/{camera => sensor}/database.cc | 4 +- src/colmap/{camera => sensor}/database.h | 4 +- .../{camera => sensor}/database_test.cc | 2 +- src/colmap/{camera => sensor}/models.cc | 2 +- src/colmap/{camera => sensor}/models.h | 0 src/colmap/{camera => sensor}/models_test.cc | 2 +- src/colmap/{camera => sensor}/specs.cc | 2 +- src/colmap/{camera => sensor}/specs.h | 0 src/colmap/sfm/incremental_mapper.cc | 12 +- src/colmap/ui/colormaps.cc | 2 +- src/colmap/ui/database_management_widget.cc | 2 +- src/colmap/ui/feature_extraction_widget.cc | 4 +- src/colmap/ui/feature_matching_widget.cc | 2 +- src/colmap/ui/main_window.h | 2 +- src/colmap/ui/qt_utils.cc | 2 +- src/colmap/ui/qt_utils.h | 2 +- src/colmap/util/endian_test.cc | 4 +- 78 files changed, 669 insertions(+), 620 deletions(-) rename src/colmap/{feature/extraction.cc => controllers/feature_extraction.cc} (99%) rename src/colmap/{feature/extraction.h => controllers/feature_extraction.h} (99%) rename src/colmap/{feature/matching.cc => controllers/feature_matching.cc} (97%) rename src/colmap/{feature/matching.h => controllers/feature_matching.h} (99%) rename src/colmap/{image/reader.cc => controllers/image_reader.cc} (99%) rename src/colmap/{image/reader.h => controllers/image_reader.h} (99%) rename src/colmap/{scene => estimators}/alignment.cc (99%) rename src/colmap/{scene => estimators}/alignment.h (100%) create mode 100644 src/colmap/scene/two_view_geometry.cc create mode 100644 src/colmap/scene/two_view_geometry.h rename src/colmap/{estimators => scene}/two_view_geometry_test.cc (98%) rename src/colmap/{camera => sensor}/CMakeLists.txt (88%) rename src/colmap/{image => sensor}/bitmap.cc (99%) rename src/colmap/{image => sensor}/bitmap.h (100%) rename src/colmap/{image => sensor}/bitmap_test.cc (99%) rename src/colmap/{camera => sensor}/database.cc (97%) rename src/colmap/{camera => sensor}/database.h (97%) rename src/colmap/{camera => sensor}/database_test.cc (98%) rename src/colmap/{camera => sensor}/models.cc (99%) rename src/colmap/{camera => sensor}/models.h (100%) rename src/colmap/{camera => sensor}/models_test.cc (99%) rename src/colmap/{camera => sensor}/specs.cc (99%) rename src/colmap/{camera => sensor}/specs.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf524a8ae2..816e8921a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,8 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "ClangTidy") if(NOT CLANG_TIDY_EXE) message(FATAL_ERROR "Could not find the clang-tidy executable, please set CLANG_TIDY_EXE") endif() +else() + unset(CLANG_TIDY_EXE) endif() if(IS_MSVC) @@ -185,7 +187,7 @@ link_directories(${COLMAP_LINK_DIRS}) set(COLMAP_LIBS colmap_util colmap_math - colmap_camera + colmap_sensor colmap_image colmap_feature colmap_geometry @@ -212,7 +214,6 @@ COLMAP_ADD_SOURCE_DIR(src/lib/PoissonRecon LIB_POISSON_RECON_SRCS *.h *.cpp *.in COLMAP_ADD_SOURCE_DIR(src/lib/SiftGPU LIB_SIFT_GPU_SRCS *.h *.cpp *.cu) COLMAP_ADD_SOURCE_DIR(src/lib/VLFeat LIB_VLFEAT_SRCS *.h *.c *.tc) -COLMAP_ADD_SOURCE_DIR(src/colmap/camera CAMERA_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/controllers CONTROLLERS_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/estimators ESTIMATORS_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/exe EXE_SRCS *.h *.cc) @@ -224,6 +225,7 @@ COLMAP_ADD_SOURCE_DIR(src/colmap/mvs MVS_SRCS *.h *.cc *.cu) COLMAP_ADD_SOURCE_DIR(src/colmap/optim OPTIM_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/retrieval RETRIEVAL_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/scene SCENE_SRCS *.h *.cc) +COLMAP_ADD_SOURCE_DIR(src/colmap/sensor SENSOR_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/sfm SFM_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/tools TOOLS_SRCS *.h *.cc) COLMAP_ADD_SOURCE_DIR(src/colmap/ui UI_SRCS *.h *.cc) @@ -238,7 +240,6 @@ add_library( ${LIB_POISSON_RECON_SRCS} ${LIB_SIFT_GPU_SRCS} ${LIB_VLFEAT_SRCS} - ${CAMERA_SRCS} ${CONTROLLERS_SRCS} ${ESTIMATORS_SRCS} ${EXE_SRCS} @@ -250,6 +251,7 @@ add_library( ${OPTIM_SRCS} ${RETRIEVAL_SRCS} ${SCENE_SRCS} + ${SENSOR_SRCS} ${SFM_SRCS} ${TOOLS_SRCS} ${UI_SRCS} diff --git a/src/colmap/CMakeLists.txt b/src/colmap/CMakeLists.txt index d355543106..2f468d0cbf 100644 --- a/src/colmap/CMakeLists.txt +++ b/src/colmap/CMakeLists.txt @@ -47,7 +47,6 @@ elseif(IS_GNU OR IS_CLANG) endif() endif() -add_subdirectory(camera) add_subdirectory(controllers) add_subdirectory(estimators) add_subdirectory(exe) @@ -59,6 +58,7 @@ add_subdirectory(mvs) add_subdirectory(optim) add_subdirectory(retrieval) add_subdirectory(scene) +add_subdirectory(sensor) add_subdirectory(sfm) add_subdirectory(tools) add_subdirectory(util) diff --git a/src/colmap/controllers/CMakeLists.txt b/src/colmap/controllers/CMakeLists.txt index 43b5c2043b..43ac0a3fd2 100644 --- a/src/colmap/controllers/CMakeLists.txt +++ b/src/colmap/controllers/CMakeLists.txt @@ -37,6 +37,9 @@ COLMAP_ADD_LIBRARY( automatic_reconstruction.h automatic_reconstruction.cc bundle_adjustment.h bundle_adjustment.cc hierarchical_mapper.h hierarchical_mapper.cc + feature_extraction.h feature_extraction.cc + feature_matching.h feature_matching.cc + image_reader.h image_reader.cc incremental_mapper.h incremental_mapper.cc option_manager.h option_manager.cc PUBLIC_LINK_LIBS diff --git a/src/colmap/controllers/automatic_reconstruction.cc b/src/colmap/controllers/automatic_reconstruction.cc index b66de674ea..94fd143afe 100644 --- a/src/colmap/controllers/automatic_reconstruction.cc +++ b/src/colmap/controllers/automatic_reconstruction.cc @@ -33,8 +33,8 @@ #include "colmap/controllers/incremental_mapper.h" #include "colmap/controllers/option_manager.h" -#include "colmap/feature/extraction.h" -#include "colmap/feature/matching.h" +#include "colmap/controllers/feature_extraction.h" +#include "colmap/controllers/feature_matching.h" #include "colmap/image/undistortion.h" #include "colmap/mvs/fusion.h" #include "colmap/mvs/meshing.h" diff --git a/src/colmap/feature/extraction.cc b/src/colmap/controllers/feature_extraction.cc similarity index 99% rename from src/colmap/feature/extraction.cc rename to src/colmap/controllers/feature_extraction.cc index 0c1ac0bec5..2a51068619 100644 --- a/src/colmap/feature/extraction.cc +++ b/src/colmap/controllers/feature_extraction.cc @@ -29,7 +29,7 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -#include "colmap/feature/extraction.h" +#include "colmap/controllers/feature_extraction.h" #include "colmap/feature/sift.h" #include "colmap/util/cuda.h" diff --git a/src/colmap/feature/extraction.h b/src/colmap/controllers/feature_extraction.h similarity index 99% rename from src/colmap/feature/extraction.h rename to src/colmap/controllers/feature_extraction.h index 2b6dada8cd..7c1c3d3c9a 100644 --- a/src/colmap/feature/extraction.h +++ b/src/colmap/controllers/feature_extraction.h @@ -32,7 +32,7 @@ #pragma once #include "colmap/feature/sift.h" -#include "colmap/image/reader.h" +#include "colmap/controllers/image_reader.h" #include "colmap/scene/database.h" #include "colmap/util/opengl_utils.h" #include "colmap/util/threading.h" diff --git a/src/colmap/feature/matching.cc b/src/colmap/controllers/feature_matching.cc similarity index 97% rename from src/colmap/feature/matching.cc rename to src/colmap/controllers/feature_matching.cc index 2f368f9fc7..7c3f0f31a7 100644 --- a/src/colmap/feature/matching.cc +++ b/src/colmap/controllers/feature_matching.cc @@ -29,7 +29,7 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -#include "colmap/feature/matching.h" +#include "colmap/controllers/feature_matching.h" #include "colmap/feature/utils.h" #include "colmap/geometry/gps.h" @@ -668,19 +668,21 @@ void TwoViewGeometryVerifier::Run() { const auto& points2 = FeatureKeypointsToPointsVector(*keypoints2); if (options_.multiple_models) { - data.two_view_geometry.EstimateMultiple(camera1, - points1, - camera2, - points2, - data.matches, - two_view_geometry_options_); + data.two_view_geometry = + EstimateMultipleTwoViewGeometries(camera1, + points1, + camera2, + points2, + data.matches, + two_view_geometry_options_); } else { - data.two_view_geometry.Estimate(camera1, - points1, - camera2, - points2, - data.matches, - two_view_geometry_options_); + data.two_view_geometry = + EstimateTwoViewGeometry(camera1, + points1, + camera2, + points2, + data.matches, + two_view_geometry_options_); } CHECK(output_queue_->Push(std::move(data))); @@ -1744,8 +1746,7 @@ void FeaturePairsFeatureMatcher::Run() { const auto keypoints1 = cache_.GetKeypoints(image1.ImageId()); const auto keypoints2 = cache_.GetKeypoints(image2.ImageId()); - TwoViewGeometry two_view_geometry; - TwoViewGeometry::Options two_view_geometry_options; + TwoViewGeometryOptions two_view_geometry_options; two_view_geometry_options.min_num_inliers = static_cast(match_options_.min_num_inliers); two_view_geometry_options.ransac_options.max_error = @@ -1759,12 +1760,13 @@ void FeaturePairsFeatureMatcher::Run() { two_view_geometry_options.ransac_options.min_inlier_ratio = match_options_.min_inlier_ratio; - two_view_geometry.Estimate(camera1, - FeatureKeypointsToPointsVector(*keypoints1), - camera2, - FeatureKeypointsToPointsVector(*keypoints2), - matches, - two_view_geometry_options); + TwoViewGeometry two_view_geometry = + EstimateTwoViewGeometry(camera1, + FeatureKeypointsToPointsVector(*keypoints1), + camera2, + FeatureKeypointsToPointsVector(*keypoints2), + matches, + two_view_geometry_options); database_.WriteTwoViewGeometry( image1.ImageId(), image2.ImageId(), two_view_geometry); diff --git a/src/colmap/feature/matching.h b/src/colmap/controllers/feature_matching.h similarity index 99% rename from src/colmap/feature/matching.h rename to src/colmap/controllers/feature_matching.h index f81641e781..7cfa673295 100644 --- a/src/colmap/feature/matching.h +++ b/src/colmap/controllers/feature_matching.h @@ -335,7 +335,7 @@ class TwoViewGeometryVerifier : public Thread { void Run() override; const SiftMatchingOptions options_; - TwoViewGeometry::Options two_view_geometry_options_; + TwoViewGeometryOptions two_view_geometry_options_; FeatureMatcherCache* cache_; JobQueue* input_queue_; JobQueue* output_queue_; diff --git a/src/colmap/controllers/hierarchical_mapper.cc b/src/colmap/controllers/hierarchical_mapper.cc index e511e54ff9..ef91edd39c 100644 --- a/src/colmap/controllers/hierarchical_mapper.cc +++ b/src/colmap/controllers/hierarchical_mapper.cc @@ -31,7 +31,7 @@ #include "colmap/controllers/hierarchical_mapper.h" -#include "colmap/scene/alignment.h" +#include "colmap/estimators/alignment.h" #include "colmap/scene/scene_clustering.h" #include "colmap/util/misc.h" diff --git a/src/colmap/controllers/hierarchical_mapper_test.cc b/src/colmap/controllers/hierarchical_mapper_test.cc index f5ed05c2f1..41c9593137 100644 --- a/src/colmap/controllers/hierarchical_mapper_test.cc +++ b/src/colmap/controllers/hierarchical_mapper_test.cc @@ -31,7 +31,7 @@ #include "colmap/controllers/hierarchical_mapper.h" -#include "colmap/scene/alignment.h" +#include "colmap/estimators/alignment.h" #include "colmap/scene/synthetic.h" #include "colmap/util/testing.h" diff --git a/src/colmap/image/reader.cc b/src/colmap/controllers/image_reader.cc similarity index 99% rename from src/colmap/image/reader.cc rename to src/colmap/controllers/image_reader.cc index 3404db46b1..ee909c10e4 100644 --- a/src/colmap/image/reader.cc +++ b/src/colmap/controllers/image_reader.cc @@ -29,9 +29,9 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -#include "colmap/image/reader.h" +#include "colmap/controllers/image_reader.h" -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/util/misc.h" namespace colmap { diff --git a/src/colmap/image/reader.h b/src/colmap/controllers/image_reader.h similarity index 99% rename from src/colmap/image/reader.h rename to src/colmap/controllers/image_reader.h index 1acfeb6388..2559e8c9f4 100644 --- a/src/colmap/image/reader.h +++ b/src/colmap/controllers/image_reader.h @@ -31,7 +31,7 @@ #pragma once -#include "colmap/image/bitmap.h" +#include "colmap/sensor/bitmap.h" #include "colmap/scene/database.h" #include "colmap/util/threading.h" diff --git a/src/colmap/controllers/incremental_mapper_test.cc b/src/colmap/controllers/incremental_mapper_test.cc index c349e10ecc..855102a905 100644 --- a/src/colmap/controllers/incremental_mapper_test.cc +++ b/src/colmap/controllers/incremental_mapper_test.cc @@ -31,7 +31,7 @@ #include "colmap/controllers/incremental_mapper.h" -#include "colmap/scene/alignment.h" +#include "colmap/estimators/alignment.h" #include "colmap/scene/synthetic.h" #include "colmap/util/testing.h" diff --git a/src/colmap/controllers/option_manager.cc b/src/colmap/controllers/option_manager.cc index 2b5b3bf629..ebd923e9c7 100644 --- a/src/colmap/controllers/option_manager.cc +++ b/src/colmap/controllers/option_manager.cc @@ -33,10 +33,10 @@ #include "colmap/controllers/incremental_mapper.h" #include "colmap/estimators/bundle_adjustment.h" -#include "colmap/feature/extraction.h" -#include "colmap/feature/matching.h" +#include "colmap/controllers/feature_extraction.h" +#include "colmap/controllers/feature_matching.h" #include "colmap/feature/sift.h" -#include "colmap/image/reader.h" +#include "colmap/controllers/image_reader.h" #include "colmap/math/random.h" #include "colmap/mvs/fusion.h" #include "colmap/mvs/meshing.h" diff --git a/src/colmap/estimators/CMakeLists.txt b/src/colmap/estimators/CMakeLists.txt index e261d0a19f..35edff09f4 100644 --- a/src/colmap/estimators/CMakeLists.txt +++ b/src/colmap/estimators/CMakeLists.txt @@ -36,6 +36,7 @@ COLMAP_ADD_LIBRARY( SRCS absolute_pose.h absolute_pose.cc affine_transform.h affine_transform.cc + alignment.h alignment.cc bundle_adjustment.h bundle_adjustment.cc coordinate_frame.h coordinate_frame.cc cost_functions.h @@ -57,6 +58,9 @@ COLMAP_ADD_LIBRARY( colmap_math colmap_feature colmap_geometry + colmap_sensor + colmap_image + colmap_scene Eigen3::Eigen Ceres::ceres ) @@ -126,8 +130,3 @@ COLMAP_ADD_TEST( SRCS translation_transform_test.cc LINK_LIBS colmap_estimators ) -COLMAP_ADD_TEST( - NAME two_view_geometry_test - SRCS two_view_geometry_test.cc - LINK_LIBS colmap_estimators -) diff --git a/src/colmap/scene/alignment.cc b/src/colmap/estimators/alignment.cc similarity index 99% rename from src/colmap/scene/alignment.cc rename to src/colmap/estimators/alignment.cc index b0776d223a..2a023a07f0 100644 --- a/src/colmap/scene/alignment.cc +++ b/src/colmap/estimators/alignment.cc @@ -29,7 +29,7 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -#include "colmap/scene/alignment.h" +#include "colmap/estimators/alignment.h" #include "colmap/estimators/similarity_transform.h" #include "colmap/geometry/pose.h" diff --git a/src/colmap/scene/alignment.h b/src/colmap/estimators/alignment.h similarity index 100% rename from src/colmap/scene/alignment.h rename to src/colmap/estimators/alignment.h diff --git a/src/colmap/estimators/bundle_adjustment.cc b/src/colmap/estimators/bundle_adjustment.cc index f640346058..2981c171eb 100644 --- a/src/colmap/estimators/bundle_adjustment.cc +++ b/src/colmap/estimators/bundle_adjustment.cc @@ -37,7 +37,7 @@ #include #endif -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/estimators/cost_functions.h" #include "colmap/scene/projection.h" #include "colmap/util/misc.h" diff --git a/src/colmap/estimators/bundle_adjustment_test.cc b/src/colmap/estimators/bundle_adjustment_test.cc index e3c7bf389d..6424f48481 100644 --- a/src/colmap/estimators/bundle_adjustment_test.cc +++ b/src/colmap/estimators/bundle_adjustment_test.cc @@ -31,7 +31,7 @@ #include "colmap/estimators/bundle_adjustment.h" -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/math/random.h" #include "colmap/scene/correspondence_graph.h" #include "colmap/scene/projection.h" diff --git a/src/colmap/estimators/cost_functions_test.cc b/src/colmap/estimators/cost_functions_test.cc index c583f1e076..952f932641 100644 --- a/src/colmap/estimators/cost_functions_test.cc +++ b/src/colmap/estimators/cost_functions_test.cc @@ -31,7 +31,7 @@ #include "colmap/estimators/cost_functions.h" -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/geometry/pose.h" #include diff --git a/src/colmap/estimators/essential_matrix_test.cc b/src/colmap/estimators/essential_matrix_test.cc index a557e97c9a..dd923b74e2 100644 --- a/src/colmap/estimators/essential_matrix_test.cc +++ b/src/colmap/estimators/essential_matrix_test.cc @@ -31,7 +31,7 @@ #include "colmap/geometry/essential_matrix.h" -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/estimators/essential_matrix.h" #include "colmap/geometry/pose.h" #include "colmap/math/random.h" diff --git a/src/colmap/estimators/pose.cc b/src/colmap/estimators/pose.cc index 4d35da68a5..f1e1cfadf9 100644 --- a/src/colmap/estimators/pose.cc +++ b/src/colmap/estimators/pose.cc @@ -31,7 +31,7 @@ #include "colmap/estimators/pose.h" -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/estimators/absolute_pose.h" #include "colmap/estimators/bundle_adjustment.h" #include "colmap/estimators/cost_functions.h" diff --git a/src/colmap/estimators/pose.h b/src/colmap/estimators/pose.h index 46c172aa41..11cbbfea42 100644 --- a/src/colmap/estimators/pose.h +++ b/src/colmap/estimators/pose.h @@ -31,7 +31,7 @@ #pragma once -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/geometry/rigid3.h" #include "colmap/optim/loransac.h" #include "colmap/scene/camera.h" diff --git a/src/colmap/estimators/two_view_geometry.cc b/src/colmap/estimators/two_view_geometry.cc index dd1ceb1f0e..05c781d69a 100644 --- a/src/colmap/estimators/two_view_geometry.cc +++ b/src/colmap/estimators/two_view_geometry.cc @@ -96,94 +96,236 @@ inline bool IsImagePointInBoundingBox(const Eigen::Vector2d& point, point.y() <= maxy; } -} // namespace +TwoViewGeometry EstimateCalibratedHomography( + const Camera& camera1, + const std::vector& points1, + const Camera& camera2, + const std::vector& points2, + const FeatureMatches& matches, + const TwoViewGeometryOptions& options) { + options.Check(); + + TwoViewGeometry geometry; + + if (matches.size() < options.min_num_inliers) { + geometry.config = TwoViewGeometry::ConfigurationType::DEGENERATE; + return geometry; + } + + // Extract corresponding points. + std::vector matched_points1(matches.size()); + std::vector matched_points2(matches.size()); + for (size_t i = 0; i < matches.size(); ++i) { + matched_points1[i] = points1[matches[i].point2D_idx1]; + matched_points2[i] = points2[matches[i].point2D_idx2]; + } + + // Estimate planar or panoramic model. + + LORANSAC H_ransac( + options.ransac_options); + const auto H_report = H_ransac.Estimate(matched_points1, matched_points2); + geometry.H = H_report.model; + + if (!H_report.success || + H_report.support.num_inliers < options.min_num_inliers) { + geometry.config = TwoViewGeometry::ConfigurationType::DEGENERATE; + return geometry; + } else { + geometry.config = TwoViewGeometry::ConfigurationType::PLANAR_OR_PANORAMIC; + } + + geometry.inlier_matches = ExtractInlierMatches( + matches, H_report.support.num_inliers, H_report.inlier_mask); + if (options.detect_watermark && DetectWatermark(camera1, + matched_points1, + camera2, + matched_points2, + H_report.support.num_inliers, + H_report.inlier_mask, + options)) { + geometry.config = TwoViewGeometry::ConfigurationType::WATERMARK; + } + + if (options.compute_relative_pose) { + EstimateTwoViewGeometryPose(camera1, points1, camera2, points2, &geometry); + } + + return geometry; +} + +TwoViewGeometry EstimateUncalibratedTwoViewGeometry( + const Camera& camera1, + const std::vector& points1, + const Camera& camera2, + const std::vector& points2, + const FeatureMatches& matches, + const TwoViewGeometryOptions& options) { + options.Check(); + + TwoViewGeometry geometry; + + if (matches.size() < options.min_num_inliers) { + geometry.config = TwoViewGeometry::ConfigurationType::DEGENERATE; + return geometry; + } + + // Extract corresponding points. + std::vector matched_points1(matches.size()); + std::vector matched_points2(matches.size()); + for (size_t i = 0; i < matches.size(); ++i) { + matched_points1[i] = points1[matches[i].point2D_idx1]; + matched_points2[i] = points2[matches[i].point2D_idx2]; + } + + // Estimate epipolar model. + + LORANSAC + F_ransac(options.ransac_options); + const auto F_report = F_ransac.Estimate(matched_points1, matched_points2); + geometry.F = F_report.model; + + // Estimate planar or panoramic model. + + LORANSAC H_ransac( + options.ransac_options); + const auto H_report = H_ransac.Estimate(matched_points1, matched_points2); + geometry.H = H_report.model; + + if ((!F_report.success && !H_report.success) || + (F_report.support.num_inliers < options.min_num_inliers && + H_report.support.num_inliers < options.min_num_inliers)) { + geometry.config = TwoViewGeometry::ConfigurationType::DEGENERATE; + return geometry; + } + + // Determine inlier ratios of different models. + + const double H_F_inlier_ratio = + static_cast(H_report.support.num_inliers) / + F_report.support.num_inliers; + + const std::vector* best_inlier_mask = &F_report.inlier_mask; + size_t num_inliers = F_report.support.num_inliers; + + if (H_F_inlier_ratio > options.max_H_inlier_ratio) { + geometry.config = TwoViewGeometry::ConfigurationType::PLANAR_OR_PANORAMIC; + if (H_report.support.num_inliers >= F_report.support.num_inliers) { + num_inliers = H_report.support.num_inliers; + best_inlier_mask = &H_report.inlier_mask; + } + } else { + geometry.config = TwoViewGeometry::ConfigurationType::UNCALIBRATED; + } + + geometry.inlier_matches = + ExtractInlierMatches(matches, num_inliers, *best_inlier_mask); + + if (options.detect_watermark && DetectWatermark(camera1, + matched_points1, + camera2, + matched_points2, + num_inliers, + *best_inlier_mask, + options)) { + geometry.config = TwoViewGeometry::ConfigurationType::WATERMARK; + } -void TwoViewGeometry::Invert() { - F.transposeInPlace(); - E.transposeInPlace(); - H = H.inverse().eval(); - cam2_from_cam1 = Inverse(cam2_from_cam1); - for (auto& match : inlier_matches) { - std::swap(match.point2D_idx1, match.point2D_idx2); + if (options.compute_relative_pose) { + EstimateTwoViewGeometryPose(camera1, points1, camera2, points2, &geometry); } + + return geometry; } -void TwoViewGeometry::Estimate(const Camera& camera1, - const std::vector& points1, - const Camera& camera2, - const std::vector& points2, - const FeatureMatches& matches, - const Options& options) { +} // namespace + +TwoViewGeometry EstimateTwoViewGeometry( + const Camera& camera1, + const std::vector& points1, + const Camera& camera2, + const std::vector& points2, + const FeatureMatches& matches, + const TwoViewGeometryOptions& options) { if (options.force_H_use) { - EstimateHomography(camera1, points1, camera2, points2, matches, options); + return EstimateCalibratedHomography( + camera1, points1, camera2, points2, matches, options); } else if (camera1.HasPriorFocalLength() && camera2.HasPriorFocalLength()) { - EstimateCalibrated(camera1, points1, camera2, points2, matches, options); + return EstimateCalibratedTwoViewGeometry( + camera1, points1, camera2, points2, matches, options); } else { - EstimateUncalibrated(camera1, points1, camera2, points2, matches, options); + return EstimateUncalibratedTwoViewGeometry( + camera1, points1, camera2, points2, matches, options); } } -void TwoViewGeometry::EstimateMultiple( +TwoViewGeometry EstimateMultipleTwoViewGeometries( const Camera& camera1, const std::vector& points1, const Camera& camera2, const std::vector& points2, const FeatureMatches& matches, - const Options& options) { + const TwoViewGeometryOptions& options) { FeatureMatches remaining_matches = matches; - std::vector two_view_geometries; + TwoViewGeometry multi_geometry; + std::vector geometries; while (true) { - TwoViewGeometry two_view_geometry; - two_view_geometry.Estimate( + TwoViewGeometry geometry = EstimateTwoViewGeometry( camera1, points1, camera2, points2, remaining_matches, options); - if (two_view_geometry.config == ConfigurationType::DEGENERATE) { + if (geometry.config == TwoViewGeometry::ConfigurationType::DEGENERATE) { break; } if (options.multiple_ignore_watermark) { - if (two_view_geometry.config != ConfigurationType::WATERMARK) { - two_view_geometries.push_back(two_view_geometry); + if (geometry.config != TwoViewGeometry::ConfigurationType::WATERMARK) { + geometries.push_back(geometry); } } else { - two_view_geometries.push_back(two_view_geometry); + geometries.push_back(geometry); } - remaining_matches = ExtractOutlierMatches(remaining_matches, - two_view_geometry.inlier_matches); + remaining_matches = + ExtractOutlierMatches(remaining_matches, geometry.inlier_matches); } - if (two_view_geometries.empty()) { - config = ConfigurationType::DEGENERATE; - } else if (two_view_geometries.size() == 1) { - *this = two_view_geometries[0]; + if (geometries.empty()) { + multi_geometry.config = TwoViewGeometry::ConfigurationType::DEGENERATE; + } else if (geometries.size() == 1) { + multi_geometry = geometries[0]; } else { - config = ConfigurationType::MULTIPLE; - - for (const auto& two_view_geometry : two_view_geometries) { - inlier_matches.insert(inlier_matches.end(), - two_view_geometry.inlier_matches.begin(), - two_view_geometry.inlier_matches.end()); + multi_geometry.config = TwoViewGeometry::ConfigurationType::MULTIPLE; + for (const auto& geometry : geometries) { + multi_geometry.inlier_matches.insert(multi_geometry.inlier_matches.end(), + geometry.inlier_matches.begin(), + geometry.inlier_matches.end()); } } + + return multi_geometry; } -bool TwoViewGeometry::EstimateRelativePose( - const Camera& camera1, - const std::vector& points1, - const Camera& camera2, - const std::vector& points2) { +bool EstimateTwoViewGeometryPose(const Camera& camera1, + const std::vector& points1, + const Camera& camera2, + const std::vector& points2, + TwoViewGeometry* geometry) { // We need a valid epopolar geometry to estimate the relative pose. - if (config != CALIBRATED && config != UNCALIBRATED && config != PLANAR && - config != PANORAMIC && config != PLANAR_OR_PANORAMIC) { + if (geometry->config != TwoViewGeometry::ConfigurationType::CALIBRATED && + geometry->config != TwoViewGeometry::ConfigurationType::UNCALIBRATED && + geometry->config != TwoViewGeometry::ConfigurationType::PLANAR && + geometry->config != TwoViewGeometry::ConfigurationType::PANORAMIC && + geometry->config != + TwoViewGeometry::ConfigurationType::PLANAR_OR_PANORAMIC) { return false; } // Extract normalized inlier points. std::vector inlier_points1_normalized; - inlier_points1_normalized.reserve(inlier_matches.size()); + inlier_points1_normalized.reserve(geometry->inlier_matches.size()); std::vector inlier_points2_normalized; - inlier_points2_normalized.reserve(inlier_matches.size()); - for (const auto& match : inlier_matches) { + inlier_points2_normalized.reserve(geometry->inlier_matches.size()); + for (const auto& match : geometry->inlier_matches) { inlier_points1_normalized.push_back( camera1.CamFromImg(points1[match.point2D_idx1])); inlier_points2_normalized.push_back( @@ -193,68 +335,77 @@ bool TwoViewGeometry::EstimateRelativePose( Eigen::Matrix3d cam2_from_cam1_rot_mat; std::vector points3D; - if (config == CALIBRATED || config == UNCALIBRATED) { + if (geometry->config == TwoViewGeometry::ConfigurationType::CALIBRATED || + geometry->config == TwoViewGeometry::ConfigurationType::UNCALIBRATED) { // Try to recover relative pose for calibrated and uncalibrated // configurations. In the uncalibrated case, this most likely leads to a // ill-defined reconstruction, but sometimes it succeeds anyways after e.g. // subsequent bundle-adjustment etc. - PoseFromEssentialMatrix(E, + PoseFromEssentialMatrix(geometry->E, inlier_points1_normalized, inlier_points2_normalized, &cam2_from_cam1_rot_mat, - &cam2_from_cam1.translation, + &geometry->cam2_from_cam1.translation, &points3D); - } else if (config == PLANAR || config == PANORAMIC || - config == PLANAR_OR_PANORAMIC) { + } else if (geometry->config == TwoViewGeometry::ConfigurationType::PLANAR || + geometry->config == + TwoViewGeometry::ConfigurationType::PANORAMIC || + geometry->config == + TwoViewGeometry::ConfigurationType::PLANAR_OR_PANORAMIC) { Eigen::Vector3d normal; - PoseFromHomographyMatrix(H, + PoseFromHomographyMatrix(geometry->H, camera1.CalibrationMatrix(), camera2.CalibrationMatrix(), inlier_points1_normalized, inlier_points2_normalized, &cam2_from_cam1_rot_mat, - &cam2_from_cam1.translation, + &geometry->cam2_from_cam1.translation, &normal, &points3D); } else { return false; } - cam2_from_cam1.rotation = Eigen::Quaterniond(cam2_from_cam1_rot_mat); + geometry->cam2_from_cam1.rotation = + Eigen::Quaterniond(cam2_from_cam1_rot_mat); if (points3D.empty()) { - tri_angle = 0; + geometry->tri_angle = 0; } else { - tri_angle = Median(CalculateTriangulationAngles( - Eigen::Vector3d::Zero(), - -cam2_from_cam1_rot_mat.transpose() * cam2_from_cam1.translation, - points3D)); + geometry->tri_angle = Median( + CalculateTriangulationAngles(Eigen::Vector3d::Zero(), + -cam2_from_cam1_rot_mat.transpose() * + geometry->cam2_from_cam1.translation, + points3D)); } - if (config == PLANAR_OR_PANORAMIC) { - if (cam2_from_cam1.translation.norm() == 0) { - config = PANORAMIC; - tri_angle = 0; + if (geometry->config == + TwoViewGeometry::ConfigurationType::PLANAR_OR_PANORAMIC) { + if (geometry->cam2_from_cam1.translation.norm() == 0) { + geometry->config = TwoViewGeometry::ConfigurationType::PANORAMIC; + geometry->tri_angle = 0; } else { - config = PLANAR; + geometry->config = TwoViewGeometry::ConfigurationType::PLANAR; } } return true; } -void TwoViewGeometry::EstimateCalibrated( +TwoViewGeometry EstimateCalibratedTwoViewGeometry( const Camera& camera1, const std::vector& points1, const Camera& camera2, const std::vector& points2, const FeatureMatches& matches, - const Options& options) { + const TwoViewGeometryOptions& options) { options.Check(); + TwoViewGeometry geometry; + if (matches.size() < options.min_num_inliers) { - config = ConfigurationType::DEGENERATE; - return; + geometry.config = TwoViewGeometry::ConfigurationType::DEGENERATE; + return geometry; } // Extract corresponding points. @@ -283,27 +434,27 @@ void TwoViewGeometry::EstimateCalibrated( E_ransac(E_ransac_options); const auto E_report = E_ransac.Estimate(matched_points1_normalized, matched_points2_normalized); - E = E_report.model; + geometry.E = E_report.model; LORANSAC F_ransac(options.ransac_options); const auto F_report = F_ransac.Estimate(matched_points1, matched_points2); - F = F_report.model; + geometry.F = F_report.model; // Estimate planar or panoramic model. LORANSAC H_ransac( options.ransac_options); const auto H_report = H_ransac.Estimate(matched_points1, matched_points2); - H = H_report.model; + geometry.H = H_report.model; if ((!E_report.success && !F_report.success && !H_report.success) || (E_report.support.num_inliers < options.min_num_inliers && F_report.support.num_inliers < options.min_num_inliers && H_report.support.num_inliers < options.min_num_inliers)) { - config = ConfigurationType::DEGENERATE; - return; + geometry.config = TwoViewGeometry::ConfigurationType::DEGENERATE; + return geometry; } // Determine inlier ratios of different models. @@ -335,13 +486,13 @@ void TwoViewGeometry::EstimateCalibrated( } if (H_E_inlier_ratio > options.max_H_inlier_ratio) { - config = PLANAR_OR_PANORAMIC; + geometry.config = TwoViewGeometry::ConfigurationType::PLANAR_OR_PANORAMIC; if (H_report.support.num_inliers > num_inliers) { num_inliers = H_report.support.num_inliers; best_inlier_mask = &H_report.inlier_mask; } } else { - config = ConfigurationType::CALIBRATED; + geometry.config = TwoViewGeometry::ConfigurationType::CALIBRATED; } } else if (F_report.success && F_report.support.num_inliers >= options.min_num_inliers) { @@ -351,26 +502,26 @@ void TwoViewGeometry::EstimateCalibrated( best_inlier_mask = &F_report.inlier_mask; if (H_F_inlier_ratio > options.max_H_inlier_ratio) { - config = ConfigurationType::PLANAR_OR_PANORAMIC; + geometry.config = TwoViewGeometry::ConfigurationType::PLANAR_OR_PANORAMIC; if (H_report.support.num_inliers > num_inliers) { num_inliers = H_report.support.num_inliers; best_inlier_mask = &H_report.inlier_mask; } } else { - config = ConfigurationType::UNCALIBRATED; + geometry.config = TwoViewGeometry::ConfigurationType::UNCALIBRATED; } } else if (H_report.success && H_report.support.num_inliers >= options.min_num_inliers) { num_inliers = H_report.support.num_inliers; best_inlier_mask = &H_report.inlier_mask; - config = ConfigurationType::PLANAR_OR_PANORAMIC; + geometry.config = TwoViewGeometry::ConfigurationType::PLANAR_OR_PANORAMIC; } else { - config = ConfigurationType::DEGENERATE; - return; + geometry.config = TwoViewGeometry::ConfigurationType::DEGENERATE; + return geometry; } if (best_inlier_mask != nullptr) { - inlier_matches = + geometry.inlier_matches = ExtractInlierMatches(matches, num_inliers, *best_inlier_mask); if (options.detect_watermark && DetectWatermark(camera1, @@ -380,158 +531,25 @@ void TwoViewGeometry::EstimateCalibrated( num_inliers, *best_inlier_mask, options)) { - config = ConfigurationType::WATERMARK; + geometry.config = TwoViewGeometry::ConfigurationType::WATERMARK; } if (options.compute_relative_pose) { - EstimateRelativePose(camera1, points1, camera2, points2); - } - } -} - -void TwoViewGeometry::EstimateUncalibrated( - const Camera& camera1, - const std::vector& points1, - const Camera& camera2, - const std::vector& points2, - const FeatureMatches& matches, - const Options& options) { - options.Check(); - - if (matches.size() < options.min_num_inliers) { - config = ConfigurationType::DEGENERATE; - return; - } - - // Extract corresponding points. - std::vector matched_points1(matches.size()); - std::vector matched_points2(matches.size()); - for (size_t i = 0; i < matches.size(); ++i) { - matched_points1[i] = points1[matches[i].point2D_idx1]; - matched_points2[i] = points2[matches[i].point2D_idx2]; - } - - // Estimate epipolar model. - - LORANSAC - F_ransac(options.ransac_options); - const auto F_report = F_ransac.Estimate(matched_points1, matched_points2); - F = F_report.model; - - // Estimate planar or panoramic model. - - LORANSAC H_ransac( - options.ransac_options); - const auto H_report = H_ransac.Estimate(matched_points1, matched_points2); - H = H_report.model; - - if ((!F_report.success && !H_report.success) || - (F_report.support.num_inliers < options.min_num_inliers && - H_report.support.num_inliers < options.min_num_inliers)) { - config = ConfigurationType::DEGENERATE; - return; - } - - // Determine inlier ratios of different models. - - const double H_F_inlier_ratio = - static_cast(H_report.support.num_inliers) / - F_report.support.num_inliers; - - const std::vector* best_inlier_mask = &F_report.inlier_mask; - size_t num_inliers = F_report.support.num_inliers; - - if (H_F_inlier_ratio > options.max_H_inlier_ratio) { - config = ConfigurationType::PLANAR_OR_PANORAMIC; - if (H_report.support.num_inliers >= F_report.support.num_inliers) { - num_inliers = H_report.support.num_inliers; - best_inlier_mask = &H_report.inlier_mask; + EstimateTwoViewGeometryPose( + camera1, points1, camera2, points2, &geometry); } - } else { - config = ConfigurationType::UNCALIBRATED; } - inlier_matches = - ExtractInlierMatches(matches, num_inliers, *best_inlier_mask); - - if (options.detect_watermark && DetectWatermark(camera1, - matched_points1, - camera2, - matched_points2, - num_inliers, - *best_inlier_mask, - options)) { - config = ConfigurationType::WATERMARK; - } - - if (options.compute_relative_pose) { - EstimateRelativePose(camera1, points1, camera2, points2); - } -} - -void TwoViewGeometry::EstimateHomography( - const Camera& camera1, - const std::vector& points1, - const Camera& camera2, - const std::vector& points2, - const FeatureMatches& matches, - const Options& options) { - options.Check(); - - if (matches.size() < options.min_num_inliers) { - config = ConfigurationType::DEGENERATE; - return; - } - - // Extract corresponding points. - std::vector matched_points1(matches.size()); - std::vector matched_points2(matches.size()); - for (size_t i = 0; i < matches.size(); ++i) { - matched_points1[i] = points1[matches[i].point2D_idx1]; - matched_points2[i] = points2[matches[i].point2D_idx2]; - } - - // Estimate planar or panoramic model. - - LORANSAC H_ransac( - options.ransac_options); - const auto H_report = H_ransac.Estimate(matched_points1, matched_points2); - H = H_report.model; - - if (!H_report.success || - H_report.support.num_inliers < options.min_num_inliers) { - config = ConfigurationType::DEGENERATE; - return; - } else { - config = ConfigurationType::PLANAR_OR_PANORAMIC; - } - - inlier_matches = ExtractInlierMatches( - matches, H_report.support.num_inliers, H_report.inlier_mask); - if (options.detect_watermark && DetectWatermark(camera1, - matched_points1, - camera2, - matched_points2, - H_report.support.num_inliers, - H_report.inlier_mask, - options)) { - config = ConfigurationType::WATERMARK; - } - - if (options.compute_relative_pose) { - EstimateRelativePose(camera1, points1, camera2, points2); - } + return geometry; } -bool TwoViewGeometry::DetectWatermark( - const Camera& camera1, - const std::vector& points1, - const Camera& camera2, - const std::vector& points2, - const size_t num_inliers, - const std::vector& inlier_mask, - const Options& options) { +bool DetectWatermark(const Camera& camera1, + const std::vector& points1, + const Camera& camera2, + const std::vector& points2, + const size_t num_inliers, + const std::vector& inlier_mask, + const TwoViewGeometryOptions& options) { options.Check(); // Check if inlier points in border region and extract inlier matches. diff --git a/src/colmap/estimators/two_view_geometry.h b/src/colmap/estimators/two_view_geometry.h index 9cd3e6249e..33a590b52a 100644 --- a/src/colmap/estimators/two_view_geometry.h +++ b/src/colmap/estimators/two_view_geometry.h @@ -35,233 +35,154 @@ #include "colmap/geometry/rigid3.h" #include "colmap/optim/ransac.h" #include "colmap/scene/camera.h" +#include "colmap/scene/two_view_geometry.h" #include "colmap/util/logging.h" -namespace colmap { - -// Two-view geometry estimator. -struct TwoViewGeometry { - // The configuration of the estimated two-view geometry. - enum ConfigurationType { - UNDEFINED = 0, - // Degenerate configuration (e.g., no overlap or not enough inliers). - DEGENERATE = 1, - // Essential matrix. - CALIBRATED = 2, - // Fundamental matrix. - UNCALIBRATED = 3, - // Homography, planar scene with baseline. - PLANAR = 4, - // Homography, pure rotation without baseline. - PANORAMIC = 5, - // Homography, planar or panoramic. - PLANAR_OR_PANORAMIC = 6, - // Watermark, pure 2D translation in image borders. - WATERMARK = 7, - // Multi-model configuration, i.e. the inlier matches result from multiple - // individual, non-degenerate configurations. - MULTIPLE = 8, - }; - - // Estimation options. - struct Options { - // Minimum number of inliers for non-degenerate two-view geometry. - size_t min_num_inliers = 15; - - // In case both cameras are calibrated, the calibration is verified by - // estimating an essential and fundamental matrix and comparing their - // fractions of number of inliers. If the essential matrix produces - // a similar number of inliers (`min_E_F_inlier_ratio * F_num_inliers`), - // the calibration is assumed to be correct. - double min_E_F_inlier_ratio = 0.95; - - // In case an epipolar geometry can be verified, it is checked whether - // the geometry describes a planar scene or panoramic view (pure rotation) - // described by a homography. This is a degenerate case, since epipolar - // geometry is only defined for a moving camera. If the inlier ratio of - // a homography comes close to the inlier ratio of the epipolar geometry, - // a planar or panoramic configuration is assumed. - double max_H_inlier_ratio = 0.8; - - // In case of valid two-view geometry, it is checked whether the geometry - // describes a pure translation in the border region of the image. If more - // than a certain ratio of inlier points conform with a pure image - // translation, a watermark is assumed. - double watermark_min_inlier_ratio = 0.7; - - // Watermark matches have to be in the border region of the image. The - // border region is defined as the area around the image borders and - // is defined as a fraction of the image diagonal. - double watermark_border_size = 0.1; - - // Whether to enable watermark detection. A watermark causes a pure - // translation in the image space with inliers in the border region. - bool detect_watermark = true; - - // Whether to ignore watermark models in multiple model estimation. - bool multiple_ignore_watermark = true; - - // In case the user asks for it, only going to estimate a Homography - // between both cameras. - bool force_H_use = false; - - // Whether to compute the relative pose between the two views. - bool compute_relative_pose = false; - - // Options used to robustly estimate the geometry. - RANSACOptions ransac_options; - - void Check() const { - CHECK_GE(min_num_inliers, 0); - CHECK_GE(min_E_F_inlier_ratio, 0); - CHECK_LE(min_E_F_inlier_ratio, 1); - CHECK_GE(max_H_inlier_ratio, 0); - CHECK_LE(max_H_inlier_ratio, 1); - CHECK_GE(watermark_min_inlier_ratio, 0); - CHECK_LE(watermark_min_inlier_ratio, 1); - CHECK_GE(watermark_border_size, 0); - CHECK_LE(watermark_border_size, 1); - ransac_options.Check(); - } - }; - - TwoViewGeometry() - : config(ConfigurationType::UNDEFINED), - E(Eigen::Matrix3d::Zero()), - F(Eigen::Matrix3d::Zero()), - H(Eigen::Matrix3d::Zero()), - tri_angle(0) {} - - // Invert the two-view geometry in-place. - void Invert(); - - // Estimate two-view geometry from calibrated or uncalibrated image pair, - // depending on whether a prior focal length is given or not. - // - // @param camera1 Camera of first image. - // @param points1 Feature points in first image. - // @param camera2 Camera of second image. - // @param points2 Feature points in second image. - // @param matches Feature matches between first and second image. - // @param options Two-view geometry estimation options. - void Estimate(const Camera& camera1, - const std::vector& points1, - const Camera& camera2, - const std::vector& points2, - const FeatureMatches& matches, - const Options& options); +#include - // Recursively estimate multiple configurations by removing the previous set - // of inliers from the matches until not enough inliers are found. Inlier - // matches are concatenated and the configuration type is `MULTIPLE` if - // multiple models could be estimated. This is useful to estimate the two-view - // geometry for images with large distortion or multiple rigidly moving - // objects in the scene. - // - // Note that in case the model type is `MULTIPLE`, only the `inlier_matches` - // field will be initialized. - // - // @param camera1 Camera of first image. - // @param points1 Feature points in first image. - // @param camera2 Camera of second image. - // @param points2 Feature points in second image. - // @param matches Feature matches between first and second image. - // @param options Two-view geometry estimation options. - void EstimateMultiple(const Camera& camera1, - const std::vector& points1, - const Camera& camera2, - const std::vector& points2, - const FeatureMatches& matches, - const Options& options); - - // Estimate two-view geometry and its relative pose from a calibrated or an - // uncalibrated image pair. - // - // @param camera1 Camera of first image. - // @param points1 Feature points in first image. - // @param camera2 Camera of second image. - // @param points2 Feature points in second image. - // @param matches Feature matches between first and second image. - // @param options Two-view geometry estimation options. - bool EstimateRelativePose(const Camera& camera1, - const std::vector& points1, - const Camera& camera2, - const std::vector& points2); - - // Estimate two-view geometry from calibrated image pair. - // - // @param camera1 Camera of first image. - // @param points1 Feature points in first image. - // @param camera2 Camera of second image. - // @param points2 Feature points in second image. - // @param matches Feature matches between first and second image. - // @param options Two-view geometry estimation options. - void EstimateCalibrated(const Camera& camera1, - const std::vector& points1, - const Camera& camera2, - const std::vector& points2, - const FeatureMatches& matches, - const Options& options); - - // Estimate two-view geometry from uncalibrated image pair. - // - // @param camera1 Camera of first image. - // @param points1 Feature points in first image. - // @param camera2 Camera of second image. - // @param points2 Feature points in second image. - // @param matches Feature matches between first and second image. - // @param options Two-view geometry estimation options. - void EstimateUncalibrated(const Camera& camera1, - const std::vector& points1, - const Camera& camera2, - const std::vector& points2, - const FeatureMatches& matches, - const Options& options); - - // Estimate two-view geometry using a Homography, - // depending on the option was user specified or not. - // - // @param camera1 Camera of first image. - // @param points1 Feature points in first image. - // @param camera2 Camera of second image. - // @param points2 Feature points in second image. - // @param matches Feature matches between first and second image. - // @param options Two-view geometry estimation options. - void EstimateHomography(const Camera& camera1, - const std::vector& points1, - const Camera& camera2, - const std::vector& points2, - const FeatureMatches& matches, - const Options& options); - - // Detect if inlier matches are caused by a watermark. - // A watermark causes a pure translation in the border are of the image. - static bool DetectWatermark(const Camera& camera1, - const std::vector& points1, - const Camera& camera2, - const std::vector& points2, - size_t num_inliers, - const std::vector& inlier_mask, - const Options& options); - - // One of `ConfigurationType`. - int config; - - // Essential matrix. - Eigen::Matrix3d E; - // Fundamental matrix. - Eigen::Matrix3d F; - // Homography matrix. - Eigen::Matrix3d H; - - // Relative pose. - Rigid3d cam2_from_cam1; - - // Inlier matches of the configuration. - FeatureMatches inlier_matches; +namespace colmap { - // Median triangulation angle. - double tri_angle; +// Estimation options. +struct TwoViewGeometryOptions { + // Minimum number of inliers for non-degenerate two-view geometry. + size_t min_num_inliers = 15; + + // In case both cameras are calibrated, the calibration is verified by + // estimating an essential and fundamental matrix and comparing their + // fractions of number of inliers. If the essential matrix produces + // a similar number of inliers (`min_E_F_inlier_ratio * F_num_inliers`), + // the calibration is assumed to be correct. + double min_E_F_inlier_ratio = 0.95; + + // In case an epipolar geometry can be verified, it is checked whether + // the geometry describes a planar scene or panoramic view (pure rotation) + // described by a homography. This is a degenerate case, since epipolar + // geometry is only defined for a moving camera. If the inlier ratio of + // a homography comes close to the inlier ratio of the epipolar geometry, + // a planar or panoramic configuration is assumed. + double max_H_inlier_ratio = 0.8; + + // In case of valid two-view geometry, it is checked whether the geometry + // describes a pure translation in the border region of the image. If more + // than a certain ratio of inlier points conform with a pure image + // translation, a watermark is assumed. + double watermark_min_inlier_ratio = 0.7; + + // Watermark matches have to be in the border region of the image. The + // border region is defined as the area around the image borders and + // is defined as a fraction of the image diagonal. + double watermark_border_size = 0.1; + + // Whether to enable watermark detection. A watermark causes a pure + // translation in the image space with inliers in the border region. + bool detect_watermark = true; + + // Whether to ignore watermark models in multiple model estimation. + bool multiple_ignore_watermark = true; + + // In case the user asks for it, only going to estimate a Homography + // between both cameras. + bool force_H_use = false; + + // Whether to compute the relative pose between the two views. + bool compute_relative_pose = false; + + // TwoViewGeometryOptions used to robustly estimate the geometry. + RANSACOptions ransac_options; + + void Check() const { + CHECK_GE(min_num_inliers, 0); + CHECK_GE(min_E_F_inlier_ratio, 0); + CHECK_LE(min_E_F_inlier_ratio, 1); + CHECK_GE(max_H_inlier_ratio, 0); + CHECK_LE(max_H_inlier_ratio, 1); + CHECK_GE(watermark_min_inlier_ratio, 0); + CHECK_LE(watermark_min_inlier_ratio, 1); + CHECK_GE(watermark_border_size, 0); + CHECK_LE(watermark_border_size, 1); + ransac_options.Check(); + } }; +// Estimate two-view geometry from calibrated or uncalibrated image pair, +// depending on whether a prior focal length is given or not. +// +// @param camera1 Camera of first image. +// @param points1 Feature points in first image. +// @param camera2 Camera of second image. +// @param points2 Feature points in second image. +// @param matches Feature matches between first and second image. +// @param options Two-view geometry estimation options. +TwoViewGeometry EstimateTwoViewGeometry( + const Camera& camera1, + const std::vector& points1, + const Camera& camera2, + const std::vector& points2, + const FeatureMatches& matches, + const TwoViewGeometryOptions& options); + +// Recursively estimate multiple configurations by removing the previous set +// of inliers from the matches until not enough inliers are found. Inlier +// matches are concatenated and the configuration type is `MULTIPLE` if +// multiple models could be estimated. This is useful to estimate the two-view +// geometry for images with large distortion or multiple rigidly moving +// objects in the scene. +// +// Note that in case the model type is `MULTIPLE`, only the `inlier_matches` +// field will be initialized. +// +// @param camera1 Camera of first image. +// @param points1 Feature points in first image. +// @param camera2 Camera of second image. +// @param points2 Feature points in second image. +// @param matches Feature matches between first and second image. +// @param options Two-view geometry estimation options. +TwoViewGeometry EstimateMultipleTwoViewGeometries( + const Camera& camera1, + const std::vector& points1, + const Camera& camera2, + const std::vector& points2, + const FeatureMatches& matches, + const TwoViewGeometryOptions& options); + +// Estimate relative pose for two-view geometry. +// +// @param camera1 Camera of first image. +// @param points1 Feature points in first image. +// @param camera2 Camera of second image. +// @param points2 Feature points in second image. +// @param matches Feature matches between first and second image. +// @param options Two-view geometry estimation options. +bool EstimateTwoViewGeometryPose(const Camera& camera1, + const std::vector& points1, + const Camera& camera2, + const std::vector& points2, + TwoViewGeometry* geometry); + +// Estimate two-view geometry from calibrated image pair. +// +// @param camera1 Camera of first image. +// @param points1 Feature points in first image. +// @param camera2 Camera of second image. +// @param points2 Feature points in second image. +// @param matches Feature matches between first and second image. +// @param options Two-view geometry estimation options. +TwoViewGeometry EstimateCalibratedTwoViewGeometry( + const Camera& camera1, + const std::vector& points1, + const Camera& camera2, + const std::vector& points2, + const FeatureMatches& matches, + const TwoViewGeometryOptions& options); + +// Detect if inlier matches are caused by a watermark. +// A watermark causes a pure translation in the border are of the image. +bool DetectWatermark(const Camera& camera1, + const std::vector& points1, + const Camera& camera2, + const std::vector& points2, + size_t num_inliers, + const std::vector& inlier_mask, + const TwoViewGeometryOptions& options); + } // namespace colmap diff --git a/src/colmap/exe/feature.cc b/src/colmap/exe/feature.cc index 361a29bb09..3531a74572 100644 --- a/src/colmap/exe/feature.cc +++ b/src/colmap/exe/feature.cc @@ -31,12 +31,12 @@ #include "colmap/exe/feature.h" -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/controllers/option_manager.h" #include "colmap/exe/gui.h" -#include "colmap/feature/extraction.h" -#include "colmap/feature/matching.h" -#include "colmap/image/reader.h" +#include "colmap/controllers/feature_extraction.h" +#include "colmap/controllers/feature_matching.h" +#include "colmap/controllers/image_reader.h" #include "colmap/util/misc.h" #include "colmap/util/opengl_utils.h" diff --git a/src/colmap/exe/feature.h b/src/colmap/exe/feature.h index 381adddc2a..f58627b98d 100644 --- a/src/colmap/exe/feature.h +++ b/src/colmap/exe/feature.h @@ -31,7 +31,7 @@ #pragma once -#include "colmap/image/reader.h" +#include "colmap/controllers/image_reader.h" namespace colmap { diff --git a/src/colmap/exe/model.cc b/src/colmap/exe/model.cc index ac3b937a04..c96c07b354 100644 --- a/src/colmap/exe/model.cc +++ b/src/colmap/exe/model.cc @@ -32,10 +32,11 @@ #include "colmap/exe/model.h" #include "colmap/controllers/option_manager.h" +#include "colmap/estimators/alignment.h" #include "colmap/estimators/coordinate_frame.h" #include "colmap/geometry/gps.h" #include "colmap/geometry/pose.h" -#include "colmap/scene/alignment.h" +#include "colmap/optim/ransac.h" #include "colmap/util/misc.h" #include "colmap/util/threading.h" diff --git a/src/colmap/exe/vocab_tree.cc b/src/colmap/exe/vocab_tree.cc index e641c85589..ea15c87015 100644 --- a/src/colmap/exe/vocab_tree.cc +++ b/src/colmap/exe/vocab_tree.cc @@ -32,7 +32,7 @@ #include "colmap/exe/vocab_tree.h" #include "colmap/controllers/option_manager.h" -#include "colmap/feature/matching.h" +#include "colmap/controllers/feature_matching.h" #include "colmap/feature/sift.h" #include "colmap/feature/utils.h" #include "colmap/retrieval/visual_index.h" diff --git a/src/colmap/feature/CMakeLists.txt b/src/colmap/feature/CMakeLists.txt index a1487e501a..af46fc5fa0 100644 --- a/src/colmap/feature/CMakeLists.txt +++ b/src/colmap/feature/CMakeLists.txt @@ -34,8 +34,6 @@ set(FOLDER_NAME "feature") COLMAP_ADD_LIBRARY( NAME colmap_feature SRCS - extraction.h extraction.cc - matching.h matching.cc sift.h sift.cc types.h types.cc utils.h utils.cc @@ -43,7 +41,8 @@ COLMAP_ADD_LIBRARY( Eigen3::Eigen PRIVATE_LINK_LIBS colmap_util - colmap_image + colmap_math + colmap_sensor colmap_sift_gpu colmap_vlfeat flann diff --git a/src/colmap/feature/sift.h b/src/colmap/feature/sift.h index 6f69b80709..f300880685 100644 --- a/src/colmap/feature/sift.h +++ b/src/colmap/feature/sift.h @@ -33,7 +33,7 @@ #include "colmap/estimators/two_view_geometry.h" #include "colmap/feature/types.h" -#include "colmap/image/bitmap.h" +#include "colmap/sensor/bitmap.h" class SiftGPU; class SiftMatchGPU; diff --git a/src/colmap/geometry/pose.cc b/src/colmap/geometry/pose.cc index 4ac5247324..1f6e67126f 100644 --- a/src/colmap/geometry/pose.cc +++ b/src/colmap/geometry/pose.cc @@ -32,7 +32,7 @@ #include "colmap/geometry/pose.h" #include "colmap/geometry/triangulation.h" -#include "colmap/scene/projection.h" +#include "colmap/math/matrix.h" #include @@ -154,6 +154,16 @@ Rigid3d InterpolateCameraPoses(const Rigid3d& cam_from_world1, cam_from_world1.translation + translation12 * t); } +namespace { + +double CalculateDepth(const Eigen::Matrix3x4d& cam_from_world, + const Eigen::Vector3d& point3D) { + const double proj_z = cam_from_world.row(2).dot(point3D.homogeneous()); + return proj_z * cam_from_world.col(2).norm(); +} + +} // namespace + bool CheckCheirality(const Eigen::Matrix3d& R, const Eigen::Vector3d& t, const std::vector& points1, diff --git a/src/colmap/image/CMakeLists.txt b/src/colmap/image/CMakeLists.txt index 516e82cca2..ffb46f246f 100644 --- a/src/colmap/image/CMakeLists.txt +++ b/src/colmap/image/CMakeLists.txt @@ -34,25 +34,18 @@ set(FOLDER_NAME "image") COLMAP_ADD_LIBRARY( NAME colmap_image SRCS - bitmap.h bitmap.cc - reader.h reader.cc line.h line.cc undistortion.h undistortion.cc warp.h warp.cc PUBLIC_LINK_LIBS - colmap_scene Eigen3::Eigen - freeimage PRIVATE_LINK_LIBS + colmap_util + colmap_sensor + colmap_scene colmap_lsd - colmap_vlfeat ) -COLMAP_ADD_TEST( - NAME bitmap_test - SRCS bitmap_test.cc - LINK_LIBS colmap_image -) COLMAP_ADD_TEST( NAME line_test SRCS line_test.cc diff --git a/src/colmap/image/line.h b/src/colmap/image/line.h index 86ee27699f..5f4df699e7 100644 --- a/src/colmap/image/line.h +++ b/src/colmap/image/line.h @@ -31,7 +31,7 @@ #pragma once -#include "colmap/image/bitmap.h" +#include "colmap/sensor/bitmap.h" #include diff --git a/src/colmap/image/undistortion.cc b/src/colmap/image/undistortion.cc index 0f8372b782..4ae2d66b00 100644 --- a/src/colmap/image/undistortion.cc +++ b/src/colmap/image/undistortion.cc @@ -31,7 +31,7 @@ #include "colmap/image/undistortion.h" -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/geometry/pose.h" #include "colmap/image/warp.h" #include "colmap/util/misc.h" diff --git a/src/colmap/image/undistortion.h b/src/colmap/image/undistortion.h index 1ac448d835..c447e11a1c 100644 --- a/src/colmap/image/undistortion.h +++ b/src/colmap/image/undistortion.h @@ -32,7 +32,7 @@ #pragma once #include "colmap/geometry/rigid3.h" -#include "colmap/image/bitmap.h" +#include "colmap/sensor/bitmap.h" #include "colmap/scene/reconstruction.h" #include "colmap/util/misc.h" #include "colmap/util/threading.h" diff --git a/src/colmap/image/warp.h b/src/colmap/image/warp.h index 15711b5f51..9e8c28d306 100644 --- a/src/colmap/image/warp.h +++ b/src/colmap/image/warp.h @@ -31,7 +31,7 @@ #pragma once -#include "colmap/image/bitmap.h" +#include "colmap/sensor/bitmap.h" #include "colmap/scene/camera.h" namespace colmap { diff --git a/src/colmap/mvs/CMakeLists.txt b/src/colmap/mvs/CMakeLists.txt index f713b924e9..20e3943e62 100644 --- a/src/colmap/mvs/CMakeLists.txt +++ b/src/colmap/mvs/CMakeLists.txt @@ -46,6 +46,8 @@ COLMAP_ADD_LIBRARY( colmap_util colmap_scene PRIVATE_LINK_LIBS + colmap_sensor + colmap_image colmap_poisson_recon Eigen3::Eigen CGAL diff --git a/src/colmap/mvs/depth_map.h b/src/colmap/mvs/depth_map.h index 91de7d8775..1041f6b484 100644 --- a/src/colmap/mvs/depth_map.h +++ b/src/colmap/mvs/depth_map.h @@ -31,7 +31,7 @@ #pragma once -#include "colmap/image/bitmap.h" +#include "colmap/sensor/bitmap.h" #include "colmap/mvs/mat.h" #include diff --git a/src/colmap/mvs/image.h b/src/colmap/mvs/image.h index 0e6f97efea..dbe5bb75d8 100644 --- a/src/colmap/mvs/image.h +++ b/src/colmap/mvs/image.h @@ -31,7 +31,7 @@ #pragma once -#include "colmap/image/bitmap.h" +#include "colmap/sensor/bitmap.h" #include #include diff --git a/src/colmap/mvs/model.cc b/src/colmap/mvs/model.cc index 980678478f..3eabaaefcc 100644 --- a/src/colmap/mvs/model.cc +++ b/src/colmap/mvs/model.cc @@ -31,7 +31,7 @@ #include "colmap/mvs/model.h" -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/geometry/pose.h" #include "colmap/geometry/triangulation.h" #include "colmap/scene/projection.h" diff --git a/src/colmap/mvs/normal_map.h b/src/colmap/mvs/normal_map.h index 3c94ae4775..e730d7af7e 100644 --- a/src/colmap/mvs/normal_map.h +++ b/src/colmap/mvs/normal_map.h @@ -31,7 +31,7 @@ #pragma once -#include "colmap/image/bitmap.h" +#include "colmap/sensor/bitmap.h" #include "colmap/mvs/mat.h" #include diff --git a/src/colmap/mvs/workspace.h b/src/colmap/mvs/workspace.h index 47dd990953..2a7f1c7898 100644 --- a/src/colmap/mvs/workspace.h +++ b/src/colmap/mvs/workspace.h @@ -31,7 +31,7 @@ #pragma once -#include "colmap/image/bitmap.h" +#include "colmap/sensor/bitmap.h" #include "colmap/mvs/consistency_graph.h" #include "colmap/mvs/depth_map.h" #include "colmap/mvs/model.h" diff --git a/src/colmap/scene/CMakeLists.txt b/src/colmap/scene/CMakeLists.txt index 146d9c2952..f2972cdb35 100644 --- a/src/colmap/scene/CMakeLists.txt +++ b/src/colmap/scene/CMakeLists.txt @@ -34,7 +34,6 @@ set(FOLDER_NAME "scene") COLMAP_ADD_LIBRARY( NAME colmap_scene SRCS - alignment.h alignment.cc camera.h camera.cc camera_rig.h camera_rig.cc correspondence_graph.h correspondence_graph.cc @@ -49,10 +48,10 @@ COLMAP_ADD_LIBRARY( scene_clustering.h scene_clustering.cc synthetic.h synthetic.cc track.h track.cc + two_view_geometry.h two_view_geometry.cc visibility_pyramid.h visibility_pyramid.cc PUBLIC_LINK_LIBS - colmap_camera - colmap_image + colmap_sensor colmap_feature colmap_geometry Eigen3::Eigen @@ -129,6 +128,11 @@ COLMAP_ADD_TEST( SRCS track_test.cc LINK_LIBS colmap_scene ) +COLMAP_ADD_TEST( + NAME two_view_geometry_test + SRCS two_view_geometry_test.cc + LINK_LIBS colmap_scene +) COLMAP_ADD_TEST( NAME visibility_pyramid_test SRCS visibility_pyramid_test.cc diff --git a/src/colmap/scene/camera.cc b/src/colmap/scene/camera.cc index 539abf2d14..7743626aed 100644 --- a/src/colmap/scene/camera.cc +++ b/src/colmap/scene/camera.cc @@ -31,7 +31,7 @@ #include "colmap/scene/camera.h" -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/util/logging.h" #include "colmap/util/misc.h" diff --git a/src/colmap/scene/camera_test.cc b/src/colmap/scene/camera_test.cc index d88ee56cbd..dc9931ab3e 100644 --- a/src/colmap/scene/camera_test.cc +++ b/src/colmap/scene/camera_test.cc @@ -31,7 +31,7 @@ #include "colmap/scene/camera.h" -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include diff --git a/src/colmap/scene/database.h b/src/colmap/scene/database.h index c72fb75f7e..731bb8eac8 100644 --- a/src/colmap/scene/database.h +++ b/src/colmap/scene/database.h @@ -31,10 +31,10 @@ #pragma once -#include "colmap/estimators/two_view_geometry.h" #include "colmap/feature/types.h" #include "colmap/scene/camera.h" #include "colmap/scene/image.h" +#include "colmap/scene/two_view_geometry.h" #include "colmap/util/types.h" #include diff --git a/src/colmap/scene/database_cache.h b/src/colmap/scene/database_cache.h index d2b606ec4a..65f07f3640 100644 --- a/src/colmap/scene/database_cache.h +++ b/src/colmap/scene/database_cache.h @@ -31,7 +31,7 @@ #pragma once -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/scene/camera.h" #include "colmap/scene/correspondence_graph.h" #include "colmap/scene/database.h" diff --git a/src/colmap/scene/projection.cc b/src/colmap/scene/projection.cc index 7a7caeec0f..12071fe4a5 100644 --- a/src/colmap/scene/projection.cc +++ b/src/colmap/scene/projection.cc @@ -106,12 +106,6 @@ double CalculateNormalizedAngularError( return std::acos(ray1.normalized().transpose() * ray2.normalized()); } -double CalculateDepth(const Eigen::Matrix3x4d& cam_from_world, - const Eigen::Vector3d& point3D) { - const double proj_z = cam_from_world.row(2).dot(point3D.homogeneous()); - return proj_z * cam_from_world.col(2).norm(); -} - bool HasPointPositiveDepth(const Eigen::Matrix3x4d& cam_from_world, const Eigen::Vector3d& point3D) { return cam_from_world.row(2).dot(point3D.homogeneous()) >= diff --git a/src/colmap/scene/projection.h b/src/colmap/scene/projection.h index 9044de0567..00380dd914 100644 --- a/src/colmap/scene/projection.h +++ b/src/colmap/scene/projection.h @@ -81,19 +81,6 @@ double CalculateNormalizedAngularError(const Eigen::Vector2d& point2D, const Eigen::Vector3d& point3D, const Eigen::Matrix3x4d& cam_from_world); -// Calculate depth of 3D point with respect to camera. -// -// The depth is defined as the Euclidean distance of a 3D point from the -// camera and is positive if the 3D point is in front and negative if -// behind of the camera. -// -// @param cam_from_world 3x4 projection matrix. -// @param point3D 3D point as 3x1 vector. -// -// @return Depth of 3D point. -double CalculateDepth(const Eigen::Matrix3x4d& cam_from_world, - const Eigen::Vector3d& point3D); - // Check if 3D point passes cheirality constraint, // i.e. it lies in front of the camera and not in the image plane. // diff --git a/src/colmap/scene/projection_test.cc b/src/colmap/scene/projection_test.cc index c2b2ddbd18..d77d430d22 100644 --- a/src/colmap/scene/projection_test.cc +++ b/src/colmap/scene/projection_test.cc @@ -31,7 +31,7 @@ #include "colmap/scene/projection.h" -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/geometry/pose.h" #include "colmap/math/math.h" @@ -147,30 +147,6 @@ TEST(CalculateAngularError, Nominal) { EXPECT_NEAR(error11, M_PI * 3 / 4, 1e-6); } -TEST(CalculateDepth, Nominal) { - const Rigid3d cam_from_world(Eigen::Quaterniond::Identity(), - Eigen::Vector3d::Zero()); - const Eigen::Matrix3x4d cam_from_world_mat = cam_from_world.ToMatrix(); - - // In the image plane - const double depth1 = - CalculateDepth(cam_from_world_mat, Eigen::Vector3d(0, 0, 0)); - EXPECT_NEAR(depth1, 0, 1e-10); - const double depth2 = - CalculateDepth(cam_from_world_mat, Eigen::Vector3d(0, 2, 0)); - EXPECT_NEAR(depth2, 0, 1e-10); - - // Infront of camera - const double depth3 = - CalculateDepth(cam_from_world_mat, Eigen::Vector3d(0, 0, 1)); - EXPECT_NEAR(depth3, 1, 1e-10); - - // Behind camera - const double depth4 = - CalculateDepth(cam_from_world_mat, Eigen::Vector3d(0, 0, -1)); - EXPECT_NEAR(depth4, -1, 1e-10); -} - TEST(HasPointPositiveDepth, Nominal) { const Rigid3d cam_from_world(Eigen::Quaterniond::Identity(), Eigen::Vector3d::Zero()); diff --git a/src/colmap/scene/reconstruction.cc b/src/colmap/scene/reconstruction.cc index 316c3b308e..52dbd5abef 100644 --- a/src/colmap/scene/reconstruction.cc +++ b/src/colmap/scene/reconstruction.cc @@ -34,7 +34,7 @@ #include "colmap/geometry/gps.h" #include "colmap/geometry/pose.h" #include "colmap/geometry/triangulation.h" -#include "colmap/image/bitmap.h" +#include "colmap/sensor/bitmap.h" #include "colmap/optim/loransac.h" #include "colmap/scene/database_cache.h" #include "colmap/scene/projection.h" diff --git a/src/colmap/scene/reconstruction_test.cc b/src/colmap/scene/reconstruction_test.cc index 8076afd334..5816355566 100644 --- a/src/colmap/scene/reconstruction_test.cc +++ b/src/colmap/scene/reconstruction_test.cc @@ -31,7 +31,7 @@ #include "colmap/scene/reconstruction.h" -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/geometry/pose.h" #include "colmap/geometry/sim3.h" #include "colmap/scene/correspondence_graph.h" diff --git a/src/colmap/scene/synthetic.h b/src/colmap/scene/synthetic.h index 37ee101101..c53532f8ad 100644 --- a/src/colmap/scene/synthetic.h +++ b/src/colmap/scene/synthetic.h @@ -31,7 +31,7 @@ #pragma once -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/scene/database.h" #include "colmap/scene/reconstruction.h" #include "colmap/util/types.h" diff --git a/src/colmap/scene/two_view_geometry.cc b/src/colmap/scene/two_view_geometry.cc new file mode 100644 index 0000000000..4098ee9cc9 --- /dev/null +++ b/src/colmap/scene/two_view_geometry.cc @@ -0,0 +1,46 @@ +// 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. +// +// Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) + +#include "colmap/scene/two_view_geometry.h" + +namespace colmap { + +void TwoViewGeometry::Invert() { + F.transposeInPlace(); + E.transposeInPlace(); + H = H.inverse().eval(); + cam2_from_cam1 = Inverse(cam2_from_cam1); + for (auto& match : inlier_matches) { + std::swap(match.point2D_idx1, match.point2D_idx2); + } +} + +} // namespace colmap diff --git a/src/colmap/scene/two_view_geometry.h b/src/colmap/scene/two_view_geometry.h new file mode 100644 index 0000000000..b84d57b821 --- /dev/null +++ b/src/colmap/scene/two_view_geometry.h @@ -0,0 +1,86 @@ +// 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. +// +// Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) + +#pragma once + +#include "colmap/feature/types.h" +#include "colmap/geometry/rigid3.h" + +namespace colmap { + +// Two-view geometry. +struct TwoViewGeometry { + // The configuration of the two-view geometry. + enum ConfigurationType { + UNDEFINED = 0, + // Degenerate configuration (e.g., no overlap or not enough inliers). + DEGENERATE = 1, + // Essential matrix. + CALIBRATED = 2, + // Fundamental matrix. + UNCALIBRATED = 3, + // Homography, planar scene with baseline. + PLANAR = 4, + // Homography, pure rotation without baseline. + PANORAMIC = 5, + // Homography, planar or panoramic. + PLANAR_OR_PANORAMIC = 6, + // Watermark, pure 2D translation in image borders. + WATERMARK = 7, + // Multi-model configuration, i.e. the inlier matches result from multiple + // individual, non-degenerate configurations. + MULTIPLE = 8, + }; + + // One of `ConfigurationType`. + int config = ConfigurationType::UNDEFINED; + + // Essential matrix. + Eigen::Matrix3d E = Eigen::Matrix3d::Zero(); + // Fundamental matrix. + Eigen::Matrix3d F = Eigen::Matrix3d::Zero(); + // Homography matrix. + Eigen::Matrix3d H = Eigen::Matrix3d::Zero(); + + // Relative pose. + Rigid3d cam2_from_cam1; + + // Inlier matches of the configuration. + FeatureMatches inlier_matches; + + // Median triangulation angle. + double tri_angle = -1; + + // Invert the geometry to match swapped cameras. + void Invert(); +}; + +} // namespace colmap diff --git a/src/colmap/estimators/two_view_geometry_test.cc b/src/colmap/scene/two_view_geometry_test.cc similarity index 98% rename from src/colmap/estimators/two_view_geometry_test.cc rename to src/colmap/scene/two_view_geometry_test.cc index 0fd72c7b34..84b5b251b7 100644 --- a/src/colmap/estimators/two_view_geometry_test.cc +++ b/src/colmap/scene/two_view_geometry_test.cc @@ -29,7 +29,7 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -#include "colmap/estimators/two_view_geometry.h" +#include "colmap/scene/two_view_geometry.h" #include "colmap/geometry/pose.h" diff --git a/src/colmap/camera/CMakeLists.txt b/src/colmap/sensor/CMakeLists.txt similarity index 88% rename from src/colmap/camera/CMakeLists.txt rename to src/colmap/sensor/CMakeLists.txt index b45c4884b2..930df37cad 100644 --- a/src/colmap/camera/CMakeLists.txt +++ b/src/colmap/sensor/CMakeLists.txt @@ -29,28 +29,36 @@ # # Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -set(FOLDER_NAME "camera") +set(FOLDER_NAME "sensor") COLMAP_ADD_LIBRARY( - NAME colmap_camera + NAME colmap_sensor SRCS + bitmap.h bitmap.cc database.h database.cc models.h models.cc specs.h specs.cc PUBLIC_LINK_LIBS - Eigen3::Eigen Ceres::ceres + Eigen3::Eigen + freeimage PRIVATE_LINK_LIBS colmap_util + colmap_vlfeat ) +COLMAP_ADD_TEST( + NAME bitmap_test + SRCS bitmap_test.cc + LINK_LIBS colmap_sensor +) COLMAP_ADD_TEST( NAME database_test SRCS database_test.cc - LINK_LIBS colmap_camera + LINK_LIBS colmap_sensor ) COLMAP_ADD_TEST( NAME models_test SRCS models_test.cc - LINK_LIBS colmap_camera + LINK_LIBS colmap_sensor ) diff --git a/src/colmap/image/bitmap.cc b/src/colmap/sensor/bitmap.cc similarity index 99% rename from src/colmap/image/bitmap.cc rename to src/colmap/sensor/bitmap.cc index f585711725..f0e8e451d5 100644 --- a/src/colmap/image/bitmap.cc +++ b/src/colmap/sensor/bitmap.cc @@ -29,9 +29,9 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -#include "colmap/image/bitmap.h" +#include "colmap/sensor/bitmap.h" -#include "colmap/camera/database.h" +#include "colmap/sensor/database.h" #include "colmap/math/math.h" #include "colmap/util/logging.h" #include "colmap/util/misc.h" diff --git a/src/colmap/image/bitmap.h b/src/colmap/sensor/bitmap.h similarity index 100% rename from src/colmap/image/bitmap.h rename to src/colmap/sensor/bitmap.h diff --git a/src/colmap/image/bitmap_test.cc b/src/colmap/sensor/bitmap_test.cc similarity index 99% rename from src/colmap/image/bitmap_test.cc rename to src/colmap/sensor/bitmap_test.cc index 1414a4ae48..58c4d2620b 100644 --- a/src/colmap/image/bitmap_test.cc +++ b/src/colmap/sensor/bitmap_test.cc @@ -29,7 +29,7 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -#include "colmap/image/bitmap.h" +#include "colmap/sensor/bitmap.h" #include diff --git a/src/colmap/camera/database.cc b/src/colmap/sensor/database.cc similarity index 97% rename from src/colmap/camera/database.cc rename to src/colmap/sensor/database.cc index 6c934b5128..28e3e9e5da 100644 --- a/src/colmap/camera/database.cc +++ b/src/colmap/sensor/database.cc @@ -29,7 +29,7 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -#include "colmap/camera/database.h" +#include "colmap/sensor/database.h" #include "colmap/util/string.h" @@ -37,8 +37,6 @@ namespace colmap { const camera_specs_t CameraDatabase::specs_ = InitializeCameraSpecs(); -CameraDatabase::CameraDatabase() {} - bool CameraDatabase::QuerySensorWidth(const std::string& make, const std::string& model, double* sensor_width) { diff --git a/src/colmap/camera/database.h b/src/colmap/sensor/database.h similarity index 97% rename from src/colmap/camera/database.h rename to src/colmap/sensor/database.h index f93ed6b9a5..b87040c7ad 100644 --- a/src/colmap/camera/database.h +++ b/src/colmap/sensor/database.h @@ -31,7 +31,7 @@ #pragma once -#include "colmap/camera/specs.h" +#include "colmap/sensor/specs.h" #include @@ -41,7 +41,7 @@ namespace colmap { // to automatically extract the focal length if EXIF information is incomplete. class CameraDatabase { public: - CameraDatabase(); + CameraDatabase() = default; size_t NumEntries() const { return specs_.size(); } diff --git a/src/colmap/camera/database_test.cc b/src/colmap/sensor/database_test.cc similarity index 98% rename from src/colmap/camera/database_test.cc rename to src/colmap/sensor/database_test.cc index 9792ee0c2d..e12dfd387a 100644 --- a/src/colmap/camera/database_test.cc +++ b/src/colmap/sensor/database_test.cc @@ -29,7 +29,7 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -#include "colmap/camera/database.h" +#include "colmap/sensor/database.h" #include diff --git a/src/colmap/camera/models.cc b/src/colmap/sensor/models.cc similarity index 99% rename from src/colmap/camera/models.cc rename to src/colmap/sensor/models.cc index 69d18448d9..158310f6e7 100644 --- a/src/colmap/camera/models.cc +++ b/src/colmap/sensor/models.cc @@ -29,7 +29,7 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include diff --git a/src/colmap/camera/models.h b/src/colmap/sensor/models.h similarity index 100% rename from src/colmap/camera/models.h rename to src/colmap/sensor/models.h diff --git a/src/colmap/camera/models_test.cc b/src/colmap/sensor/models_test.cc similarity index 99% rename from src/colmap/camera/models_test.cc rename to src/colmap/sensor/models_test.cc index 2c1b5deab7..7ba2e1825e 100644 --- a/src/colmap/camera/models_test.cc +++ b/src/colmap/sensor/models_test.cc @@ -29,7 +29,7 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include diff --git a/src/colmap/camera/specs.cc b/src/colmap/sensor/specs.cc similarity index 99% rename from src/colmap/camera/specs.cc rename to src/colmap/sensor/specs.cc index 5bd94cf004..c65b919296 100644 --- a/src/colmap/camera/specs.cc +++ b/src/colmap/sensor/specs.cc @@ -29,7 +29,7 @@ // // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) -#include "colmap/camera/specs.h" +#include "colmap/sensor/specs.h" namespace colmap { diff --git a/src/colmap/camera/specs.h b/src/colmap/sensor/specs.h similarity index 100% rename from src/colmap/camera/specs.h rename to src/colmap/sensor/specs.h diff --git a/src/colmap/sfm/incremental_mapper.cc b/src/colmap/sfm/incremental_mapper.cc index cc79329ab5..b97bd7f7e1 100644 --- a/src/colmap/sfm/incremental_mapper.cc +++ b/src/colmap/sfm/incremental_mapper.cc @@ -32,9 +32,10 @@ #include "colmap/sfm/incremental_mapper.h" #include "colmap/estimators/pose.h" +#include "colmap/estimators/two_view_geometry.h" #include "colmap/geometry/triangulation.h" -#include "colmap/image/bitmap.h" #include "colmap/scene/projection.h" +#include "colmap/sensor/bitmap.h" #include "colmap/util/misc.h" #include @@ -1152,15 +1153,14 @@ bool IncrementalMapper::EstimateInitialTwoViewGeometry( points2.push_back(point.xy); } - TwoViewGeometry two_view_geometry; - TwoViewGeometry::Options two_view_geometry_options; + TwoViewGeometryOptions two_view_geometry_options; two_view_geometry_options.ransac_options.min_num_trials = 30; two_view_geometry_options.ransac_options.max_error = options.init_max_error; - two_view_geometry.EstimateCalibrated( + TwoViewGeometry two_view_geometry = EstimateCalibratedTwoViewGeometry( camera1, points1, camera2, points2, matches, two_view_geometry_options); - if (!two_view_geometry.EstimateRelativePose( - camera1, points1, camera2, points2)) { + if (!EstimateTwoViewGeometryPose( + camera1, points1, camera2, points2, &two_view_geometry)) { return false; } diff --git a/src/colmap/ui/colormaps.cc b/src/colmap/ui/colormaps.cc index 990f782ba8..52b7d06cdd 100644 --- a/src/colmap/ui/colormaps.cc +++ b/src/colmap/ui/colormaps.cc @@ -31,7 +31,7 @@ #include "colmap/ui/colormaps.h" -#include "colmap/image/bitmap.h" +#include "colmap/sensor/bitmap.h" namespace colmap { diff --git a/src/colmap/ui/database_management_widget.cc b/src/colmap/ui/database_management_widget.cc index 93d56e0909..2abb3edb5e 100644 --- a/src/colmap/ui/database_management_widget.cc +++ b/src/colmap/ui/database_management_widget.cc @@ -31,7 +31,7 @@ #include "colmap/ui/database_management_widget.h" -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" namespace colmap { diff --git a/src/colmap/ui/feature_extraction_widget.cc b/src/colmap/ui/feature_extraction_widget.cc index 2d752718e8..0c90ae8587 100644 --- a/src/colmap/ui/feature_extraction_widget.cc +++ b/src/colmap/ui/feature_extraction_widget.cc @@ -31,8 +31,8 @@ #include "colmap/ui/feature_extraction_widget.h" -#include "colmap/camera/models.h" -#include "colmap/feature/extraction.h" +#include "colmap/sensor/models.h" +#include "colmap/controllers/feature_extraction.h" #include "colmap/ui/options_widget.h" #include "colmap/ui/qt_utils.h" #include "colmap/ui/thread_control_widget.h" diff --git a/src/colmap/ui/feature_matching_widget.cc b/src/colmap/ui/feature_matching_widget.cc index aaba24b13b..4804b6bb70 100644 --- a/src/colmap/ui/feature_matching_widget.cc +++ b/src/colmap/ui/feature_matching_widget.cc @@ -31,7 +31,7 @@ #include "colmap/ui/feature_matching_widget.h" -#include "colmap/feature/matching.h" +#include "colmap/controllers/feature_matching.h" #include "colmap/ui/options_widget.h" #include "colmap/ui/thread_control_widget.h" diff --git a/src/colmap/ui/main_window.h b/src/colmap/ui/main_window.h index b58e03037f..d493a8b67c 100644 --- a/src/colmap/ui/main_window.h +++ b/src/colmap/ui/main_window.h @@ -32,7 +32,7 @@ #pragma once #include "colmap/controllers/incremental_mapper.h" -#include "colmap/image/bitmap.h" +#include "colmap/sensor/bitmap.h" #include "colmap/scene/reconstruction.h" #include "colmap/ui/automatic_reconstruction_widget.h" #include "colmap/ui/bundle_adjustment_widget.h" diff --git a/src/colmap/ui/qt_utils.cc b/src/colmap/ui/qt_utils.cc index 2b9311aff7..2bdef7a4fe 100644 --- a/src/colmap/ui/qt_utils.cc +++ b/src/colmap/ui/qt_utils.cc @@ -31,7 +31,7 @@ #include "colmap/ui/qt_utils.h" -#include "colmap/camera/models.h" +#include "colmap/sensor/models.h" #include "colmap/util/misc.h" namespace colmap { diff --git a/src/colmap/ui/qt_utils.h b/src/colmap/ui/qt_utils.h index 1286b10114..b6941784f3 100644 --- a/src/colmap/ui/qt_utils.h +++ b/src/colmap/ui/qt_utils.h @@ -32,7 +32,7 @@ #pragma once #include "colmap/feature/types.h" -#include "colmap/image/bitmap.h" +#include "colmap/sensor/bitmap.h" #include "colmap/util/types.h" #include diff --git a/src/colmap/util/endian_test.cc b/src/colmap/util/endian_test.cc index 8358238c30..57b2a9ed0b 100644 --- a/src/colmap/util/endian_test.cc +++ b/src/colmap/util/endian_test.cc @@ -154,7 +154,7 @@ void TestIntReadWriteBinaryLittleEndian() { std::stringstream file_vector; std::vector orig_vector(100); - std::generate(orig_vector.begin(), orig_vector.end(), [&distribution]() { + std::generate(orig_vector.begin(), orig_vector.end(), [&]() { return distribution(prng); }); WriteBinaryLittleEndian(&file_vector, orig_vector); @@ -181,7 +181,7 @@ void TestFloatReadWriteBinaryLittleEndian() { std::stringstream file_vector; std::vector orig_vector(100); - std::generate(orig_vector.begin(), orig_vector.end(), [&distribution]() { + std::generate(orig_vector.begin(), orig_vector.end(), [&]() { return distribution(prng); }); WriteBinaryLittleEndian(&file_vector, orig_vector); From 4e59252976945d464c174f65d1d094e1731e9b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Tue, 25 Jul 2023 15:58:01 +0200 Subject: [PATCH 19/38] f --- src/colmap/controllers/automatic_reconstruction.cc | 4 ++-- src/colmap/controllers/feature_extraction.h | 2 +- src/colmap/controllers/image_reader.h | 2 +- src/colmap/controllers/option_manager.cc | 6 +++--- src/colmap/estimators/bundle_adjustment.cc | 2 +- src/colmap/estimators/bundle_adjustment_test.cc | 2 +- src/colmap/estimators/cost_functions_test.cc | 2 +- src/colmap/estimators/essential_matrix_test.cc | 2 +- src/colmap/estimators/pose.cc | 2 +- src/colmap/estimators/pose.h | 2 +- src/colmap/exe/feature.cc | 6 +++--- src/colmap/exe/vocab_tree.cc | 2 +- src/colmap/image/undistortion.cc | 2 +- src/colmap/image/undistortion.h | 2 +- src/colmap/image/warp.h | 2 +- src/colmap/mvs/depth_map.h | 2 +- src/colmap/mvs/model.cc | 2 +- src/colmap/mvs/normal_map.h | 2 +- src/colmap/mvs/workspace.h | 2 +- src/colmap/scene/database_cache.h | 2 +- src/colmap/scene/projection_test.cc | 2 +- src/colmap/scene/reconstruction.cc | 2 +- src/colmap/scene/reconstruction_test.cc | 2 +- src/colmap/scene/synthetic.h | 2 +- src/colmap/sensor/bitmap.cc | 2 +- src/colmap/ui/feature_extraction_widget.cc | 2 +- src/colmap/ui/main_window.h | 2 +- 27 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/colmap/controllers/automatic_reconstruction.cc b/src/colmap/controllers/automatic_reconstruction.cc index 94fd143afe..101807342f 100644 --- a/src/colmap/controllers/automatic_reconstruction.cc +++ b/src/colmap/controllers/automatic_reconstruction.cc @@ -31,10 +31,10 @@ #include "colmap/controllers/automatic_reconstruction.h" -#include "colmap/controllers/incremental_mapper.h" -#include "colmap/controllers/option_manager.h" #include "colmap/controllers/feature_extraction.h" #include "colmap/controllers/feature_matching.h" +#include "colmap/controllers/incremental_mapper.h" +#include "colmap/controllers/option_manager.h" #include "colmap/image/undistortion.h" #include "colmap/mvs/fusion.h" #include "colmap/mvs/meshing.h" diff --git a/src/colmap/controllers/feature_extraction.h b/src/colmap/controllers/feature_extraction.h index 7c1c3d3c9a..1f40f2db48 100644 --- a/src/colmap/controllers/feature_extraction.h +++ b/src/colmap/controllers/feature_extraction.h @@ -31,8 +31,8 @@ #pragma once -#include "colmap/feature/sift.h" #include "colmap/controllers/image_reader.h" +#include "colmap/feature/sift.h" #include "colmap/scene/database.h" #include "colmap/util/opengl_utils.h" #include "colmap/util/threading.h" diff --git a/src/colmap/controllers/image_reader.h b/src/colmap/controllers/image_reader.h index 2559e8c9f4..31b89994b8 100644 --- a/src/colmap/controllers/image_reader.h +++ b/src/colmap/controllers/image_reader.h @@ -31,8 +31,8 @@ #pragma once -#include "colmap/sensor/bitmap.h" #include "colmap/scene/database.h" +#include "colmap/sensor/bitmap.h" #include "colmap/util/threading.h" #include diff --git a/src/colmap/controllers/option_manager.cc b/src/colmap/controllers/option_manager.cc index ebd923e9c7..e369fe2211 100644 --- a/src/colmap/controllers/option_manager.cc +++ b/src/colmap/controllers/option_manager.cc @@ -31,12 +31,12 @@ #include "colmap/controllers/option_manager.h" -#include "colmap/controllers/incremental_mapper.h" -#include "colmap/estimators/bundle_adjustment.h" #include "colmap/controllers/feature_extraction.h" #include "colmap/controllers/feature_matching.h" -#include "colmap/feature/sift.h" #include "colmap/controllers/image_reader.h" +#include "colmap/controllers/incremental_mapper.h" +#include "colmap/estimators/bundle_adjustment.h" +#include "colmap/feature/sift.h" #include "colmap/math/random.h" #include "colmap/mvs/fusion.h" #include "colmap/mvs/meshing.h" diff --git a/src/colmap/estimators/bundle_adjustment.cc b/src/colmap/estimators/bundle_adjustment.cc index 2981c171eb..8ba68430d0 100644 --- a/src/colmap/estimators/bundle_adjustment.cc +++ b/src/colmap/estimators/bundle_adjustment.cc @@ -37,9 +37,9 @@ #include #endif -#include "colmap/sensor/models.h" #include "colmap/estimators/cost_functions.h" #include "colmap/scene/projection.h" +#include "colmap/sensor/models.h" #include "colmap/util/misc.h" #include "colmap/util/threading.h" #include "colmap/util/timer.h" diff --git a/src/colmap/estimators/bundle_adjustment_test.cc b/src/colmap/estimators/bundle_adjustment_test.cc index 6424f48481..ed434c724f 100644 --- a/src/colmap/estimators/bundle_adjustment_test.cc +++ b/src/colmap/estimators/bundle_adjustment_test.cc @@ -31,10 +31,10 @@ #include "colmap/estimators/bundle_adjustment.h" -#include "colmap/sensor/models.h" #include "colmap/math/random.h" #include "colmap/scene/correspondence_graph.h" #include "colmap/scene/projection.h" +#include "colmap/sensor/models.h" #include diff --git a/src/colmap/estimators/cost_functions_test.cc b/src/colmap/estimators/cost_functions_test.cc index 952f932641..1c629df119 100644 --- a/src/colmap/estimators/cost_functions_test.cc +++ b/src/colmap/estimators/cost_functions_test.cc @@ -31,8 +31,8 @@ #include "colmap/estimators/cost_functions.h" -#include "colmap/sensor/models.h" #include "colmap/geometry/pose.h" +#include "colmap/sensor/models.h" #include diff --git a/src/colmap/estimators/essential_matrix_test.cc b/src/colmap/estimators/essential_matrix_test.cc index dd923b74e2..1dbf184eb6 100644 --- a/src/colmap/estimators/essential_matrix_test.cc +++ b/src/colmap/estimators/essential_matrix_test.cc @@ -31,12 +31,12 @@ #include "colmap/geometry/essential_matrix.h" -#include "colmap/sensor/models.h" #include "colmap/estimators/essential_matrix.h" #include "colmap/geometry/pose.h" #include "colmap/math/random.h" #include "colmap/optim/ransac.h" #include "colmap/scene/projection.h" +#include "colmap/sensor/models.h" #include #include diff --git a/src/colmap/estimators/pose.cc b/src/colmap/estimators/pose.cc index f1e1cfadf9..37c889f173 100644 --- a/src/colmap/estimators/pose.cc +++ b/src/colmap/estimators/pose.cc @@ -31,7 +31,6 @@ #include "colmap/estimators/pose.h" -#include "colmap/sensor/models.h" #include "colmap/estimators/absolute_pose.h" #include "colmap/estimators/bundle_adjustment.h" #include "colmap/estimators/cost_functions.h" @@ -39,6 +38,7 @@ #include "colmap/geometry/essential_matrix.h" #include "colmap/geometry/pose.h" #include "colmap/math/matrix.h" +#include "colmap/sensor/models.h" #include "colmap/util/misc.h" #include "colmap/util/threading.h" diff --git a/src/colmap/estimators/pose.h b/src/colmap/estimators/pose.h index 11cbbfea42..82363c4c8d 100644 --- a/src/colmap/estimators/pose.h +++ b/src/colmap/estimators/pose.h @@ -31,10 +31,10 @@ #pragma once -#include "colmap/sensor/models.h" #include "colmap/geometry/rigid3.h" #include "colmap/optim/loransac.h" #include "colmap/scene/camera.h" +#include "colmap/sensor/models.h" #include "colmap/util/logging.h" #include "colmap/util/threading.h" #include "colmap/util/types.h" diff --git a/src/colmap/exe/feature.cc b/src/colmap/exe/feature.cc index 3531a74572..4936d5326d 100644 --- a/src/colmap/exe/feature.cc +++ b/src/colmap/exe/feature.cc @@ -31,12 +31,12 @@ #include "colmap/exe/feature.h" -#include "colmap/sensor/models.h" -#include "colmap/controllers/option_manager.h" -#include "colmap/exe/gui.h" #include "colmap/controllers/feature_extraction.h" #include "colmap/controllers/feature_matching.h" #include "colmap/controllers/image_reader.h" +#include "colmap/controllers/option_manager.h" +#include "colmap/exe/gui.h" +#include "colmap/sensor/models.h" #include "colmap/util/misc.h" #include "colmap/util/opengl_utils.h" diff --git a/src/colmap/exe/vocab_tree.cc b/src/colmap/exe/vocab_tree.cc index ea15c87015..04671893f2 100644 --- a/src/colmap/exe/vocab_tree.cc +++ b/src/colmap/exe/vocab_tree.cc @@ -31,8 +31,8 @@ #include "colmap/exe/vocab_tree.h" -#include "colmap/controllers/option_manager.h" #include "colmap/controllers/feature_matching.h" +#include "colmap/controllers/option_manager.h" #include "colmap/feature/sift.h" #include "colmap/feature/utils.h" #include "colmap/retrieval/visual_index.h" diff --git a/src/colmap/image/undistortion.cc b/src/colmap/image/undistortion.cc index 4ae2d66b00..1fb37a581d 100644 --- a/src/colmap/image/undistortion.cc +++ b/src/colmap/image/undistortion.cc @@ -31,9 +31,9 @@ #include "colmap/image/undistortion.h" -#include "colmap/sensor/models.h" #include "colmap/geometry/pose.h" #include "colmap/image/warp.h" +#include "colmap/sensor/models.h" #include "colmap/util/misc.h" #include diff --git a/src/colmap/image/undistortion.h b/src/colmap/image/undistortion.h index c447e11a1c..141116c36b 100644 --- a/src/colmap/image/undistortion.h +++ b/src/colmap/image/undistortion.h @@ -32,8 +32,8 @@ #pragma once #include "colmap/geometry/rigid3.h" -#include "colmap/sensor/bitmap.h" #include "colmap/scene/reconstruction.h" +#include "colmap/sensor/bitmap.h" #include "colmap/util/misc.h" #include "colmap/util/threading.h" diff --git a/src/colmap/image/warp.h b/src/colmap/image/warp.h index 9e8c28d306..ad54e87faa 100644 --- a/src/colmap/image/warp.h +++ b/src/colmap/image/warp.h @@ -31,8 +31,8 @@ #pragma once -#include "colmap/sensor/bitmap.h" #include "colmap/scene/camera.h" +#include "colmap/sensor/bitmap.h" namespace colmap { diff --git a/src/colmap/mvs/depth_map.h b/src/colmap/mvs/depth_map.h index 1041f6b484..b3e94aa5e6 100644 --- a/src/colmap/mvs/depth_map.h +++ b/src/colmap/mvs/depth_map.h @@ -31,8 +31,8 @@ #pragma once -#include "colmap/sensor/bitmap.h" #include "colmap/mvs/mat.h" +#include "colmap/sensor/bitmap.h" #include #include diff --git a/src/colmap/mvs/model.cc b/src/colmap/mvs/model.cc index 3eabaaefcc..3678505d51 100644 --- a/src/colmap/mvs/model.cc +++ b/src/colmap/mvs/model.cc @@ -31,11 +31,11 @@ #include "colmap/mvs/model.h" -#include "colmap/sensor/models.h" #include "colmap/geometry/pose.h" #include "colmap/geometry/triangulation.h" #include "colmap/scene/projection.h" #include "colmap/scene/reconstruction.h" +#include "colmap/sensor/models.h" #include "colmap/util/misc.h" namespace colmap { diff --git a/src/colmap/mvs/normal_map.h b/src/colmap/mvs/normal_map.h index e730d7af7e..83c01fb8a3 100644 --- a/src/colmap/mvs/normal_map.h +++ b/src/colmap/mvs/normal_map.h @@ -31,8 +31,8 @@ #pragma once -#include "colmap/sensor/bitmap.h" #include "colmap/mvs/mat.h" +#include "colmap/sensor/bitmap.h" #include #include diff --git a/src/colmap/mvs/workspace.h b/src/colmap/mvs/workspace.h index 2a7f1c7898..9bc8ff07a1 100644 --- a/src/colmap/mvs/workspace.h +++ b/src/colmap/mvs/workspace.h @@ -31,11 +31,11 @@ #pragma once -#include "colmap/sensor/bitmap.h" #include "colmap/mvs/consistency_graph.h" #include "colmap/mvs/depth_map.h" #include "colmap/mvs/model.h" #include "colmap/mvs/normal_map.h" +#include "colmap/sensor/bitmap.h" #include "colmap/util/cache.h" #include "colmap/util/misc.h" diff --git a/src/colmap/scene/database_cache.h b/src/colmap/scene/database_cache.h index 65f07f3640..0e75e9fa29 100644 --- a/src/colmap/scene/database_cache.h +++ b/src/colmap/scene/database_cache.h @@ -31,11 +31,11 @@ #pragma once -#include "colmap/sensor/models.h" #include "colmap/scene/camera.h" #include "colmap/scene/correspondence_graph.h" #include "colmap/scene/database.h" #include "colmap/scene/image.h" +#include "colmap/sensor/models.h" #include "colmap/util/types.h" #include diff --git a/src/colmap/scene/projection_test.cc b/src/colmap/scene/projection_test.cc index d77d430d22..a6c7a686e3 100644 --- a/src/colmap/scene/projection_test.cc +++ b/src/colmap/scene/projection_test.cc @@ -31,9 +31,9 @@ #include "colmap/scene/projection.h" -#include "colmap/sensor/models.h" #include "colmap/geometry/pose.h" #include "colmap/math/math.h" +#include "colmap/sensor/models.h" #include #include diff --git a/src/colmap/scene/reconstruction.cc b/src/colmap/scene/reconstruction.cc index 52dbd5abef..0cf38d25aa 100644 --- a/src/colmap/scene/reconstruction.cc +++ b/src/colmap/scene/reconstruction.cc @@ -34,10 +34,10 @@ #include "colmap/geometry/gps.h" #include "colmap/geometry/pose.h" #include "colmap/geometry/triangulation.h" -#include "colmap/sensor/bitmap.h" #include "colmap/optim/loransac.h" #include "colmap/scene/database_cache.h" #include "colmap/scene/projection.h" +#include "colmap/sensor/bitmap.h" #include "colmap/util/misc.h" #include "colmap/util/ply.h" diff --git a/src/colmap/scene/reconstruction_test.cc b/src/colmap/scene/reconstruction_test.cc index 5816355566..afb9de3ba5 100644 --- a/src/colmap/scene/reconstruction_test.cc +++ b/src/colmap/scene/reconstruction_test.cc @@ -31,10 +31,10 @@ #include "colmap/scene/reconstruction.h" -#include "colmap/sensor/models.h" #include "colmap/geometry/pose.h" #include "colmap/geometry/sim3.h" #include "colmap/scene/correspondence_graph.h" +#include "colmap/sensor/models.h" #include diff --git a/src/colmap/scene/synthetic.h b/src/colmap/scene/synthetic.h index c53532f8ad..0688db6eaa 100644 --- a/src/colmap/scene/synthetic.h +++ b/src/colmap/scene/synthetic.h @@ -31,9 +31,9 @@ #pragma once -#include "colmap/sensor/models.h" #include "colmap/scene/database.h" #include "colmap/scene/reconstruction.h" +#include "colmap/sensor/models.h" #include "colmap/util/types.h" namespace colmap { diff --git a/src/colmap/sensor/bitmap.cc b/src/colmap/sensor/bitmap.cc index f0e8e451d5..cb56ef946e 100644 --- a/src/colmap/sensor/bitmap.cc +++ b/src/colmap/sensor/bitmap.cc @@ -31,8 +31,8 @@ #include "colmap/sensor/bitmap.h" -#include "colmap/sensor/database.h" #include "colmap/math/math.h" +#include "colmap/sensor/database.h" #include "colmap/util/logging.h" #include "colmap/util/misc.h" diff --git a/src/colmap/ui/feature_extraction_widget.cc b/src/colmap/ui/feature_extraction_widget.cc index 0c90ae8587..ff29d28911 100644 --- a/src/colmap/ui/feature_extraction_widget.cc +++ b/src/colmap/ui/feature_extraction_widget.cc @@ -31,8 +31,8 @@ #include "colmap/ui/feature_extraction_widget.h" -#include "colmap/sensor/models.h" #include "colmap/controllers/feature_extraction.h" +#include "colmap/sensor/models.h" #include "colmap/ui/options_widget.h" #include "colmap/ui/qt_utils.h" #include "colmap/ui/thread_control_widget.h" diff --git a/src/colmap/ui/main_window.h b/src/colmap/ui/main_window.h index d493a8b67c..0152397c07 100644 --- a/src/colmap/ui/main_window.h +++ b/src/colmap/ui/main_window.h @@ -32,8 +32,8 @@ #pragma once #include "colmap/controllers/incremental_mapper.h" -#include "colmap/sensor/bitmap.h" #include "colmap/scene/reconstruction.h" +#include "colmap/sensor/bitmap.h" #include "colmap/ui/automatic_reconstruction_widget.h" #include "colmap/ui/bundle_adjustment_widget.h" #include "colmap/ui/database_management_widget.h" From e58603267b6c21a0c3a76e117c610df109165800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Tue, 25 Jul 2023 16:16:12 +0200 Subject: [PATCH 20/38] One more --- CMakeLists.txt | 112 +++++++++++++------------- doc/install.rst | 3 +- src/colmap/controllers/CMakeLists.txt | 5 +- src/colmap/ui/CMakeLists.txt | 2 +- src/colmap/ui/render_options.cc | 47 ----------- src/colmap/ui/render_options.h | 11 ++- 6 files changed, 70 insertions(+), 110 deletions(-) delete mode 100644 src/colmap/ui/render_options.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 816e8921a2..b1c65dfbd0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,6 @@ option(ASAN_ENABLED "Whether to enable AddressSanitizer flags" OFF) option(PROFILING_ENABLED "Whether to enable google-perftools linker flags" OFF) option(CCACHE_ENABLED "Whether to enable compiler caching, if available" ON) option(CGAL_ENABLED "Whether to enable the CGAL library" ON) -option(LIBRARY_ENABLED "Whether to build and install COLMAP as a shared/static library" OFF) if(TESTS_ENABLED) enable_testing() @@ -192,8 +191,8 @@ set(COLMAP_LIBS colmap_feature colmap_geometry colmap_scene - colmap_estimators colmap_optim + colmap_estimators colmap_mvs colmap_retrieval colmap_sfm @@ -289,59 +288,56 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeUninstall.cmake.in" add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/CMakeUninstall.cmake) set_target_properties(uninstall PROPERTIES FOLDER ${CMAKE_TARGETS_ROOT_FOLDER}) - -if(LIBRARY_ENABLED) - add_library(colmap INTERFACE) - target_link_libraries(colmap INTERFACE ${COLMAP_LIBS}) - set(INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include") - target_include_directories( - colmap INTERFACE $) - - install( - TARGETS - colmap - ${COLMAP_LIBS} - colmap_lsd - colmap_poisson_recon - colmap_vlfeat - colmap_sift_gpu - EXPORT colmap-targets - LIBRARY DESTINATION lib/) - - # Generate config and version. - include(CMakePackageConfigHelpers) - set(PACKAGE_CONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/colmap-config.cmake") - set(INSTALL_CONFIG_DIR "share/colmap") - configure_package_config_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/colmap-config.cmake.in ${PACKAGE_CONFIG_FILE} - INSTALL_DESTINATION ${INSTALL_CONFIG_DIR}) - install(FILES ${PACKAGE_CONFIG_FILE} DESTINATION ${INSTALL_CONFIG_DIR}) - - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/colmap-config-version.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/colmap-config-version.cmake" @ONLY) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/colmap-config-version.cmake" - DESTINATION "share/colmap") - - # Install targets. - install( - EXPORT colmap-targets - FILE colmap-targets.cmake - NAMESPACE colmap:: - DESTINATION ${INSTALL_CONFIG_DIR}) - - # Install header files. - install( - DIRECTORY src/colmap - DESTINATION include - FILES_MATCHING PATTERN "*.h") - install( - DIRECTORY src/lib - DESTINATION include/colmap - FILES_MATCHING REGEX ".*[.]h|.*[.]hpp|.*[.]inl") - - # Install find_package scripts for dependencies. - install( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake - DESTINATION share/colmap - FILES_MATCHING PATTERN "Find*.cmake") -endif() +add_library(colmap INTERFACE) +target_link_libraries(colmap INTERFACE ${COLMAP_LIBS}) +set(INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include") +target_include_directories( + colmap INTERFACE $) + +install( + TARGETS + colmap + ${COLMAP_LIBS} + colmap_lsd + colmap_poisson_recon + colmap_vlfeat + colmap_sift_gpu + EXPORT colmap-targets + LIBRARY DESTINATION lib/) + +# Generate config and version. +include(CMakePackageConfigHelpers) +set(PACKAGE_CONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/colmap-config.cmake") +set(INSTALL_CONFIG_DIR "share/colmap") +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/colmap-config.cmake.in ${PACKAGE_CONFIG_FILE} + INSTALL_DESTINATION ${INSTALL_CONFIG_DIR}) +install(FILES ${PACKAGE_CONFIG_FILE} DESTINATION ${INSTALL_CONFIG_DIR}) + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/colmap-config-version.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/colmap-config-version.cmake" @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/colmap-config-version.cmake" + DESTINATION "share/colmap") + +# Install targets. +install( + EXPORT colmap-targets + FILE colmap-targets.cmake + NAMESPACE colmap:: + DESTINATION ${INSTALL_CONFIG_DIR}) + +# Install header files. +install( + DIRECTORY src/colmap + DESTINATION include + FILES_MATCHING PATTERN "*.h") +install( + DIRECTORY src/lib + DESTINATION include/colmap + FILES_MATCHING REGEX ".*[.]h|.*[.]hpp|.*[.]inl") + +# Install find_package scripts for dependencies. +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake + DESTINATION share/colmap + FILES_MATCHING PATTERN "Find*.cmake") diff --git a/doc/install.rst b/doc/install.rst index a44d6e046e..f7fc0f3f77 100755 --- a/doc/install.rst +++ b/doc/install.rst @@ -330,7 +330,8 @@ Then compile and run your code as:: mkdir build cd build - cmake .. -GNinja -Dcolmap_DIR=${CMAKE_INSTALL_PREFIX}/share/colmap + export colmap_DIR=${CMAKE_INSTALL_PREFIX}/share/colmap + cmake .. -GNinja ninja ./hello_world diff --git a/src/colmap/controllers/CMakeLists.txt b/src/colmap/controllers/CMakeLists.txt index 43ac0a3fd2..177a50b7ba 100644 --- a/src/colmap/controllers/CMakeLists.txt +++ b/src/colmap/controllers/CMakeLists.txt @@ -47,12 +47,13 @@ COLMAP_ADD_LIBRARY( colmap_util Eigen3::Eigen PRIVATE_LINK_LIBS - colmap_math colmap_estimators colmap_feature colmap_image - colmap_sfm + colmap_math colmap_mvs + colmap_retrieval + colmap_sfm Ceres::ceres Boost::program_options ) diff --git a/src/colmap/ui/CMakeLists.txt b/src/colmap/ui/CMakeLists.txt index d3c490e681..05d6a79413 100644 --- a/src/colmap/ui/CMakeLists.txt +++ b/src/colmap/ui/CMakeLists.txt @@ -57,7 +57,7 @@ COLMAP_ADD_LIBRARY( reconstruction_manager_widget.h reconstruction_manager_widget.cc reconstruction_options_widget.h reconstruction_options_widget.cc reconstruction_stats_widget.h reconstruction_stats_widget.cc - render_options.h render_options.cc + render_options.h render_options_widget.h render_options_widget.cc thread_control_widget.h thread_control_widget.cc triangle_painter.h triangle_painter.cc diff --git a/src/colmap/ui/render_options.cc b/src/colmap/ui/render_options.cc deleted file mode 100644 index 918b19d8f6..0000000000 --- a/src/colmap/ui/render_options.cc +++ /dev/null @@ -1,47 +0,0 @@ -// 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. -// -// Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) - -#include "colmap/ui/render_options.h" - -#include "colmap/util/logging.h" - -namespace colmap { - -bool RenderOptions::Check() const { - CHECK_OPTION_GE(min_track_len, 0); - CHECK_OPTION_GE(max_error, 0); - CHECK_OPTION_GT(refresh_rate, 0); - CHECK_OPTION(projection_type == ProjectionType::PERSPECTIVE || - projection_type == ProjectionType::ORTHOGRAPHIC); - return true; -} - -} // namespace colmap diff --git a/src/colmap/ui/render_options.h b/src/colmap/ui/render_options.h index 5809ec6e11..e8a6fd8a46 100644 --- a/src/colmap/ui/render_options.h +++ b/src/colmap/ui/render_options.h @@ -33,6 +33,8 @@ #include +#include "colmap/util/logging.h" + namespace colmap { struct RenderOptions { @@ -60,7 +62,14 @@ struct RenderOptions { // The projection type of the renderer. int projection_type = ProjectionType::PERSPECTIVE; - bool Check() const; + inline bool Check() const { + CHECK_OPTION_GE(min_track_len, 0); + CHECK_OPTION_GE(max_error, 0); + CHECK_OPTION_GT(refresh_rate, 0); + CHECK_OPTION(projection_type == ProjectionType::PERSPECTIVE || + projection_type == ProjectionType::ORTHOGRAPHIC); + return true; + } }; } // namespace colmap From 29c15a1890460d913ef478527b628dee9a58a656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Tue, 25 Jul 2023 19:58:23 +0200 Subject: [PATCH 21/38] f --- src/colmap/util/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/colmap/util/CMakeLists.txt b/src/colmap/util/CMakeLists.txt index a7a928ede2..1b806b1842 100644 --- a/src/colmap/util/CMakeLists.txt +++ b/src/colmap/util/CMakeLists.txt @@ -50,7 +50,7 @@ COLMAP_ADD_LIBRARY( Boost::filesystem Eigen3::Eigen glog::glog - OpenGL + OpenGL::GL Qt5::Core Qt5::OpenGL SQLite::SQLite3 From a5c36563f3fd037e356c37649db04201e41eeccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Tue, 25 Jul 2023 20:03:37 +0200 Subject: [PATCH 22/38] openmp --- .azure-pipelines/build-ubuntu.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/build-ubuntu.yaml b/.azure-pipelines/build-ubuntu.yaml index 872df4a6a1..7fd5e6d69e 100644 --- a/.azure-pipelines/build-ubuntu.yaml +++ b/.azure-pipelines/build-ubuntu.yaml @@ -74,14 +74,14 @@ jobs: - ${{ if eq(parameters.asanEnabled, true) }}: - script: | - sudo apt-get install -y clang-15 + sudo apt-get install -y clang-15 libomp-15-dev echo '##vso[task.setvariable variable=CC]/usr/bin/clang-15' echo '##vso[task.setvariable variable=CXX]/usr/bin/clang++-15' displayName: Install Clang - ${{ if eq(parameters.cmakeBuildType, 'ClangTidy') }}: - script: | - sudo apt-get install -y clang-15 clang-tidy-15 + sudo apt-get install -y clang-15 clang-tidy-15 libomp-15-dev echo '##vso[task.setvariable variable=CC]/usr/bin/clang-15' echo '##vso[task.setvariable variable=CXX]/usr/bin/clang++-15' displayName: Install Clang From 4b86268994fd76674b289e6797957bb4311ed7d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Tue, 25 Jul 2023 20:04:34 +0200 Subject: [PATCH 23/38] d --- src/colmap/mvs/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/colmap/mvs/CMakeLists.txt b/src/colmap/mvs/CMakeLists.txt index 20e3943e62..2bea5569a8 100644 --- a/src/colmap/mvs/CMakeLists.txt +++ b/src/colmap/mvs/CMakeLists.txt @@ -83,7 +83,6 @@ if(CUDA_ENABLED) patch_match.h patch_match.cc patch_match_cuda.h patch_match_cuda.cu PUBLIC_LINK_LIBS - colmap_mvs Cuda::cudart Cuda::curand ) From c0b81993ee709e078af9f0855e65a23c4f07aa00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Tue, 25 Jul 2023 20:28:50 +0200 Subject: [PATCH 24/38] d --- cmake/FindCOLMAPDependencies.cmake | 2 +- src/lib/PoissonRecon/CMakeLists.txt | 5 +++-- src/lib/VLFeat/CMakeLists.txt | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmake/FindCOLMAPDependencies.cmake b/cmake/FindCOLMAPDependencies.cmake index d91c956e48..fe6b5f0b81 100644 --- a/cmake/FindCOLMAPDependencies.cmake +++ b/cmake/FindCOLMAPDependencies.cmake @@ -54,7 +54,7 @@ if(TESTS_ENABLED) endif() if(OPENMP_ENABLED) - find_package(OpenMP ${COLMAP_FIND_TYPE}) + find_package(OpenMP QUIET) endif() if(OPENMP_ENABLED AND OPENMP_FOUND) diff --git a/src/lib/PoissonRecon/CMakeLists.txt b/src/lib/PoissonRecon/CMakeLists.txt index 62bde852e2..0ffc9a7809 100644 --- a/src/lib/PoissonRecon/CMakeLists.txt +++ b/src/lib/PoissonRecon/CMakeLists.txt @@ -46,6 +46,7 @@ COLMAP_ADD_LIBRARY( SparseMatrix.h SparseMatrix.inl SurfaceTrimmer.h SurfaceTrimmer.cpp - PUBLIC_LINK_LIBS - OpenMP::OpenMP_CXX ) +if(OPENMP_FOUND) + target_link_libraries(colmap_poisson_recon PRIVATE OpenMP::OpenMP_CXX) +endif() diff --git a/src/lib/VLFeat/CMakeLists.txt b/src/lib/VLFeat/CMakeLists.txt index d59fba85b0..f92251e683 100644 --- a/src/lib/VLFeat/CMakeLists.txt +++ b/src/lib/VLFeat/CMakeLists.txt @@ -110,6 +110,7 @@ endif() COLMAP_ADD_LIBRARY( NAME colmap_vlfeat SRCS ${VLFEAT_SOURCE_FILES} - PUBLIC_LINK_LIBS - OpenMP::OpenMP_C ) +if(OPENMP_FOUND) + target_link_libraries(colmap_vlfeat PRIVATE OpenMP::OpenMP_C) +endif() From ddd6ea662258f121d0450b3cd98047dc94a2627d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Tue, 25 Jul 2023 20:31:44 +0200 Subject: [PATCH 25/38] f --- src/colmap/mvs/CMakeLists.txt | 4 ++-- src/colmap/util/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/colmap/mvs/CMakeLists.txt b/src/colmap/mvs/CMakeLists.txt index 2bea5569a8..14336152b1 100644 --- a/src/colmap/mvs/CMakeLists.txt +++ b/src/colmap/mvs/CMakeLists.txt @@ -83,8 +83,8 @@ if(CUDA_ENABLED) patch_match.h patch_match.cc patch_match_cuda.h patch_match_cuda.cu PUBLIC_LINK_LIBS - Cuda::cudart - Cuda::curand + CUDA::cudart + CUDA::curand ) target_link_libraries(colmap_mvs PRIVATE colmap_mvs_cuda) diff --git a/src/colmap/util/CMakeLists.txt b/src/colmap/util/CMakeLists.txt index 1b806b1842..9023024e29 100644 --- a/src/colmap/util/CMakeLists.txt +++ b/src/colmap/util/CMakeLists.txt @@ -63,7 +63,7 @@ if(CUDA_ENABLED) cuda.h cuda.cc cudacc.h cudacc.cc PUBLIC_LINK_LIBS - Cuda::cudart + CUDA::cudart ) target_link_libraries(colmap_util PUBLIC colmap_util_cuda) endif() From 8a32e1eea02ea7a38e46a90e6eed126f101f0e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 26 Jul 2023 09:19:21 +0200 Subject: [PATCH 26/38] f --- CMakeLists.txt | 1 + src/colmap/estimators/two_view_geometry.h | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1c65dfbd0..fe338222e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,6 +109,7 @@ if(IS_MSVC) # Some fixes for the Glog library. add_definitions("-DGLOG_NO_ABBREVIATED_SEVERITIES") add_definitions("-DGL_GLEXT_PROTOTYPES") + add_definitions("-DNOMINMAX") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") # Enable object level parallel builds in Visual Studio. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") diff --git a/src/colmap/estimators/two_view_geometry.h b/src/colmap/estimators/two_view_geometry.h index 33a590b52a..ba5d6bf2b6 100644 --- a/src/colmap/estimators/two_view_geometry.h +++ b/src/colmap/estimators/two_view_geometry.h @@ -38,8 +38,6 @@ #include "colmap/scene/two_view_geometry.h" #include "colmap/util/logging.h" -#include - namespace colmap { // Estimation options. From 0fb2d9699598f0a1d8bde9769442fb1683859e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 26 Jul 2023 09:27:59 +0200 Subject: [PATCH 27/38] d --- CMakeLists.txt | 58 ++++++++++++++++++++--------------- src/colmap/exe/CMakeLists.txt | 7 ++++- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe338222e7..cc33c5ebf0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,23 +184,6 @@ include(GenerateVersionDefinitions) include_directories(src) link_directories(${COLMAP_LINK_DIRS}) -set(COLMAP_LIBS - colmap_util - colmap_math - colmap_sensor - colmap_image - colmap_feature - colmap_geometry - colmap_scene - colmap_optim - colmap_estimators - colmap_mvs - colmap_retrieval - colmap_sfm - colmap_controllers - colmap_ui -) - add_subdirectory(src/lib) add_subdirectory(src/colmap) @@ -289,20 +272,45 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeUninstall.cmake.in" add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/CMakeUninstall.cmake) set_target_properties(uninstall PROPERTIES FOLDER ${CMAKE_TARGETS_ROOT_FOLDER}) +set(COLMAP_EXPORT_LIBS + # Internal. + colmap_controllers + colmap_estimators + colmap_feature + colmap_geometry + colmap_image + colmap_math + colmap_mvs + colmap_optim + colmap_retrieval + colmap_scene + colmap_sensor + colmap_sfm + colmap_ui + colmap_util + # Third-party. + colmap_lsd + colmap_poisson_recon + colmap_vlfeat + colmap_sift_gpu +) +if(CUDA_ENABLED) + list(APPEND COLMAP_EXPORT_LIBS + colmap_util_cuda + colmap_mvs_cuda + colmap_sift_gpu_cuda + ) +endif() + +# Add unified interface library target to export. add_library(colmap INTERFACE) -target_link_libraries(colmap INTERFACE ${COLMAP_LIBS}) +target_link_libraries(colmap INTERFACE ${COLMAP_EXPORT_LIBS}) set(INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include") target_include_directories( colmap INTERFACE $) install( - TARGETS - colmap - ${COLMAP_LIBS} - colmap_lsd - colmap_poisson_recon - colmap_vlfeat - colmap_sift_gpu + TARGETS colmap ${COLMAP_EXPORT_LIBS} EXPORT colmap-targets LIBRARY DESTINATION lib/) diff --git a/src/colmap/exe/CMakeLists.txt b/src/colmap/exe/CMakeLists.txt index f75f4e9a33..3bae387517 100644 --- a/src/colmap/exe/CMakeLists.txt +++ b/src/colmap/exe/CMakeLists.txt @@ -50,5 +50,10 @@ COLMAP_ADD_EXECUTABLE( sfm.cc vocab_tree.cc LINK_LIBS - ${COLMAP_LIBS}) + colmap_controllers + colmap_scene + colmap_sfm + colmap_ui + colmap_util +) set_target_properties(colmap_exe PROPERTIES OUTPUT_NAME colmap) From 52bdb99650698ea3e636eacc65a7313248d057eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 26 Jul 2023 09:38:26 +0200 Subject: [PATCH 28/38] d --- src/colmap/mvs/CMakeLists.txt | 1 + src/colmap/mvs/patch_match.h | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/colmap/mvs/CMakeLists.txt b/src/colmap/mvs/CMakeLists.txt index 14336152b1..0828e74a40 100644 --- a/src/colmap/mvs/CMakeLists.txt +++ b/src/colmap/mvs/CMakeLists.txt @@ -83,6 +83,7 @@ if(CUDA_ENABLED) patch_match.h patch_match.cc patch_match_cuda.h patch_match_cuda.cu PUBLIC_LINK_LIBS + colmap_util CUDA::cudart CUDA::curand ) diff --git a/src/colmap/mvs/patch_match.h b/src/colmap/mvs/patch_match.h index 32c057851d..d2e99faae4 100644 --- a/src/colmap/mvs/patch_match.h +++ b/src/colmap/mvs/patch_match.h @@ -35,13 +35,13 @@ #include "colmap/mvs/image.h" #include "colmap/mvs/model.h" #include "colmap/mvs/normal_map.h" +#ifndef __CUDACC__ +#include "colmap/util/threading.h" +#endif #include #include #include -#ifndef __CUDACC__ -#include "colmap/util/threading.h" -#endif namespace colmap { namespace mvs { From 7394c202c414086a1e92c801d781fd21196ca45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 26 Jul 2023 10:01:31 +0200 Subject: [PATCH 29/38] f --- src/colmap/CMakeLists.txt | 55 +++++++++++------------------------ src/colmap/mvs/CMakeLists.txt | 4 ++- 2 files changed, 20 insertions(+), 39 deletions(-) diff --git a/src/colmap/CMakeLists.txt b/src/colmap/CMakeLists.txt index 2f468d0cbf..016e5bf779 100644 --- a/src/colmap/CMakeLists.txt +++ b/src/colmap/CMakeLists.txt @@ -32,6 +32,8 @@ if(IS_MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3") + # Avoid pulling in too many header files through + add_definitions("-DWIN32_LEAN_AND_MEAN") elseif(IS_GNU OR IS_CLANG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") @@ -47,6 +49,21 @@ elseif(IS_GNU OR IS_CLANG) endif() endif() +if(CUDA_ENABLED) + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --use_fast_math") + + # Use a separate stream per thread to allow for concurrent kernel execution + # between multiple threads on the same device. + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --default-stream per-thread") + + # Suppress warnings: + # ptxas warning : Stack size for entry function X cannot be statically determined. + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xptxas=-suppress-stack-size-warning") + + # Fix for Ubuntu 16.04. + add_definitions("-D_MWAITXINTRIN_H_INCLUDED") +endif() + add_subdirectory(controllers) add_subdirectory(estimators) add_subdirectory(exe) @@ -65,41 +82,3 @@ add_subdirectory(util) if (GUI_ENABLED) add_subdirectory(ui) endif() - -# COLMAP_ADD_LIBRARY( -# NAME colmap -# SRCS colmap_lib.cc) - -if(CUDA_ENABLED) - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --use_fast_math") - - # Use a separate stream per thread to allow for concurrent kernel execution - # between multiple threads on the same device. - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --default-stream per-thread") - - # Suppress warnings: - # ptxas warning : Stack size for entry function X cannot be statically determined. - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xptxas=-suppress-stack-size-warning") - - # Fix for Ubuntu 16.04. - add_definitions("-D_MWAITXINTRIN_H_INCLUDED") - - if(MSVC) - # Avoid pulling in too many header files through - add_definitions("-DWIN32_LEAN_AND_MEAN") - endif() - - # COLMAP_ADD_LIBRARY( - # NAME colmap_cuda - # SRCS ${COLMAP_CUDA_SOURCES} - # PRIVATE_LINK_LIBS - # CUDA::cudart - # CUDA::curand - # colmap - # ) - # target_link_libraries(colmap - # colmap_cuda ${COLMAP_INTERNAL_LIBRARIES} ${COLMAP_EXTERNAL_LIBRARIES}) -else() - # target_link_libraries(colmap - # ${COLMAP_INTERNAL_LIBRARIES} ${COLMAP_EXTERNAL_LIBRARIES}) -endif() diff --git a/src/colmap/mvs/CMakeLists.txt b/src/colmap/mvs/CMakeLists.txt index 0828e74a40..b35279ada8 100644 --- a/src/colmap/mvs/CMakeLists.txt +++ b/src/colmap/mvs/CMakeLists.txt @@ -92,6 +92,8 @@ if(CUDA_ENABLED) COLMAP_ADD_TEST( NAME gpu_mat_test SRCS gpu_mat_test.cu - LINK_LIBS colmap_mvs + LINK_LIBS + colmap_mvs + colmap_mvs_cuda ) endif() From 457411eef68eade035bcaac3bb9569e680e183d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 26 Jul 2023 10:19:09 +0200 Subject: [PATCH 30/38] d --- src/colmap/mvs/CMakeLists.txt | 6 ++---- src/colmap/util/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/colmap/mvs/CMakeLists.txt b/src/colmap/mvs/CMakeLists.txt index b35279ada8..924d824acd 100644 --- a/src/colmap/mvs/CMakeLists.txt +++ b/src/colmap/mvs/CMakeLists.txt @@ -83,7 +83,7 @@ if(CUDA_ENABLED) patch_match.h patch_match.cc patch_match_cuda.h patch_match_cuda.cu PUBLIC_LINK_LIBS - colmap_util + colmap_util_cuda CUDA::cudart CUDA::curand ) @@ -92,8 +92,6 @@ if(CUDA_ENABLED) COLMAP_ADD_TEST( NAME gpu_mat_test SRCS gpu_mat_test.cu - LINK_LIBS - colmap_mvs - colmap_mvs_cuda + LINK_LIBS colmap_mvs ) endif() diff --git a/src/colmap/util/CMakeLists.txt b/src/colmap/util/CMakeLists.txt index 9023024e29..6c38d67c15 100644 --- a/src/colmap/util/CMakeLists.txt +++ b/src/colmap/util/CMakeLists.txt @@ -63,9 +63,9 @@ if(CUDA_ENABLED) cuda.h cuda.cc cudacc.h cudacc.cc PUBLIC_LINK_LIBS + colmap_util CUDA::cudart ) - target_link_libraries(colmap_util PUBLIC colmap_util_cuda) endif() COLMAP_ADD_TEST( From 58c08d7653ded09b79b59cf827b5ce3b14dcc9f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 26 Jul 2023 11:21:20 +0200 Subject: [PATCH 31/38] f --- src/colmap/estimators/bundle_adjustment.cc | 4 ---- src/colmap/exe/CMakeLists.txt | 8 ++++++++ src/colmap/mvs/CMakeLists.txt | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/colmap/estimators/bundle_adjustment.cc b/src/colmap/estimators/bundle_adjustment.cc index 8ba68430d0..8b5bdb67f9 100644 --- a/src/colmap/estimators/bundle_adjustment.cc +++ b/src/colmap/estimators/bundle_adjustment.cc @@ -33,10 +33,6 @@ #include -#if defined(COLMAP_OPENMP_ENABLED) -#include -#endif - #include "colmap/estimators/cost_functions.h" #include "colmap/scene/projection.h" #include "colmap/sensor/models.h" diff --git a/src/colmap/exe/CMakeLists.txt b/src/colmap/exe/CMakeLists.txt index 3bae387517..7369304ed4 100644 --- a/src/colmap/exe/CMakeLists.txt +++ b/src/colmap/exe/CMakeLists.txt @@ -35,6 +35,13 @@ if(IS_MSVC) add_compile_options("/bigobj") endif() +if(CUDA_ENABLED) + set(OPTIONAL_CUDA_LIBS + colmap_util_cuda + colmap_mvs_cuda + ) +endif() + COLMAP_ADD_EXECUTABLE( NAME colmap_exe SRCS @@ -55,5 +62,6 @@ COLMAP_ADD_EXECUTABLE( colmap_sfm colmap_ui colmap_util + ${OPTIONAL_CUDA_LIBS} ) set_target_properties(colmap_exe PROPERTIES OUTPUT_NAME colmap) diff --git a/src/colmap/mvs/CMakeLists.txt b/src/colmap/mvs/CMakeLists.txt index 924d824acd..30593fb804 100644 --- a/src/colmap/mvs/CMakeLists.txt +++ b/src/colmap/mvs/CMakeLists.txt @@ -83,15 +83,15 @@ if(CUDA_ENABLED) patch_match.h patch_match.cc patch_match_cuda.h patch_match_cuda.cu PUBLIC_LINK_LIBS + colmap_mvs colmap_util_cuda CUDA::cudart CUDA::curand ) - target_link_libraries(colmap_mvs PRIVATE colmap_mvs_cuda) COLMAP_ADD_TEST( NAME gpu_mat_test SRCS gpu_mat_test.cu - LINK_LIBS colmap_mvs + LINK_LIBS colmap_mvs_cuda ) endif() From 92da332ff3647c88881e1086608ba8cc851e0388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 26 Jul 2023 12:11:22 +0200 Subject: [PATCH 32/38] d --- doc/install.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/install.rst b/doc/install.rst index f7fc0f3f77..327c856635 100755 --- a/doc/install.rst +++ b/doc/install.rst @@ -282,10 +282,9 @@ Library ------- If you want to include and link COLMAP against your own library, the easiest way -is to use CMake as a build configuration tool. By setting `-DLIBRARY_ENABLED` -when configuring the COLMAP build and then running `ninja/make install`, COLMAP -automatically installs all headers to -``${CMAKE_INSTALL_PREFIX}/include/colmap``, all libraries to +is to use CMake as a build configuration tool. After configuring the COLMAP +build and running `ninja/make install`, COLMAP automatically installs all +headers to ``${CMAKE_INSTALL_PREFIX}/include/colmap``, all libraries to ``${CMAKE_INSTALL_PREFIX}/lib/colmap``, and the CMake configuration to ``${CMAKE_INSTALL_PREFIX}/share/colmap``. From 28f0d232746fd35f091d2434062a65eebfab7596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 26 Jul 2023 13:37:19 +0200 Subject: [PATCH 33/38] d --- .azure-pipelines/build-ubuntu.yaml | 16 +++++++++++++++- doc/install.rst | 4 +++- doc/sample-project/CMakeLists.txt | 9 +++++++++ doc/sample-project/hello_world.cc | 21 +++++++++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 doc/sample-project/CMakeLists.txt create mode 100644 doc/sample-project/hello_world.cc diff --git a/.azure-pipelines/build-ubuntu.yaml b/.azure-pipelines/build-ubuntu.yaml index 7fd5e6d69e..81feddfe73 100644 --- a/.azure-pipelines/build-ubuntu.yaml +++ b/.azure-pipelines/build-ubuntu.yaml @@ -106,17 +106,31 @@ jobs: condition: ne(variables.CCACHE_RESTORED, 'true') - script: | + set -x cmake --version mkdir build cd build cmake .. \ -GNinja \ -DCMAKE_BUILD_TYPE=${{ parameters.cmakeBuildType }} \ + -DCMAKE_INSTALL_PREFIX=./install -DTESTS_ENABLED=ON \ -DCMAKE_CUDA_ARCHITECTURES=50 \ -DASAN_ENABLED=${{ parameters.asanEnabled }} ninja -k $(numAllowedNinjaErrors) - displayName: Configure and build + displayName: Configure and build colmap + + - script: | + set -x + cd build + ninja install + cd ../doc/sample-project + mkdir build + cd build + colmap_DIR=$(Build.SourcesDirectory)/build/install/share/colmap cmake .. -GNinja + ninja + ./hello_world + displayName: Install and build sample project - ${{ if ne(parameters.cmakeBuildType, 'ClangTidy') }}: - script: | diff --git a/doc/install.rst b/doc/install.rst index 327c856635..ea5cf0fc86 100755 --- a/doc/install.rst +++ b/doc/install.rst @@ -293,7 +293,7 @@ using the following ``CMakeLists.txt``:: cmake_minimum_required(VERSION 3.10) - project(TestProject) + project(SampleProject) find_package(colmap REQUIRED) # or to require a specific version: find_package(colmap 3.4 REQUIRED) @@ -334,6 +334,8 @@ Then compile and run your code as:: ninja ./hello_world +The sources of this example are stored under ``doc/sample-project``. + ---------------- AddressSanitizer ---------------- diff --git a/doc/sample-project/CMakeLists.txt b/doc/sample-project/CMakeLists.txt new file mode 100644 index 0000000000..04ff27b88f --- /dev/null +++ b/doc/sample-project/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.10) + +project(SampleProject) + +find_package(colmap REQUIRED) +# or to require a specific version: find_package(colmap 3.4 REQUIRED) + +add_executable(hello_world hello_world.cc) +target_link_libraries(hello_world colmap::colmap) diff --git a/doc/sample-project/hello_world.cc b/doc/sample-project/hello_world.cc new file mode 100644 index 0000000000..eddaa480ed --- /dev/null +++ b/doc/sample-project/hello_world.cc @@ -0,0 +1,21 @@ +#include +#include + +#include +#include + +int main(int argc, char** argv) { + colmap::InitializeGlog(argv); + + std::string input_path; + std::string output_path; + + colmap::OptionManager options; + options.AddRequiredOption("input_path", &input_path); + options.AddRequiredOption("output_path", &output_path); + options.Parse(argc, argv); + + std::cout << colmap::StringPrintf("Hello %s!", "COLMAP") << std::endl; + + return EXIT_SUCCESS; +} From ba3fd907ddecff1e248c5c9b5194a93d62dc0c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 26 Jul 2023 13:41:14 +0200 Subject: [PATCH 34/38] f --- .azure-pipelines/build-ubuntu.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/build-ubuntu.yaml b/.azure-pipelines/build-ubuntu.yaml index 81feddfe73..cb66f9c995 100644 --- a/.azure-pipelines/build-ubuntu.yaml +++ b/.azure-pipelines/build-ubuntu.yaml @@ -113,7 +113,7 @@ jobs: cmake .. \ -GNinja \ -DCMAKE_BUILD_TYPE=${{ parameters.cmakeBuildType }} \ - -DCMAKE_INSTALL_PREFIX=./install + -DCMAKE_INSTALL_PREFIX=./install \ -DTESTS_ENABLED=ON \ -DCMAKE_CUDA_ARCHITECTURES=50 \ -DASAN_ENABLED=${{ parameters.asanEnabled }} From 60286cc1411c50b637d10713c43372801f406d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 26 Jul 2023 14:05:01 +0200 Subject: [PATCH 35/38] d --- .azure-pipelines/build-ubuntu.yaml | 2 +- doc/install.rst | 11 ++++------- doc/sample-project/hello_world.cc | 9 +++------ 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/.azure-pipelines/build-ubuntu.yaml b/.azure-pipelines/build-ubuntu.yaml index cb66f9c995..141120c1cf 100644 --- a/.azure-pipelines/build-ubuntu.yaml +++ b/.azure-pipelines/build-ubuntu.yaml @@ -129,7 +129,7 @@ jobs: cd build colmap_DIR=$(Build.SourcesDirectory)/build/install/share/colmap cmake .. -GNinja ninja - ./hello_world + ./hello_world --message "world" displayName: Install and build sample project - ${{ if ne(parameters.cmakeBuildType, 'ClangTidy') }}: diff --git a/doc/install.rst b/doc/install.rst index ea5cf0fc86..c9af9fbd80 100755 --- a/doc/install.rst +++ b/doc/install.rst @@ -312,15 +312,12 @@ with the source code ``hello_world.cc``:: int main(int argc, char** argv) { colmap::InitializeGlog(argv); - std::string input_path; - std::string output_path; - + std::string message; colmap::OptionManager options; - options.AddRequiredOption("input_path", &input_path); - options.AddRequiredOption("output_path", &output_path); + options.AddRequiredOption("message", &message); options.Parse(argc, argv); - std::cout << colmap::StringPrintf("Hello %s!", "COLMAP") << std::endl; + std::cout << colmap::StringPrintf("Hello %s!", message.c_str()) << std::endl; return EXIT_SUCCESS; } @@ -332,7 +329,7 @@ Then compile and run your code as:: export colmap_DIR=${CMAKE_INSTALL_PREFIX}/share/colmap cmake .. -GNinja ninja - ./hello_world + ./hello_world --message "world" The sources of this example are stored under ``doc/sample-project``. diff --git a/doc/sample-project/hello_world.cc b/doc/sample-project/hello_world.cc index eddaa480ed..6c6cb4ccf7 100644 --- a/doc/sample-project/hello_world.cc +++ b/doc/sample-project/hello_world.cc @@ -7,15 +7,12 @@ int main(int argc, char** argv) { colmap::InitializeGlog(argv); - std::string input_path; - std::string output_path; - + std::string message; colmap::OptionManager options; - options.AddRequiredOption("input_path", &input_path); - options.AddRequiredOption("output_path", &output_path); + options.AddRequiredOption("message", &message); options.Parse(argc, argv); - std::cout << colmap::StringPrintf("Hello %s!", "COLMAP") << std::endl; + std::cout << colmap::StringPrintf("Hello %s!", message.c_str()) << std::endl; return EXIT_SUCCESS; } From d147a4401caf7a098e8724dbb2e4d7729de846f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 26 Jul 2023 14:05:24 +0200 Subject: [PATCH 36/38] d --- .azure-pipelines/build-ubuntu.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/build-ubuntu.yaml b/.azure-pipelines/build-ubuntu.yaml index 141120c1cf..ce826fa75c 100644 --- a/.azure-pipelines/build-ubuntu.yaml +++ b/.azure-pipelines/build-ubuntu.yaml @@ -130,7 +130,7 @@ jobs: colmap_DIR=$(Build.SourcesDirectory)/build/install/share/colmap cmake .. -GNinja ninja ./hello_world --message "world" - displayName: Install and build sample project + displayName: Install colmap and build sample - ${{ if ne(parameters.cmakeBuildType, 'ClangTidy') }}: - script: | From 7955cd1cb268193af1d46b6b4e9a22e554ec0d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 26 Jul 2023 14:34:10 +0200 Subject: [PATCH 37/38] d --- .azure-pipelines/build-ubuntu.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.azure-pipelines/build-ubuntu.yaml b/.azure-pipelines/build-ubuntu.yaml index ce826fa75c..a595d999cc 100644 --- a/.azure-pipelines/build-ubuntu.yaml +++ b/.azure-pipelines/build-ubuntu.yaml @@ -127,7 +127,9 @@ jobs: cd ../doc/sample-project mkdir build cd build - colmap_DIR=$(Build.SourcesDirectory)/build/install/share/colmap cmake .. -GNinja + colmap_DIR=$(Build.SourcesDirectory)/build/install/share/colmap cmake .. \ + -GNinja \ + -DCMAKE_CUDA_ARCHITECTURES=50 ninja ./hello_world --message "world" displayName: Install colmap and build sample From d630fce8e8dc757c3bcfb967dfff47726c7e5445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 26 Jul 2023 16:16:51 +0200 Subject: [PATCH 38/38] d --- .azure-pipelines/build-ubuntu.yaml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.azure-pipelines/build-ubuntu.yaml b/.azure-pipelines/build-ubuntu.yaml index a595d999cc..b193c8211c 100644 --- a/.azure-pipelines/build-ubuntu.yaml +++ b/.azure-pipelines/build-ubuntu.yaml @@ -120,19 +120,20 @@ jobs: ninja -k $(numAllowedNinjaErrors) displayName: Configure and build colmap - - script: | - set -x - cd build - ninja install - cd ../doc/sample-project - mkdir build - cd build - colmap_DIR=$(Build.SourcesDirectory)/build/install/share/colmap cmake .. \ - -GNinja \ - -DCMAKE_CUDA_ARCHITECTURES=50 - ninja - ./hello_world --message "world" - displayName: Install colmap and build sample + - ${{ if and(eq(parameters.cmakeBuildType, 'Release'), eq(parameters.asanEnabled, false)) }}: + - script: | + set -x + cd build + ninja install + cd ../doc/sample-project + mkdir build + cd build + colmap_DIR=$(Build.SourcesDirectory)/build/install/share/colmap cmake .. \ + -GNinja \ + -DCMAKE_CUDA_ARCHITECTURES=50 + ninja + ./hello_world --message "world" + displayName: Install colmap and build sample - ${{ if ne(parameters.cmakeBuildType, 'ClangTidy') }}: - script: |