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 503B

12345678910111213141516171819
  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.zeros((height, width, 3), dtype=np.uint8)
  8. image[:, :] = (200, 200, 200)
  9. return image
  10. def image_to_path(image: np.ndarray, suffix: str = ".png") -> Path:
  11. with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as tmp:
  12. cv2.imwrite(tmp.name, image)
  13. return Path(tmp.name)