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 完成,您可以尝试将结果作为第二条命令进行 cat-ing。 shell_exec 似乎比 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'));

提示:

in laravel => 6.png Into the folder public

lang=> eng or ara are language