mirror of
https://github.com/Ladebeze66/llm_ticket3.git
synced 2025-12-15 20:56:52 +01:00
23 lines
607 B
Python
23 lines
607 B
Python
# utils/ocr_utils.py
|
|
|
|
from PIL import Image
|
|
import pytesseract
|
|
import logging
|
|
|
|
logger = logging.getLogger("OCR")
|
|
|
|
def extraire_texte_fr(image_path: str) -> str:
|
|
"""
|
|
Effectue un OCR sur une image en langue française.
|
|
Retrourne le texte brut extrait (vide si échec).
|
|
"""
|
|
try:
|
|
image = Image.open(image_path)
|
|
texte = pytesseract.image_to_string(image, lang="fra").strip()
|
|
logger.debug(f"OCR FR pour {image_path}: {texte}")
|
|
return texte
|
|
except Exception as e:
|
|
logger.error(f"Erreur lors de l'OCR de {image_path}: {e}")
|
|
return ""
|
|
|
|
|