我正在尝试使用Python中的Tesseract模块从图像中提取文本:
from pytesser import *
image = Image.open('fnord.tif') # Open image object using PIL
print image_to_string(image) # Run tesseract.exe on image
fnord但是我得到了以下错误:
在处理上述异常的过程中,发生了另一个异常:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\pytesser\pytesser.py", line 49, in image_file_to_string
text = image_to_string(im, cleanup)
File "C:\Python34\lib\pytesser\pytesser.py", line 31, in image_to_string
call_tesseract(scratch_image_name, scratch_text_name_root)
File "C:\Python34\lib\pytesser\pytesser.py", line 24, in call_tesseract
errors.check_for_errors()
File "C:\Python34\lib\pytesser\errors.py", line 15, in check_for_errors
raise Tesser_General_Exception(text)
pytesser.errors.Tesser_General_Exception: Tessedit:Error:Usage:Tessedit imagename outputbase [configfile [[+|-]varfile]...]
Signal_exit 25 ABORT. LocCode: 3 AbortCode: 0发布于 2015-10-20 00:54:30
这是在Mac上吗?
尝试编辑call_tesseract函数。更改:
proc = subprocess.Popen(args)
retcode = proc.wait()至:
retcode = subprocess.call(args)发布于 2017-03-04 19:13:13
从以下位置下载2mb文件:
https://code.google.com/archive/p/pytesser/downloads
复制tesseract.exe的路径,然后打开文件pytesseract.py文件中有一个名为'tesseract_cmd‘的变量,它保存文件tesseract.exe的路径。将复制的路径存储在变量中。
运行你的程序,你的错误就不会再出现了。
发布于 2017-06-29 21:11:36
我个人推荐pytesseract (pytesser和pytesseract是不同的),因为pytesser只有一个版本就停止了。
因此,只需通过pip安装pytesseract包
注意: Python 2不会很好地支持外语提取,所以最好使用python 3。
https://stackoverflow.com/questions/31089737
复制相似问题