scan, split, OCR, prepare for LLM
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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)