bicycle/tesseract-bridge

Integration of tesseract bridge via FFI and CLI

0.250 2021-01-28 16:13 UTC

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.

Minimum PHP Version Build Status Codacy Badge codecov Scrutinizer Code Quality Latest stable version on packagist Total downloads Monthly downloads License

‼️ 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

example

  • 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.