From f0fbeeb78f82dfaf37758fa2d2571da28d059cd0 Mon Sep 17 00:00:00 2001 From: Paul-Edouard Sarlin Date: Tue, 5 Nov 2024 12:04:07 +0100 Subject: [PATCH 1/6] Update to COLMAP HEAD --- glomap/controllers/global_mapper.cc | 3 ++- glomap/controllers/track_retriangulation.cc | 16 +++++++++------- glomap/estimators/bundle_adjustment.cc | 2 +- glomap/exe/global_mapper.cc | 3 ++- glomap/io/colmap_converter.cc | 11 +++++++---- glomap/io/colmap_io.cc | 1 + 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/glomap/controllers/global_mapper.cc b/glomap/controllers/global_mapper.cc index 22f14c8..c359419 100644 --- a/glomap/controllers/global_mapper.cc +++ b/glomap/controllers/global_mapper.cc @@ -7,6 +7,7 @@ #include "glomap/processors/track_filter.h" #include "glomap/processors/view_graph_manipulation.h" +#include #include namespace glomap { @@ -325,4 +326,4 @@ bool GlobalMapper::Solve(const colmap::Database& database, return true; } -} // namespace glomap \ No newline at end of file +} // namespace glomap diff --git a/glomap/controllers/track_retriangulation.cc b/glomap/controllers/track_retriangulation.cc index 18559c2..678f99a 100644 --- a/glomap/controllers/track_retriangulation.cc +++ b/glomap/controllers/track_retriangulation.cc @@ -2,10 +2,12 @@ #include "glomap/io/colmap_converter.h" -#include +#include #include #include +#include + namespace glomap { bool RetriangulateTracks(const TriangulatorOptions& options, @@ -40,7 +42,7 @@ bool RetriangulateTracks(const TriangulatorOptions& options, std::unordered_map(), *reconstruction_ptr); - colmap::IncrementalMapperOptions options_colmap; + colmap::IncrementalPipelineOptions options_colmap; options_colmap.triangulation.complete_max_reproj_error = options.tri_complete_max_reproj_error; options_colmap.triangulation.merge_max_reproj_error = @@ -57,13 +59,13 @@ bool RetriangulateTracks(const TriangulatorOptions& options, const auto tri_options = options_colmap.Triangulation(); const auto mapper_options = options_colmap.Mapper(); - const std::vector& reg_image_ids = reconstruction_ptr->RegImageIds(); + const std::set& reg_image_ids = reconstruction_ptr->RegImageIds(); - for (size_t i = 0; i < reg_image_ids.size(); ++i) { - std::cout << "\r Triangulating image " << i + 1 << " / " + size_t image_idx = 0; + for (const image_t image_id : reg_image_ids) { + std::cout << "\r Triangulating image " << image_idx++ + 1 << " / " << reg_image_ids.size() << std::flush; - const image_t image_id = reg_image_ids[i]; const auto& image = reconstruction_ptr->Image(image_id); int num_tris = mapper.TriangulateImage(tri_options, image_id); @@ -128,4 +130,4 @@ bool RetriangulateTracks(const TriangulatorOptions& options, return true; } -} // namespace glomap \ No newline at end of file +} // namespace glomap diff --git a/glomap/estimators/bundle_adjustment.cc b/glomap/estimators/bundle_adjustment.cc index 32204ba..f9aa51c 100644 --- a/glomap/estimators/bundle_adjustment.cc +++ b/glomap/estimators/bundle_adjustment.cc @@ -70,7 +70,7 @@ void BundleAdjuster::AddPointToCameraConstraints( Image& image = images[observation.first]; ceres::CostFunction* cost_function = - colmap::CameraCostFunction( + colmap::CreateCameraCostFunction( cameras[image.camera_id].model_id, image.features[observation.second]); diff --git a/glomap/exe/global_mapper.cc b/glomap/exe/global_mapper.cc index 7e4deac..fb1e512 100644 --- a/glomap/exe/global_mapper.cc +++ b/glomap/exe/global_mapper.cc @@ -4,6 +4,7 @@ #include "glomap/io/colmap_io.h" #include "glomap/types.h" +#include #include #include @@ -151,4 +152,4 @@ int RunMapperResume(int argc, char** argv) { return EXIT_SUCCESS; } -} // namespace glomap \ No newline at end of file +} // namespace glomap diff --git a/glomap/io/colmap_converter.cc b/glomap/io/colmap_converter.cc index eceaead..75ab3ba 100644 --- a/glomap/io/colmap_converter.cc +++ b/glomap/io/colmap_converter.cc @@ -9,9 +9,10 @@ void ConvertGlomapToColmapImage(const Image& image, bool keep_points) { image_colmap.SetImageId(image.image_id); image_colmap.SetCameraId(image.camera_id); - image_colmap.SetRegistered(image.is_registered); image_colmap.SetName(image.file_name); - image_colmap.CamFromWorld() = image.cam_from_world; + if (image.is_registered) { + image_colmap.SetCamFromWorld(image.cam_from_world); + } if (keep_points) { image_colmap.SetPoints2D(image.features); @@ -130,8 +131,10 @@ void ConvertColmapToGlomap(const colmap::Reconstruction& reconstruction, image_colmap.Name()))); Image& image = ite.first->second; - image.is_registered = image_colmap.IsRegistered(); - image.cam_from_world = static_cast(image_colmap.CamFromWorld()); + image.is_registered = image_colmap.HasPose(); + if (image_colmap.HasPose()) { + image.cam_from_world = static_cast(image_colmap.CamFromWorld()); + } image.features.clear(); image.features.reserve(image_colmap.NumPoints2D()); diff --git a/glomap/io/colmap_io.cc b/glomap/io/colmap_io.cc index 88dc4cc..5189e6d 100644 --- a/glomap/io/colmap_io.cc +++ b/glomap/io/colmap_io.cc @@ -1,5 +1,6 @@ #include "glomap/io/colmap_io.h" +#include #include namespace glomap { From 1fd34ed4edd502010f447b2f6fc29aaedc7ebf1a Mon Sep 17 00:00:00 2001 From: Paul-Edouard Sarlin Date: Tue, 5 Nov 2024 12:32:41 +0100 Subject: [PATCH 2/6] Bump COLMAP tag --- cmake/FindDependencies.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindDependencies.cmake b/cmake/FindDependencies.cmake index 7bcf202..6e86a9e 100644 --- a/cmake/FindDependencies.cmake +++ b/cmake/FindDependencies.cmake @@ -35,7 +35,7 @@ message(STATUS "Configuring PoseLib... done") FetchContent_Declare(COLMAP GIT_REPOSITORY https://github.com/colmap/colmap.git - GIT_TAG 66fd8e56a0d160d68af2f29e9ac6941d442d2322 + GIT_TAG 3254263266949413d7c669e44abeb4a7c2670a8b EXCLUDE_FROM_ALL ) message(STATUS "Configuring COLMAP...") From 7ffa421ee32766de05b81c70cc00855e18d300e6 Mon Sep 17 00:00:00 2001 From: Paul-Edouard Sarlin <15985472+sarlinpe@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:38:23 +0100 Subject: [PATCH 3/6] Install gmock in CI --- .github/workflows/ubuntu.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index a8246f9..5800015 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -107,6 +107,7 @@ jobs: libmetis-dev \ libgoogle-glog-dev \ libgtest-dev \ + libgmock-dev \ libsqlite3-dev \ libglew-dev \ qtbase5-dev \ From 362d49f6d76be49dc78722020068eb50af5a7145 Mon Sep 17 00:00:00 2001 From: Paul-Edouard Sarlin <15985472+sarlinpe@users.noreply.github.com> Date: Tue, 5 Nov 2024 21:26:59 +0100 Subject: [PATCH 4/6] Apply clang-tidy only to GLOMAP headers --- .clang-tidy | 1 + 1 file changed, 1 insertion(+) diff --git a/.clang-tidy b/.clang-tidy index 50b9315..4867062 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -17,3 +17,4 @@ Checks: > WarningsAsErrors: '*' FormatStyle: 'file' User: 'user' +HeaderFilterRegex: '.*\\/glomap\\/.*' From 367e9f4c566380b2ba5efd7d9da3cb8173ff700e Mon Sep 17 00:00:00 2001 From: Paul-Edouard Sarlin <15985472+sarlinpe@users.noreply.github.com> Date: Tue, 5 Nov 2024 21:41:32 +0100 Subject: [PATCH 5/6] Fix clang-tidy regexp header filter --- .clang-tidy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index 4867062..adc4329 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -17,4 +17,4 @@ Checks: > WarningsAsErrors: '*' FormatStyle: 'file' User: 'user' -HeaderFilterRegex: '.*\\/glomap\\/.*' +HeaderFilterRegex: '.*\\/glomap\\/(controllers|estimators|exe|io|math|processors|scene|types\\.h).*' From f6dc3d0c2d43f9329dd40db57b4525bafdd453cf Mon Sep 17 00:00:00 2001 From: Paul-Edouard Sarlin Date: Tue, 5 Nov 2024 22:20:39 +0100 Subject: [PATCH 6/6] Make PoseLib a system include --- .clang-tidy | 1 - cmake/FindDependencies.cmake | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index adc4329..50b9315 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -17,4 +17,3 @@ Checks: > WarningsAsErrors: '*' FormatStyle: 'file' User: 'user' -HeaderFilterRegex: '.*\\/glomap\\/(controllers|estimators|exe|io|math|processors|scene|types\\.h).*' diff --git a/cmake/FindDependencies.cmake b/cmake/FindDependencies.cmake index 6e86a9e..5a89c7c 100644 --- a/cmake/FindDependencies.cmake +++ b/cmake/FindDependencies.cmake @@ -24,6 +24,7 @@ FetchContent_Declare(PoseLib GIT_REPOSITORY https://github.com/PoseLib/PoseLib.git GIT_TAG 0439b2d361125915b8821043fca9376e6cc575b9 EXCLUDE_FROM_ALL + SYSTEM ) message(STATUS "Configuring PoseLib...") if (FETCH_POSELIB)