护照识别

接口描述

支持对中国大陆居民护照的资料页进行结构化识别,包含国家码、姓名、姓名拼音、性别、护照号、出生日期、出生地点、签发日期、有效期至、签发地点。

请求说明

请求示例

HTTP 方法:POST

请求URL: https://aip.baidubce.com/rest/2.0/ocr/v1/passport

URL参数:

参数
access_token 通过API Key和Secret Key获取的access_token,参考“Access Token获取

Header如下:

参数
Content-Type application/x-www-form-urlencoded

Body中放置请求参数,参数详情如下:

请求参数

参数 是否必选 类型 可选值范围 说明
image string - 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式

请求代码示例

参考通用文字识别(含位置信息版)

返回说明

返回参数

字段 是否必选 类型 说明
log_id uint64 唯一的log id,用于问题定位
words_result_num uint32 识别结果数,表示words_result的元素个数
words_result array() 定位和识别结果数组
-location uint32 水平坐标
-words string 识别内容

返回示例

{
    "log_id": 1291777459,
    "words_result": {
        "国家码": {
            "location": {
                "left": 231,
                "top": -64,
                "width": 51,
                "height": 70
            },
            "words": "CHN"
        },
        "姓名": {
            "location": {
                "left": 234,
                "top": 26,
                "width": 29,
                "height": 16
            },
            "words": "袁运筹"
        },
        "性别": {
            "location": {
                "left": 139,
                "top": 57,
                "width": 53,
                "height": 50
            },
            "words": "男/M"
        },
        "生日": {
            "location": {
                "left": 321,
                "top": 134,
                "width": 35,
                "height": 14
            },
            "words": "24NOV1990"
        },
        "护照签发地点": {
            "location": {
                "left": 165,
                "top": 206,
                "width": 78,
                "height": 15
            },
            "words": "福建/FUJIAN"
        },
        "有效期至": {
            "location": {
                "left": 321,
                "top": 215,
                "width": 30,
                "height": 14
            },
            "words": "078月/AUG2024"
        },
        "护照号码": {
            "location": {
                "left": 326,
                "top": 33,
                "width": 12,
                "height": 14
            },
            "words": "E21202282"
        },
        "签发日期": {
            "location": {
                "left": 324,
                "top": 181,
                "width": 45,
                "height": 15
            },
            "words": "08月/AUG2014"
        },
        "姓名拼音": {
            "location": {
                "left": 142,
                "top": 18,
                "width": 112,
                "height": 54
            },
            "words": "SC"
        },
        "出生地点": {
            "location": {
                "left": 648,
                "top": 599,
                "width": 349,
                "height": 115
            },
            "words": "江苏/JIANGSU"
        }
    },
    "words_result_num": 10
}