我正在定义一个功能,它将图像转换为灰度(位黑白色),然后将其传递给:
text = pytesseract.image_to_string(Image.open(gray_scale_image))
Run Code Online (Sandbox Code Playgroud)
然后我打印我收到的文本,但它抛出错误:
Traceback (most recent call last):
File "C:\Users\HP\PycharmProjects\nayaproject\venv\lib\site-packages\PIL\Image.py", line 2613, in open
fp.seek(0)
AttributeError: 'numpy.ndarray' object has no attribute 'seek'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/HP/PycharmProjects/nayaproject/new.py", line 17, in <module>
text = pytesseract.image_to_string(Image.open(g))
File "C:\Users\HP\PycharmProjects\nayaproject\venv\lib\site-packages\PIL\Image.py", line 2615, in open
fp = io.BytesIO(fp.read())
AttributeError: 'numpy.ndarray' object has no attribute 'read'
Run Code Online (Sandbox Code Playgroud)
而不是 Image.open(grayscale),当我使用 Image.fromarray(grayscale) 我得到这些错误:
Traceback (most recent call last):
File "C:\Users\HP\PycharmProjects\nayaproject\venv\lib\site-packages\pytesseract\pytesseract.py", line 170, in run_tesseract
proc = …Run Code Online (Sandbox Code Playgroud) 我正在使用python制作一个OCR系统,该系统可以从ID卡读取并提供图像的准确结果,但是由于tesseract读取的错误字符过多,因此无法提供正确的答案。我该如何训练tesseract,使其能够完美地读取ID卡并为我们提供正确和准确的详细信息,此外,我如何才能进入.tiff文件并使tesseract用于我的项目。