File size: 306 Bytes
1b64148
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
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)