8000 fix bug caused by negative weight when calculating mst by cre185 · Pull Request #90 · colmap/glomap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix bug caused by negative weight when calculating mst #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 3, 2024
Merged
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
18 changes: 14 additions & 4 deletions glomap/math/tree.cc
83F9
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ image_t MaximumSpanningTree(const ViewGraph& view_graph,
image_id_to_idx[image_id] = image_id_to_idx.size();
}

double max_weight = 0;
for (const auto& [pair_id, image_pair] : view_graph.image_pairs) {
if (image_pair.is_valid == false) continue;
if (type == INLIER_RATIO)
max_weight = std::max(max_weight, image_pair.weight);
else
max_weight =
std::max(max_weight, static_cast<double>(image_pair.inliers.size()));
}

// establish graph
weighted_graph G(image_id_to_idx.size());
weight_map weights_boost = boost::get(boost::edge_weight, G);
Expand All @@ -111,11 +121,11 @@ image_t MaximumSpanningTree(const ViewGraph& view_graph,
// spanning tree
e = boost::add_edge(idx1, idx2, G).first;
if (type == INLIER_NUM)
weights_boost[e] = -image_pair.inliers.size();
weights_boost[e] = max_weight - image_pair.inliers.size();
else if (type == INLIER_RATIO)
weights_boost[e] = -image_pair.weight;
weights_boost[e] = max_weight - image_pair.weight;
else
weights_boost[e] = -image_pair.inliers.size();
weights_boost[e] = max_weight - image_pair.inliers.size();
}

std::vector<edge_desc>
Expand All @@ -142,4 +152,4 @@ image_t MaximumSpanningTree(const ViewGraph& view_graph,
return idx_to_image_id[0];
}

}; // namespace glomap
}; // namespace glomap
0