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,11 +38,15 @@ def remove_overlaps_min_spans(spans): ...@@ -38,11 +38,15 @@ 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:
overlap_box = get_minbox_if_overlap_by_ratio(span1['bbox'], span2['bbox'], 0.65) # span1 或 span2 任何一个都不应该在 dropped_spans 中
if overlap_box is not None: if span1 in dropped_spans or span2 in dropped_spans:
span_need_remove = next((span for span in spans if span['bbox'] == overlap_box), None) continue
if span_need_remove is not None and span_need_remove not in dropped_spans: else:
dropped_spans.append(span_need_remove) overlap_box = get_minbox_if_overlap_by_ratio(span1['bbox'], span2['bbox'], 0.65)
if overlap_box is not None:
span_need_remove = next((span for span in spans if span['bbox'] == overlap_box), None)
if span_need_remove is not None and span_need_remove not in dropped_spans:
dropped_spans.append(span_need_remove)
if len(dropped_spans) > 0: if len(dropped_spans) > 0:
for span_need_remove in dropped_spans: for span_need_remove in dropped_spans:
......
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