I am trying to get words from images using pytesseract library. I already installed Google’s Tesseract OCR, Pytesseract, PIL, Opencv, Pillow libraries.

After that, I download and put tessdata and langdata from GitHub.

I am using Tesseract 4.0.0. and pytesseract 0.2.6.

when I try to lang='eng' that is given me perfect result but when I try lang='sin' it is given me the following error message.

---------------------------------------------------------------------------
TesseractError                            Traceback (most recent call last)
<ipython-input-1-a50dd4690117> in <module>
     10 cv2.destroyAllWindows()
     11 test_image = Image.fromarray(img)
---> 12 text = tess.image_to_string(test_image, lang='sin')
     13 print("PyTesseract Detected the following text: ", text)

~\Anaconda3\envs\mainenv\lib\site-packages\pytesseract\pytesseract.py in image_to_string(image, lang, config, nice, output_type)
    307         Output.DICT: lambda: {'text': run_and_get_output(*args)},
    308         Output.STRING: lambda: run_and_get_output(*args),
--> 309     }[output_type]()
    310 
    311 

~\Anaconda3\envs\mainenv\lib\site-packages\pytesseract\pytesseract.py in <lambda>()
    306         Output.BYTES: lambda: run_and_get_output(*(args + [True])),
    307         Output.DICT: lambda: {'text': run_and_get_output(*args)},
--> 308         Output.STRING: lambda: run_and_get_output(*args),
    309     }[output_type]()
    310 

~\Anaconda3\envs\mainenv\lib\site-packages\pytesseract\pytesseract.py in run_and_get_output(image, extension, lang, config, nice, return_bytes)
    216         }
    217 
--> 218         run_tesseract(**kwargs)
    219         filename = kwargs['output_filename_base'] + os.extsep + extension
    220         with open(filename, 'rb') as output_file:

~\Anaconda3\envs\mainenv\lib\site-packages\pytesseract\pytesseract.py in run_tesseract(input_filename, output_filename_base, extension, lang, config, nice)
    192 
    193     if status_code:
--> 194         raise TesseractError(status_code, get_errors(error_string))
    195 
    196     return True

TesseractError: (3221225477, '')

Python 3.6 code:

from PIL import Image
import pytesseract as tess
import cv2

tess.pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract-OCR\tesseract.exe"

img = cv2.imread("./images/scr.png")
cv2.imshow("Test Image", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
test_image = Image.fromarray(img)
text = tess.image_to_string(test_image, lang='sin')
print("PyTesseract Detected the following text: ", text)

How to solve this error message?

0 Answers