The Best Image OCR SDK For BAT.

  • Baidu OCR
    • Universal character recognition
    • General Character Recognition (High Precision Version)
    • General Character Recognition (including position information version)
    • General character Recognition (including position high Precision version)
    • General Character Recognition (including rare characters)
    • Network picture text recognition
    • Bank card identification
    • Identification card
    • Driver’s license recognition
    • Identification of driving license
    • License plate recognition
    • Business license identification
    • General bill identification
  • Aliyun OCR
    • Identification card
    • Identification of driving license
    • Driver’s license recognition
    • Store identification
    • English identification
    • Business license identification
    • Bank card identification
    • Business card recognition
    • Train ticket identification
    • License plate recognition
    • Universal character recognition
  • Tencent OCR
    • Business card recognition
    • Identification card
    • Driving license identification
    • General print recognition

Project address github.com/godruoyi/oc…

It’s Tuesday, a good day to launch wheels. @overtrue

Feature

  • Custom cache support;
  • PSR compliant, easy to integrate with your framework;
  • Less messy naming;
  • Support the current market many service providers

Support

  • Baidu OCR
  • Tencent Vientiane Map
  • Ali OCR

Requirement

  • PHP > 5.6
  • composer

Installation

composer require godruoyi/ocrCopy the code

Laravel 5 Expansion pack

Usage

Basic Use (Take Baidu OCR as an example)

use Godruoyi\OCR\Application; $app = new Application([ 'ocrs' => [ 'baidu' => [ 'app_key' => 'app_key', 'secret_key' => 'secret_key' ], ] ]); $result = $app->baidu->idcard($filePath);Copy the code

Returns the result

