# 身份证识别

接口说明:支持识别身份证正反面信息,包括姓名、性别、出生、住址、民族、公民身份号码、失效日期、签发机关、签发日期等。

请求方式: POST(HTTPS
请求地址: https://openapi.waiqin365.com/api/ocr/v1/idcard/{ openid }/{ timestamp }/{ digest }/{ msg_id } 在线调试
请求示例:

{
"transfer_id": 3453434212,
 "image": "/9j/4AA",
 "url": "https://image.com/example1.jpg", 
 "ID_card_side": "front",
 "quality_detection": "false",
 "risk_detection": "false",
 "card_cropping": "false",
 "photo_detection": "false"
}
说明: 本示例仅供参考,具体以参数说明为准。

参数说明:

参数 类型 必填 说明
transfer_id uint64 业务调用id,不允许重复由调用方给出,不能超过32位,提交图片后可根据该id查询识明别结果
image STRING
和url二选一
图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过8M,最短边至少15px,最长边最大8192px,支持jpg/jpeg/png/bmp格式,优先级:image > url ,当image字段存在时,url字段失效
url STRING 和image二选一 图片完整url,url长度不超过1024字节,url对应的图片base64编码后大小不超过8M,最短边至少15px,最长边最大8192px,支持jpg/jpeg/png/bmp格式 优先级:image > url ,当image字段存在时,url字段失效,请注意关闭URL防盗链
ID_card_side STRING 自动检测身份证正反面,如果传参指定方向与图片相反,支持正常识别,返回参数photo_status字段为"reversed_side”。 front:身份证头像面; back:身份证国徽面
quality_detection STRING 是否开启身份证质量检测功能(边框/四角不完整、头像或关键字段被遮挡/马赛克),默认false。 true:开启,返回参数card_quality; false:不开启
risk_detection STRING 是否开启身份证风险检测功能(复印件、临时身份证、翻拍、修改过的身份证),默认false。 true:开启,返回参数risk_type; false:不开启
card_cropping STRING 是否对身份证进行检测后裁剪,默认false。 true:检测身份证并返回身份证裁剪图的 base64 编码及位置信息; false:不检测
photo_detection STRING 是否检测头像内容,默认false。 true:检测头像并返回头像切图的 base64 编码及位置信息; false:不检测

响应示例:

{
    "return_code": "0", 
    "return_msg": "响应信息",
    "msg_id": "{ msg_id }",
    "response_data": "<<DATA>>"
}

数据DATA示例(身份证头像面):


{
    "transfer_id": "3453434212",
    "recognition_id": 547777451,
    "direction": 0,
    "photo_status": "normal",
    "ID_photo": "/9j/4AAQSkZJRgABA......",
    "ID_number_type": 3,
    "photo_location": {
        "width": 1189,
        "top": 638,
        "left": 2248,
        "height": 1483
    },
    "card": "/9j/4AAQSkZJRgABA......",
    "card_location": {
        "top": 328,
        "left": 275,
        "width": 1329,
        "height": 571
    },
    "recognition_results": {
        "住址": {
            "location": {
                "left": 267,
                "top": 453,
                "width": 459,
                "height": 99
            },
            "words": "江苏省南京市建邺区嘉陵江东街18号"
        },
        "公民身份号码": {
            "location": {
                "left": 443,
                "top": 681,
                "width": 589,
                "height": 45
            },
            "words": "330881198904173914"
        },
        "出生": {
            "location": {
                "left": 270,
                "top": 355,
                "width": 357,
                "height": 45
            },
            "words": "19890417"
        },
        "姓名": {
            "location": {
                "left": 267,
                "top": 176,
                "width": 152,
                "height": 50
            },
            "words": "张三"
        },
        "性别": {
            "location": {
                "left": 269,
                "top": 262,
                "width": 33,
                "height": 52
            },
            "words": "男"
        },
        "民族": {
            "location": {
                "left": 492,
                "top": 279,
                "width": 30,
                "height": 37
            },
            "words": "汉"
        }
    },
    "result_num": 6
}

数据DATA示例(身份证国徽面):


{
    "transfer_id": "3453434212",
    "recognition_id": "1559208562721579328",
    "photo_status": "normal",
    "recognition_results": {
        "失效日期": {
            "words": "20390711",
            "location": {
                "top": 445,
                "left": 523,
                "width": 153,
                "height": 38
            }
        },
        "签发机关": {
            "words": "陆丰市公安局",
            "location": {
                "top": 377,
                "left": 339,
                "width": 195,
                "height": 38
            }
        },
        "签发日期": {
            "words": "20190606",
            "location": {
                "top": 445,
                "left": 343,
                "width": 152,
                "height": 38
            }
        }
    },
    "result_num": 3
}

参数说明:

参数 类型 说明
transfer_id uint64 业务调用id,不允许重复由调用方给出,不能超过32位,提交图片后可根据该id查询识明别结果
recognition_id uint64 算法识别id,用于问题定位
recognition_results object 定位和识别结果数组
result_num uint32 识别结果数
direction int32 图像方向。-1:未定义; 0:正向; 1:逆时针90度; 2:逆时针180度; 3:逆时针270度
photo_status string normal-识别正常; reversed_side-身份证正反面颠倒; no_IDcard-上传的图片中不包含身份证; blurred-身份证模糊; other_type_card-其他类型证照; over_exposure-身份证关键字段反光或过曝; over_dark-身份证欠曝(亮度过低); unknown-未知状态
risk_type string 当输入参数 risk_detection = true 时,则返回该字段识别身份证类型:normal-正常身份证; copy-复印件; temporary-临时身份证; screen-翻拍; unknown-其他未知情况
edit_tool string 当输入参数 risk_detection = true 时,且检测到身份证被编辑过,则返回编辑软件的名称,如:Adobe Photoshop CS6,如果没有二者都无,则返回值无此参数
card_quality string 当输入参数 quality_detection = true 时,则返回身份证质量类型:IsClear - 是否清晰; IsComplete - 边框/四角是否完整; IsNoCover - 头像、关键字段是否无遮挡/马赛克。 及对应的概率:IsClear_propobility、IsComplete_propobility、IsNoCover_propobility,值在0-1之间,值越大表示图像质量越好。 默认阈值:当 IsClear_propobility 超过0.5时,IsClear返回1,低于0.5,则返回0。IsComplete_propobility 、IsNoCover_propobility同上
ID_photo string 当请求参数 photo_detection = true时返回,头像切图的 base64 编码(无编码头,需自行处理)
photo_location object 当请求参数 photo_detection = true时返回,头像的位置信息(坐标0点为左上角)
card_cropping string 当请求参数 card_cropping = true时返回,身份证裁剪切图的位置信息(坐标0点为左上角)
ID_number_type int 用于校验身份证号码、性别、出生是否一致,输出结果及其对应关系如下:-1: 身份证正面所有字段全为空; 0: 身份证证号不合法,此情况下不返回身份证证号; 1: 身份证证号和性别、出生信息一致; 2: 身份证证号和性别、出生信息都不一致; 3: 身份证证号和出生信息不一致; 4: 身份证证号和性别信息不一致
location object 位置数组(坐标0点为左上角)
top uint32 表示定位位置的长方形左上顶点的垂直坐标
left uint32 表示定位位置的长方形左上顶点的水平坐标
height uint32 表示定位位置的长方形的高度
width uint32 表示定位位置的长方形的宽度
words string 识别结果字符串