PHP TesseractOCR exec command issue

北战南征 提交于 2020-02-07 06:58:27

问题


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

but the same command is not working in

exec("tesseract "hello.png" /Applications/MAMP/tmp/php/987051047")

and the full code is

$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();

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


回答1:


Ok after installation we need to change the path for bin

$path = getenv('PATH'); putenv("PATH=$path:/usr/local/bin");

add these lines and it will work

Thanks



来源:https://stackoverflow.com/questions/29316728/php-tesseractocr-exec-command-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!