Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update to COLMAP HEAD #132

Merged
merged 6 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ jobs:
libmetis-dev \
libgoogle-glog-dev \
libgtest-dev \
libgmock-dev \
libsqlite3-dev \
libglew-dev \
qtbase5-dev \
Expand Down
3 changes: 2 additions & 1 deletion cmake/FindDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -35,7 +36,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...")
Expand Down
3 changes: 2 additions & 1 deletion glomap/controllers/global_mapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "glomap/processors/track_filter.h"
#include "glomap/processors/view_graph_manipulation.h"

#include <colmap/util/file.h>
#include <colmap/util/timer.h>

namespace glomap {
Expand Down Expand Up @@ -325,4 +326,4 @@ bool GlobalMapper::Solve(const colmap::Database& database,
return true;
}

} // namespace glomap
} // namespace glomap
16 changes: 9 additions & 7 deletions glomap/controllers/track_retriangulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

#include "glomap/io/colmap_converter.h"

#include <colmap/controllers/incremental_mapper.h>
#include <colmap/controllers/incremental_pipeline.h>
#include <colmap/estimators/bundle_adjustment.h>
#include <colmap/scene/database_cache.h>

#include <set>

namespace glomap {

bool RetriangulateTracks(const TriangulatorOptions& options,
Expand Down Expand Up @@ -40,7 +42,7 @@ bool RetriangulateTracks(const TriangulatorOptions& options,
std::unordered_map<track_t, Track>(),
*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 =
Expand All @@ -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<image_t>& reg_image_ids = reconstruction_ptr->RegImageIds();
const std::set<image_t>& 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);
Expand Down Expand Up @@ -128,4 +130,4 @@ bool RetriangulateTracks(const TriangulatorOptions& options,
return true;
}

} // namespace glomap
} // namespace glomap
2 changes: 1 addition & 1 deletion glomap/estimators/bundle_adjustment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void BundleAdjuster::AddPointToCameraConstraints(
Image& image = images[observation.first];

ceres::CostFunction* cost_function =
colmap::CameraCostFunction<colmap::ReprojErrorCostFunction>(
colmap::CreateCameraCostFunction<colmap::ReprojErrorCostFunctor>(
cameras[image.camera_id].model_id,
image.features[observation.second]);

Expand Down
3 changes: 2 additions & 1 deletion glomap/exe/global_mapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "glomap/io/colmap_io.h"
#include "glomap/types.h"

#include <colmap/util/file.h>
#include <colmap/util/misc.h>
#include <colmap/util/timer.h>

Expand Down Expand Up @@ -151,4 +152,4 @@ int RunMapperResume(int argc, char** argv) {
return EXIT_SUCCESS;
}

} // namespace glomap
} // namespace glomap
11 changes: 7 additions & 4 deletions glomap/io/colmap_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<Rigid3d>(image_colmap.CamFromWorld());
image.is_registered = image_colmap.HasPose();
if (image_colmap.HasPose()) {
image.cam_from_world = static_cast<Rigid3d>(image_colmap.CamFromWorld());
}
image.features.clear();
image.features.reserve(image_colmap.NumPoints2D());

Expand Down
1 change: 1 addition & 0 deletions glomap/io/colmap_io.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "glomap/io/colmap_io.h"

#include <colmap/util/file.h>
#include <colmap/util/misc.h>

namespace glomap {
Expand Down
Loading