问题
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