(items, image_h, image_w)
| 204 | if y > int(image_h * 0.22): |
| 205 | continue |
| 206 | chars = parse_prompt_chars(text) |
| 207 | if PROMPT_PREFIX in text or ('点击' in text and len(chars) >= 2): |
| 208 | prompt_candidates.append((len(chars), w, -y, item)) |
| 209 | |
| 210 | if prompt_candidates: |
| 211 | prompt_candidates.sort(reverse=True) |
| 212 | return prompt_candidates[0][3] |
| 213 | |
| 214 | wide_top_items = [ |
| 215 | item |
| 216 | for item in items |
| 217 | if ( |
| 218 | item['bbox'][1] <= int(image_h * 0.18) |
| 219 | and item['bbox'][2] >= int(image_w * 0.25) |
| 220 | and is_prompt_like_text(item['text']) |
| 221 | ) |
| 222 | ] |
| 223 | if wide_top_items: |
| 224 | return sorted(wide_top_items, key=lambda it: (it['bbox'][1], -it['bbox'][2]))[0] |
| 225 | return None |
| 226 | |
| 227 | |
| 228 | def build_prompt_chars(items, image, engine): |
| 229 | prompt_item = find_prompt_item(items, image.shape[0], image.shape[1]) |
| 230 | if prompt_item is not None: |
| 231 | chars = parse_prompt_chars(prompt_item['text']) |
| 232 | if len(chars) >= 2: |
| 233 | return prompt_item, chars |
| 234 | |
| 235 | top_roi = image[: int(image.shape[0] * 0.14), :] |
no test coverage detected