617
手机大全
营业执照识别__API介绍_文字识别_人工智能图像类-阿里云
本页面主要介绍服务对应的接口和返回结果中的关键字段的含义,请在阅读本页面之前,了解请求数据格式介绍,了解输入输出的通用数据格式。 此外,在本页最后,附上了营业执照识别服务调用的程序示例,以供参考。(注:目前营业执照识别服务只适用于识别最新的竖版“三证合一”营业执照)
请求接口
云市场接口
- 请求方法: POST
- 请求url: 在云市场搜索
印刷文字识别-营业执照识别
,在API接口
中找到调用地址
数加接口
- 请求方法: POST
- 请求url: 打开管理控制台,接口名称选择
ocr_business
,查看请求地址
请求参数
参数名称 | 参数类型 | 描述 | 默认值 |
---|---|---|---|
image | string | dataType为50, dataValue是base64编码后的图像数据 | 空字符串 |
POST请求body 示例如下:
{
"inputs": [
{
"image": {
"dataType": 50, #50表示image的数据类型为字符串
"dataValue": "base64_image_string" #图片以base64编码的string
}
}]
}
返回结果格式
返回结果格式如下:
{
"outputs": [
{
"outputLabel": "ocr_business",
"outputMulti": {},
"outputValue": {
"dataType": 50,
"dataValue": "{
"config_str": "", #配置字符串信息
"reg_num": "123456765432101", #注册号/统一社会信用代码
"name": "杭州西溪科技有限公司", #公司名称
"person":"张三", #法定代表人
"valid_period" : "20340801", #营业期限结束日期,输出格式为"年月日(YYYYMMDD)"
#证件中的"长期"输出为"长期",若证件没有营业期限,则默认其为"长期"
"address" : "浙江省杭州市文一西路969号", #公司地址
"capital" : "500万元", #注册资本
"success": true #识别成功与否 true/false
"request_id":"84701974fb983158_20160526100112", #请求对应的唯一表示
}"
}
}]
}
每一个请求返回的结果都是一个json字符串,由dataValue关键词可以索引到,主要有如下字段:
- config_str: 表示发送请求时候的配置字符串,目前该字段没有用,返回为空, 类型为字符串
- reg_num: 注册号/统一社会信用代码, 类型为字符串
- name: 公司名称, 类型为字符串
- person: 法定代表人, 类型为字符串
- valid_period: 营业期限结束日期—输出格式为”年月日(YYYYMMDD)”,证件中的”长期”输出为”长期”,若证件没有营业期限,则默认其为”长期”, 类型为字符串
- address: 公司地址, 类型为字符串
- capital: 注册资本, 类型为字符串
- request_id: 请求对应的唯一表示, 用户可以保存该字段用以进行问题追溯,类型为字符串
- success: 识别流程是否出现异常, false表示识别失败,true表示识别成功, 类型为布尔型
程序示例
云市场
在云市场搜索印刷文字识别-营业执照识别
,在API接口
中找到请求示例
数加平台
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import sun.misc.BASE64Encoder;
import org.json.JSONObject;
import org.json.JSONArray;
import org.json.JSONException;
@SuppressWarnings("restriction")
public class BusinessLicense {
/*
* 获取参数的json对象
*/
public static JSONObject getParam(int type, JSONObject dataValue) {
JSONObject obj = new JSONObject();
try {
obj.put("dataType", type);
obj.put("dataValue", dataValue);
} catch (JSONException e) {
e.printStackTrace();
}
return obj;
}
/*
* 获取参数的json对象
*/
public static JSONObject getParam(int type, String dataValue) {
JSONObject obj = new JSONObject();
try {
obj.put("dataType", type);
obj.put("dataValue", dataValue);
} catch (JSONException e) {
e.printStackTrace();
}
return obj;
}
public static void main(String[] args) {
String img_file = "business_license.jpg";
String service_url = "your-service-url";
String ak_id = "your access key id";
String ak_secret = "your access key secret";
// 对图像进行base64编码
String img_base64 = "";
try {
File file = new File(img_file);
byte[] content = new byte[(int) file.length()];
FileInputStream finputstream = new FileInputStream(file);
finputstream.read(content);
finputstream.close();
img_base64 = (new BASE64Encoder()).encode(content);
} catch (IOException e) {
e.printStackTrace();
return;
}
// 拼装请求body的json字符串
JSONObject request_obj = new JSONObject();
try {
JSONObject obj = new JSONObject();
JSONArray input_array = new JSONArray();
obj.put("image", getParam(50, img_base64));
input_array.put(obj);
request_obj.put("inputs", input_array);
} catch (JSONException e) {
e.printStackTrace();
}
String body = request_obj.toString();
//Sender代码参考 https://help.aliyun.com/document_detail/shujia/OCR/ocr-api/sender.html
String result = Sender.sendPost(service_url, body, ak_id, ak_secret);
System.out.println(result);
// 解析请求结果
try {
JSONObject result_obj = new JSONObject(result);
JSONArray output_array = result_obj.getJSONArray("outputs");
String output = output_array.getJSONObject(0).getJSONObject("outputValue").getString("dataValue"); // 取出结果json字符串
JSONObject out = new JSONObject(output);
if (out.getBoolean("success")) {
String reg_num = out.getString("reg_num"); // 获取注册号/统一社会信用代码
String name = out.getString("name"); // 获取公司名
String person = out.getString("person"); // 获取公司法人
String valid_period = out.getString("valid_period"); // 获取公司有效期
String address = out.getString("address"); // 获取地址
String capital = out.getString("capital"); // 获取注册资本
String request_id = out.getString("request_id"); // 获取request_id
System.out.printf("reg_num: %s n name : %s n person : %sn valid_periode: %s n address : %sn capital : %sn",reg_num,name,person,valid_period,address,capital);
}
else {
System.out.println("predict error");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
最后更新:2016-11-23 16:04:16
上一篇:
行驶证识别__API介绍_文字识别_人工智能图像类-阿里云
下一篇:
门店识别__API介绍_文字识别_人工智能图像类-阿里云
编辑用户__用户管理_DMS for MongoDB_用户指南(NoSQL)_数据管理-阿里云
UploadPart__关于MultipartUpload的操作_API 参考_对象存储 OSS-阿里云
日志清洗中关于时间字段date设置的常见问题与解决方法__最佳实践_业务实时监控服务 ARMS-阿里云
InstanceAttributesType__数据类型_API 参考_云服务器 ECS-阿里云
SetLoadBalancerName__LoadBalancer相关API_API 参考_负载均衡-阿里云
使用第三方数据卷__数据卷指南_用户指南_容器服务-阿里云
画像分析__产品与架构介绍_-阿里云
2016年10月12日安全管家控制台发布__产品升级更新_安全管家服务-阿里云
查询模板信息__模板相关接口_API 文档_资源编排-阿里云
权限和安全__产品概念_产品简介_数据集成-阿里云
相关内容
常见错误说明__附录_大数据计算服务-阿里云
发送短信接口__API使用手册_短信服务-阿里云
接口文档__Android_安全组件教程_移动安全-阿里云
运营商错误码(联通)__常见问题_短信服务-阿里云
设置短信模板__使用手册_短信服务-阿里云
OSS 权限问题及排查__常见错误及排除_最佳实践_对象存储 OSS-阿里云
消息通知__操作指南_批量计算-阿里云
设备端快速接入(MQTT)__快速开始_阿里云物联网套件-阿里云
查询API调用流量数据__API管理相关接口_API_API 网关-阿里云
使用STS访问__JavaScript-SDK_SDK 参考_对象存储 OSS-阿里云