8000 Improved tests for reconstruction merging by ahojnnes · Pull Request #3413 · colmap/colmap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improved tests for reconstruction merging #3413

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

Merged
merged 1 commit into from
Jun 23, 2025
Merged
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
48 changes: 33 additions & 15 deletions src/colmap/estimators/alignment_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,34 +178,52 @@ TEST(Alignment, MergeReconstructions) {
// Synthesize a reconstruction which has at least two cameras
Reconstruction src_reconstruction;
SyntheticDatasetOptions synthetic_dataset_options;
synthetic_dataset_options.num_rigs = 2;
synthetic_dataset_options.num_rigs = 3;
synthetic_dataset_options.num_cameras_per_rig = 1;
synthetic_dataset_options.num_frames_per_rig = 10;
synthetic_dataset_options.num_points3D = 50;
synthetic_dataset_options.point2D_stddev = 0;
SynthesizeDataset(synthetic_dataset_options, &src_reconstruction);
Reconstruction orig_reconstruction = src_reconstruction;
Reconstruction tgt_reconstruction = src_reconstruction;

// Remove the rig of the first image from the target reconstruction.
const std::vector<frame_t> frame_ids = tgt_reconstruction.RegFrameIds();
const rig_t rig_id = tgt_reconstruction.Frame(*frame_ids.begin()).RigId();
for (const auto& frame_id : frame_ids) {
if (tgt_reconstruction.Frame(frame_id).RigId() == rig_id) {
tgt_reconstruction.DeRegisterFrame(frame_id);
auto remove_rig_frames = [](Reconstruction& reconstruction, rig_t rig_id) {
const std::vector<frame_t> frame_ids = reconstruction.RegFrameIds();
for (const auto& frame_id : frame_ids) {
if (reconstruction.Frame(frame_id).RigId() == rig_id) {
reconstruction.DeRegisterFrame(frame_id);
}
}
}
tgt_reconstruction.TearDown();
EXPECT_EQ(tgt_reconstruction.NumCameras(), 1);
EXPECT_EQ(tgt_reconstruction.NumImages(), 10);
};

// Merge reconstructions
ASSERT_TRUE(
MergeReconstructions(0.01, src_reconstruction, tgt_reconstruction));
remove_rig_frames(src_reconstruction, 1);
remove_rig_frames(tgt_reconstruction, 2);

// Remove all unregistered rigs/cameras/frames/images.
src_reconstruction.TearDown();
tgt_reconstruction.TearDown();
EXPECT_EQ(src_reconstruction.NumRigs(), 2);
EXPECT_EQ(src_reconstruction.NumCameras(), 2);
EXPECT_EQ(src_reconstruction.NumFrames(), 20);
EXPECT_EQ(src_reconstruction.NumRegFrames(), 20);
EXPECT_EQ(src_reconstruction.NumImages(), 20);
EXPECT_EQ(tgt_reconstruction.NumRigs(), 2);
EXPECT_EQ(tgt_reconstruction.NumCameras(), 2);
EXPECT_EQ(tgt_reconstruction.NumFrames(), 20);
EXPECT_EQ(tgt_reconstruction.NumRegFrames(), 20);
EXPECT_EQ(tgt_reconstruction.NumImages(), 20);

// Merge reconstructions.
ASSERT_TRUE(MergeReconstructions(
/*max_reproj_error=*/1e-4, src_reconstruction, tgt_reconstruction));
EXPECT_EQ(tgt_reconstruction.NumRigs(), 3);
EXPECT_EQ(tgt_reconstruction.NumCameras(), 3);
EXPECT_EQ(tgt_reconstruction.NumFrames(), 30);
EXPECT_EQ(tgt_reconstruction.NumRegFrames(), 30);
EXPECT_EQ(tgt_reconstruction.NumImages(), 30);
EXPECT_EQ(tgt_reconstruction.NumPoints3D(), 50);
EXPECT_EQ(tgt_reconstruction.ComputeNumObservations(),
src_reconstruction.ComputeNumObservations());
orig_reconstruction.ComputeNumObservations());
}

} // namespace
Expand Down
Loading
0