Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
34 changes: 32 additions & 2 deletions src/colmap/estimators/alignment_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ void ExpectEqualSim3d(const Sim3d& gt_tgt_from_src, const Sim3d& tgt_from_src) {
}

Reconstruction GenerateReconstructionForAlignment() {
// const std::string database_path = CreateTestDir() + "/database.db";
// Database database(database_path);
Reconstruction reconstruction;
SyntheticDatasetOptions synthetic_dataset_options;
synthetic_dataset_options.num_cameras = 2;
Expand Down Expand Up @@ -116,4 +114,36 @@ TEST(Alignment, AlignReconstructionsViaPoints) {
ExpectEqualSim3d(gt_tgt_from_src, tgt_from_src);
}

TEST(Alignment, MergeReconstructions) {
// Synthesize a reconstruction which has at least two cameras
Reconstruction src_reconstruction;
SyntheticDatasetOptions synthetic_dataset_options;
synthetic_dataset_options.num_cameras = 2;
synthetic_dataset_options.num_images = 20;
synthetic_dataset_options.num_points3D = 50;
synthetic_dataset_options.point2D_stddev = 0;
SynthesizeDataset(synthetic_dataset_options, &src_reconstruction);
Reconstruction tgt_reconstruction = src_reconstruction;

// Remove the camera of the first image from the target reconstruction
const std::vector<image_t>& image_ids = tgt_reconstruction.RegImageIds();
camera_t camera_id = tgt_reconstruction.Image(image_ids[0]).CameraId();
for (const auto& image_id : image_ids) {
if (tgt_reconstruction.Image(image_id).CameraId() == camera_id) {
tgt_reconstruction.DeRegisterImage(image_id);
}
}
tgt_reconstruction.TearDown();
EXPECT_EQ(tgt_reconstruction.NumCameras(), 1);
EXPECT_EQ(tgt_reconstruction.NumImages(), 10);

// Merge reconstructions
MergeReconstructions(0.01, src_reconstruction, tgt_reconstruction);
EXPECT_EQ(tgt_reconstruction.NumCameras(), 2);
EXPECT_EQ(tgt_reconstruction.NumImages(), 20);
EXPECT_EQ(tgt_reconstruction.NumPoints3D(), 50);
EXPECT_EQ(tgt_reconstruction.ComputeNumObservations(),
src_reconstruction.ComputeNumObservations());
}

} // namespace colmap