(img, prompt_item, candidate_items, click_items)
| 797 | |
| 798 | for item in candidate_items: |
| 799 | x, y, w, h = item['bbox'] |
| 800 | cv2.rectangle(vis, (x, y), (x + w, y + h), (0, 255, 255), 1) |
| 801 | |
| 802 | for index, item in enumerate(click_items, start=1): |
| 803 | if item is None: |
| 804 | continue |
| 805 | x, y, w, h = item['bbox'] |
| 806 | cv2.rectangle(vis, (x, y), (x + w, y + h), (0, 255, 0), 2) |
| 807 | cv2.circle(vis, (x + w // 2, y + h // 2), 14, (0, 255, 0), 2) |
| 808 | cv2.putText( |
| 809 | vis, |
| 810 | str(index), |
| 811 | (x + w // 2 - 8, y + h // 2 + 8), |
| 812 | cv2.FONT_HERSHEY_SIMPLEX, |
| 813 | 0.8, |
| 814 | (0, 255, 0), |
| 815 | 2, |
| 816 | ) |
| 817 | |
| 818 | return vis |
| 819 | |
| 820 | |
| 821 | def run_pipeline_bytes(image_bytes: bytes, prompt_text: str | None = None, include_debug: bool = False): |
| 822 | arr = np.frombuffer(image_bytes, dtype=np.uint8) |
| 823 | image = cv2.imdecode(arr, cv2.IMREAD_COLOR) |
| 824 | if image is None: |
| 825 | raise RuntimeError('无法解码图片') |
| 826 | |
| 827 | engine = get_engine() |
| 828 | ocr_result = engine(image) |
no outgoing calls
no test coverage detected