image-recognition / handler.py
ojasm's picture
api
8192189
raw
history blame contribute delete
453 Bytes
from typing import Any
import pytesseract
import urllib.request
from PIL import Image
pytesseract.pytesseract.tesseract_cmd = r'E:\tesseract ocr\tesseract.exe'
class EndpointHandler():
def __init__(self):
pass
def __call__(self, imageUrl: str) -> str:
urllib.request.urlretrieve(imageUrl, "image.jpg")
img = Image.open("image.jpg")
text = pytesseract.image_to_string(img)
print(text)
return text