Tesseract执行器不起作用


Tesseract exec not working

我已经尝试解决这个问题几天了,但无法破解它。

我正在尝试使用 php 来回显 tesseract 的结果。

在我研究和尝试了所有内容之后,我觉得下面的代码应该可以工作。

<?php
echo '<pre>';
echo exec('/usr/local/bin/tesseract /home/username/www/ocr/images/hello.png result');
echo '</pre>';
?>

该命令通过SSH运行良好,如果我更改上述内容以适应ifconfig则工作正常。

有什么想法可以让这个工作吗?

一旦完成 tesseract,您可以尝试将结果作为第二个命令。 与执行相比,shell_exec似乎更擅长返回完整输出。

<?php
$res = shell_exec('/opt/local/bin/tesseract /Users/stressederic/Sites/Sandbox/OCR/CC/gold.jpg result && cat result.txt');
var_dump($res);

我最终通过分解所有内容来解决这个问题。

file_put_contents("$tmpFile",file_get_contents($img));
$cmd = "/usr/local/bin/tesseract $tmpFile stdout";
exec($cmd, $msg);
$arraymsg = $msg;
$msg = implode(' ', $msg);
echo $msg;

它的工作

var_dump(exec('/usr/bin/tesseract 6.png out1 -l eng+ara'));

var_dump(shell_exec('/usr/bin/tesseract 6.png out1 -l eng+ara'));

提示:

在拉拉维尔=>6.png 进入文件夹公共

lang=> eng or ara are language