534
手机大全
行驶证识别__API介绍_文字识别_人工智能图像类-阿里云
本页面主要介绍服务对应的接口和返回结果中的关键字段的含义,请在阅读本页面之前,了解请求数据格式介绍,了解输入输出的通用数据格式。 此外,在本页最后,附上了驾驶证识别服务调用的程序示例,以供参考。
请求接口
云市场接口
- 请求方法: POST
- 请求url: 在云市场搜索
印刷文字识别-行驶证识别
,在API接口
中找到调用地址
数加接口
- 请求方法: POST
- 请求url: 打开管理控制台,接口名称选择
ocr_vehicle_license
,查看请求地址
请求参数
参数名称 | 参数类型 | 描述 | 默认值 |
---|---|---|---|
image | string | dataType为50, dataValue是base64编码后的图像数据 | 空字符串 |
POST请求body 示例如下:
{
"inputs": [
{
"image": {
"dataType": 50, #50表示image的数据类型为字符串
"dataValue": "base64_image_string" #图片以base64编码的string
}
}]
}
返回结果格式
返回结果格式如下:
{
"outputs": [
{
"outputLabel": "ocr_vehicle_license",
"outputMulti": {},
"outputValue": {
"dataType": 50,
"dataValue": "{
"config_str": "", #配置字符串信息
"owner": "张三", #所有人名称
"plate_num": "沪A0M084", #车牌号码
"model":"奥德赛HG7420", #品牌型号
"vin" : "LSVFF66R8C2116280", #车辆识别代号
"engine_num" : "416098", #发动机号码
"register_date": "20121127", #注册日期
"request_id": "84701974fb983158_20160526100112", #请求对应的唯一表示
"success": true #识别成功与否 true/false
}"
}
}]
}
每一个请求返回的结果都是一个json字符串,由dataValue关键词可以索引到,主要有如下字段:
- config_str: 表示发送请求时候的配置字符串,为json字符串格式,表示输入时候的配置参数, 类型为字符串
- owner: 所有人名称, 类型为字符串
- plate_num: 车牌号码, 类型为字符串
- model: 品牌型号, 类型为字符串
- vin: 车辆识别代号, 类型为字符串
- engine_num: 发动机号码, 类型为字符串
- register_date: 注册日期, 类型为字符串
- 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 vehicle {
/*
* 获取参数的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 = "vehicle.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 owner = out.getString("owner"); // 获取所有人
String plate_num = out.getString("plate_num"); // 获取车牌号码
String model_type = out.getString("model"); // 获取品牌型号
String vin = out.getString("vin"); // 获取车辆识别代码
String engine_num = out.getString("engine_num"); // 获取发动机号码
String register_date = out.getString("register_date"); // 获取注册日期
String request_id = out.getString("request_id"); // 获取request_id
System.out.printf(" owner : %s n plate_num : %sn model_type : %sn vin : %sn engine_num : %sn register_date : %sn request_id : %sn", owner, plate_num, model_type,
vin, engine_num, register_date, request_id);
} else {
System.out.println("predict error");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
最后更新:2016-11-23 16:04:15
上一篇:
驾驶证识别__API介绍_文字识别_人工智能图像类-阿里云
下一篇:
营业执照识别__API介绍_文字识别_人工智能图像类-阿里云
服务连接__基本概念_基本介绍_大数据计算服务-阿里云
实例状态表__附录_API 参考_云服务器 ECS-阿里云
DML语句__SQL_大数据计算服务-阿里云
消息轨迹查询__消息管理相关接口_Open API_消息队列 MQ-阿里云
接收删除消息__队列消息操作_快速入门_消息服务-阿里云
1.2 挂载数据盘__ECS快速开始_云服务器ECS 体验_体验馆-阿里云
GetRole__角色管理接口_RAM API文档_访问控制-阿里云
depends__服务编排文档_用户指南_容器服务-阿里云
修改API分组__API分组相关接口_API_API 网关-阿里云
堡垒机__使用金融云产品_金融云-阿里云
相关内容
常见错误说明__附录_大数据计算服务-阿里云
发送短信接口__API使用手册_短信服务-阿里云
接口文档__Android_安全组件教程_移动安全-阿里云
运营商错误码(联通)__常见问题_短信服务-阿里云
设置短信模板__使用手册_短信服务-阿里云
OSS 权限问题及排查__常见错误及排除_最佳实践_对象存储 OSS-阿里云
消息通知__操作指南_批量计算-阿里云
设备端快速接入(MQTT)__快速开始_阿里云物联网套件-阿里云
查询API调用流量数据__API管理相关接口_API_API 网关-阿里云
使用STS访问__JavaScript-SDK_SDK 参考_对象存储 OSS-阿里云