对接阿里OCR身份证照片识别
Posted niuniu0108
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了对接阿里OCR身份证照片识别相关的知识,希望对你有一定的参考价值。
1、下面是我的文件结构
2、我将贡献源码
2.1、common文件夹下的文件
AliyunHttpUtils
package com.cardid.demo.common;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
public class AliyunHttpUtils {
/**
* get
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @return
* @throws Exception
*/
public static HttpResponse doGet(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpGet request = new HttpGet(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
return httpClient.execute(request);
}
/**
* post form
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param bodys
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
Map<String, String> bodys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (bodys != null) {
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
for (String key : bodys.keySet()) {
nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
}
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
request.setEntity(formEntity);
}
return httpClient.execute(request);
}
/**
* Post String
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
String body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (StringUtils.isNotBlank(body)) {
request.setEntity(new StringEntity(body, "utf-8"));
}
return httpClient.execute(request);
}
/**
* Post stream
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
byte[] body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
}
/**
* Put String
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPut(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
String body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (StringUtils.isNotBlank(body)) {
request.setEntity(new StringEntity(body, "utf-8"));
}
return httpClient.execute(request);
}
/**
* Put stream
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPut(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
byte[] body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
}
/**
* Delete
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @return
* @throws Exception
*/
public static HttpResponse doDelete(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
return httpClient.execute(request);
}
private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
StringBuilder sbUrl = new StringBuilder();
sbUrl.append(host);
if (!StringUtils.isBlank(path)) {
sbUrl.append(path);
}
if (null != querys) {
StringBuilder sbQuery = new StringBuilder();
for (Map.Entry<String, String> query : querys.entrySet()) {
if (0 < sbQuery.length()) {
sbQuery.append("&");
}
if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
sbQuery.append(query.getValue());
}
if (!StringUtils.isBlank(query.getKey())) {
sbQuery.append(query.getKey());
if (!StringUtils.isBlank(query.getValue())) {
sbQuery.append("=");
sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));
}
}
}
if (0 < sbQuery.length()) {
sbUrl.append("?").append(sbQuery);
}
}
return sbUrl.toString();
}
private static HttpClient wrapClient(String host) {
HttpClient httpClient = new DefaultHttpClient();
if (host.startsWith("https://")) {
sslClient(httpClient);
}
return httpClient;
}
private static void sslClient(HttpClient httpClient) {
try {
SSLContext ctx = SSLContext.getInstance("TLS");
X509TrustManager tm = new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] xcs, String str) {
}
public void checkServerTrusted(X509Certificate[] xcs, String str) {
}
};
ctx.init(null, new TrustManager[] { tm }, null);
SSLSocketFactory ssf = new SSLSocketFactory(ctx);
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
ClientConnectionManager ccm = httpClient.getConnectionManager();
SchemeRegistry registry = ccm.getSchemeRegistry();
registry.register(new Scheme("https", 443, ssf));
} catch (KeyManagementException ex) {
throw new RuntimeException(ex);
} catch (NoSuchAlgorithmException ex) {
throw new RuntimeException(ex);
}
}
}
DBRsHelp
package com.cardid.demo.common;
import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class DBRsHelp<T> {
public List<T> util(T t, ResultSet rs) throws Exception {
// 创建一个对应的空的泛型集合
List<T> list = new ArrayList<T>();
// 反射出类类型(方便后续做操作)
Class c = t.getClass();
// 获得该类所有自己声明的字段,不问访问权限.所有。所有。所有
Field[] fs = c.getDeclaredFields();
// 大家熟悉的操作,不用多说
if (rs != null) {
while (rs.next()) {
// 创建实例
t = (T) c.newInstance();
// 赋值
for (int i = 0; i < fs.length; i++) {
/*
* fs[i].getName():获得字段名
*
* f:获得的字段信息
*/
Field f = t.getClass().getDeclaredField(fs[i].getName());
// 参数true 可跨越访问权限进行操作
f.setAccessible(true);
/*
* f.getType().getName():获得字段类型的名字
*/
// 判断其类型进行赋值操作
if (f.getType().getName().equals(String.class.getName())) {
f.set(t, rs.getString(fs[i].getName()));
} else if (f.getType().getName().equals(int.class.getName())) {
f.set(t, rs.getInt(fs[i].getName()));
}
}
list.add(t);
}
}
// 返回结果
return list;
}
}
OCR
package com.cardid.demo.common;
import com.cardid.demo.dto.CardIDInfo;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.web.bind.annotation.GetMapping;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class OCR {
@GetMapping("/getCardIDInfo")
public ResponseModel getCardIDInfo(String imgPath) {
ResponseModel responseModel = null;
CardIDInfo cardIDInfo = new CardIDInfo();
String host = "https://dm-51.data.aliyun.com";
String path = "/rest/160601/ocr/ocr_idcard.json";
String method = "POST";
String appcode = "这里就需要各位用自己的了";
Map<String, String> headers = new HashMap<String, String>();
// 最后在header中的格式(中间是英文空格)为Authorization:APPCODE ******
headers.put("Authorization", "APPCODE " + appcode);
String pathImage = imgPath;
String binaryToString = getImageBinaryToString(pathImage);
// 根据API的要求,定义相对应的Content-Type
headers.put("Content-Type", "application/json; charset=UTF-8");
Map<String, String> querys = new HashMap<String, String>();
String bodys = "{"inputs": [{"image": {"dataType": 50,"dataValue": "" + binaryToString
+ ""},"configure": {"dataType": 50,"dataValue": "{"side":"face"}"}}]}";
try {
/**
* 重要提示如下: HttpUtils请从
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
* 下载
*
* 相应的依赖请参照
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
*/
HttpResponse response = AliyunHttpUtils.doPost(host, path, method, headers, querys, bodys);
HttpEntity httpEntity = response.getEntity();
String str = EntityUtils.toString(httpEntity);
JSONObject resultObj = new JSONObject(str);
JSONArray outputArray = resultObj.getJSONArray("outputs");
// 取出结果json字符串
String output = outputArray.getJSONObject(0).getJSONObject("outputValue").getString("dataValue");
JSONObject out = new JSONObject(output);
if (out.getBoolean("success")) {
// 获取地址
String addr = out.getString("address");
// 获取名字
String name = out.getString("name");
// 获取生日
String birth = out.getString("birth");
// 获取性别
String sex = out.getString("sex");
// 获取民族
String nationality = out.getString("nationality");
// 获取身份证号
String num = out.getString("num");
cardIDInfo.setAddress(addr);
cardIDInfo.setBirth(birth);
cardIDInfo.setName(name);
cardIDInfo.setNationality(nationality);
cardIDInfo.setNum(num);
cardIDInfo.setSex(sex);
responseModel = new ResponseModel(cardIDInfo, true, "成功", 200);
} else {
responseModel = new ResponseModel(cardIDInfo, false, "predict error", 500);
}
} catch (Exception e) {
responseModel = new ResponseModel(cardIDInfo, false, e.getMessage(), 500);
}
return responseModel;
}
/**
* 获取图片的base64编码数据
* </p>
*
* @param imagePath
* @return
*/
public static String getImageBinaryToString(String imagePath) {
try {
File file = new File(imagePath);
byte[] content = new byte[(int) file.length()];
FileInputStream finputstream = new FileInputStream(file);
finputstream.read(content);
finputstream.close();
return new String(Base64.encodeBase64(content));
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}
ResponseModel
package com.cardid.demo.common;
public class ResponseModel {
private Object Data;
private boolean Success;
private String Message;
private Integer Code;
public ResponseModel(){
}
public ResponseModel(boolean success, String message, Integer code) {
Success = success;
Message = message;
Code = code;
}
public ResponseModel(Object data, boolean success, String message, Integer code) {
Data = data;
Success = success;
Message = message;
Code = code;
}
public Object getData() {
return Data;
}
public void setData(Object data) {
Data = data;
}
public boolean getisSuccess() {
return Success;
}
public void setSuccess(boolean success) {
this.Success = success;
}
public String getMessage() {
return Message;
}
public void setMessage(String message) {
this.Message = message;
}
public Integer getCode() {
return Code;
}
public void setCode(Integer code) {
this.Code = code;
}
}
SqlHelp
package com.cardid.demo.common;
import java.sql.*;
public class SqlHelp<T> {
/**
* 驱动程序名
*/
private static final String DRIVER = "com.mysql.jdbc.Driver";
/**
* URL指向要访问的数据库
*/
private static final String URL = "jdbc:mysql://localhost:3306/people_total?useSSL=false&characterEncoding=utf8&serverTimezone=UTC";
/**
* MySQL配置时的用户名
*/
private static final String USER = "root";
/**
* MySQL配置时的密码
*/
private static final String PASSWORD = "xiaoniuniu0108";
/**
* 新增
*/
public ResponseModel add(String sql) {
ResponseModel responseModel = null;
//声明Connection对象
Connection con;
//遍历查询结果集
try {
//加载驱动程序
Class.forName(DRIVER);
//1.getConnection()方法,连接MySQL数据库!!
con = DriverManager.getConnection(URL, USER, PASSWORD);
//2.创建statement类对象,用来执行SQL语句!!
Statement statement = con.createStatement();
//3.ResultSet类,用来存放获取的结果集!!
int result = statement.executeUpdate(sql);
con.close();
responseModel = new ResponseModel(null, true, "提交成功", 200);
} catch (ClassNotFoundException e) {
//数据库驱动类异常处理
responseModel = new ResponseModel(null, false, "提交失败:" + e.getMessage(), 500);
} catch (SQLException e) {
//数据库连接失败异常处理
e.printStackTrace();
responseModel = new ResponseModel(null, false, "提交失败:" + e.getMessage(), 500);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
responseModel = new ResponseModel(null, false, "提交失败:" + e.getMessage(), 500);
}
return responseModel;
}
/**
* 查询
*/
public ResponseModel query(String sql, T t) {
ResponseModel responseModel = null;
//声明Connection对象
Connection con;
//遍历查询结果集
try {
//加载驱动程序
Class.forName(DRIVER);
//1.getConnection()方法,连接MySQL数据库!!
con = DriverManager.getConnection(URL, USER, PASSWORD);
//2.创建statement类对象,用来执行SQL语句!!
Statement statement = con.createStatement();
//3.ResultSet类,用来存放获取的结果集!!
ResultSet rs = statement.executeQuery(sql);
Object result = new DBRsHelp().util(t, rs);
con.close();
responseModel = new ResponseModel(result, true, "成功", 200);
} catch (ClassNotFoundException e) {
//数据库驱动类异常处理
responseModel = new ResponseModel(null, false, "未找到驱动程序:" + e.getMessage(), 500);
} catch (SQLException e) {
//数据库连接失败异常处理
responseModel = new ResponseModel(null, false, e.getMessage(), 500);
} catch (Exception e) {
// TODO: handle exception
responseModel = new ResponseModel(null, false, e.getMessage(), 500);
}
return responseModel;
}
}
2.2、controller文件夹下的文件
FileUpload
package com.cardid.demo.controller;
import com.cardid.demo.common.OCR;
import com.cardid.demo.common.ResponseModel;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.UUID;
@RestController
@RequestMapping("/FileUpload")
@CrossOrigin
public class FileUpload {
//上传图片,返回attach_id
@PostMapping("/addImg")
public ResponseModel addImg(HttpServletRequest request, @RequestParam("file") MultipartFile file) throws UnsupportedEncodingException {
ResponseModel responseModel=null;
request.setCharacterEncoding("utf-8");
//设定为当前文件夹
File directory = new File("");
String currentPath = directory.getAbsolutePath() + "/uploadFile";
File filePath = new File(currentPath);
if (!filePath.exists()) {
filePath.mkdir();
}
String uploadPath = filePath.getAbsolutePath();
//做文件上传
if ("".equals(file.getName()) || file.isEmpty()) {
}
if (file.getSize() > 3000000) {
}
//判断文件
if (!file.isEmpty()) {
//上传的文件的名称
String oldFileName = file.getOriginalFilename();
//取文件名的后缀
String suffix = oldFileName.substring(oldFileName.lastIndexOf("."));
String id = UUID.randomUUID().toString();
//新的文件名
String fileName = id + suffix;
uploadPath = uploadPath +""+ fileName;
//文件保存路径
File savePath = new File(uploadPath);
//设置附件路径
try {
//通过封装好的方法将文件上传到指定的文件夹
file.transferTo(savePath);
responseModel=new OCR().getCardIDInfo(uploadPath);
} catch (IOException e) {
responseModel=new ResponseModel("",true,e.getMessage(),500);
}
}
return responseModel;
}
}
PeopleTotal
package com.cardid.demo.controller;
import com.cardid.demo.common.ResponseModel;
import com.cardid.demo.common.SqlHelp;
import com.cardid.demo.dto.PeopleInfo;
import com.cardid.demo.dto.PeopleList;
import org.springframework.web.bind.annotation.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@RestController
@RequestMapping("/PeopleTotal")
@CrossOrigin
public class PeopleTotal {
@PostMapping("/saveInfo")
public ResponseModel saveInfo(@RequestBody PeopleInfo peopleInfo) {
ResponseModel responseModel = null;
if (peopleInfo.getLeave().equals("否")) {
peopleInfo.setLeave_date("");
peopleInfo.setCity("");
peopleInfo.setBack_date("");
peopleInfo.setTraffic_tool("");
}
//设置日期格式
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String sql = String.format("insert peopleinfo(`ID`,`name`,`sex`,`nationality`,`birth`,`address`,`card_id`,`phone`,`healthValue`,`healthText`,`contact`,`leave`,`leave_date`,`city`,`back_date`,`traffic_tool`,`live_address`,`createTime`) values(‘%s‘,‘%s‘,‘%s‘,‘%s‘,‘%s‘,‘%s‘,‘%s‘,‘%s‘,‘%s‘,‘%s‘,‘%s‘,‘%s‘,‘%s‘,‘%s‘,‘%s‘,‘%s‘,‘%s‘,‘%s‘)", UUID.randomUUID().toString(), peopleInfo.getName(), peopleInfo.getSex(), peopleInfo.getNationality(), peopleInfo.getBirth(), peopleInfo.getAddress(), peopleInfo.getCard_id(), peopleInfo.getPhone(), peopleInfo.getHealthValue(), peopleInfo.getHealthText(), peopleInfo.getContact(), peopleInfo.getLeave(), peopleInfo.getLeave_date(), peopleInfo.getCity(), peopleInfo.getBack_date(), peopleInfo.getTraffic_tool(), peopleInfo.getLive_address(), df.format(new Date()));
SqlHelp sqlHelp = new SqlHelp();
return sqlHelp.add(sql);
}
/**
* 查询列表
*/
@PostMapping("/getList")
public ResponseModel getList() throws SQLException {
ResponseModel responseModel = null;
PeopleList peopleList = new PeopleList();
String sql = "select * from peopleinfo";
SqlHelp sqlHelp = new SqlHelp();
ResponseModel list = sqlHelp.query(sql,peopleList);
if (list.getisSuccess()) {
List<PeopleList> resultList = (List<PeopleList>) list.getData();
// while (rs.next()) {
//
// peopleList.setID(rs.getString("ID"));
// peopleList.setName(rs.getString("name"));
// peopleList.setSex(rs.getString("sex"));
// peopleList.setNationality(rs.getString("nationality"));
// peopleList.setBirth(rs.getString("birth"));
// peopleList.setAddress(rs.getString("address"));
// peopleList.setCard_id(rs.getString("card_id"));
// peopleList.setPhone(rs.getString("phone"));
// peopleList.setHealthValue(rs.getString("healthValue"));
// peopleList.setHealthText(rs.getString("healthText"));
// peopleList.setContact(rs.getString("contact"));
// peopleList.setLeave(rs.getString("leave"));
// peopleList.setLeave_date(rs.getString("leave_date"));
// peopleList.setCity(rs.getString("city"));
// peopleList.setBack_date(rs.getString("back_date"));
// peopleList.setTraffic_tool(rs.getString("traffic_tool"));
// peopleList.setLive_address(rs.getString("live_address"));
// peopleList.setCreateTime(rs.getString("createTime"));
// peopleList.setCreateUserID(rs.getString("createUserID"));
// peopleList.setCreateUserName(rs.getString("createUserName"));
// resultList.add(peopleList);
// }
responseModel = new ResponseModel(resultList, true, "成功", 200);
} else {
responseModel = list;
}
return responseModel;
}
}
2.3、dto文件夹下的文件
CardIDInfo
package com.cardid.demo.dto;
public class CardIDInfo {
//地址
private String Address;
//名字
private String Name;
//生日
private String Birth;
//性别
private String Sex;
//民族
private String Nationality;
//身份证号
private String Num;
public String getAddress() {
return Address;
}
public void setAddress(String address) {
Address = address;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public String getBirth() {
return Birth;
}
public void setBirth(String birth) {
Birth = birth;
}
public String getSex() {
return Sex;
}
public void setSex(String sex) {
Sex = sex;
}
public String getNationality() {
return Nationality;
}
public void setNationality(String nationality) {
Nationality = nationality;
}
public String getNum() {
return Num;
}
public void setNum(String num) {
Num = num;
}
}
PeopleInfo
package com.cardid.demo.dto;
import java.util.Date;
public class PeopleInfo {
//姓名
private String name;
//性别
private String sex;
//民族
private String nationality;
//生日
private String birth;
//家庭地址
private String address;
//身份证号
private String card_id;
//手机号码
private String phone;
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
//健康状况
private String healthValue;
//健康状况
private String healthText;
//14天内是否接触过防疫重点人员
private String contact;
//是否离沪
private String leave;
//离沪时间
private String leave_date;
//所至城市
private String city;
//返沪时间
private String back_date;
//交通工具
private String traffic_tool;
//上海居住地址
private String live_address;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getNationality() {
return nationality;
}
public void setNationality(String nationality) {
this.nationality = nationality;
}
public String getBirth() {
return birth;
}
public void setBirth(String birth) {
this.birth = birth;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCard_id() {
return card_id;
}
public void setCard_id(String card_id) {
this.card_id = card_id;
}
public String getHealthValue() {
return healthValue;
}
public void setHealthValue(String healthValue) {
this.healthValue = healthValue;
}
public String getHealthText() {
return healthText;
}
public void setHealthText(String healthText) {
this.healthText = healthText;
}
public String getContact() {
return contact;
}
public void setContact(String contact) {
this.contact = contact;
}
public String getLeave() {
return leave;
}
public void setLeave(String leave) {
this.leave = leave;
}
public String getLeave_date() {
return leave_date;
}
public void setLeave_date(String leave_date) {
this.leave_date = leave_date;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getBack_date() {
return back_date;
}
public void setBack_date(String back_date) {
this.back_date = back_date;
}
public String getTraffic_tool() {
return traffic_tool;
}
public void setTraffic_tool(String traffic_tool) {
this.traffic_tool = traffic_tool;
}
public String getLive_address() {
return live_address;
}
public void setLive_address(String live_address) {
this.live_address = live_address;
}
}
PeopleList
package com.cardid.demo.dto;
public class PeopleList {
private String ID;
//姓名
private String name;
//性别
private String sex;
//民族
private String nationality;
//生日
private String birth;
//家庭地址
private String address;
//身份证号
private String card_id;
//手机号码
private String phone;
//健康状况
private String healthValue;
//健康状况
private String healthText;
//14天内是否接触过防疫重点人员
private String contact;
//是否离沪
private String leave;
//离沪时间
private String leave_date;
//所至城市
private String city;
//返沪时间
private String back_date;
//交通工具
private String traffic_tool;
//上海居住地址
private String live_address;
//上海居住地址
private String createTime;
//上海居住地址
private String createUserID;
//上海居住地址
private String createUserName;
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getNationality() {
return nationality;
}
public void setNationality(String nationality) {
this.nationality = nationality;
}
public String getBirth() {
return birth;
}
public void setBirth(String birth) {
this.birth = birth;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCard_id() {
return card_id;
}
public void setCard_id(String card_id) {
this.card_id = card_id;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getHealthValue() {
return healthValue;
}
public void setHealthValue(String healthValue) {
this.healthValue = healthValue;
}
public String getHealthText() {
return healthText;
}
public void setHealthText(String healthText) {
this.healthText = healthText;
}
public String getContact() {
return contact;
}
public void setContact(String contact) {
this.contact = contact;
}
public String getLeave() {
return leave;
}
public void setLeave(String leave) {
this.leave = leave;
}
public String getLeave_date() {
return leave_date;
}
public void setLeave_date(String leave_date) {
this.leave_date = leave_date;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getBack_date() {
return back_date;
}
public void setBack_date(String back_date) {
this.back_date = back_date;
}
public String getTraffic_tool() {
return traffic_tool;
}
public void setTraffic_tool(String traffic_tool) {
this.traffic_tool = traffic_tool;
}
public String getLive_address() {
return live_address;
}
public void setLive_address(String live_address) {
this.live_address = live_address;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getCreateUserID() {
return createUserID;
}
public void setCreateUserID(String createUserID) {
this.createUserID = createUserID;
}
public String getCreateUserName() {
return createUserName;
}
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName;
}
}
3、到此为止,所有源码已尽数奉献,若对你们有帮助还望可以点个赞,谢谢!
以上是关于对接阿里OCR身份证照片识别的主要内容,如果未能解决你的问题,请参考以下文章