使用阿里云身份证扫描识别接口案例——CSDN博客
来源:互联网 发布:免费的会计软件 编辑:程序博客网 时间:2024/05/16 05:47
/** * * @Title: idcard* @Description: 该方法的主要作用:扫描身份证* @param @return 设定文件 * @return 返回类型:String * @throws */public void idcard(){String host = "https://dm-51.data.aliyun.com"; String path = "/rest/160601/ocr/ocr_idcard.json"; String method = "POST"; Map<String, String> headers = new HashMap<String, String>(); headers.put("Authorization", "APPCODE " + appcode); headers.put("Content-Type", "application/json; charset=UTF-8"); Map<String, String> querys = new HashMap<String, String>(); String bodys = "{\"inputs\": [{\"image\": {\"dataType\": 50,\"dataValue\":\""+img+"\"},\"configure\": {\"dataType\": 50,\"dataValue\":\"{\\\"side\\\":\\\"face\\\"}\"}}]}"; try { HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys); //System.out.println(EntityUtils.toString(response.getEntity())); String result = EntityUtils.toString(response.getEntity()); System.out.println(result); JSONObject jObject = JSONObject.fromObject(result); JSONArray jarray = jObject.optJSONArray("outputs"); for (int i = 0; i < jarray.size(); i++) {JSONObject subject = jarray.getJSONObject(i);String outputValue = subject.get("outputValue").toString();/*outputValue={ "dataType": 50, "dataValue": { "address": "山西省xxxx041", "birth": "19980908", "config_str": "{\"side\":\"face\"}", "face_rect": { "angle": -90, "center": { "x": 446, "y": 210 }, "size": { "height": 92, "width": 84 } }, "name": "xxx", "nationality": "汉", "num": "1411251998xxxxxxX", "request_id": "20170806200141_c5338b2c4fd601ea7f00c4dcc5c8ee0e", "sex": "男", "success": true }}*/JSONObject j_outputValue = JSONObject.fromObject(outputValue);String dataValue = j_outputValue.getString("dataValue");JSONObject j_dataValue = JSONObject.fromObject(dataValue);customerInfo = new CustomerInfo();customerInfo.setName(j_dataValue.getString("name").toString()); //姓名String date = j_dataValue.getString("birth").toString();customerInfo.setBorn(date);SimpleDateFormat format = new SimpleDateFormat(date);Date birth = format.parse(date);customerInfo.setBirth(birth);//生日customerInfo.setAddress(j_dataValue.getString("address").toString());customerInfo.setNationality(j_dataValue.getString("nationality").toString());customerInfo.setNum(j_dataValue.getString("num").toString());customerInfo.setSex(j_dataValue.getString("sex").toString());} System.out.println(customerInfo.getName()); String jsonc = JSON.toJSONString(customerInfo); HttpServletResponse response1 = ServletActionContext.getResponse();response1.setContentType("text/html;charset=utf-8");PrintWriter out = response1.getWriter();out.print(jsonc); } catch (Exception e) { e.printStackTrace(); }}
阅读全文
1 0
- 使用阿里云身份证扫描识别接口案例——CSDN博客
- 使用阿里云火车票查询接口案例——CSDN博客
- 使用阿里云智能翻译接口案例——CSDN博客
- 调用阿里云身份证识别接口(使用appcode方式)
- 使用阿里身份证识别接口(使用appkey和secret)
- 阿里接口平台--印刷字识别_身份证识别API接口phpdemo使用
- 阿里云 OCR身份证识别Api 使用(一)
- 阿里云 OCR身份证识别Api 使用(二)
- 调用阿里云接口实现短信消息的发送源码——CSDN博客
- java使用循环案例——CSDN博客
- Android平台上实现身份证识别(通过阿里云Api-印刷文字识别_身份证识别)
- 如何用阿里云的API进行身份证识别
- tf21: 身份证识别——识别身份证号
- Android身份证扫描拍照识别SDK
- 身份证自动扫描拍照识别技术SDK
- 自动拍照扫描识别身份证信息SDK
- 自动拍照扫描识别身份证信息SDK
- Android拍照扫描识别身份证信息SDK
- 2017北大信科夏令营机试B:编码字符串
- QT多线程使用总结
- JAVA8新特性[第五季]-并行流与串行流
- javescript机试题
- 利用crash工具分析堆栈死机问题
- 使用阿里云身份证扫描识别接口案例——CSDN博客
- KMP 算法持续更新
- Web css named way BEM
- FSM 大法好 —— 从过程到定义(转载)
- 推送通知小结
- 取两张mysql表中分别两个字段相同的值
- 《Unix网络编程》卷1:套接字联网API(第3版):非阻塞I/O、ioctl操作、路由套接字
- nginx和ftp搭建图片服务器
- HDU