scan, split, OCR, prepare for LLM
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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)