Commit e4810cee authored by myhloli's avatar myhloli
Browse files

fix(remove_overlaps_min_spans): optimize overlap detection in OCR span list modification

- Improve logic to skip dropped spans in overlap detection
- Enhance efficiency by avoiding unnecessary comparisons
parent a07007e5
...@@ -38,6 +38,10 @@ def remove_overlaps_min_spans(spans): ...@@ -38,6 +38,10 @@ def remove_overlaps_min_spans(spans):
for span1 in spans: for span1 in spans:
for span2 in spans: for span2 in spans:
if span1 != span2: if span1 != span2:
# span1 或 span2 任何一个都不应该在 dropped_spans 中
if span1 in dropped_spans or span2 in dropped_spans:
continue
else:
overlap_box = get_minbox_if_overlap_by_ratio(span1['bbox'], span2['bbox'], 0.65) overlap_box = get_minbox_if_overlap_by_ratio(span1['bbox'], span2['bbox'], 0.65)
if overlap_box is not None: if overlap_box is not None:
span_need_remove = next((span for span in spans if span['bbox'] == overlap_box), None) span_need_remove = next((span for span in spans if span['bbox'] == overlap_box), None)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment