zelotech / services /ocr.py
matheusalencar's picture
first commit
1b64148
Raw History Blame Contribute Delete
306 Bytes
import pytesseract
from PIL import Image
def ocr_image(image: Image.Image, lang: str = "por") -> str:
return pytesseract.image_to_string(image, lang=lang)
def ocr_image_path(path: str, lang: str = "por") -> str:
with Image.open(path) as img:
return ocr_image(img, lang=lang)