python-无法使用pytesseract从图像获取文本
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python-无法使用pytesseract从图像获取文本,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2278字,纯文字阅读大概需要4分钟。
内容图文
当我使用下面的代码时,将错误显示为“ WindowsError:[Error 2]系统找不到指定的文件”.请帮助我从图像获取文本.
from pytesseract import image_to_string
from PIL import Image
print image_to_string(Image.open(r'D:\\name.jpg'),lang='eng')
错误:
WindowsError Traceback (most recent call
last) in ()
2 from PIL import Image
3
—-> 4 print image_to_string(Image.open(r’D:\name.jpg’),lang=’eng’)C:\ProgramData\Anaconda2\lib\site-packages\pytesseract\pytesseract.pyc
in image_to_string(image, lang, boxes, config)
120 lang=lang,
121 boxes=boxes,
–> 122 config=config)
123 if status:
124 errors = get_errors(error_string)C:\ProgramData\Anaconda2\lib\site-packages\pytesseract\pytesseract.pyc
in run_tesseract(input_filename, output_filename_base, lang, boxes,
config)
44 command += shlex.split(config)
45
—> 46 proc = subprocess.Popen(command, stderr=subprocess.PIPE)
47 status = proc.wait()
48 error_string = proc.stderr.read()C:\ProgramData\Anaconda2\lib\subprocess.pyc in init(self, args,
bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds,
shell, cwd, env, universal_newlines, startupinfo, creationflags)
388 p2cread, p2cwrite,
389 c2pread, c2pwrite,
–> 390 errread, errwrite)
391 except Exception:
392 # Preserve original exception in case os.close raises.C:\ProgramData\Anaconda2\lib\subprocess.pyc in _execute_child(self,
args, executable, preexec_fn, close_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell, to_close, p2cread, p2cwrite,
c2pread, c2pwrite, errread, errwrite)
638 env,
639 cwd,
–> 640 startupinfo)
641 except pywintypes.error, e:
642 # Translate pywintypes.error to WindowsError, which isWindowsError: [Error 2] The system cannot find the file specified
解决方法:
安装所有软件包和Tesseract-OCR应用程序后,应重新启动PC.我尝试了您的代码,并遇到了同样的问题,但是重新启动PC后,它对我有用.请试试.
内容总结
以上是互联网集市为您收集整理的python-无法使用pytesseract从图像获取文本全部内容,希望文章能够帮你解决python-无法使用pytesseract从图像获取文本所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。