arrange polygons: limit width ratio when merging boxes

This commit is contained in:
Thomas Krijnen
2026-05-15 21:12:43 +02:00
parent a24cdf4958
commit 227d85d81f
+7
View File
@@ -1457,6 +1457,13 @@ std::pair<double, double> merge_score(const MergedBoxRecord& a, const MergedBoxR
} }
bool clusters_can_merge(const BoxCluster& a, const BoxCluster& b, double angle_tol_deg = 5., double axis_overlap_ratio_limit = 0.5) { bool clusters_can_merge(const BoxCluster& a, const BoxCluster& b, double angle_tol_deg = 5., double axis_overlap_ratio_limit = 0.5) {
auto min_width = a.box.avg_width < b.box.avg_width ? a.box.avg_width : b.box.avg_width;
auto max_width = a.box.avg_width > b.box.avg_width ? a.box.avg_width : b.box.avg_width;
if (min_width > 1.e-9) {
if (max_width / min_width > 5) {
return false;
}
}
if (!aabb_overlap(a.box.bbox, b.box.bbox)) { if (!aabb_overlap(a.box.bbox, b.box.bbox)) {
return false; return false;
} }