简体   繁体   English

php exec tesseract输出空数组

[英]php exec tesseract outputs empty array

I installed tesseract v3.01 on windows 7. I added tesseract path to the environments variables. 我在Windows 7上安装了tesseract v3.01。我在环境变量中添加了tesseract路径。 I obtains the right output after typing this command in the cmd windows: "tesseract test.tif test". 在cmd窗口中键入以下命令后,我将获得正确的输出:“ tesseract test.tif test”。

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中获得相同的结果时,我得到一个空数组,并且未生成文件:

<?php

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

?>

Any clue ? 有什么线索吗?

thanks in advance ! 提前致谢 !

<?php

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

?>

Why not try specifying the full path to tesseract? 为什么不尝试指定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. 不确定如何在Windows上执行此操作,但是在Mac终端上,我键入which tesseract ,它将找到tesseract的完整路径。 You can then enter that full path, in my case /usr/local/bin/tesseract into the exec command. 然后,您可以在exec命令中输入完整路径,在我的情况下为/usr/local/bin/tesseract

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM