From 7b1b46a737fef95da12867dec8f25be9b359445b Mon Sep 17 00:00:00 2001 From: Constantine Parkhimovich Date: Thu, 17 Mar 2022 22:41:54 +0300 Subject: [PATCH] Fixed ZeroDivisionError in text_in_bbox --- camelot/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/camelot/utils.py b/camelot/utils.py index 404c00b..7941293 100644 --- a/camelot/utils.py +++ b/camelot/utils.py @@ -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)