php exec tesseract outputs empty array

此生再无相见时 提交于 2019-12-14 02:15:50

问题


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

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;
}

?>

Any clue ?

thanks in advance !


回答1:


<?php

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

?>



回答2:


Why not try specifying the full path to 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;
}


来源:https://stackoverflow.com/questions/12448915/php-exec-tesseract-outputs-empty-array

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!