Skip to content

Commit

Permalink
load only valid image pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
lpanaf committed Dec 17, 2024
1 parent adfee7e commit e441804
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions glomap/io/colmap_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -220,27 +220,31 @@ void ConvertDatabaseToGlomap(const colmap::Database& database,
cameras[camera_id] = camera;
}

// Add the matches
std::vector<std::pair<colmap::image_pair_t, colmap::FeatureMatches>>
all_matches = database.ReadAllMatches();
// Add the valid matches
std::vector<std::pair<image_pair_t, int>> two_view_geometries_inliers =
database.ReadTwoViewGeometryNumInliers();

// Go through all matches and store the matche with enough observations in the
// view_graph
size_t invalid_count = 0;
std::unordered_map<image_pair_t, ImagePair>& image_pairs =
view_graph.image_pairs;
for (size_t match_idx = 0; match_idx < all_matches.size(); match_idx++) {
if ((match_idx + 1) % 1000 == 0 || match_idx == all_matches.size() - 1)
for (size_t match_idx = 0; match_idx < two_view_geometries_inliers.size();
match_idx++) {
if ((match_idx + 1) % 1000 == 0 ||
match_idx == two_view_geometries_inliers.size() - 1)
std::cout << "\r Loading Image Pair " << match_idx + 1 << " / "
<< all_matches.size() << std::flush;
<< two_view_geometries_inliers.size() << std::flush;
// Read the image pair from COLMAP database
colmap::image_pair_t pair_id = all_matches[match_idx].first;
colmap::image_pair_t pair_id = two_view_geometries_inliers[match_idx].first;
std::pair<colmap::image_t, colmap::image_t> image_pair_colmap =
database.PairIdToImagePair(pair_id);
colmap::image_t image_id1 = image_pair_colmap.first;
colmap::image_t image_id2 = image_pair_colmap.second;

colmap::FeatureMatches& feature_matches = all_matches[match_idx].second;
// colmap::FeatureMatches& feature_matches = all_matches[match_idx].second;
colmap::FeatureMatches feature_matches =
database.ReadMatches(image_id1, image_id2);

// Initialize the image pair
auto ite = image_pairs.insert(
Expand Down

0 comments on commit e441804

Please sign in to comment.