请求参数
1.Action (String) 必选
示例值:RecognizeIdcard
描述:系统规定参数。取值:RecognizeIdcard。
2.Url (String) 必选
示例值:https://img.alicdn.com/tfs/TB1q5IeXAvoK1RjSZFNXXcxMVXa-483-307.jpg
描述:图片链接(长度不超 2048,不支持 base64)。
返回数据
1.RequestId (String) 请求唯一 ID
示例值:86B83935-DD36-195B-B6E4-D07BE370C8B6
2.Data (String) 返回数据
{"data":{"face":{"data":{"name":"方大呆","sex":"女","ethnicity":"汉","birthDate":"2006年10月2日","address":"上海市西藏南路-瞿溪路弘辉名苑","idNumber":"371002200610020000"},"ftype":0,"height":307,"orgHeight":307,"orgWidth":483,"prism_keyValueInfo":[{"key":"name","keyProb":100,"value":"方大呆","valuePos":[{"x":142,"y":40},{"x":142,"y":60},{"x":82,"y":60},{"x":82,"y":40}],"valueProb":100},{"key":"sex","keyProb":100,"value":"女","valuePos":[{"x":104,"y":77},{"x":104,"y":96},{"x":85,"y":96},{"x":85,"y":77}],"valueProb":100},{"key":"ethnicity","keyProb":100,"value":"汉","valuePos":[{"x":212,"y":75},{"x":212,"y":95},{"x":192,"y":95},{"x":192,"y":75}],"valueProb":100},{"key":"birthDate","keyProb":100,"value":"2006年10月2日","valuePos":[{"x":214,"y":116},{"x":214,"y":131},{"x":76,"y":131},{"x":76,"y":116}],"valueProb":100},{"key":"address","keyProb":100,"value":"上海市西藏南路-瞿溪路弘辉名苑","valuePos":[{"x":278,"y":154},{"x":278,"y":196},{"x":73,"y":196},{"x":73,"y":154}],"valueProb":100},{"key":"idNumber","keyProb":100,"value":"371002200610020000","valuePos":[{"x":379,"y":256},{"x":379,"y":274},{"x":162,"y":274},{"x":162,"y":256}],"valueProb":100}],"sliceRect":{"x0":0,"y0":0,"x1":481,"y1":0,"x2":481,"y2":307,"x3":0,"y3":307},"width":483}},"height":307,"orgHeight":307,"orgWidth":483,"width":483}
3.Code (String) 状态码
示例值:200/400/404/500/503
4.Message (String) 详细信息
示例值:message
SDK依赖
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>ocr_api20210707</artifactId>
<version>1.1.3</version>
</dependency>
JAVA示例代码
// This file is auto-generated, don't edit it. Thanks.
// This file is auto-generated, don't edit it. Thanks.
package com.aliyun.sample;
import com.aliyun.tea.*;
import com.aliyun.ocr_api20210707.*;
import com.aliyun.ocr_api20210707.models.*;
import com.aliyun.teaopenapi.*;
import com.aliyun.teaopenapi.models.*;
public class Sample {
/**
* 使用AK&SK初始化账号Client
* @param accessKeyId
* @param accessKeySecret
* @return Client
* @throws Exception
*/
public static com.aliyun.ocr_api20210707.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
Config config = new Config()
// 您的AccessKey ID
.setAccessKeyId(accessKeyId)
// 您的AccessKey Secret
.setAccessKeySecret(accessKeySecret);
// 访问的域名
config.endpoint = "ocr-api.cn-hangzhou.aliyuncs.com";
return new com.aliyun.ocr_api20210707.Client(config);
}
public static void main(String[] args_) throws Exception {
java.util.List<String> args = java.util.Arrays.asList(args_);
com.aliyun.ocr_api20210707.Client client = Sample.createClient("accessKeyId", "accessKeySecret");
RecognizeIdcardRequest recognizeIdcardRequest = new RecognizeIdcardRequest()
.setUrl("https://img.alicdn.com/tfs/TB1q5IeXAvoK1RjSZFNXXcxMVXa-483-307.jpg");
// 复制代码运行请自行打印 API 的返回值
client.recognizeIdcard(recognizeIdcardRequest);
}
}