PHPackages                             jasongzj/laravel-qcloud-image - 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. jasongzj/laravel-qcloud-image

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

jasongzj/laravel-qcloud-image
=============================

tencent image detection SDK for Laravel

1.0.1(7y ago)20681MITPHP

Since Nov 26Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Jasongzj/laravel-qcloud-image)[ Packagist](https://packagist.org/packages/jasongzj/laravel-qcloud-image)[ RSS](/packages/jasongzj-laravel-qcloud-image/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (2)Versions (7)Used By (0)

 Laravel-Qcloud-Image
======================

[](#-laravel-qcloud-image-)

 腾讯云云智AI图像服务的SDK for Laravel.

[![StyleCI](https://camo.githubusercontent.com/f3b06af58d1a022e379b58d19d81e60c9d039c8ac2bfd8bd2c3b7daae724e30b/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3135383638383233362f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/158688236)

安装
--

[](#安装)

```
$ composer require jasongzj/laravel-qcloud-image -vvv

```

配置
--

[](#配置)

1. 在 config/app.php 注册 ServiceProvider (Laravel 5.5 无需手动注册)

```
'providers' => [
    // ...
    Jasongzj\LaravelQcloudImage\ServiceProvider::class,
]

```

2. 在 `config/services.php` 文件中添加如下配置

```
'qcloud_image' => [
    'appid' => env('QCLOUD_IMAGE_APPID'),
    'secret_id' => env('QCLOUD_IMAGE_SECRET_ID'),
    'secret_key' => env('QCLOUD_IMAGE_SECRET_KEY'),
],

```

3. 在 `.env` 文件中配置相关参数

```
QCLOUD_IMAGE_APPID=xxxxx
QCLOUD_IMAGE_SECRET_ID=xxxxxxxxxxx
QCLOUD_IMAGE_SECRET_KEY=xxxxxxxxx

```

使用
--

[](#使用)

#### 方法参数注入

[](#方法参数注入)

```
use Jasongzj\LaravelQcloudImage\QcloudImage;
·
·
·
    public function detect(QcloudImage $qcloudImage)
    {
        $image = array('url' => 'http://img3.a0bi.com/upload/ttq/20160814/1471155260063.png');
        $qcloudImage->faceRecognition->faceDetect($image, 1);
    }
·
·
·

```

#### 服务名访问

[](#服务名访问)

```
use Jasongzj\LaravelQcloudImage\QcloudImage;
·
·
·
    public function detect()
    {
        $image = array('url' => 'http://img3.a0bi.com/upload/ttq/20160814/1471155260063.png');
        app(QcloudImage::class)->faceRecognition->faceDetect($image, 1);
    }
·
·
·

```

API
---

[](#api)

### 人脸识别

[](#人脸识别)

#### 人脸检测

[](#人脸检测)

检测给定图片中的所有人脸( Face )的位置和相应的面部属性，位置包括(x，y，w，h)，面部属性包括性别( gender )、年龄( age )、表情( expression )、魅力( beauty )、眼镜( glass )和姿态 (pitch，roll，yaw )。

```
// 单个图片 URL， mode:1 为检测最大的人脸，0 为检测所有人脸
$qcloudImage->faceRecognition->faceDetect(array('url'=>'http://img3.a0bi.com/upload/ttq/20160814/1471155260063.png'), 1);
// 单个图片 file,mode:1 为检测最大的人脸，0 为检测所有人脸
$qcloudImage->faceRecognition->faceDetect(array('file'=>'F:\pic\face1.jpg'),0);
// 单个图片内容，mode:1 为检测最大的人脸，0 为检测所有人脸
$qcloudImage->faceRecognition->faceDetect(array('buffer'=>file_get_contents('F:\pic\face1.jpg')), 1);

```

#### 五官定位

[](#五官定位)

对请求图片进行五官定位，计算构成人脸轮廓的 88 个点，包括眉毛（左右各 8 点）、眼睛（左右各 8 点）、鼻子（ 13 点）、嘴巴（ 22 点）、脸型轮廓（ 21 点）。

```
// 单个图片Url,mode:1为检测最大的人脸 , 0为检测所有人脸
$qcloudImage->faceRecognition->faceShape(array('url'=>'YOUR URL'),1);
// 单个图片file,mode:1为检测最大的人脸 , 0为检测所有人脸
$qcloudImage->faceRecognition->faceShape(array('file'=>'F:\pic\face1.jpg'),0);
// 单个图片内容,mode:1为检测最大的人脸 , 0为检测所有人脸
$qcloudImage->faceRecognition->faceShape(array('buffer'=>file_get_contents('F:\pic\face1.jpg')), 1);

```

#### 人脸对比

[](#人脸对比)

计算两个 Face 的相似性以及五官相似度。

```
// 两个对比图片的文件url
$qcloudImage->faceRecognition->faceCompare(array('url'=>"YOUR URL A"), array('url'=>'YOUR URL B'));
// 两个对比图片的文件file
$qcloudImage->faceRecognition->faceCompare(array('file'=>'F:\pic\yang.jpg'), array('file'=>'F:\pic\yang2.jpg'));
// 两个对比图片的文件内容
$qcloudImage->faceRecognition->faceCompare(array('file'=>'F:\pic\yang.jpg'), array('file'=>'F:\pic\yang2.jpg'));

```

#### 个体信息管理

[](#个体信息管理)

```
// 个体创建,创建一个Person，并将Person放置到group_ids指定的组当中，不存在的group_id会自动创建。
// 创建一个Person, 使用图片url
$qcloudImage->faceRecognition->faceNewPerson('person1111', array('group11',), array('url'=>'YOUR URL'), 'xiaoxin');
// 创建一个Person, 使用图片file
$qcloudImage->faceRecognition->faceNewPerson('person2111', array('group11',), array('file'=>'F:\pic\hot1.jpg'));
// 创建一个Person, 使用图片内容
$qcloudImage->faceRecognition->faceNewPerson('person3111', array('group11',), array('buffer'=>file_get_contents('F:\pic\zhao1.jpg')));

// 增加人脸,将一组Face加入到一个Person中。
// 将单个或者多个Face的url加入到一个Person中
$qcloudImage->faceRecognition->faceAddFace('person1111', array('urls'=>array('YOUR URL A', 'YOUR URL B')));
// 将单个或者多个Face的file加入到一个Person中
$qcloudImage->faceRecognition->faceAddFace('person2111', array('files'=>array('F:\pic\yang.jpg', 'F:\pic\yang2.jpg')));
// 将单个或者多个Face的文件内容加入到一个Person中
$qcloudImage->faceRecognition->faceAddFace('person3111', array('buffers'=>array(file_get_contents('F:\pic\yang.jpg'), file_get_contents('F:\pic\yang2.jpg'))));

// 删除人脸,删除一个person下的face
$qcloudImage->faceRecognition->faceDelFace('person1', array('12346'));

// 设置信息
$qcloudImage->faceRecognition->faceSetInfo('person1', 'fanbing');

// 获取信息
$qcloudImage->faceRecognition->faceGetInfo('person1');

// 获取所有组列表
$qcloudImage->faceRecognition->faceGetGroupIds();

// 获取组下所有人列表
$qcloudImage->faceRecognition->faceGetPersonIds('group1');

// 获取人下所有人脸列表
$qcloudImage->faceRecognition->faceGetFaceIds('person1');

// 获取人脸信息
$qcloudImage->faceRecognition->faceGetFaceInfo('1704147773393235686');

// 删除个人
$qcloudImage->faceRecognition->faceDelPerson('person11');

// 新增group_id
$qcloudImage->faceRecognition->faceAddGroupIds('person11', array('group2', 'group3'));

// 删除group_id
$qcloudImage->faceRecognition->faceDelGroupIds('person11', array('group2', 'group3'));

```

#### 人脸验证

[](#人脸验证)

给定一个图片和一个 Person ，检查是否是同一个人。

```
// 单个图片Url
$qcloudImage->faceRecognition->faceVerify('person1', array('url'=>'YOUR URL'));
// 单个图片file
$qcloudImage->faceRecognition->faceVerify('person3111', array('file'=>'F:\pic\yang3.jpg'));
// 单个图片内容
$qcloudImage->faceRecognition->faceVerify('person3111', array('buffer'=>file_get_contents('F:\pic\yang3.jpg')));

```

#### 人脸检索

[](#人脸检索)

对一张待识别的人脸图片，在一个或多个 group 中识别出最相似的 Top5 person 作为其身份返回，返回的 Top5 中按照相似度从大到小排列。

```
// 单个文件url
$qcloudImage->faceRecognition->faceIdentify('group1', array('url'=>'YOUR URL'));
// 单个文件file
$qcloudImage->faceRecognition->faceIdentify('group11', array('file'=>'F:\pic\yang3.jpg'));
// 单个文件内容
$qcloudImage->faceRecognition->faceIdentify('group11', array('buffer'=>file_get_contents('F:\pic\yang3.jpg')));

```

#### 多脸检索

[](#多脸检索)

对一张包含多个待识别的人脸的图片，在一个 group 或多个 groups 中识别出最相似的 person 作为其身份返回，返回的 Top5 中按照相似度从大到小排列。

```
// 单张文件url，一个group
$qcloudImage->faceRecognition->multidentify(array('url'=>'YOUR URL'), array('group_id' => 'group111'));
// 单张文件url，多个groups
$qcloudImage->faceRecognition->multidentify(array('url'=>'YOUR URL'), array('group_ids' => array('group111','group222')));
// 单个文件file，一个group
$qcloudImage->faceRecognition->multidentify(array('file'=>'F:\pic\yang3.jpg'), array('group_id' => 'group111'));
// 单个文件file，多个groups
$qcloudImage->faceRecognition->multidentify(array('file'=>'F:\pic\yang3.jpg'), array('group_ids' => array('group111','group222')));
// 单个文件内容，一个group
$qcloudImage->faceRecognition->multidentify(array('buffer'=>file_get_contents('F:\pic\yang3.jpg'), array('group_id' => 'group111'));
// 单个文件内容，多个groups
$qcloudImage->faceRecognition->multidentify(array('buffer'=>file_get_contents('F:\pic\yang3.jpg'), array('group_ids' => array('group111','group222')));

```

### 人脸核身

[](#人脸核身)

#### 人脸静态活体检测

[](#人脸静态活体检测)

对用户上传的静态照片进行人脸活体检测，判断是否为活体

```
// 单个文件url
$qcloudImage->faceIn->liveDetectPicture(array('url'=>'YOUR URL'));
// 单个文件file
$qcloudImage->faceIn->liveDetectPicture(array('file'=>'F:\pic\yang3.jpg'));
// 单个文件内容
$qcloudImage->faceIn->liveDetectPicture(array('buffer'=>file_get_contents('F:\pic\yang3.jpg')));

```

#### 用户上传照片身份信息核验

[](#用户上传照片身份信息核验)

用于判断给定一张照片与身份证号和姓名对应的登记照的人脸相似度，即判断给定照片中的人与身份证上的人是否为同一人。

```
// 身份证号，身份证姓名，单个文件url
$qcloudImage->faceIn->liveDetectPicture('idcardNumber', 'idcardName', array('url'=>'YOUR URL'));
// 身份证号，身份证姓名，单个文件file
$qcloudImage->faceIn->liveDetectPicture('idcardNumber', 'idcardName', array('file'=>'F:\pic\yang3.jpg'));
// 身份证号，身份证姓名，单个文件内容
$qcloudImage->faceIn->liveDetectPicture('idcardNumber', 'idcardName', array('buffer'=>file_get_contents('F:\pic\yang3.jpg')));

```

#### 活体检测-获取唇语验证码

[](#活体检测-获取唇语验证码)

获取一个唇语验证字符串，用于录制视频，进行活体检测。

```
$obj = $qcloudImage->faceIn->faceLiveGetFour();
var_dump ($obj);
$validate_data = $obj['data']['validate_data'];

```

#### 活体检测-视频与用户照片的比对

[](#活体检测-视频与用户照片的比对)

判断录制的唇语视频中人物是否为真人（活体检测），同时判断唇语视频中的人脸与给定的一张人脸照片的人脸相似度，即判断视频中的人与给定一张照片的人是否为同一人。

```
$qcloudImage->faceIn->faceLiveDetectFour($validate_data, array('file'=>'F:\pic\ZOE_0171.mp4'), False, array('F:\pic\idcard.jpg'));

```

#### 活体检测-视频与身份证高清照片的比对

[](#活体检测-视频与身份证高清照片的比对)

判断录制的唇语视频中人物是否为真人（活体检测），同时判断唇语视频中的人脸与身份证号和姓名对应的登记照的人脸相似度，即判断视频中的人与身份证上的人是否为同一人。

```
$qcloudImage->faceIn->faceIdCardLiveDetectFour($validate_data, array('file'=>'F:\pic\ZOE_0171.mp4'), 'xxxxxxxxxxx', 'xxxxxxxxxxx');

```

### 智能鉴黄

[](#智能鉴黄)

```
// 单个或多个图片 URL
$qcloudImage->pornIdentification->pornDetect(array('urls'=> array('http://img3.a0bi.com/upload/ttq/20160814/1471155260063.png',
            "http://jiangsu.china.com.cn/uploadfile/2015/1102/1446443026382534.jpg")));
// 单个或多个图片 file
$qcloudImage->pornIdentification->pornDetect(array('files'=> array('F:\pic\你好.jpg','G:\pic\test2.jpg')));

```

### 文字识别-ORC

[](#文字识别-orc)

#### 身份证识别

[](#身份证识别)

```

// 单个或多个图片 URL，cardType: 0为身份证有照片的一面，1为身份证有国徽的一面
$qcloudImage->ORC->namecardV2Detect(array('urls'=>array('http://imgs.focus.cn/upload/sz/5876/a_58758051.jpg',
                            'http://img5.iqilu.com/c/u/2013/0530/1369896921237.jpg')), 0);
// 单个或多个图片 file，cardType: 0为身份证有照片的一面，1为身份证有国徽的一面
$qcloudImage->ORC->namecardV2Detect(array('files'=>array('F:\pic\id6zheng.jpg', 'F:\pic\id2zheng.jpg')), 1);
// 单个或多个图片内容，cardType: 0为身份证有照片的一面，1为身份证有国徽的一面
$qcloudImage->ORC->namecardV2Detect(array('buffers'=>array(file_get_contents('F:\pic\id6_zheng.jpg'),
                            file_get_contents('F:\pic\id2_zheng.jpg'))), 0);

```

#### 名片识别（V2）

[](#名片识别v2)

```
// 单个或多个图片 URL，
$qcloudImage->ORC->idcardDetect(array('urls'=>array('http://imgs.focus.cn/upload/sz/5876/a_58758051.jpg',
                            'http://img5.iqilu.com/c/u/2013/0530/1369896921237.jpg')));
// 单个或多个图片 file，
$qcloudImage->ORC->idcardDetect(array('files'=>array('F:\pic\id6zheng.jpg', 'F:\pic\id2zheng.jpg')));
// 单个或多个图片内容，cardType:
$qcloudImage->ORC->idcardDetect(array('buffers'=>array(file_get_contents('F:\pic\id6_zheng.jpg'),
                            file_get_contents('F:\pic\id2_zheng.jpg'))));

```

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

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

```
// 单个图片 URL， type:0 表示行驶证，1 表示驾驶证，2 表示行驶证副页。
$qcloudImage->ORC->drivingLicence(array('url'=>'http://img3.a0bi.com/upload/ttq/20160814/1471155260063.png'), 1);
// 单个图片 file,type:0 表示行驶证，1 表示驾驶证，2 表示行驶证副页。
$qcloudImage->ORC->drivingLicence(array('file'=>'F:\pic\face1.jpg'),0);
// 单个图片内容，type:0 表示行驶证，1 表示驾驶证，2 表示行驶证副页。
$qcloudImage->ORC->drivingLicence(array('buffer'=>file_get_contents('F:\pic\face1.jpg')), 1);

```

#### 车牌号识别

[](#车牌号识别)

```
// 单个图片 URL
$qcloudImage->ORC->plate(array('url'=>'http://img3.a0bi.com/upload/ttq/20160814/1471155260063.png'));
// 单个图片 file
$qcloudImage->ORC->plate(array('file'=>'F:\pic\face1.jpg'));
// 单个图片内容
$qcloudImage->ORC->plate(array('buffer'=>file_get_contents('F:\pic\face1.jpg')));

```

#### 银行卡识别

[](#银行卡识别)

```
// 单个图片 URL
$qcloudImage->ORC->bankcard(array('url'=>'http://img3.a0bi.com/upload/ttq/20160814/1471155260063.png'));
// 单个图片 file
$qcloudImage->ORC->bankcard(array('file'=>'F:\pic\face1.jpg'));
// 单个图片内容
$qcloudImage->ORC->bankcard(array('buffer'=>file_get_contents('F:\pic\face1.jpg')));

```

#### 营业执照识别

[](#营业执照识别)

```
// 单个图片 URL
$qcloudImage->ORC->bizlicense(array('url'=>'http://img3.a0bi.com/upload/ttq/20160814/1471155260063.png'));
// 单个图片 file
$qcloudImage->ORC->bizlicense(array('file'=>'F:\pic\face1.jpg'));
// 单个图片内容
$qcloudImage->ORC->bizlicense(array('buffer'=>file_get_contents('F:\pic\face1.jpg')));

```

#### 通用印刷体识别

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

```
// 单个图片 URL
$qcloudImage->ORC->general(array('url'=>'http://img3.a0bi.com/upload/ttq/20160814/1471155260063.png'));
// 单个图片 file
$qcloudImage->ORC->general(array('file'=>'F:\pic\face1.jpg'));
// 单个图片内容
$qcloudImage->ORC->general(array('buffer'=>file_get_contents('F:\pic\face1.jpg')));

```

#### 手写体识别

[](#手写体识别)

```
// 单个图片 URL
$qcloudImage->ORC->handwriting(array('url'=>'http://img3.a0bi.com/upload/ttq/20160814/1471155260063.png'));
// 单个图片 file
$qcloudImage->ORC->handwriting(array('file'=>'F:\pic\face1.jpg'));
// 单个图片内容
$qcloudImage->ORC->handwriting(array('buffer'=>file_get_contents('F:\pic\face1.jpg')));

```

参考
--

[](#参考)

[云智AI应用服务智能图像 SDK V2.0](https://github.com/tencentyun/image-php-sdk-v2.0)

[PHP 扩展包实战教程 - 从入门到发布](https://laravel-china.org/courses/creating-package)

License
-------

[](#license)

MIT

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~5 days

Total

4

Last Release

2708d ago

Major Versions

0.0.2 → 1.0.02018-11-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/9fb853bdf695fc672716d60af0d2b61eb8c8dd52c9931896b39a37591a1025ce?d=identicon)[Jasongzj](/maintainers/Jasongzj)

---

Top Contributors

[![Jasongzj](https://avatars.githubusercontent.com/u/24838580?v=4)](https://github.com/Jasongzj "Jasongzj (17 commits)")

### Embed Badge

![Health badge](/badges/jasongzj-laravel-qcloud-image/health.svg)

```
[![Health](https://phpackages.com/badges/jasongzj-laravel-qcloud-image/health.svg)](https://phpackages.com/packages/jasongzj-laravel-qcloud-image)
```

###  Alternatives

[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)[opentok/opentok

OpenTok is a platform for creating real time streaming video applications, created by TokBox.

1413.0M10](/packages/opentok-opentok)[automattic/wistia-php

PHP wrapper for Wistia API

1431.9k](/packages/automattic-wistia-php)[daun/statamic-placeholders

Generate low-quality image placeholders for lazyloading Statamic assets

106.6k](/packages/daun-statamic-placeholders)[daun/statamic-mux

Seamless video encoding and streaming using Mux on Statamic sites

132.3k](/packages/daun-statamic-mux)

PHPackages © 2026

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