Fixed ZeroDivisionError in text_in_bbox

pull/292/head
Constantine Parkhimovich 2022-03-17 22:41:54 +03:00
parent 644bbe7c6d
commit 7b1b46a737
1 changed files with 2 additions and 1 deletions

View File

@ -372,8 +372,9 @@ def text_in_bbox(bbox, text):
if ba == bb:
continue
if bbox_intersect(ba, bb):
ba_area = bbox_area(ba)
# if the intersection is larger than 80% of ba's size, we keep the longest
if (bbox_intersection_area(ba, bb) / bbox_area(ba)) > 0.8:
if ba_area == 0 or (bbox_intersection_area(ba, bb) / ba_area) > 0.8:
if bbox_longer(bb, ba):
rest.discard(ba)
unique_boxes = list(rest)