MCPcopy Create free account
hub / github.com/colmap/colmap / ImageReader

Method ImageReader

src/colmap/controllers/image_reader.cc:49–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49ImageReader::ImageReader(const ImageReaderOptions& options, Database* database)
50 : options_(options), database_(database), image_index_(0) {
51 THROW_CHECK(options_.Check());
52
53 // Get a list of all files in the image path, sorted by image name.
54 if (options_.image_names.empty()) {
55 auto image_paths = GetRecursiveFileList(options_.image_path);
56 std::sort(image_paths.begin(), image_paths.end());
57 options_.image_names.reserve(image_paths.size());
58 for (const auto& image_path : image_paths) {
59 options_.image_names.push_back(
60 GetNormalizedRelativePath(image_path, options_.image_path));
61 }
62 } else {
63 if (!std::is_sorted(options_.image_names.begin(),
64 options_.image_names.end())) {
65 std::sort(options_.image_names.begin(), options_.image_names.end());
66 }
67 }
68
69 if (static_cast<camera_t>(options_.existing_camera_id) != kInvalidCameraId) {
70 THROW_CHECK(database->ExistsCamera(options_.existing_camera_id));
71 prev_camera_ = database->ReadCamera(options_.existing_camera_id);
72 if (std::optional<Rig> rig =
73 database->ReadRigWithSensor(prev_camera_.SensorId());
74 rig.has_value()) {
75 prev_rig_ = std::move(*rig);
76 } else {
77 // For backwards compatibility with old databases without rigs.
78 prev_rig_.AddRefSensor(prev_camera_.SensorId());
79 prev_rig_.SetRigId(database_->WriteRig(prev_rig_));
80 }
81 } else {
82 // Set the manually specified camera parameters.
83 prev_camera_.camera_id = kInvalidCameraId;
84 THROW_CHECK(ExistsCameraModelWithName(options_.camera_model));
85 prev_camera_.model_id = CameraModelNameToId(options_.camera_model);
86 prev_camera_.params.resize(CameraModelNumParams(prev_camera_.model_id), 0.);
87 if (!options_.camera_params.empty()) {
88 THROW_CHECK(prev_camera_.SetParamsFromString(options_.camera_params));
89 prev_camera_.has_prior_focal_length = true;
90 }
91 }
92}
93
94ImageReader::Status ImageReader::Next(Rig* rig,
95 Camera* camera,

Callers

nothing calls this directly

Calls 15

GetRecursiveFileListFunction · 0.85
CameraModelNameToIdFunction · 0.85
CameraModelNumParamsFunction · 0.85
emptyMethod · 0.80
sizeMethod · 0.80
SensorIdMethod · 0.80
AddRefSensorMethod · 0.80
SetParamsFromStringMethod · 0.80
CheckMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected