如何从Python访问Tesseract的命令行? [英] How to access the command line for Tesseract from Python?
本文介绍了如何从Python访问Tesseract的命令行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Python进行一些处理,并且需要使用Tesseract进行OCR.有没有办法可以从python输入以下内容:
I am using Python to do some processing, and I need to OCR with Tesseract. Is there a way I can, from python, type this:
"tesseract --tessdata-dir/usr/share映像名输出库-l eng -psm 3"
"tesseract --tessdata-dir /usr/share imagename outputbase -l eng -psm 3"
以某种方式或等效方式进入命令行?
into the command line somehow or its equivalent?
谢谢!
推荐答案
请参见下面的示例.
import subprocess
p = subprocess.Popen(["ping", "localhost"], stdout=subprocess.PIPE)
output, err = p.communicate()
print output
输出:
Pinging w10-PC [::1] with 32 bytes of data:
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Ping statistics for ::1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
在示例中将["ping", "localhost"]
替换为
["tesseract", "--tessdata-dir", "/usr/share", "imagename", "outputbase", "-l", "eng", "-psm", "3"].
您可以在此处进一步查看示例 ,此 execute-shell-commands-in-python 问题和 Python 2.7文档了解更多信息.
You may further check examples here, this execute-shell-commands-in-python question and Python 2.7 doc for more information.
这篇关于如何从Python访问Tesseract的命令行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文