fix dealername3
Showing
1 changed file
with
12 additions
and
13 deletions
... | @@ -105,20 +105,15 @@ class Retriever: | ... | @@ -105,20 +105,15 @@ class Retriever: |
105 | y_min_find = None | 105 | y_min_find = None |
106 | value = None | 106 | value = None |
107 | coordinates = None | 107 | coordinates = None |
108 | for (x0, y0, x1, y1, x2, y2, x3, y3), text in go_res.values(): | 108 | for (x0, y0, _, _, x1, y1, _, _), text in go_res.values(): |
109 | new_x0 = min(x0, x1, x2, x3) | 109 | cent_x = x0 + ((x1 - x0)/2) |
110 | new_y0 = min(y0, y1, y2, y3) | 110 | cent_y = y0 + ((y1 - y0)/2) |
111 | new_x1 = max(x0, x1, x2, x3) | ||
112 | new_y1 = max(y0, y1, y2, y3) | ||
113 | |||
114 | cent_x = new_x0 + ((new_x1 - new_x0)/2) | ||
115 | cent_y = new_y0 + ((new_y1 - new_y0)/2) | ||
116 | if x_min < cent_x < x_max and y_min < cent_y < y_max: | 111 | if x_min < cent_x < x_max and y_min < cent_y < y_max: |
117 | if y_min_find is None or new_y0 < y_min_find: | 112 | if y_min_find is None or y0 < y_min_find: |
118 | if len(text.strip()) > 0: | 113 | if len(text.strip()) > 0: |
119 | y_min_find = new_y0 | 114 | y_min_find = y0 |
120 | value = text | 115 | value = text |
121 | coordinates = (new_x0, new_y0, new_x1, new_y1) | 116 | coordinates = (x0, y0, x1, y1) |
122 | return value, coordinates | 117 | return value, coordinates |
123 | 118 | ||
124 | @staticmethod | 119 | @staticmethod |
... | @@ -150,9 +145,13 @@ class Retriever: | ... | @@ -150,9 +145,13 @@ class Retriever: |
150 | key_text_info = dict() | 145 | key_text_info = dict() |
151 | for key_text_list in self.target_fields[self.keys_str].values(): | 146 | for key_text_list in self.target_fields[self.keys_str].values(): |
152 | for key_text, key_re, _, _ in key_text_list: | 147 | for key_text, key_re, _, _ in key_text_list: |
153 | for (x0, y0, _, _, x1, y1, _, _), text in go_res.values(): | 148 | for (x0, y0, x1, y1, x2, y2, x3, y3), text in go_res.values(): |
154 | if re.match(key_re, text): | 149 | if re.match(key_re, text): |
155 | key_text_info.setdefault(key_text, list()).append((x0, y0, x1, y1)) | 150 | x_min = min(x0, x1, x2, x3) |
151 | y_min = min(y0, y1, y2, y3) | ||
152 | x_max = max(x0, x1, x2, x3) | ||
153 | y_max = max(y0, y1, y2, y3) | ||
154 | key_text_info.setdefault(key_text, list()).append((x_min, y_min, x_max, y_max)) | ||
156 | 155 | ||
157 | # if text in self.key_text_set: | 156 | # if text in self.key_text_set: |
158 | # key_text_info.setdefault(text, list()).append((x0, y0, x1, y1)) | 157 | # key_text_info.setdefault(text, list()).append((x0, y0, x1, y1)) | ... | ... |
-
Please register or sign in to post a comment