{"log_id": 530427582, "image_status": "normal", "words_result_num": 6, "words_result": {" address ": {"words": "Hua cao town, minhang district of Shanghai red guard home village of lane 1"}, "birth" : {" words ":" 19870723 "}, "name" : {" words ":" Lu Han} ", "citizenship number" : {" words ": "123456789123456132 x}", "gender" : {" words ":" male "}, "nation" : {" words ":" han "}}}Copy the code

The methods supported by each platform

Please refer to the official documentation for details

Methods supported by all platforms meet the following structure:

$app->platform->$method($files, $options = [])Copy the code

The value of $files can be

  1. File path (complete)
  2. SplFileInfoobject
  3. Resource
  4. Online picture address (some service providers do not support)
  5. Array

    Note:
    optionsValues of are optional

Baidu OCR

Currently, AccessToken is used as the API authentication mode to check the authentication mechanism

Universal character recognition

$app->baidu->generalBasic($file, ['language_type' => 'CHN_ENG', Default: CHN_ENG 'DETECt_direction' => false, 'DETECt_language' => false, Default does not detect 'probability' => false, // whether the confidence of each line in the result of identification is returned]);Copy the code

General Character Recognition (High Precision Version)

$app->baidu->accurateBasic($file, ['detect_direction' => false, // whether to return the confidence of each line in the recognition result]);Copy the code

General Character Recognition (including position information version)

Recognize_granularity ($file, ['recognize_granularity' => 'big'); // Recognize_granularity => 'CHN_ENG', //CHN_ENG: Mixed Chinese and English; Default: CHN_ENG 'DETECt_direction' => false, // Detect_language => false, // Language, Default does not detect 'vertexes_location' => false, // whether the vertexes_location vertex position is returned, single-word position is not supported. Default is false 'probability' => false, // Whether the confidence of each line in the result is returned]);Copy the code

General character Recognition (including position high Precision version)

True ($file, ['recognize_granularity' => 'big', 'detect_direction' => false); // Whether to detect image orientation 'vertexes_location' => false, // whether to return text surrounding polygon vertex position, single word position is not supported. Default is false 'probability' => false, // whether the confidence of each row in the result of identification is returned]);Copy the code

General Character Recognition (including rare characters)

$app->baidu->generalEnhanced($file, ['language_type' => 'CHN_ENG', //CHN_ENG: CHN_ENG 'detect_direction' => false, // whether to detect image orientation 'vertexes_location' => false, // whether to return text surrounding polygon vertex position, not single word position. Default is false 'probability' => false, // whether the confidence of each row in the result of identification is returned]);Copy the code

Network picture text recognition

$app->baidu-> webImage ($file, ['detect_direction' => false, 'detect_language' => false, 'not detect_language');Copy the code

Identification card

$app->baidu->idcard($file, ['detect_direction' => false, 'detect_direction' => 'front', On the back of the ID card (note that this parameter is mandatory) 'DETECt_risk' => false, // Whether to enable the ID risk type function, default false]);Copy the code

Bank card identification

$app->baidu->bankcard($file, [
]);Copy the code

Driver’s license recognition

$app->baidu->drivingLicense($file, ['detect_direction' => false, // whether to detect image orientation));Copy the code

Identification of driving license

$app-> Baidu ->vehicleLicense($file, ['detect_direction' => false,) Your vehicleLicense($file, ['detect_direction' => 'normal') About 1200ms delay, default or other values use high-precision service, about 1600ms delay]);Copy the code

License plate recognition

$licensePlate($file, ['multi_detect' => false, default => false]);Copy the code

Business license identification

$app->baidu->businessLicense($file, [
]);Copy the code

General bill identification

Recognize_granularity => true $app->baidu-> Receipt ($file, ['recognize_granularity' => 'big', 'accuracy' => 'normal' // Normal uses fast service, 1200ms delay, default or other values use high precision service, 'Detect_direction' => false, // whether to detect image orientation]);Copy the code

Aliyun OCR

Currently APPCODE is used as API authentication. Check my APPCODE

use Godruoyi\OCR\Application;

$app = new Application([
    'ocrs' => [
        'aliyun' => [
            'appcode' => '40bc103c7fe6417b87152f6f68bead2f',
        ]
    ]
]);Copy the code

Ali Cloud OCR does not support online picture address

Identification card

$app - > aliyun - > idcard ($file, [' side '= >' face ', positive and negative / / id card types: face/back]);Copy the code

Identification of driving license

$app->aliyun->vehicle($file, [
]);Copy the code

Driver’s license recognition

$app - > aliyun - > driverLicense ($file, [' side '= >' face ', / / driving license/deputy home page page: face/back]);Copy the code

Store identification

$app->aliyun->shopSign($file, [
]);Copy the code

English identification

$app->aliyun->english($file, [
]);Copy the code

Business license identification

$app->aliyun->businessLicense($file, [
]);Copy the code

Bank card identification

$app->aliyun->bankCard($file, [
]);Copy the code

Business card recognition

$app->aliyun->businessCard($file, [
]);Copy the code

Train ticket identification

$app->aliyun->trainTicket($file, [
]);Copy the code

License plate recognition

$app->aliyun->vehiclePlate($file, ['multi_crop' => false, // when set to true, multi_crop prediction will be done only if the result is consistent and the confidence is >0.9);Copy the code

Universal character recognition

$app->aliyun->general($file, ['min_size' => 16, 'output_prob' => false,]);Copy the code

Tencent OCR

Can login
Cloud API key consoleLook at your
Personal API key

use Godruoyi\OCR\Application;

$app = new Application([
    'ocrs' => [
        'tencent' => [
            'app_id' => '1254032478',
            'secret_id' => 'AKIDzODdB1nOELz0T8CEjTEkgKJOob3t2Tso',
            'secret_key' => '6aHHkz236LOYu0nRuBwn5PwT0x3km7EL',
            'bucket' => 'test1'
        ],
    ]
]);Copy the code

Tencent OCR does not support online photo addresses

Business card recognition

$file -> Tencent ->namecard($file, ['ret_image' => 0,]);Copy the code

Identification card

$file -> Tencent ->idcard($file, ['card_type' => 0, 0 => 0, 1 => 0));Copy the code

Driving license identification

$app-> Tencent ->drivingLicence($file, ['type' => 0,]); $app-> Tencent ->drivingLicence($file, ['type' => 0,])Copy the code

General print recognition

$app->tencent->general($file, [
]);Copy the code

Two leng Xu love to chat miscellaneous fish