dig*_*emy 12 python ocr tesseract
我最近使用了tesseract OCR和python,当我尝试image_to_string
从tesseract 导入时,我一直收到错误.
导致问题的代码:
# Perform OCR using tesseract-ocr library
from tesseract import image_to_string
image = Image.open('input-NEAREST.tif')
print image_to_string(image)
Run Code Online (Sandbox Code Playgroud)
上述代码导致的错误:
Traceback (most recent call last):
file "./captcha.py", line 52, in <module>
from tesseract import image_to_string
ImportError: cannot import name image_to_string
Run Code Online (Sandbox Code Playgroud)
我已经确认安装了tesseract模块:
digital_alchemy@roaming-gnome /home $ pydoc modules | grep 'tesseract'
Hdf5StubImagePlugin _tesseract gzip sipconfig
ORBit cairo mako tesseract
Run Code Online (Sandbox Code Playgroud)
我相信我已经抓住了所有必需的套餐,但不幸的是我只是陷入了困境.看来该功能不在模块中.
任何帮助非常感谢.
似乎对我有用的另一种可能性是修改pytesseract,而不是从PIL导入Image导入Image
修改pytesseract后在PyCharm中有效的代码:
from pytesseract import image_to_string
from PIL import Image
im = Image.open(r'C:\Users\<user>\Downloads\dashboard-test.jpeg')
print(im)
print(image_to_string(im))
Run Code Online (Sandbox Code Playgroud)
Pytesseract我通过PyCharm内置的包管理安装
您安装的模块的语法是否正确?image_to_string
根据本页上的使用示例,
该函数看起来像是来自 PyTesser:https: //code.google.com/p/pytesser/
您的导入看起来像是针对 python-tesseract 的,其中列出了更复杂的使用示例: https: //code.google.com/p/python-tesseract/
归档时间: |
|
查看次数: |
23983 次 |
最近记录: |