(items, image, engine)
| 233 | return prompt_item, chars |
| 234 | |
| 235 | top_roi = image[: int(image.shape[0] * 0.14), :] |
| 236 | top_result = engine(top_roi) |
| 237 | top_items = ocr_items(top_result) |
| 238 | prompt_item = find_prompt_item(top_items, top_roi.shape[0], top_roi.shape[1]) |
| 239 | if prompt_item is not None: |
| 240 | chars = parse_prompt_chars(prompt_item['text']) |
| 241 | if len(chars) >= 2: |
| 242 | return prompt_item, chars |
| 243 | |
| 244 | raise RuntimeError('无法从 RapidOCR 结果中解析出提示字符。') |
| 245 | |
| 246 | |
| 247 | def is_ignored_item(item, prompt_item, image_h, image_w): |
| 248 | text = item['text'] |
| 249 | if not text: |
| 250 | return True |
| 251 | if text in IGNORE_TEXTS: |
| 252 | return True |
| 253 | if any(keyword in text for keyword in ('AI', '确定', '安全验证', '生成背景')): |
| 254 | return True |
no test coverage detected