41cd5169 by 周伟奇

fix dealername3

1 parent be642f44
......@@ -105,20 +105,15 @@ class Retriever:
y_min_find = None
value = None
coordinates = None
for (x0, y0, x1, y1, x2, y2, x3, y3), text in go_res.values():
new_x0 = min(x0, x1, x2, x3)
new_y0 = min(y0, y1, y2, y3)
new_x1 = max(x0, x1, x2, x3)
new_y1 = max(y0, y1, y2, y3)
cent_x = new_x0 + ((new_x1 - new_x0)/2)
cent_y = new_y0 + ((new_y1 - new_y0)/2)
for (x0, y0, _, _, x1, y1, _, _), text in go_res.values():
cent_x = x0 + ((x1 - x0)/2)
cent_y = y0 + ((y1 - y0)/2)
if x_min < cent_x < x_max and y_min < cent_y < y_max:
if y_min_find is None or new_y0 < y_min_find:
if y_min_find is None or y0 < y_min_find:
if len(text.strip()) > 0:
y_min_find = new_y0
y_min_find = y0
value = text
coordinates = (new_x0, new_y0, new_x1, new_y1)
coordinates = (x0, y0, x1, y1)
return value, coordinates
@staticmethod
......@@ -150,9 +145,13 @@ class Retriever:
key_text_info = dict()
for key_text_list in self.target_fields[self.keys_str].values():
for key_text, key_re, _, _ in key_text_list:
for (x0, y0, _, _, x1, y1, _, _), text in go_res.values():
for (x0, y0, x1, y1, x2, y2, x3, y3), text in go_res.values():
if re.match(key_re, text):
key_text_info.setdefault(key_text, list()).append((x0, y0, x1, y1))
x_min = min(x0, x1, x2, x3)
y_min = min(y0, y1, y2, y3)
x_max = max(x0, x1, x2, x3)
y_max = max(y0, y1, y2, y3)
key_text_info.setdefault(key_text, list()).append((x_min, y_min, x_max, y_max))
# if text in self.key_text_set:
# key_text_info.setdefault(text, list()).append((x0, y0, x1, y1))
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!