php exec tesseract输出空数组 [英] php exec tesseract outputs empty array

查看:130
本文介绍了php exec tesseract输出空数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 7上安装了tesseract v3.01.我在环境变量中添加了tesseract路径.在cmd窗口中键入以下命令后,我将获得正确的输出:"tesseract test.tif test".

I installed tesseract v3.01 on windows 7. I added tesseract path to the environments variables. I obtains the right output after typing this command in the cmd windows: "tesseract test.tif test".

当我尝试使用以下脚本在php中获得相同的结果时,我得到了一个空数组,并且未生成任何文件:

When I try to get the same result in php using the folowing script, I get an empty array and no file is generated:

<?php

try {
    exec("tesseract.exe test.tif test", $msg);
    var_export($msg);
} catch (Exception $e) {
    echo $e;
}

?>

有任何线索吗?

提前谢谢!

推荐答案

为什么不尝试指定tesseract的完整路径?

Why not try specifying the full path to tesseract?

不确定如何在Windows上执行此操作,但是在Mac终端上,我键入which tesseract,它将找到tesseract的完整路径.然后,您可以在exec命令中输入完整路径,在本例中为/usr/local/bin/tesseract.

Not sure how to do this on windows, but on mac terminal, I type in which tesseract and it will find the full path of tesseract. You can then enter that full path, in my case /usr/local/bin/tesseract into the exec command.

try {
    $msg = array();
    exec("/usr/local/bin/tesseract test.tif test", $msg);
    var_export($msg);
} catch (Exception $e) {
    echo $e;
}

这篇关于php exec tesseract输出空数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