How to setup and running Tesseract OCR for PHP (opensource)?

强颜欢笑 提交于 2019-12-24 01:19:51

问题


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,



来源:https://stackoverflow.com/questions/38091060/how-to-setup-and-running-tesseract-ocr-for-php-opensource

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