2

There is a Open source PHP wrapper class for Tesseract (https://github.com/thiagoalessio/tesseract-ocr-for-php) but i'm having problems using it:

Installed it successfully with composer, but when I call

$tesseract = new TesseractOCR('img/c11a67cdd171790771fcf33ec78461d9.png');
$tesseract->setTempDir('/var/www/dir_name/imgRead/');
$tesseract->setWhitelist(range(0,9));

When I run echo $tesseract->recognize(); I get

Message: file_get_contents(/var/www/dir_name/imgRead/573534798.txt): 
failed to open stream: No such file or directory

The author says:

IMPORTANT: Make sure that the tesseract binary is on your $PATH

but i'm not sure what this means exactly, how can I check that the binary is on my $PATH? Anyone use this before?

Edward
  • 3,061
  • 6
  • 32
  • 52

5 Answers5

1
  1. check your environment variable if the binary for Tesseract is added in your path issue printenv command on your terminal, you should see something like

    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin"

  2. if it does not exist, add something like in your ~/.profile

    export PATH=$PATH/usr/bin:/path/to/your/tesseract

or you can check out different ways on how to add one here

Community
  • 1
  • 1
mmr
  • 516
  • 11
  • 30
0

Try setting your path via PHP using

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

where /usr/local/bin is the location where you installed Tesseract.

0

Hi I have the self Problem. Is there somebody how have a solution?

My Path is:

PATH=/usr/local/jdk/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin

My Path to tesseract is:

tesseract: /usr/local/bin/tesseract

I use Cent OS 6 and the new PHP

Mann87
  • 314
  • 1
  • 4
  • 14
0

The problem might be related to the installation of Tesseract, on terminal check tesseract by

$ tesseract -v

make sure the output is close to this output. should have these libs, if its missing the libs then Tesseract is not writing txt file anywhere and that's why it can't find it.

this is my output on centos 6

tesseract 3.02.02 leptonica-1.73 libjpeg 6b (libjpeg-turbo 1.2.1) : libpng 1.2.49 : libtiff 3.9.4 : zlib 1.2.3

Sherif Badawi
  • 90
  • 1
  • 7
0

Check if TesseractOCR is installed in your system, if not:

sudo apt-get install tesseract-ocr

Tesseract-ocr-php is simply doing an exec(cammande) on system installed TesseractOCR

belious
  • 1
  • 2