scan, split, OCR, prepare for LLM
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

helpers.py 473B

123456789101112131415161718
  1. from __future__ import annotations
  2. import tempfile
  3. from pathlib import Path
  4. import cv2
  5. import numpy as np
  6. def create_test_image(width: int = 400, height: int = 300) -> np.ndarray:
  7. image = np.full((height, width, 3), 255, dtype=np.uint8)
  8. return image
  9. def image_to_path(image: np.ndarray, suffix: str = ".png") -> Path:
  10. with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as tmp:
  11. cv2.imwrite(tmp.name, image)
  12. return Path(tmp.name)