Skip to content

Commit

Permalink
Fixed ZeroDivisionError in text_in_bbox
Browse files Browse the repository at this point in the history
  • Loading branch information
const-FC committed Mar 17, 2022
1 parent 644bbe7 commit 7b1b46a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion camelot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7b1b46a

Please sign in to comment.