2016-07-28 277 views
1

我正在使用Windows應用程序tesseract,長話短說,這是一個通過命令運行的OCR應用程序。PHP shell執行命令

tesseract text.png out 

它實際上得到的圖像輸出到文本文件out.txt

我甚至改變了目錄,併爲:

安裝我用命令來測試和使用這條線工作正常的應用程序後無處不在。

現在使用PHP,當我使用的代碼如下問題就來了:

echo exec("tesseract text.png out 2>&1", $output); 
var_dump($output); 

而這個時候,而不是獲取文件時,它說的Tesseract不認可!

這是輸出:

operable program or batch file. 
C:\wamp64\www\prestashop\ocr\ocr.php:12: 
array (size=4) 
    0 => string '' (length=0) 
    1 => string 'C:\wamp64\www\prestashop\ocr>tesseract text.png out' (length=51) 
    2 => string ''tesseract' is not recognized as an internal or external command,' (length=65) 
    3 => string 'operable program or batch file.' (length=31) 

誰能幫我請!?

謝謝

回答

0

我有答案。我不知道爲什麼,但我不得不重啓PC以使其與PHP一起工作

0

似乎沒有設置Windows環境變量PATH

嘗試重置PATH

echo exec("PATH %PATH% && tesseract text.png out 2>&1", $output); 
var_dump($output); 

或者設置PATH從父會話

echo exec("PATH ".getenv('PATH')." && tesseract text.png out 2>&1", $output); 
var_dump($output); 

希望值,這將有助於