File size: 581 Bytes
6ebde35 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from paddleocr import PaddleOCR
def ocr_with_paddle(img):
"""
Perform Optical Character Recognition (OCR) on the input image.
:param img: The input image for OCR
:return: The recognized text from the input image, or 'No text detected' if no text is found
"""
finaltext = ''
ocr = PaddleOCR(lang='en', use_angle_cls=True)
result = ocr.ocr(img)
try:
for i in range(len(result[0])):
text = result[0][i][1][0]
finaltext += ' ' + text
return finaltext
except TypeError:
return 'No text detected' |