How to setup and running Tesseract OCR for PHP (op

2019-07-12 18:38发布

问题:

I have installed the Tesseract OCR via MacPorts based on the documentation provided on the GitHUb, and they were installed successfully, and

However, I am trying to use Tesseract OCR for PHP (https://github.com/thiagoalessio/tesseract-ocr-for-php), so I download the zip and include the library to my php file, and use the

echo (new TesseractOCR('text.png'))
->run();

but nothing is showing up.

Below is the full code in the php

<?php 

REQUIRE_ONCE __DIR__.'/src/TesseractOCR.php';

echo (new TesseractOCR('text.png'))
    ->run(); 

?>

My error log has this entry:

sh: tesseract: command not found

If you share me some lights on how to get this work, it will be great!

回答1:

In order to use Tesseract OCR you may need to follow following steps:

1) Install Tesseract OCR into your system For installation

please checkout:https://github.com/tesseract-ocr/tesseract/wiki.

For Ubuntu Linux System you can run :

sudo apt-get install tesseract-ocr

2) Make composer.json file with following content:

{"require":{"thiagoalessio/tesseract_ocr": "1.0.0-RC"}}

3) Execute command from terminal

composer install

4) Finally, Do PHP Code:

require_once "vendor/autoload.php";
echo (new TesseractOCR('test.png'))->run();

Hope this will works for you,