问题描述
我已经从 mac 终端安装了 TesseractOCR.当我从终端运行以下命令时,它正在工作.
I have installed TesseractOCR from terminal of mac. when i run the following command from terminal it is working.
tesseract "hello.png"/Applications/MAMP/tmp/php/987051047
tesseract "hello.png" /Applications/MAMP/tmp/php/987051047
但是相同的命令在
exec("tesseract "hello.png"/Applications/MAMP/tmp/php/987051047")
完整的代码是
$tesseract = new TesseractOCR("hello.png");
$tmp_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir();
$tesseract->setTempDir( $tmp_dir );
$test = $tesseract->recognize();
我觉得我必须在 php.ini 或任何其他配置文件中加载 tesseract.但我不知道在哪里.我使用的是 mac、MAMP、php 5.4.10
I feel I have to load tesseract in php.ini or any other configuration file. but I don't know where. I am using mac, MAMP, php 5.4.10
推荐答案
好的,安装后我们需要修改bin的路径
Ok after installation we need to change the path for bin
$path = getenv('PATH');putenv("PATH=$path:/usr/local/bin");
$path = getenv('PATH');putenv("PATH=$path:/usr/local/bin");
添加这些行,它会起作用
add these lines and it will work
谢谢
这篇关于PHP TesseractOCR exec 命令问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!