ソースを参照

orc响应结果调整

master
yangpeilai 3日前
コミット
fcc791f747

+ 6
- 9
gly-base-core/src/main/java/cn/com/taiji/core/model/comm/protocol/ats/ocr/IdCardOcrResponse.java ファイルの表示

@@ -9,18 +9,15 @@ import lombok.Setter;
public class IdCardOcrResponse extends AbstractAtsResponse {

private String imageUrl; // 图片URL
private String birthday; // 出生日期
private String begindate; // 有效期起始日期
private String address; // 住址
private String agency; // 签发机关
private String name; // 姓名
private String gender; // 性别
private String nation; // 民族
private String birthday; // 出生日期
private String address; // 住址
private String idno; // 身份证号码
private String idtype; // 身份证类型
private String enddate; // 有效期结束日期
private String identityId; // 身份ID
private String name; // 姓名
private Integer imageType; // 图片类型
private String begindate; // 签发日期
private String enddate; // 失效日期
private String agency; // 签发机关

private String code; // 状态码
private String respCode; // 响应代码

+ 21
- 19
gly-base-core/src/main/java/cn/com/taiji/core/model/comm/protocol/ats/ocr/VehicleLicenseOcrResponse.java ファイルの表示

@@ -9,29 +9,31 @@ import lombok.Setter;
public class VehicleLicenseOcrResponse extends AbstractAtsResponse {

private String imageUrl; // 图片URL
private String towing; // 拖挂车类型
private String note; // 备注
//正本
private String plate_a; // 号牌号码(前)
private String vehicle; // 车辆类型
private String character; // 车辆特征
private String file; // 档案编号
private String engine; // 发动机号码
private String apc; // 允许的乘客容量
private String alc; // 允许的载重量
private String model; // 车辆型号
private String vin; // 车辆识别号码
private String man; // 制造商
private String inspection; // 检验有效期至
private String man; // 所有人
private String address; // 住址
private String issue; // 发证机关
private String character; // 使用性质
private String model; // 品牌型号
private String vin; // 车辆识别代号
private String engine; // 发动机号码
private String register; // 注册日期
private String issue; // 发证日期
private String issueUnit; // 发证单位
//副本
private String plate_b; // 号牌号码(后)
private String file; // 档案编号
private String apc; // 核定载人数
private String gross; // 总质量
private String plate_a; // 车牌号(前)
private String plate_b; // 车牌号(后)
private String unladen; // 整备质量
private String codeNo; // 代码编号
private String driveLicenseOcrId; // 驾驶证OCR结果ID
private String overall; // 总体描述
private String pictureSize; // 图片尺寸
private String register; // 注册日期
private String alc; // 核定载质量
private String overall; // 外廓尺寸
private String towing; // 准牵引总质量
private String note; // 备注
private String inspection; // 检验记录
private String codeNo; // 证芯编号
private String fuel; // 燃油类型

private String code; // 状态码
private String respCode; // 响应代码

+ 32
- 36
zhywpt-service-ats/src/main/java/cn/com/taiji/ats/manager/ocr/BaiduOcrUtil.java ファイルの表示

@@ -247,19 +247,19 @@ public class BaiduOcrUtil {
JSONObject wordsResult = object.getJSONObject("words_result");
if (wordsResult == null) throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("身份证识别返回为空");

if(wordsResult.getJSONObject("姓名") != null) res.setName(wordsResult.getJSONObject("姓名").getString("words"));
if(wordsResult.getJSONObject("性别") != null) res.setGender(wordsResult.getJSONObject("性别").getString("words"));
if(wordsResult.getJSONObject("民族") != null) res.setNation(wordsResult.getJSONObject("民族").getString("words"));
if(wordsResult.getJSONObject("出生") != null){
String birthdayStr = wordsResult.getJSONObject("出生").getString("words");
String birthday = LocalDate.parse(birthdayStr, DateTimeFormatter.ofPattern("yyyyMMdd")).format(DateTimeFormatter.ofPattern("yyyy.MM.dd"));
res.setBirthday(birthday);
}
if(wordsResult.getJSONObject("住址") != null) res.setAddress(wordsResult.getJSONObject("住址").getString("words"));
if(wordsResult.getJSONObject("姓名") != null) res.setName(wordsResult.getJSONObject("姓名").getString("words"));
if(wordsResult.getJSONObject("公民身份号码") != null) res.setIdno(wordsResult.getJSONObject("公民身份号码").getString("words"));
if(wordsResult.getJSONObject("性别") != null) res.setGender(wordsResult.getJSONObject("性别").getString("words"));
if(wordsResult.getJSONObject("民族") != null) res.setNation(wordsResult.getJSONObject("民族").getString("words"));
if(wordsResult.getJSONObject("失效日期") != null) res.setEnddate(wordsResult.getJSONObject("失效日期").getString("words"));
if(wordsResult.getJSONObject("签发机关") != null) res.setAgency(wordsResult.getJSONObject("签发机关").getString("words"));
if(wordsResult.getJSONObject("签发日期") != null) res.setBegindate(wordsResult.getJSONObject("签发日期").getString("words"));
if(wordsResult.getJSONObject("签发机关") != null) res.setAgency(wordsResult.getJSONObject("签发机关").getString("words"));

res.setCode("0");
res.setRespCode("0000");
@@ -277,25 +277,34 @@ public class BaiduOcrUtil {
JSONObject wordsResult = object.getJSONObject("words_result");
if (wordsResult == null) throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("行驶证识别返回为空");

if(wordsResult.getJSONObject("品牌型号") != null) res.setModel(wordsResult.getJSONObject("品牌型号").getString("words"));
if(wordsResult.getJSONObject("使用性质") != null) res.setCharacter(wordsResult.getJSONObject("使用性质").getString("words"));
if(wordsResult.getJSONObject("发动机号码") != null) res.setEngine(wordsResult.getJSONObject("发动机号码").getString("words"));
if(wordsResult.getJSONObject("住址") != null) res.setAddress(wordsResult.getJSONObject("住址").getString("words"));
if(wordsResult.getJSONObject("车辆识别代号") != null) res.setVin(wordsResult.getJSONObject("车辆识别代号").getString("words"));
if(wordsResult.getJSONObject("车辆类型") != null) res.setVehicle(wordsResult.getJSONObject("车辆类型").getString("words"));
if(wordsResult.getJSONObject("整备质量") != null) res.setUnladen(wordsResult.getJSONObject("整备质量").getString("words"));
if(wordsResult.getJSONObject("号牌号码") != null) {
res.setPlate_a(wordsResult.getJSONObject("号牌号码").getString("words"));
res.setPlate_b(wordsResult.getJSONObject("号牌号码").getString("words"));
}
if(wordsResult.getJSONObject("备注") != null) res.setNote(wordsResult.getJSONObject("备注").getString("words"));
if(wordsResult.getJSONObject("准牵引总质量") != null) res.setTowing(wordsResult.getJSONObject("准牵引总质量").getString("words"));
if(wordsResult.getJSONObject("车辆类型") != null) res.setVehicle(wordsResult.getJSONObject("车辆类型").getString("words"));
if(wordsResult.getJSONObject("所有人") != null) res.setMan(wordsResult.getJSONObject("所有人").getString("words"));
if(wordsResult.getJSONObject("住址") != null) res.setAddress(wordsResult.getJSONObject("住址").getString("words"));
if(wordsResult.getJSONObject("使用性质") != null) res.setCharacter(wordsResult.getJSONObject("使用性质").getString("words"));
if(wordsResult.getJSONObject("品牌型号") != null) res.setModel(wordsResult.getJSONObject("品牌型号").getString("words"));
if(wordsResult.getJSONObject("车辆识别代号") != null) res.setVin(wordsResult.getJSONObject("车辆识别代号").getString("words"));
if(wordsResult.getJSONObject("发动机号码") != null) res.setEngine(wordsResult.getJSONObject("发动机号码").getString("words"));
if(wordsResult.getJSONObject("注册日期") != null){
String registerStr = wordsResult.getJSONObject("注册日期").getString("words");
String register = LocalDate.parse(registerStr, DateTimeFormatter.ofPattern("yyyyMMdd")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
res.setRegister(register);
}
if(wordsResult.getJSONObject("发证日期") != null){
String issueStr = wordsResult.getJSONObject("发证日期").getString("words");
String issue = LocalDate.parse(issueStr, DateTimeFormatter.ofPattern("yyyyMMdd")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
res.setIssue(issue);
}
if(wordsResult.getJSONObject("发证单位") != null) res.setIssueUnit(wordsResult.getJSONObject("发证单位").getString("words"));

if(wordsResult.getJSONObject("档案编号") != null) res.setFile(wordsResult.getJSONObject("档案编号").getString("words"));
if(wordsResult.getJSONObject("核定载人数") != null) res.setApc(wordsResult.getJSONObject("核定载人数").getString("words"));
if(wordsResult.getJSONObject("总质量") != null) res.setGross(wordsResult.getJSONObject("总质量").getString("words"));
if(wordsResult.getJSONObject("检验记录") != null) res.setInspection(wordsResult.getJSONObject("检验记录").getString("words"));
if(wordsResult.getJSONObject("整备质量") != null) res.setUnladen(wordsResult.getJSONObject("整备质量").getString("words"));
if(wordsResult.getJSONObject("核定载质量") != null) res.setAlc(wordsResult.getJSONObject("核定载质量").getString("words"));
if(wordsResult.getJSONObject("所有人") != null) res.setMan(wordsResult.getJSONObject("所有人").getString("words"));

if(wordsResult.getJSONObject("外廓尺寸") != null){
String outsideDimensions = wordsResult.getJSONObject("外廓尺寸").getString("words");
if (StringUtils.hasText(outsideDimensions) && outsideDimensions.contains("^")) {
@@ -304,26 +313,12 @@ public class BaiduOcrUtil {
outsideDimensions = outsideDimensions.toLowerCase();
res.setOverall(outsideDimensions);
}
if(wordsResult.getJSONObject("发证日期") != null){
String issueStr = wordsResult.getJSONObject("发证日期").getString("words");
String issue = LocalDate.parse(issueStr, DateTimeFormatter.ofPattern("yyyyMMdd")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
res.setIssue(issue);
}
if(wordsResult.getJSONObject("注册日期") != null){
String registerStr = wordsResult.getJSONObject("注册日期").getString("words");
String register = LocalDate.parse(registerStr, DateTimeFormatter.ofPattern("yyyyMMdd")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
res.setRegister(register);
}
// XXX
if(wordsResult.getJSONObject("档案编号") != null) res.setFile(wordsResult.getJSONObject("档案编号").getString("words"));
// JSONObject jsonFileNum = words_result.getJSONObject("档案编号");
// if (jsonFileNum != null) {
// String fileNum = jsonFileNum.getString("words");
// vehicleLicense.setFileNo(fileNum);
// }
if(wordsResult.getJSONObject("准牵引总质量") != null) res.setTowing(wordsResult.getJSONObject("准牵引总质量").getString("words"));
if(wordsResult.getJSONObject("备注") != null) res.setNote(wordsResult.getJSONObject("备注").getString("words"));
if(wordsResult.getJSONObject("证芯编号") != null) res.setCode(wordsResult.getJSONObject("证芯编号").getString("words"));
if(wordsResult.getJSONObject("燃油类型") != null) res.setFuel(wordsResult.getJSONObject("燃油类型").getString("words"));

res.setCode("0");
res.setPictureSize("0");
res.setRespCode("0000");
res.setRespMessage("ocr识别成功");
res.setStatusDesc("成功");
@@ -355,6 +350,7 @@ public class BaiduOcrUtil {
if(wordsResult.getJSONObject("地址") != null) res.setAdress(wordsResult.getJSONObject("地址").getString("words"));
if(wordsResult.getJSONObject("登记机关") != null) res.setRegAuthority(wordsResult.getJSONObject("登记机关").getString("words"));
if(wordsResult.getJSONObject("类型") != null) res.setType(wordsResult.getJSONObject("类型").getString("words"));

res.setCode("0");
res.setRespCode("0000");
res.setRespMessage("ocr识别成功");
@@ -458,7 +454,7 @@ public class BaiduOcrUtil {
}

public static void main(String[] args) {
String imagePath = "C:\\Users\\32258\\Desktop\\gy\\ocr测试图片\\身份证.jpg"; // 图片文件的路径
String imagePath = "C:\\Users\\32258\\Desktop\\gy\\ocr测试图片\\行驶证.jpg"; // 图片文件的路径
try {
// 读取图片文件
File file = new File(imagePath);
@@ -480,7 +476,7 @@ public class BaiduOcrUtil {
// String s = "http://192.168.100.63:8123/rest/2.0/ocr/v1/idcard?access_token=\"24.5ef02634e73ed6f7d9d161f706b6c4ea.2592000.1729009172.282335-26580024\"";
// System.out.println(s.replaceAll("\"",""));
BaiduOcrUtil baiduOcrUtil = new BaiduOcrUtil();
baiduOcrUtil.ocrIdCardRecognize(base64Image,"front");
baiduOcrUtil.ocrVehicleLicenseRecognize(base64Image,"front");
} catch (Exception e) {
e.printStackTrace();
}

読み込み中…
キャンセル
保存