bicycle / tesseract-bridge
Integration of tesseract bridge via FFI and CLI
0.250
2021-01-28 16:13 UTC
Requires
- php: >7.4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.17.3
- phing/phing: dev-master
- phpmd/phpmd: ^2.9.1
- phpunit/phpunit: ^9.5.0
- sebastian/phpcpd: ^6.0.3
- squizlabs/php_codesniffer: ^3.5.8
- vimeo/psalm: ^4.3.2
Suggests
- ext-ffi: So you can use tesseract via ffi integration
This package is auto-updated.
Last update: 2024-12-08 14:57:58 UTC
README
A wrapper to work with Tesseract OCR inside PHP via CLI and/or FFI interfaces.
‼️ Tested only on FreeBSD, Debian and Ubuntu platforms with Tesseract OCR version 3 and 4 (see build logs).
Installation
Via Composer:
$ composer require bicycle/tesseract-bridge
Usage
Basic usage
-
CLI ```php use Bicycle\Tesseract\Bridge as TesseractBridge;
$configuration = TesseractBridge\Configuration(['binary_path' => 'tesseract']); $bridge = new TesseractBridge\CLI($configuration); echo $bridge->testGetVersion(); print_r($bridge->getAvailableLanguages()); echo $bridge->recognizeFromFile('eurotext.png'); // Set proper path here ```
-
FFI ```php use Bicycle\Tesseract\Bridge as TesseractBridge;
$configuration = TesseractBridge\Configuration(['binary_path' => 'tesseract']); $bridge = new TesseractBridge\FFI($configuration); echo $bridge->testGetVersion(); print_r($bridge->getAvailableLanguages()); echo $bridge->recognizeFromFile('eurotext.png'); // Set proper path here ```
With languages
-
CLI ```php use Bicycle\Tesseract\Bridge as TesseractBridge;
$configuration = TesseractBridge\Configuration(['binary_path' => 'tesseract']); $bridge = new TesseractBridge\CLI($configuration); echo $bridge->testGetVersion(); print_r($bridge->getAvailableLanguages()); echo $bridge->recognizeFromFile('eurotext.png', ['deu']); // Set proper path here ```
-
FFI ```php use Bicycle\Tesseract\Bridge as TesseractBridge;
$configuration = TesseractBridge\Configuration(['binary_path' => 'tesseract']); $bridge = new TesseractBridge\FFI($configuration); echo $bridge->testGetVersion(); print_r($bridge->getAvailableLanguages()); echo $bridge->recognizeFromFile('eurotext.png', ['deu']); // Set proper path here ```
How to contribute
You can contribute to this project by:
- Opening an Issue if you found a bug or wish to propose a new feature;
- Opening PR if you want to improve/create/fix something
Additional
Please check our FAQ
License
tesseract-bridge is released under the MIT License.