Я пытаюсь получить слова из изображений, используя библиотеку pytesseract.Я уже установил Google Tesseract OCR, Pytesseract, PIL, Opencv, Pillow библиотеки.
После этого я загружаю и выкладываю tessdata и langdata из GitHub.
Я использую Tesseract 4.0.0.и pytesseract 0.2.6.
когда я пытаюсь lang='eng'
, это дает мне идеальный результат, но когда я пытаюсь lang='sin'
, мне выдается следующее сообщение об ошибке.
---------------------------------------------------------------------------
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:
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)
Как решить эту ошибку?