如何从Python访问Tesseract的命令行?

时间:2017-03-23 02:45:14

标签: ocr tesseract

我正在使用Python进行一些处理,我需要使用Tesseract进行OCR。有没有办法,我可以从python中输入:

" tesseract --tessdata-dir / usr / share imagename outputbase -l eng -psm 3"

以某种方式进入命令行或其等价物?

谢谢!

1 个答案:

答案 0 :(得分:0)

请参阅下面的示例。

$(document).ready(function () {
    $('a[href^="#"]').on('click', function (e) {
        e.preventDefault();

        var target = this.hash;
        var $target = $(target);

        $('html, body').stop().animate({
            'scrollTop': $target.offset().top
        }, 900, 'swing', function () {
            window.location.hash = target;
        });
    });
});

输出:

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"]

您可以在此处进一步检查examples,此execute-shell-commands-in-python问题和Python 2.7 doc以获取更多信息。