首页 > 解决方案 > php 正方体错误!找不到命令“tesseract”

问题描述

我正在尝试并未能使用 tesseract php。我收到此错误:

 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:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Users\Peppe\AppData\Local\Microsoft\WindowsApps;C:\Users\Peppe\AppData\Roaming\Composer\vendor\bin in C:\Users\Peppe\vendor\thiagoalessio\tesseract_ocr\src\FriendlyErrors.php:48 Stack trace: #0 
C:\Users\Peppe\vendor\thiagoalessio\tesseract_ocr\src\TesseractOCR.php(26): thiagoalessio\TesseractOCR\FriendlyErrors::checkTesseractPresence('tesseract') #1 C:\xampp\htdocs\index.php(7): thiagoalessio\TesseractOCR\TesseractOCR->run() #2 {main} thrown in C:\Users\Peppe\vendor\thiagoalessio\tesseract_ocr\src\FriendlyErrors.php on line 48

我正在使用在 C:\xampp 中安装了 xampp 的 Windows 10。php 版本 7.4 我从https://github.com/UB-Mannheim/tesseract/wiki安装了 x32 和 x64 的 tesseract.exe 我使用 composer 安装了https://github.com/thiagoalessio/tesseract-ocr-for- php,它没有给出任何错误。

<?php
require_once 'C:\Users\Peppe\vendor\autoload.php';  

use thiagoalessio\TesseractOCR\TesseractOCR;
$ocr = new TesseractOCR("caption.jpg");
$content = $ocr->run();
echo $content;

?>

最后,caption.jpg 位于 htdocs 文件夹、主文件夹和与 index.php 相同的文件夹中,其中出现了上述代码。

任何解决方案?

标签: phptesseract

解决方案


In my case I have to add new variable tesseract with full path C:\Program Files\Tesseract-OCR\tesseract.exe as showing in below screenshot

enter image description here


推荐阅读