[英]How do I get the largest text in an image using tesseract in Python?
[英]Using Python Tesseract to get text from image, but getting an error
我正在尝试使用Python Tesseract在macOS桌面上从图像获取文本,并且遇到了无法解决的错误。 我正在运行macOS High Sierra 10.3.2
我的目录设置为桌面(图像所在的位置),并且已经指定了tesseract可执行文件的路径。
我在跑
print(pytesseract.image_to_string(Image.open('test.png'))
并得到以下错误:
File "/Users/name/anaconda2/lib/python2.7/site-packages/pytesseract/pytesseract.py", line 140, in run_and_get_output
run_tesseract(**kwargs)
File "/Users/name/anaconda2/lib/python2.7/site-packages/pytesseract/pytesseract.py", line 116, in run_tesseract
raise TesseractError(status_code, get_errors(error_string))
pytesseract.pytesseract.TesseractError: (1, u'File "/var/folders/cp/dg2snlxn2631h8jx1bwb7jk80000gn/T/tess_cK4lka.PNG", line 1 SyntaxError: Non-ASCII character \'\\x89\' in file /var/folders/cp/dg2snlxn2631h8jx1bwb7jk80000gn/T/tess_cK4lka.PNG on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details')
知道是什么原因造成的,如何解决? 很乐意提供任何澄清的细节。
谢谢!
使用unidecode库
from unidecode import unidecode
.
.
.
print unidecode(pytesseract.image_to_string(Image.open('test.png')))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.