因此,我正在使用此处https://github.com/thiagoalessio/tesseract-ocr-for-php给出的tesseract-php包装器。 这是我的php代码的样子:
<?php
require_once "vendor/autoload.php";
use thiagoalessio\TesseractOCR\TesseractOCR;
echo (new TesseractOCR('image1.jpeg'))->run();
?>
通过cmd运行时,效果很好。但是,尝试在xampp服务器上运行时,出现此错误
Fatal error: Uncaught thiagoalessio\TesseractOCR\TesseractNotFoundException:
Error! The command "tesseract" was not found. Make sure you have Tesseract
OCR installed on your system: https://github.com/tesseract-ocr/tesseract The
current $PATH is C:\ProgramData\Oracle\Java\javapath;C:\Program Files
(x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program
Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
Files\Java\jdk1.8.0_151\bin;C:\Program Files\Git\
in C:\xampp\htdocs\tesseract_project\vendor\thiagoalessio\tesseract_ocr\src\FriendlyErrors.php on line 42
我在这里阅读了一些答案,事实证明添加此方法将有所帮助
$path = getenv('PATH');
putenv("PATH=$path:C:\Program Files (x86)\Tesseract-OCR");
但是,没有任何变化,而且我仍然遇到相同的错误。我在做错什么吗?
答案 0 :(得分:0)
在您的系统中安装TESSERACT,然后定义tesseract可执行文件的自定义位置(如果由于任何原因它不在$ PATH中)。
->executable('/path/to/tesseract')
->run();