产品详情
API参数 护照OCR 调用地址: http,https://passportocr.api.bdymkt.com/passport_ocr/post 请求方式: POST 支持格式: application/x-www-form-urlencoded 调用工具: 去调试 请求参数(Headers) 请求参数(Query) 请求参数(Body)
- 名称
- 类型
- 是否必须
- 示例值
- 描述
- image
- string
- false
- --
- 图片base64字符串,image、url二选一
- url
- string
- false
- --
- 图片url ,image、url二选一
<dependency>
<groupId>com.baidubce</groupId>
<artifactId>api-explorer-sdk</artifactId>
<version>1.0.0</version>
</dependency>
import com.baidubce.http.ApiExplorerClient;
import com.baidubce.http.AppSigner;
import com.baidubce.http.HttpMethodName;
import com.baidubce.model.ApiExplorerRequest;
import com.baidubce.model.ApiExplorerResponse;
// 护照OCR Java示例代码
public class RequestDemo {
public static void main(String[] args) {
String path = "http://gwgp-eyjrhqs7ku2.n.bdcloudapi.com/passport_ocr/post";
ApiExplorerRequest request = new ApiExplorerRequest(HttpMethodName.POST, path);
request.setCredentials("您的 access key", "您的 secret key");
request.addHeaderParameter("Content-Type", "application/x-www-form-urlencoded");
ApiExplorerClient client = new ApiExplorerClient(new AppSigner());
try {
ApiExplorerResponse response = client.sendRequest(request);
// 返回结果格式为Json字符串
System.out.println(response.getResult());
} catch (Exception e) {
e.printStackTrace();
}
}
}
点击复制代码
正常返回示例 {
"msg": "成功",
"success": true,
"code": 200,
"data": {
"order_no": "694557636569468928",
"result": {
"log_id": 235509498581932799,
"words_result": {
"姓名": {
"words": "张三三",
"location": {
"top": 53,
"left": 124,
"width": 36,
"height": 11
}
},
"护照签发地点": {
"words": "青Q/INGHAI",
"location": {
"top": 126,
"left": 225,
"width": 78,
"height": 11
}
},
"签发机关": {
"words": "山东SHANDONG",
"location": {
"top": 173,
"left": 126,
"width": 83,
"height": 11
}
},
"护照号码": {
"words": "G06091123",
"location": {
"top": 20,
"left": 266,
"width": 75,
"height": 12
}
},
"签发日期": {
"words": "2002**30",
"location": {
"top": 148,
"left": 125,
"width": 75,
"height": 11
}
},
"出生地点": {
"words": "/",
"location": {
"top": 101,
"left": 226,
"width": 124,
"height": 12
}
},
"生日": {
"words": "19751124",
"location": {
"top": 126,
"left": 125,
"width": 75,
"height": 12
}
},
"国家码": {
"words": "CHN",
"location": {
"top": 19,
"left": 169,
"width": 21,
"height": 8
}
},
"有效期至": {
"words": "20071229",
"location": {
"top": 148,
"left": 225,
"width": 77,
"height": 11
}
},
"姓名拼音": {
"words": "ZHANG,SANSAN",
"location": {
"top": 77,
"left": 125,
"width": 76,
"height": 12
}
},
"性别": {
"words": "男/M",
"location": {
"top": 102,
"left": 125,
"width": 26,
"height": 11
}
}
},
"words_result_num": 11
}
}
}
失败返回示例 {
"msg": "入参错误,
"success": false,
"code": 400,
"data": { }
}
错误码定义
