2016-07-28 218 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); 

希望值,这将有助于