| 42 | namespace { |
| 43 | |
| 44 | TEST(Model, ReadCOLMAP) { |
| 45 | SetPRNGSeed(0); |
| 46 | Reconstruction reconstruction; |
| 47 | SyntheticDatasetOptions synthetic_dataset_options; |
| 48 | synthetic_dataset_options.num_rigs = 1; |
| 49 | synthetic_dataset_options.num_cameras_per_rig = 1; |
| 50 | synthetic_dataset_options.num_frames_per_rig = 3; |
| 51 | synthetic_dataset_options.num_points3D = 10; |
| 52 | SynthesizeDataset(synthetic_dataset_options, &reconstruction); |
| 53 | |
| 54 | const auto test_dir = CreateTestDir(); |
| 55 | const auto sparse_path = test_dir / "sparse"; |
| 56 | std::filesystem::create_directories(sparse_path); |
| 57 | reconstruction.WriteBinary(sparse_path); |
| 58 | |
| 59 | Model model; |
| 60 | model.ReadFromCOLMAP(test_dir); |
| 61 | EXPECT_EQ(model.images.size(), reconstruction.NumRegImages()); |
| 62 | EXPECT_EQ(model.points.size(), reconstruction.NumPoints3D()); |
| 63 | |
| 64 | Model model_lower; |
| 65 | model_lower.Read(test_dir, "colmap"); |
| 66 | EXPECT_EQ(model_lower.images.size(), reconstruction.NumRegImages()); |
| 67 | EXPECT_EQ(model_lower.points.size(), reconstruction.NumPoints3D()); |
| 68 | |
| 69 | // Verify case insensitivity. |
| 70 | Model model_upper; |
| 71 | model_upper.Read(test_dir, "COLMAP"); |
| 72 | EXPECT_EQ(model_upper.images.size(), reconstruction.NumRegImages()); |
| 73 | EXPECT_EQ(model_upper.points.size(), reconstruction.NumPoints3D()); |
| 74 | |
| 75 | const std::string name = model.GetImageName(0); |
| 76 | EXPECT_FALSE(name.empty()); |
| 77 | EXPECT_EQ(model.GetImageIdx(name), 0); |
| 78 | |
| 79 | EXPECT_THROW(model.GetImageIdx("nonexistent"), std::exception); |
| 80 | EXPECT_THROW(model.GetImageName(-1), std::exception); |
| 81 | EXPECT_THROW(model.GetImageName(model.images.size()), std::exception); |
| 82 | } |
| 83 | |
| 84 | TEST(Model, ComputeSharedPoints) { |
| 85 | Model model; |
nothing calls this directly
no test coverage detected