Skip to content

Commit a33098c

Browse files
committed
d
1 parent e256b1e commit a33098c

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

glomap/exe/global_mapper.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ int RunMapper(int argc, char** argv) {
6868
return EXIT_FAILURE;
6969
}
7070

71+
std::unordered_set<std::string> image_filenames;
7172
if (image_list_path != "") {
7273
if (!colmap::ExistsFile(image_list_path)) {
7374
LOG(ERROR) << "`image_list_path` is not a file";
7475
return EXIT_FAILURE;
7576
}
77+
ReadImageList(image_list_path, image_filenames);
7678
}
7779

7880
// Load the database
@@ -82,7 +84,7 @@ int RunMapper(int argc, char** argv) {
8284
std::unordered_map<track_t, Track> tracks;
8385

8486
const colmap::Database database(database_path);
85-
ConvertDatabaseToGlomap(database, view_graph, cameras, images);
87+
ConvertDatabaseToGlomap(database, view_graph, cameras, images, &image_filenames);
8688

8789
if (view_graph.image_pairs.empty()) {
8890
LOG(ERROR) << "Can't continue without image pairs";

glomap/io/colmap_converter.cc

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,12 @@ void ConvertColmapPoints3DToGlomapTracks(
176176

177177
// For ease of debug, go through the database twice: first extract the available
178178
// pairs, then read matches from pairs.
179-
void ConvertDatabaseToGlomap(const colmap::Database& database,
180-
ViewGraph& view_graph,
181-
std::unordered_map<camera_t, Camera>& cameras,
182-
std::unordered_map<image_t, Image>& images) {
179+
void ConvertDatabaseToGlomap(
180+
const colmap::Database& database,
181+
ViewGraph& view_graph,
182+
std::unordered_map<camera_t, Camera>& cameras,
183+
std::unordered_map<image_t, Image>& images,
184+
const std::unordered_set<std::string>* image_filenames) {
183185
// Add the images
184186
std::vector<colmap::Image> images_colmap = database.ReadAllImages();
185187
image_t counter = 0;
@@ -188,6 +190,11 @@ void ConvertDatabaseToGlomap(const colmap::Database& database,
188190
<< images_colmap.size() << std::flush;
189191
counter++;
190192

193+
if (image_filenames &&
194+
image_filenames->find(image.Name()) == image_filenames->end()) {
195+
continue; // Skip images not in the specified set
196+
}
197+
191198
const image_t image_id = image.ImageId();
192199
if (image_id == colmap::kInvalidImageId) continue;
193200
auto ite = images.insert(std::make_pair(
@@ -239,6 +246,12 @@ void ConvertDatabaseToGlomap(const colmap::Database& database,
239246
colmap::image_t image_id1 = image_pair_colmap.first;
240247
colmap::image_t image_id2 = image_pair_colmap.second;
241248

249+
if (images.find(image_id1) == images.end() ||
250+
images.find(image_id2) == images.end()) {
251+
// If the image is not added to the images map, then skip
252+
continue;
253+
}
254+
242255
colmap::FeatureMatches& feature_matches = all_matches[match_idx].second;
243256

244257
// Initialize the image pair

glomap/io/colmap_converter.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ void ConvertColmapPoints3DToGlomapTracks(
2727
const colmap::Reconstruction& reconstruction,
2828
std::unordered_map<track_t, Track>& tracks);
2929

30-
void ConvertDatabaseToGlomap(const colmap::Database& database,
31-
ViewGraph& view_graph,
32-
std::unordered_map<camera_t, Camera>& cameras,
33-
std::unordered_map<image_t, Image>& images);
30+
void ConvertDatabaseToGlomap(
31+
const colmap::Database& database,
32+
ViewGraph& view_graph,
33+
std::unordered_map<camera_t, Camera>& cameras,
34+
std::unordered_map<image_t, Image>& images,
35+
const std::unordered_set<std::string>* image_filenames = nullptr);
3436

3537
} // namespace glomap

0 commit comments

Comments
 (0)