本文介绍了调用图片同步检测接口识别结构化卡证OCR的方法。结构化卡证OCR能够识别证件类图像中的文字并以结构化的方式返回文字内容。使用该场景的前提是您知道要检测的图像包含哪种类型的证件。
结构化卡证OCR目前支持识别以下卡证类型:营业执照、身份证(人像面和国徽面)、护照、银行卡、驾驶证(正反面)、行驶证(正反面)、车牌、车辆VIN码、户口簿户主页、户口簿常住人口页。
使用说明
业务接口:/green/image/scan,表示图片同步检测。
您可以调用该接口创建图片同步检测任务。关于如何构造HTTP请求,请参见请求结构;您也可以直接选用已构造好的HTTP请求,更多信息,请参见SDK概览。
- 计费信息:
该接口为收费接口。关于计费方式,请参见内容安全产品定价。
- 检测超时:
同步检测允许的最长检测时间是6秒,如果检测在该时间限制内没有完成,系统会强制返回超时错误码。如果您对实时性要求不高,可以选择异步检测,其他情况下请选择同步检测,同步检测接口的调用相对简单些。对于同步检测接口的调用,建议您将超时时间设置为6秒。
- 返回结果:
同步检测请求一般会在一秒内返回结果,但在一些特殊场景(例如系统繁忙导致堆积严重、图片较大、含有OCR内容较多等),耗时可能会增加。OCR的处理速度依赖图片中文字的字数,字数越多处理时间越长。如果您检测的场景中文字较多,推荐您使用图片异步检测接口。
- 图片要求:
- 图片链接支持以下协议:HTTP和HTTPS。
- 图片支持以下格式:PNG、JPG、JPEG、BMP、GIF、WEBP。
- 图片大小限制为20 MB以内(适用于同步和异步调用),高度或者宽度不能超过30,000像素(px),且图像总像素不超过2.5亿(px)。
- 图片下载时间限制为3秒内,如果下载时间超过3秒,返回下载超时。
- 图片像素建议不低于256*256(px),像素过低可能会影响识别效果。
- 图片检测接口的响应时间依赖图片的下载时间。请保证被检测图片所在的存储服务稳定可靠,建议您使用阿里云OSS存储或者CDN缓存等。
QPS限制
本接口的单用户QPS限制为10次/秒。超过限制,API调用会被限流,这可能会影响您的业务,请合理调用。
请求参数
名称 | 类型 | 是否必须 | 示例值 | 描述 |
---|---|---|---|---|
bizType | String | 否 | default | 该字段用于标识您的业务场景。您可以通过内容安全控制台创建业务场景(具体操作,请参见自定义机审标准)。 |
scenes | StringArray | 是 | ["ocr"] | 指定检测场景,取值:ocr。 |
tasks | JSONArray | 是 | 指定检测对象,JSON数组中的每个元素是一个检测任务结构体。最多支持100个元素,即每次提交100条内容进行检测,支持100个元素的前提是需要将并发任务调整到100个以上。关于每个元素的具体结构描述,请参见task。 | |
extras | JSONObject | 是 | {"card":"bank-card"} | 指定要识别的证件类型,格式为{"card":"${CardType}"} 。CardType 表示证件类型,取值:
|
名称 | 类型 | 是否必须 | 示例值 | 描述 |
---|---|---|---|---|
dataId | String | 否 | test_data_xxxx | 数据ID。需要保证在一次请求中所有的ID不重复。 |
url | String | 是 | https://aliyundoc.com/test_image_xxxx.png | 检测对象的URL。
|
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
code | Integer | 200 | 错误码,和HTTP状态码一致。 更多信息,请参见公共错误码。 |
msg | String | OK | 请求信息的响应消息。 |
dataId | String | test_data_xxxx | 检测对象对应的数据ID。 说明 如果在检测请求参数中传入了dataId,则此处返回对应的dataId。 |
taskId | String | img5A@k7a@B4q@6K@d9nfKgOs-1s**** | 检测任务的ID。 |
url | String | https://aliyundoc.com/test_image_xxxx.png | 检测对象的URL。
|
extras | JSONObject | {"card":"bank-card"} | 额外调用参数,对应检测请求参数中的extras。 说明 该参数可能会被调整,目前请勿依赖该参数的返回值。 |
results | Array | 返回结果。调用成功时(code=200),返回结果中包含一个或多个元素。每个元素是个结构体,具体结构描述请参见result。 |
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
scene | String | ocr | 检测场景。取值:ocr。 |
label | String | ocr | 检测结果的分类。取值:
|
suggestion | String | review | 建议用户执行的操作。取值:
|
rate | Float | 99.91 | 在OCR图文识别场景中,可以不用关注该返回值。 |
businessLicenseInfo | Object | 识别出来的营业执照信息。关于具体结构描述,请参见businessLicenseInfo。 说明 只有在请求参数extras中指定了 {"card":"business-license"} 才会返回该结果。 | |
idCardInfo | Object | 识别出来的身份证信息。关于具体结构描述,请参见idCardInfo。 说明 只有在请求参数extras中指定了 {"card":"id-card-front"} 或{"card":"id-card-back"} 才会返回该结果。 | |
passportInfo | Object | 识别出来的护照信息。关于具体结构描述,请参见passportInfo。 说明 只有在请求参数extras中指定了 {"card":"passport"} 才会返回该结果。 | |
bankCardInfo | Object | 识别出来的银行卡信息。关于具体结构描述,请参见bankCardInfo。 说明 只有在请求参数extras中指定了 {"card":"bank-card"} 才会返回该结果。 | |
driverLicenseFrontInfo | Object | 识别出来的驾驶证正面信息。关于具体结构描述,请参见driverLicenseFrontInfo。 说明 只有在请求参数extras中指定了 {"card":"driver-license-front"} 才会返回该结果。 | |
driverLicenseBackInfo | Object | 识别出来的驾驶证反面信息。关于具体结构描述,请参见driverLicenseBackInfo。 说明 只有在请求参数extras中指定 {"card":"driver-license-back"} 才会返回该结果。 | |
vehicleLicenseFrontInfo | Object | 识别出来的行驶证正面信息。关于具体结构描述,请参见vehicleLicenseFrontInfo。 说明 只有在请求参数extras中指定了 {"card":"vehicle-license-front"} 才会返回该结果。 | |
vehicleLicenseBackInfo | Object | 识别出来的行驶证反面信息。关于具体结构描述,请参见vehicleLicenseBackInfo。 说明 只有在请求参数extras中指定了 {"card":"vehicle-license-back"} 才会返回该结果。 | |
vehicleNumInfo | Object | 识别出来的车牌信息。关于具体结构描述,请参见vehicleNumInfo。 说明 只有在请求参数extras中指定了 {"card":"vehicle-num"} 才会返回该结果。 | |
vehicleVinInfo | Object | 识别出来的车辆VIN码信息。关于具体结构描述,请参见vehicleVinInfo。 说明 只有在请求参数extras中指定了 {"card":"vehicle-vin"} 才会返回该结果。 | |
ocrCardInfo | Object | 识别出来的其他卡证的OCR信息。关于具体结构描述,请参见ocrCardInfo。 说明 只有在请求参数extras中指定了以下内容,才会返回相应结果:
|
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
companyName | String | xxx技术有限公司 | 公司名称。 |
companyType | String | 有限责任公司 | 公司类型。 |
legalPerson | String | 张XX | 企业法人。 |
establishDate | String | 2000年01月01日 | 注册日期。 |
vaildPeriod | String | 2030年01月01日 | 营业终止日期。 |
address | String | xxx | 地址。 |
capital | String | xxx | 注册资本。 |
business | String | 计算机软硬件开发 | 经营范围。 |
copy | Boolean | false | 是否是副本。取值:
|
copyId | String | xxx | 副本号。 |
certSN | String | xxx | 证照编号。 |
creditCode | String | xxx | 统一社会信用代码。 |
organizationCode | String | xxx | 组织机构代码。 |
taxCode | String | xxx | 税务登记号。 |
companySN | String | xxx | 公司编号。 |
composition | String | xxx | 组成形式。 |
paidInCapital | String | xxx | 实收资本。 |
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
name | String | 张XX | 姓名。 |
nationality | String | 汉 | 民族。 |
number | String | 5****************9 | 身份证号。 |
birth | String | 2022-01-01 | 出生日期。格式:YYYY-MM-DD。 |
address | String | xxx | 住址。 |
authority | String | xxx | 签发机构。 |
startDate | String | 2022-06-30 | 有效期开始日期。格式:YYYY-MM-DD。 |
endDate | String | 2032-06-30 | 有效期结束日期。格式:YYYY-MM-DD。 说明 该字段可能返回以下值:长期。 |
angle | Float | 96.2 | 证件顺时针旋转的角度。 |
copy | Boolean | false | 身份证照片是否是复印件。取值:
说明 默认不返回该字段。如果需要返回,请联系商务经理。 |
remake | Boolean | false | 身份证照片是否是翻拍。取值:
说明 默认不返回该字段。如果需要返回,请联系商务经理。 |
type | String | front | 证件类型。取值:
|
numberValid | Boolean | true | 证件号码是否合法。取值:
|
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
authority | String | xxx | 发证机关。 |
birthDate | String | 2020年01月01日 | 出生日期。 |
birthDay | String | 01月01日 | 生日。 |
birthPlace | String | xxx | 出生地。 |
birthPlaceRaw | String | xxx | 出生地(字母)。 |
expireDate | String | 2030年01月01日 | 到期时间。 |
expireDay | String | 01月01日 | 到期日。 |
issueDate | String | 2022年01月01日 | 发证日期。 |
issuePlace | String | xxx | 发证地址。 |
issuePlaceRaw | String | xxx | 发证地址(字母)。 |
name | String | 王xx | 姓名。 |
cnName | String | xxx | 中文名称。 |
cnNameRaw | String | xxx | 中文名称(字母)。 |
personId | String | 5****************9 | 身份ID。 |
srcCountry | String | 中国 | 国籍。 |
type | String | xxx | 类型。 |
line0 | String | xxx | 底部第一行。 |
line1 | String | xxx | 底部第二行。 |
surname | String | 王 | 姓。 |
givenName | String | xx | 名。 |
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
bankCardNum | String | 622576888888**** | 银行卡号。 |
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
name | String | 张XX | 姓名。 |
number | String | 123xxxxxxxxxxxxxxxx | 驾驶证号。 |
address | String | xx省xx市xx区xx街道xx号 | 住址。 |
vehicleType | String | C1 | 准驾车型。 |
validStartDate | String | 2022-01-01 | 有效期开始时间,格式:YYYY-MM-DD。 |
validEndDate | String | 2028-01-01 | 有效期截止时间,格式:YYYY-MM-DD。 |
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
archiveNum | String | xxx | 档案编号。 |
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
plateNum | String | 陕xxxxxx | 车牌号。 |
vehicleType | String | 小型普通客车 | 车辆类型。 |
owner | String | 张XX | 所有者名字。 |
useCharacter | String | 非营运 | 车辆使用性质。 |
address | String | xx省xx市xx区xx街道xx号 | 住址。 |
model | String | 东风日产牌ABCxxxxx | 车辆品牌。 |
vin | String | ABCxxxxxxxx1234 | 车辆识别代号。 |
engineNum | String | 12xxxxA | 发动机号码。 |
registerDate | String | 2022-01-01 | 注册日期,格式:YYYY-MM-DD。 |
issueDate | String | 2022-01-01 | 发证日期,格式:YYYY-MM-DD。 |
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
plateNum | String | 陕Axxxxx | 车牌号。 |
fileNum | String | 12345678**** | 档案编号。 |
appprovedPassengerCapacity | Integer | xxx | 核定载人数。 |
grossMass | String | xxx | 总质量。 |
unladenMass | String | xxx | 整备质量。 |
approvedLoad | String | xxx | 核定载质量。 |
tractionMass | String | xxx | 准牵引总质量。 |
inspectionRecord | String | 1 | 检验记录。 |
overallDimension | Object | 车辆轮廓尺寸信息。关于具体结构描述,请参见下表overallDimension。 |
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
length | Integer | 4000 | 车辆长度,单位:毫米。 |
width | Integer | 2000 | 车辆宽度,单位:毫米。 |
height | Integer | 1000 | 车辆高度,单位:毫米。 |
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
num | String | 陕Axxxxx | 车牌号。 |
rate | Float | 99.01 | 车牌号的置信度,取值范围:0~100。值越高表示识别出的车牌号越可信。 |
vehicleType | String | 小型汽车 | 车牌类型,取值:
|
vehicleTypeRate | Float | 99.01 | 车牌类型的置信度,取值范围:0~100。值越高表示识别出的车牌类型越可信。 |
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
vin | String | ABCxxxxxxxx1234 | VIN号。 |
ocrCardInfo
表 14. 户口簿户主页信息 名称 类型 示例值 描述 locationNumber String xxx 地段号。 issueDate String 2022年01月01日 签发日期。 householdType String 居民户口 户别。 houseHolder String 张XX 户主姓名。 address String 广西xxx 住址。 community String xxx 户主社区。 householdNumber String xxx 户号。 undertaker String xxx 承办人签章。 type String household-head 卡证的类型,取值固定为household-head,表示户口簿户主页。 表 15. 户口簿常住人口页信息 名称 类型 示例值 描述 occupation String 粮农 职业。 migrationDate1 String 2022年01月01日 何时由何地迁来本址。 idNumber String 5****************9 身份证编号。 education String 初中 文化程度。 birthPlace String xxx 出生地。 servicePremises String xxx 服务处所。 householdNumber String xxx 户号。 hometown String 四川成都 籍贯。 name String 张XX 姓名。 formerName String xxx 曾用名。 maritalStatus String 未婚 婚姻状况。 nation String 汉族 民族。 otherAddress String xxx 本市其他住址。 birthday String 2020年01月01日 出生日期。 militaryService String xxx 兵役状况。 relationTo String 户主 与户主关系。 religion String xxx 宗教信仰。 bloodType String B 血型。 registerDate String 2023年02月06日 登记日期。 height String xxx 身高。 migrationDate2 String xxx县xxx乡xxx村xx迁来 何时何地迁来本市。 undertaker String xxx 承办人签章。 type String household-resident 卡证的类型,取值固定为household-resident,表示户口簿常住人口页。
示例
请求示例
http(s)://[Endpoint]/green/image/scan
&<公共请求参数>
{
"scenes": [
"ocr"
],
"extras": {
"card": "bank-card"
},
"tasks": [
{
"dataId": "test_data_xxxx",
"url": "https://aliyundoc.com/test_image_xxxx.png"
}
]
}
正常返回示例
- 银行卡信息
{ "code": 200, "data": [ { "code": 200, "dataId": "test_data_xxxx", "extras": { }, "msg": "OK", "results": [ { "bankCardInfo": { "bankCardNum": "622576888888****" }, "label": "ocr", "rate": 99.91, "scene": "ocr", "suggestion": "review" } ], "taskId": "img5A@k7a@B4q@6K@d9nfKgOs-1sWeLu", "url": "https://aliyundoc.com/test_image_xxxx.png" } ], "msg": "success", "requestId": "1a2faf93-dd41-47d8-95ad-bdf6226540e4" }
- 户口簿户主页信息
{ "msg": "OK", "code": 200, "data": [ { "msg": "OK", "code": 200, "dataId": "test_data_xxxx", "extras": { }, "results": [ { "rate": 99.91, "suggestion": "review", "label": "ocr", "ocrCardInfo": { "houseHolder": "居民户口", "address": "广西xxxxxx", "type": "household-head", "locationNumber": "", "issueDate": "广西xxx", "community": "", "householdNumber": "", "householdType": "xxx", "undertaker": "汉" }, "scene": "ocr" } ], "taskId": "img5EZCRaOpH8G4QFbNFLMf9p-1sWeKV", "url": "https://aliyundoc.com/test_image_xxxx.png" } ], "requestId": "6162F805-A6B9-446C-9B7C-5F26CFB03D89" }
- 户口簿常住人口页信息
{ "msg": "OK", "code": 200, "data": [ { "msg": "OK", "code": 200, "dataId": "test_data_xxxx", "extras": { }, "results": [ { "rate": 99.91, "suggestion": "review", "label": "ocr", "ocrCardInfo": { "birthday": "2020年01月01日", "hometown": "四孔成都", "occupation": "粮农", "education": "初中", "nation": "汉族", "militaryService": "", "relationTo": "户主", "type": "household-resident", "idNumber": "5****************9", "bloodType": "", "householdNumber": "", "religion": "", "undertaker": "xxx", "birthPlace": "xx省xx", "migrationDate1": "xxx县xxx乡xxx村xx迁来", "migrationDate2": "", "otherAddress": "", "servicePremises": "", "name": "xx", "formerName": "", "maritalStatus": "", "registerDate": "2023年02月06日", "height": "" }, "scene": "ocr" } ], "taskId": "img5A@k7a@B4q@6K@d9nfKgOs-1sWeLu", "url": "https://aliyundoc.com/test_image_xxxx.png" } ], "requestId": "AE11413F-1AE4-4147-8807-2F7673D67D72" }