Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion glomap/estimators/view_graph_calibration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ void ViewGraphCalibrator::Reset(
focals_.reserve(cameras.size());
for (const auto& [camera_id, camera] : cameras) {
focals_[camera_id] = camera.Focal();
// Avoid zero focal length
if (focals_[camera_id] < 1e-3) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why and when does this happen?

Copy link
Collaborator Author

@lpanaf lpanaf Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I double checked, surprisingly, the camera with 0 focal length even has prior focal length..

focals_[camera_id] =
std::max(std::max(camera.width, camera.height) * 1.2, 1e-3);
}
}

// Set up the problem
Expand Down Expand Up @@ -179,7 +184,7 @@ size_t ViewGraphCalibrator::FilterImagePairs(ViewGraph& view_graph) const {
}

LOG(INFO) << "invalid / total number of two view geometry: "
<< invalid_counter << " / " << counter;
<< invalid_counter << " / " << (counter / 2);

return invalid_counter;
}
Expand Down
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
Loading