(result, x_offset=0, y_offset=0)
| 182 | for index, (poly, text, score) in enumerate(zip(boxes, txts, scores)): |
| 183 | poly = order_points(np.asarray(poly, dtype=np.float32)) |
| 184 | bbox = poly_to_bbox(poly) |
| 185 | x, y, w, h = bbox |
| 186 | items.append( |
| 187 | { |
| 188 | 'index': index, |
| 189 | 'poly': poly, |
| 190 | 'bbox': (x + x_offset, y + y_offset, w, h), |
| 191 | 'text': normalize_text(str(text)), |
| 192 | 'score': float(score), |
| 193 | 'area': int(w * h), |
| 194 | } |
| 195 | ) |
| 196 | return items |
| 197 | |
| 198 | |
| 199 | def find_prompt_item(items, image_h, image_w): |
| 200 | prompt_candidates = [] |
| 201 | for item in items: |
| 202 | text = item['text'] |
| 203 | x, y, w, h = item['bbox'] |
| 204 | if y > int(image_h * 0.22): |
| 205 | continue |
| 206 | chars = parse_prompt_chars(text) |
no test coverage detected