kftools/iocr

ocr图像识别

v1.1.1 2021-04-14 14:45 UTC

This package is auto-updated.

Last update: 2024-04-14 22:33:22 UTC


README

对接平台

Requirements

  • guzzlehttp/guzzle

Installation

composer require --prefer-dist kftools/iocr

Usage

//服务商 face-plus or ali
$policyType = 'face-plus';
$params = [
    'api_key' => 'xxx', 'api_secret' => 'xxxx', //服务商对应身份证识别功能产品密钥
    'image_url' => 'xxxx','image_file' => 'xxxx', 'image_base64' => '', //识别图像文件三选一,image_file使用face-plus才有用
    'side' => 'face' //正面还是反面,使用阿里服务时要传,不传默认为face正面
    ];
$ocrIdcard = new \Iocr\OcrIdCard();
$result = $ocrIdcard->identify($params, $policyType);

//返回内容示例,其中extra为对应服务商接口独立内容,其它字段统一格式
{
    "errcode": 0,
    "errmsg": "ok",
    "data": {
        "request_id": "89A4F7AD-C215-4B5C-B742-613EC184E339",
        "cards": {
            "address": "北京市东城区景山前街4号紫禁城敬事房",
            "name": "韦小宝",
            "birth": "",
            "sex": "男",
            "id_card_number": "11204416541220243X",
            "nationality": "汉",
            "side": "front",
            "extra": {
                "angle": 0,
                "card_region": [
                    {
                        "x": 13,
                        "y": 22
                    },
                    {
                        "x": 581,
                        "y": 23
                    },
                    {
                        "x": 580,
                        "y": 386
                    },
                    {
                        "x": 12,
                        "y": 386
                    }
                ],
                "face_rect": {
                    "angle": 0,
                    "center": {
                        "x": 456,
                        "y": 190
                    },
                    "size": {
                        "height": 174,
                        "width": 208
                    }
                },
                "face_rect_vertices": [
                    {
                        "x": 369,
                        "y": 86
                    },
                    {
                        "x": 544,
                        "y": 86
                    },
                    {
                        "x": 543,
                        "y": 294
                    },
                    {
                        "x": 369,
                        "y": 294
                    }
                ],
                "is_fake": false
            }
        },
        "time_used": 510,
        "success": true
    }
}

Changelog

  • 20210406 初始化项目,对接阿里和旷视身份证图像识别功能