fix hil contract
Showing
1 changed file
with
20 additions
and
0 deletions
| ... | @@ -8,6 +8,26 @@ | ... | @@ -8,6 +8,26 @@ |
| 8 | import re | 8 | import re |
| 9 | import numpy as np | 9 | import numpy as np |
| 10 | from fuzzywuzzy import fuzz | 10 | from fuzzywuzzy import fuzz |
| 11 | from shapely.geometry import Polygon | ||
| 12 | |||
| 13 | |||
| 14 | def caculate_iou(g, p): | ||
| 15 | g = Polygon(np.array(g).reshape((-1, 2))) | ||
| 16 | p = Polygon(np.array(p).reshape((-1, 2))) | ||
| 17 | inter = Polygon(g).intersection(Polygon(p)).area | ||
| 18 | union = g.area + p.area - inter | ||
| 19 | return inter/union | ||
| 20 | |||
| 21 | |||
| 22 | def get_table_info(bbox_1, bbox_2, ocr_result): | ||
| 23 | anchor = [bbox_2[0], bbox_1[1], bbox_2[2], bbox_1[3], | ||
| 24 | bbox_2[4], bbox_1[5], bbox_2[6], bbox_1[7]] | ||
| 25 | table_info = '' | ||
| 26 | for span in ocr_result: | ||
| 27 | iou = caculate_iou(anchor, span[0]) | ||
| 28 | if iou > 0: | ||
| 29 | table_info = span[1] | ||
| 30 | return table_info | ||
| 11 | 31 | ||
| 12 | 32 | ||
| 13 | class Finder: | 33 | class Finder: | ... | ... |
-
Please register or sign in to post a comment