275
阿裏雲
駕駛證識別__API介紹_文字識別_人工智能圖像類-阿裏雲
本頁麵主要介紹服務對應的接口和返回結果中的關鍵字段的含義,請在閱讀本頁麵之前,了解請求數據格式介紹,了解輸入輸出的通用數據格式。 此外,在本頁最後,附上了駕駛證識別服務調用的程序示例,以供參考。
請求接口
雲市場接口
- 請求方法: POST
- 請求url: 在雲市場搜索
印刷文字識別-駕駛證識別
,在API接口
中找到調用地址
數加接口
- 請求方法: POST
- 請求url: 打開管理控製台,接口名稱選擇
ocr_driver_license
,查看請求地址
請求參數
參數名稱 | 參數類型 | 描述 | 默認值 |
---|---|---|---|
image | string | dataType為50, dataValue是base64編碼後的圖像數據 | 空字符串 |
POST請求body 示例如下:
{
"inputs": [
{
"image": {
"dataType": 50, #50表示image的數據類型為字符串
"dataValue": "base64_image_string" #圖片以base64編碼的string
}
}]
}
返回結果格式
返回結果格式如下:
{
"outputs": [
{
"outputLabel": "ocr_driver_license",
"outputMulti": {},
"outputValue": {
"dataType": 50,
"dataValue": "{
"config_str": "", #配置字符串信息
"name": "張三三", #姓名字符串,識別不出來時,可能為"NoResult"/"InvalidInput"
"num": "360502xxxx03071357", #駕駛證號,識別錯誤時,為"NoResult"/"InvalidInput"
"vehicle_type":"C1", #駕駛證準駕車型
"start_date": "2010xxxx", #駕駛證有效期開始時間
"end_date": "6", #駕駛證有效期時長
"success": true #識別成功與否 true/false
}"
}
}]
}
每一個請求返回的結果都是一個json字符串,由dataValue關鍵詞可以索引到,主要有7個字段:
- config_str: 表示發送請求時候的配置字符串,為json字符串格式,表示輸入時候的配置參數, 類型為字符串
- name: 識別的駕駛證姓名, 類型為字符串
- num: 識別的身份證號碼, 類型為字符串
- vehicle_type: 準駕車型, 類型為字符串
- start_date: 駕駛證有效期開始時間, 類型為字符串
- end_date: 駕駛證有效期截止時間/有效時長,具體由駕駛證內容決定, 類型為字符串
- success: 識別流程是否出現異常, false表示識別失敗,true表示識別成功, 類型為布爾型
程序示例
雲市場
在雲市場搜索印刷文字識別-駕駛證識別
,在API接口
中找到請求示例
數加平台
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.commons.codec.binary.Base64;
import org.json.JSONObject;
import org.json.JSONArray;
import org.json.JSONException;
public class Driver {
/*
* 獲取參數的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 imgFile = "driver.jpg";
String serviceURL = "your-service-url";
String akID = "your access key id";
String akSecret = "your access key secret";
// 對圖像進行base64編碼
String imgBase64 = "";
try {
File file = new File(imgFile);
byte[] content = new byte[(int) file.length()];
FileInputStream finputstream = new FileInputStream(file);
finputstream.read(content);
finputstream.close();
imgBase64 = new String(Base64.encodeBase64(content));
} catch (IOException e) {
e.printStackTrace();
return;
}
// 拚裝請求body的json字符串
JSONObject requestObj = new JSONObject();
try {
JSONObject obj = new JSONObject();
JSONArray inputArray = new JSONArray();
obj.put("image", getParam(50, imgBase64));
inputArray.put(obj);
requestObj.put("inputs", inputArray);
} catch (JSONException e) {
e.printStackTrace();
}
String body = requestObj.toString();
//Sender代碼參考 https://help.aliyun.com/document_detail/shujia/OCR/ocr-api/sender.html
String result = Sender.sendPost(serviceURL, body, akID, akSecret);
System.out.println(result);
// 解析請求結果
try {
JSONObject resultObj = new JSONObject(result);
JSONArray outputArray = resultObj.getJSONArray("outputs");
String output = outputArray.getJSONObject(0).getJSONObject("outputValue").getString("dataValue"); // 取出結果json字符串
JSONObject out = new JSONObject(output);
if (out.getBoolean("success")) {
String type = out.getString("vehicle_type"); // 獲取類型
String name = out.getString("name"); // 獲取名字
String num = out.getString("num"); // 獲取身份證號
String start = out.getString("start_date"); // 獲取起始日期
String end = out.getString("end_date"); // 獲取有效時長
System.out.printf(" name : %s n num : %sn type : %sn start : %sn end : %sn", name, num, type,
start, end);
} else {
System.out.println("predict error");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
最後更新:2016-11-23 16:04:08
上一篇:
身份證識別__API介紹_文字識別_人工智能圖像類-阿裏雲
下一篇:
行駛證識別__API介紹_文字識別_人工智能圖像類-阿裏雲
負載均衡按域名和URL轉發常見問題__常見問題_負載均衡-阿裏雲
快速切換API版本__API管理相關接口_API_API 網關-阿裏雲
作業概述__作業管理_SDK參考手冊_數據集成-阿裏雲
直播實時轉寫__阿裏雲ET介紹-阿裏雲
恢複已保存的SQL窗口__使用SQL窗口_SQL操作_用戶指南(RDBMS)_數據管理-阿裏雲
本地IDC自建數據庫同RDS實例實時同步__最佳實踐_數據傳輸-阿裏雲
公眾趨勢分析__數加產品概覽_數加平台介紹-阿裏雲
文件存儲怎麼收費?__常見問題_常見問題_文件存儲-阿裏雲
ListTable__API 概覽_API 參考_表格存儲-阿裏雲
實例相關接口__API參考_高性能計算-阿裏雲
相關內容
常見錯誤說明__附錄_大數據計算服務-阿裏雲
發送短信接口__API使用手冊_短信服務-阿裏雲
接口文檔__Android_安全組件教程_移動安全-阿裏雲
運營商錯誤碼(聯通)__常見問題_短信服務-阿裏雲
設置短信模板__使用手冊_短信服務-阿裏雲
OSS 權限問題及排查__常見錯誤及排除_最佳實踐_對象存儲 OSS-阿裏雲
消息通知__操作指南_批量計算-阿裏雲
設備端快速接入(MQTT)__快速開始_阿裏雲物聯網套件-阿裏雲
查詢API調用流量數據__API管理相關接口_API_API 網關-阿裏雲
使用STS訪問__JavaScript-SDK_SDK 參考_對象存儲 OSS-阿裏雲