Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python-Tesseract_Python_Tesseract - Fatal编程技术网

Python-Tesseract

Python-Tesseract,python,tesseract,Python,Tesseract,我正在尝试使用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

我正在尝试使用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
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“C:\Python34\lib\pytesser\pytesser.py”,第49行,在图像\u文件\u到\u字符串中
text=图像到字符串(即时消息,清除)
文件“C:\Python34\lib\pytesser\pytesser.py”,第31行,在图像\u到\u字符串中
调用\u tesseract(scratch\u图像\u名称、scratch\u文本\u名称\u根)
文件“C:\Python34\lib\pytesser\pytesser.py”,第24行,在call\u tesseract中
错误。检查是否存在错误()
文件“C:\Python34\lib\pytesser\errors.py”,第15行,用于检查错误
引发Tesser\u常规\u异常(文本)
pytesser.errors.Tesser_常规_异常:Tessedit:错误:用法:Tessedit imagename outputbase[configfile[+|-]varfile]…]
信号_退出25中止。位置代码:3中止代码:0
这是在Mac电脑上吗

尝试编辑
call\u tesseract
函数。更改:

proc = subprocess.Popen(args)
retcode = proc.wait()
致:


下载2mb文件,网址为:

复制tesseract.exe的路径,然后打开文件pytesseract.py 文件中有一个名为“tesseract_cmd”的变量,它保存文件tesseract.exe的路径。将复制的路径存储在变量中

运行您的程序,您的错误将不再存在

我个人推荐(pytesser和pytesseract是不同的),因为pytesser只使用了一个版本

因此,只需pip安装pytesseract包


注意:Python2在外语提取方面没有很好的支持,所以最好使用Python3。

看起来使用错误的命令行调用了
teseract.exe
。。。这可能是库中的错误。
pip安装pytesseract
not
pytesser
看起来您应该提供一个字符串而不是PIL图像。
retcode = subprocess.call(args)