PHPackages                             skytian/ocr - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. skytian/ocr

ActiveLibrary[Image &amp; Media](/categories/media)

skytian/ocr
===========

The Best Image Ocr SDK For BAT.

1.1.7(5y ago)15MITPHP

Since Sep 29Pushed 5y ago1 watchersCompare

[ Source](https://github.com/skystian/ocr)[ Packagist](https://packagist.org/packages/skytian/ocr)[ Docs](http://github.com/godruoyi/ocr)[ RSS](/packages/skytian-ocr/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (3)Versions (15)Used By (0)

The Best Image Ocr SDK For BAT.
===============================

[](#the-best-image-ocr-sdk-for-bat)

> 注意：本库是基于godruoyi/ocr修改，由于阿里云接口有所变化故在此进行了修改，由于只使用了阿里云的营业执照识别，故对其他识别未做更改及测试。
>
> 修改了"doctrine/cache": "~1.6",应该不兼容php7.1及以上版本

[![Latest Stable Version](https://camo.githubusercontent.com/05e56a9b2022df3d734ec7a2a9a771eb9a8b83acfc59c0849163977b6293c814/68747470733a2f2f706f7365722e707567782e6f72672f676f6472756f79692f6f63722f762f737461626c65)](https://packagist.org/packages/godruoyi/ocr)[![Total Downloads](https://camo.githubusercontent.com/17b8300ed0c3eecdb4550f3dae3bc8cc9a2775ccce085750aa1c48f5bfe27896/68747470733a2f2f706f7365722e707567782e6f72672f676f6472756f79692f6f63722f646f776e6c6f616473)](https://packagist.org/packages/godruoyi/ocr)[![License](https://camo.githubusercontent.com/0ec8323bf0286c8ca2a5e562d1d465141bdf7f71c4205b6015200290c20db57c/68747470733a2f2f706f7365722e707567782e6f72672f676f6472756f79692f6f63722f6c6963656e7365)](https://packagist.org/packages/godruoyi/ocr)

- [百度 OCR](#baidu-ocr)
    - [通用文字识别](#baidu-generalBasic)
    - [通用文字识别（高精度版）](#baidu-accurateBasic)
    - [通用文字识别（含位置信息版）](#baidu-general)
    - [通用文字识别（含位置高精度版）](#baidu-accurate)
    - [通用文字识别（含生僻字版）](#baidu-generalEnhanced)
    - [网络图片文字识别](#baidu-webimage)
    - [银行卡识别](#baidu-bankcard)
    - [身份证识别](#baidu-idcard)
    - [驾驶证识别](#baidu-drivingLicense)
    - [行驶证识别](#baidu-vehicleLicense)
    - [车牌识别](#baidu-licensePlate)
    - [营业执照识别](#baidu-businessLicense)
    - [通用票据识别](#baidu-receipt)
- [Aliyun OCR](#aliyun-ocr)
    - [身份证识别](#aliyun-idcard)
    - [行驶证识别](#aliyun-vehicle)
    - [驾驶证识别](#aliyun-driverLicense)
    - [门店识别](#aliyun-shopSign)
    - [英文识别](#aliyun-english)
    - [营业执照识别](#aliyun-businessLicense)
    - [银行卡识别](#aliyun-bankCard)
    - [名片识别](#aliyun-businessCard)
    - [火车票识别](#aliyun-trainTicket)
    - [车牌识别](#aliyun-vehiclePlate)
    - [通用文字识别](#aliyun-general)
- [Tencent OCR](#tencent-ocr)
    - [名片识别](#tencent-namecard)
    - [身份证识别](#tencent-idcard)
    - [行驶证驾驶证识别](#tencent-drivingLicence)
    - [通用印刷体识别](#tencent-general)
    - [银行卡识别](#tencent-bankcard)
    - [车牌号识别](#tencent-plate)
    - [营业执照识别](#tencent-bizlicense)
- [Tencent OCR For AI](#tencent-ocr-for-ai)
    - [身份证识别](#tencent-idcard-for-ai)
    - [名片识别](#tencent-namecard-for-ai)
    - [行驶证驾驶证识别](#tencent-driverlicen-for-ai)
    - [银行卡识别](#tencent-bankcard-for-ai)
    - [通用印刷体识别](#tencent-general-for-ai)
    - [营业执照识别](#tencent-bizlicense-for-ai)

Feature
=======

[](#feature)

- 自定义缓存支持；
- 符合 PSR 标准，可以很方便的与你的框架结合；
- 命名不那么乱七八糟；
- 支持目前市面多家服务商

[查看更新日志](https://github.com/godruoyi/ocr/blob/master/CHANGELOG.md)

Support
=======

[](#support)

- [百度 OCR](http://ai.baidu.com/tech/ocr)
- [腾讯 万象优图](https://cloud.tencent.com/product/ocr)
- [腾讯 AI 开放平台](https://ai.qq.com/)
- [阿里 OCR](https://data.aliyun.com/product/ocr)

Requirement
===========

[](#requirement)

- PHP &gt; 5.6
- [composer](https://getcomposer.org/)

Installation
============

[](#installation)

```
composer require skytian/ocr
```

[Laravel 5 拓展包](https://github.com/godruoyi/laravel-ocr)

Usage
=====

[](#usage)

基本使用（以百度OCR为例）

```
use Godruoyi\OCR\Application;

$app = new Application([
    'ocrs' => [
        'baidu' => [
            'app_key' => 'app_key',
            'secret_key' => 'secret_key'
        ],
    ]
]);

//身份证识别
$result = $app->baidu->idcard($filePath);
```

**返回结果**

```
{
    "log_id": 530427582,
    "image_status": "normal",
    "words_result_num": 6,
    "words_result": {
        "住址": {
            "words": "上海市闵行区华漕镇红卫村宗家巷1号"
        },
        "出生": {
            "words": "19870723"
        },
        "姓名": {
            "words": "鹿晗"
        },
        "公民身份号码": {
            "words": "123456789123456132X"
        },
        "性别": {
            "words": "男"
        },
        "民族": {
            "words": "汉"
        }
    }
}
```

各平台支持的方法
========

[](#各平台支持的方法)

> 详情请参考官方文档

所有平台支持的方法中，都满足以下结构：

```
$app->platform->$method($files, $options = [])
```

`$files` 的值可以为

1. 文件路径（完整）
2. `SplFileInfo` 对象
3. `Resource`
4. 在线图片地址（部分服务商不支持）
5. Array

> 注：`options` 的值都是可选的

[百度OCR](http://ai.baidu.com/tech/ocr)
-------------------------------------

[](#百度ocr)

目前采用 `AccessToken` 作为 `API` 认证方式，查看[鉴权认证机制](http://ai.baidu.com/docs#/Auth/top)

#### 通用文字识别

[](#通用文字识别)

```
$app->baidu->generalBasic($file, [
    'language_type'         => 'CHN_ENG',  //支持的语言，默认为CHN_ENG（中英文混合）
    'detect_direction'      => false,      //是否检测图像朝向
    'detect_language'       => false,      //是否检测语言，默认不检测
    'probability'           => false,      //是否返回识别结果中每一行的置信度
]);
```

#### 通用文字识别（高精度版）

[](#通用文字识别高精度版)

```
$app->baidu->accurateBasic($file, [
    'detect_direction'      => false,      //是否检测图像朝向
    'probability'           => false,      //是否返回识别结果中每一行的置信度
]);
```

#### 通用文字识别（含位置信息版）

[](#通用文字识别含位置信息版)

```
$app->baidu->general($file, [
    'recognize_granularity' => 'big',      //是否定位单字符位置
    'language_type'         => 'CHN_ENG',  //CHN_ENG：中英文混合；默认为CHN_ENG
    'detect_direction'      => false,      //是否检测图像朝向
    'detect_language'       => false,      //是否检测语言，默认不检测
    'vertexes_location'     => false,      //是否返回文字外接多边形顶点位置，不支持单字位置。默认为false
    'probability'           => false,      //是否返回识别结果中每一行的置信度
]);
```

#### 通用文字识别（含位置高精度版）

[](#通用文字识别含位置高精度版)

```
$app->baidu->accurate($file, [
    'recognize_granularity' => 'big',      //是否定位单字符位置
    'detect_direction'      => false,      //是否检测图像朝向
    'vertexes_location'     => false,      //是否返回文字外接多边形顶点位置，不支持单字位置。默认为false
    'probability'           => false,      //是否返回识别结果中每一行的置信度
]);
```

#### 通用文字识别（含生僻字版）

[](#通用文字识别含生僻字版)

```
$app->baidu->generalEnhanced($file, [
    'language_type'         => 'CHN_ENG',  //CHN_ENG：中英文混合；默认为CHN_ENG
    'detect_direction'      => false,      //是否检测图像朝向
    'vertexes_location'     => false,      //是否返回文字外接多边形顶点位置，不支持单字位置。默认为false
    'probability'           => false,      //是否返回识别结果中每一行的置信度
]);
```

#### 网络图片文字识别

[](#网络图片文字识别)

```
$app->baidu->webimage($file, [
    'detect_direction'      => false,      //是否检测图像朝向
    'detect_language'       => false,      //是否检测语言，默认不检测
]);
```

#### 身份证识别

[](#身份证识别)

```
$app->baidu->idcard($file, [
    'detect_direction'      => false,      //是否检测图像朝向
    'id_card_side'          => 'front',    //front：身份证正面；back：身份证背面 （注意，该参数必选）
    'detect_risk'           => false,      //是否开启身份证风险类型功能，默认false
]);
```

#### 银行卡识别

[](#银行卡识别)

```
$app->baidu->bankcard($file, []);          //无参数
```

#### 驾驶证识别

[](#驾驶证识别)

```
$app->baidu->drivingLicense($file, [
    'detect_direction'      => false,      //是否检测图像朝向
]);
```

#### 行驶证识别

[](#行驶证识别)

```
$app->baidu->vehicleLicense($file, [
    'detect_direction'      => false,      //是否检测图像朝向
    'accuracy'              => 'normal'    // normal 使用快速服务，1200ms左右时延,缺省或其它值使用高精度服务，1600ms左右时延
]);
```

#### 车牌识别

[](#车牌识别)

```
$app->baidu->licensePlate($file, [
    'multi_detect'          => false,      //是否检测多张车牌，默认为false
]);
```

#### 营业执照识别

[](#营业执照识别)

```
$app->baidu->businessLicense($file, []);   //无参数
```

#### 通用票据识别

[](#通用票据识别)

```
$app->baidu->receipt($file, [
    'recognize_granularity' => 'big',      //是否定位单字符位置
    'probability'           => false,      //是否返回识别结果中每一行的置信度
    'accuracy'              => 'normal'    // normal 使用快速服务，1200ms左右时延,缺省或其它值使用高精度服务，1600ms左右时延
    'detect_direction'      => false,      //是否检测图像朝向
]);
```

[Aliyun OCR](https://data.aliyun.com/product/ocr)
-------------------------------------------------

[](#aliyun-ocr)

目前采用 `APPCODE` 作为 `API` 认证方式，[查看我的APPCODE](https://market.console.aliyun.com/imageconsole/index.htm)

```
use Godruoyi\OCR\Application;

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

> 阿里云OCR不支持在线图片地址

#### 身份证识别

[](#身份证识别-1)

```
$app->aliyun->idcard($file, [
    'side'                  => 'face',     //身份证正反面类型:face/back
]);
```

#### 行驶证识别

[](#行驶证识别-1)

```
$app->aliyun->vehicle($file, []);          //无可选参数
```

#### 驾驶证识别

[](#驾驶证识别-1)

```
$app->aliyun->driverLicense($file, [
    'side'                  => 'face',     //驾驶证首页/副页:face/back
]);
```

#### 门店识别

[](#门店识别)

```
$app->aliyun->shopSign($file, []);         //无可选参数
```

#### 英文识别

[](#英文识别)

```
$app->aliyun->english($file, []);          //无可选参数
```

#### 营业执照识别

[](#营业执照识别-1)

```
$app->aliyun->businessLicense($file, []);  //无可选参数
```

#### 银行卡识别

[](#银行卡识别-1)

```
$app->aliyun->bankCard($file, []);         //无可选参数
```

#### 名片识别

[](#名片识别)

```
$app->aliyun->businessCard($file, []);     //无可选参数
```

#### 火车票识别

[](#火车票识别)

```
$app->aliyun->trainTicket($file, []);      //无可选参数
```

#### 车牌识别

[](#车牌识别-1)

```
$app->aliyun->vehiclePlate($file, [
    'multi_crop'            => false,     //当设成true时,会做多crop预测，只有当多crop返回的结果一致，并且置信度>0.9时，才返回结果
]);
```

#### 通用文字识别

[](#通用文字识别-1)

```
$app->aliyun->general($file, [
    'min_size'              => 16,        //图片中文字的最小高度，
    'output_prob'           => false,     //是否输出文字框的概率，
]);
```

[Tencent OCR](https://cloud.tencent.com/product/ocr)
----------------------------------------------------

[](#tencent-ocr)

> 可登录 [云API密钥控制台](https://console.cloud.tencent.com/capi)查看你的[个人 API 密钥](https://console.cloud.tencent.com/capi)

```
use Godruoyi\OCR\Application;

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

> Tencent OCR 暂不支持在线图片地址

#### 名片识别

[](#名片识别-1)

```
$app->tencent->namecard($file, [
    'ret_image'             => 0,        //0 不返回图片，1 返回图片，
]);
```

#### 身份证识别

[](#身份证识别-2)

```
$app->tencent->idcard($file, [
    'card_type'             => 0,        //0 为身份证有照片的一面，1为身份证有国徽的一面
]);
```

#### 行驶证驾驶证识别

[](#行驶证驾驶证识别)

```
$app->tencent->drivingLicence($file, [
    'type'                  => 0,        //识别类型，0表示行驶证，1表示驾驶证，
]);
```

#### 通用印刷体识别

[](#通用印刷体识别)

```
$app->tencent->general($file, []);       //无可选参数
```

#### 银行卡识别

[](#银行卡识别-2)

```
$app->tencent->bankcard($file, []);      //无可选参数
```

#### 车牌号识别

[](#车牌号识别)

```
$app->tencent->plate($file, []);         //无可选参数
```

#### 营业执照识别

[](#营业执照识别-2)

```
$app->tencent->bizlicense($file, []);    //无可选参数
```

[Tencent OCR For AI](https://ai.qq.com/product/ocr.shtml#identify)
------------------------------------------------------------------

[](#tencent-ocr-for-ai)

> 可登录 [腾讯 AI 控制台](https://ai.qq.com/cgi-bin/console_overview)查看你的[个人 APP\_ID 及 APP\_KEY](https://ai.qq.com/cgi-bin/console_overview)

```
use Godruoyi\OCR\Application;

$app = new Application([
    'ocrs' => [
        'tencentai' => [
          'app_id' => '1106584682',
          'app_key' => 'XGgkqVif73v8wH6W',
        ],
    ]
]);
```

#### 身份证识别

[](#身份证识别-3)

```
$app->tencentai->idcard($file, [
    'card_type'             => 0,          //0 为身份证有照片的一面，1为身份证有国徽的一面 默认0
]);
```

#### 名片识别

[](#名片识别-2)

```
$app->tencentai->namecard($file, []);
```

#### 行驶证驾驶证识别

[](#行驶证驾驶证识别-1)

```
$app->tencentai->driverlicen($file, [
    'type'                  => 0,          //识别类型，0表示行驶证，1表示驾驶证，默认0
]);
```

#### 银行卡识别

[](#银行卡识别-3)

```
$app->tencentai->bankcard($file, []);      //无可选参数
```

#### 通用印刷体识别

[](#通用印刷体识别-1)

```
$app->tencentai->general($file, []);       //无可选参数
```

#### 营业执照识别

[](#营业执照识别-3)

```
$app->tencentai->bizlicense($file, []);    //无可选参数
```

MIT

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity71

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~89 days

Recently: every ~221 days

Total

13

Last Release

2086d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/44796561?v=4)[sky](/maintainers/skystian)[@skystian](https://github.com/skystian)

---

Tags

imageOCR

### Embed Badge

![Health badge](/badges/skytian-ocr/health.svg)

```
[![Health](https://phpackages.com/badges/skytian-ocr/health.svg)](https://phpackages.com/packages/skytian-ocr)
```

###  Alternatives

[folklore/image

Image manipulation library for Laravel 5 based on Imagine and inspired by Croppa for easy url based manipulation

270248.2k5](/packages/folklore-image)[alimranahmed/laraocr

Laravel Optical Character Reader(OCR) package using different OCR engines like Tesseract

17081.9k](/packages/alimranahmed-laraocr)[mohuishou/image-ocr

验证码识别

2732.8k1](/packages/mohuishou-image-ocr)[media-alchemyst/media-alchemyst

An Object Oriented wrapper for easy multimedia conversion, based on Imagine, FFMpeg, SwfTools, Unoconv and other libs

65216.4k1](/packages/media-alchemyst-media-alchemyst)[yk/laravel-ocr

A wrapper for gocr.

1356.5k](/packages/yk-laravel-ocr)[urlbox/screenshots

Use urlbox to easily generate website thumbnail screenshots from a URL

14250.4k](/packages/urlbox-screenshots)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
