APIX_身份证图像识别技术(附代码)
2015-11-22 00:38
525 查看
什么是身份证图像识别
身份证识别应用要求文字清晰的大陆二代身份证,文字朝向为正向,图像清晰。同时,身份证号码要求满足国标编码规范,否则不通过验证。API支持支持图片Base64编码和图片URL两种方法,支持的图像格式有jpg、jpeg、gif、png和bmp格式,文件大小在2M以内。
APIX 的身份证识别API,支持身份证正反面识别,其中cmd为idcardfront时,按正面识别,cmd为idcardback时,按反面识别。返回的信息包括姓名、性别、身份证号码、民族、地址,签发机关和有效期等信息。识别率高达92%。
姓名:谢*畅
性别:男
身份证号:330124××××××××9887
民族:汉
地址:广东省汕头市朝阳区光华路××街××号
签发机关:北京市公安局海淀分局
有效期限:2010.05.26-2030.05.26
代码示例,对接详见:http://apix.cn/services/show/35
<span style="font-size:12px;">package com.apix.idcardrecog;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class IDCardRecog {
public static String request(String httpUrl, String httpArg) {
BufferedReader reader = null;
String result = null;
StringBuffer sbf = new StringBuffer();
try {
URL url = new URL(httpUrl);
HttpURLConnection connection = (HttpURLConnection) url
.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
// 填入apix-key到HTTP header
connection.setRequestProperty("apix-key", "0d758082ac574c4f5***c401ba85");
connection.setDoOutput(true);
connection.getOutputStream().write(httpArg.getBytes("UTF-8"));
connection.connect();
InputStream is = connection.getInputStream();
reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String strRead = null;
while ((strRead = reader.readLine()) != null) {
sbf.append(strRead);
sbf.append("\r\n");
}
reader.close();
result = sbf.toString();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static void main(String[] args) {
//发送 GET 请求
String httpUrl = "http://a.apix.cn/apixlab/idcardrecog/idcardurl";
String httpArg = "{\"cmd\": \"idcard_front\",\"imgurl\": \"http://images0.cnblogs.com/blog2015/51591/201506/151449465134350.jpg\"}";
String jsonResult = request(httpUrl, httpArg);
System.out.println(jsonResult);
}
}
</span>
Android版代码和Demo下载:http://apix.cn/services/show/35
身份证识别应用要求文字清晰的大陆二代身份证,文字朝向为正向,图像清晰。同时,身份证号码要求满足国标编码规范,否则不通过验证。API支持支持图片Base64编码和图片URL两种方法,支持的图像格式有jpg、jpeg、gif、png和bmp格式,文件大小在2M以内。
APIX 的身份证识别API,支持身份证正反面识别,其中cmd为idcardfront时,按正面识别,cmd为idcardback时,按反面识别。返回的信息包括姓名、性别、身份证号码、民族、地址,签发机关和有效期等信息。识别率高达92%。
注意事项
传入的身份证图片要求文字方向是正向的,部分手机拍照上传识别的证件图片,多为旋转90度或者180度的身份证照片,导致无法识别。输出示例
姓名:谢*畅
性别:男
身份证号:330124××××××××9887
民族:汉
地址:广东省汕头市朝阳区光华路××街××号
签发机关:北京市公安局海淀分局
有效期限:2010.05.26-2030.05.26
代码示例,对接详见:http://apix.cn/services/show/35
<span style="font-size:12px;">package com.apix.idcardrecog;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class IDCardRecog {
public static String request(String httpUrl, String httpArg) {
BufferedReader reader = null;
String result = null;
StringBuffer sbf = new StringBuffer();
try {
URL url = new URL(httpUrl);
HttpURLConnection connection = (HttpURLConnection) url
.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
// 填入apix-key到HTTP header
connection.setRequestProperty("apix-key", "0d758082ac574c4f5***c401ba85");
connection.setDoOutput(true);
connection.getOutputStream().write(httpArg.getBytes("UTF-8"));
connection.connect();
InputStream is = connection.getInputStream();
reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String strRead = null;
while ((strRead = reader.readLine()) != null) {
sbf.append(strRead);
sbf.append("\r\n");
}
reader.close();
result = sbf.toString();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static void main(String[] args) {
//发送 GET 请求
String httpUrl = "http://a.apix.cn/apixlab/idcardrecog/idcardurl";
String httpArg = "{\"cmd\": \"idcard_front\",\"imgurl\": \"http://images0.cnblogs.com/blog2015/51591/201506/151449465134350.jpg\"}";
String jsonResult = request(httpUrl, httpArg);
System.out.println(jsonResult);
}
}
</span>
Android版代码和Demo下载:http://apix.cn/services/show/35
相关文章推荐
- Android Manifest 用法
- 什么是 GraphQL?
- 阿里云、腾讯云、UCloud、华为云云主机对比测试报告
- Spark RDD API详解(一) Map和Reduce
- 一个小型js框架myJSFrame附API使用帮助
- 详细分析交换机、路由器、集线器的区别和联系
- PowerShell打开或关闭光驱
- 批处理的api WMIC学习体会有感第1/2页
- 批处理 API实现文件下载的代码第1/2页
- Lua教程(十七):C API简介
- 强制删除工具 xdelbox xdelbox1.5正式版下载
- 揪出交换机端口背后“凶手”导致网速太慢
- 电脑重启后突然检测不到硬盘的原因分析与解决办法
- C#中设计、使用Fluent API
- Google官方支持的NodeJS访问API,提供后台登录授权
- PQ分区出错! 巧用Ghost急速补救的绝妙办法
- 深入C++中API的问题详解
- 使用WindowsAPI实现播放PCM音频的方法
- 40余种刻录盘片详细对照分析介绍第1/2页
- fullCalendar中文API官方文档