From e441804b7af67d50d0a52bea76fe265102eb7fe0 Mon Sep 17 00:00:00 2001 From: Linfei Pan Date: Tue, 17 Dec 2024 16:28:39 +0100 Subject: [PATCH] load only valid image pairs --- glomap/io/colmap_converter.cc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/glomap/io/colmap_converter.cc b/glomap/io/colmap_converter.cc index a52455c..ad67703 100644 --- a/glomap/io/colmap_converter.cc +++ b/glomap/io/colmap_converter.cc @@ -220,27 +220,31 @@ void ConvertDatabaseToGlomap(const colmap::Database& database, cameras[camera_id] = camera; } - // Add the matches - std::vector> - all_matches = database.ReadAllMatches(); + // Add the valid matches + std::vector> 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_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 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(