master
周文涛 2 years ago
parent f5f5b01305
commit c7551b3df8

@ -67,7 +67,14 @@ public class OcrSimulatorController{
//执行识别
JSONObject semanticRequestBody = new JSONObject();
semanticRequestBody.put("task_id", time+"");
semanticRequestBody.put("img_path", uploadFilePath + "/" + image);
OcrIdentifyDetail ocrIdentifyDetail=new OcrIdentifyDetail();
if (image.contains("http:") || image.contains("https:")) {
semanticRequestBody.put("img_path",image);
ocrIdentifyDetail.setImageUrl(image);//图片地址
}else{
ocrIdentifyDetail.setImageUrl(uploadFilePath + "/" + image);//图片地址
semanticRequestBody.put("img_path", uploadFilePath + "/" + image);
}
JSONObject semanticResponseJson = RestUtil.post(OcrConstant.api_test2_identify_url, semanticRequestBody);
//执行时间 调整小数点
Double nluTime = semanticResponseJson.getDouble("nlu_time");
@ -75,12 +82,11 @@ public class OcrSimulatorController{
nluTime = nluTime != null && nluTime != 0 ? new BigDecimal(nluTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() : 0;
ocrTime = ocrTime != null && ocrTime != 0 ? new BigDecimal(ocrTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() : 0;
//入库
OcrIdentifyDetail ocrIdentifyDetail=new OcrIdentifyDetail();
ocrIdentifyDetail.setIdentifyId(ocrIdentify.getId());
ocrIdentifyDetail.setOcrTime(ocrTime);
ocrIdentifyDetail.setNluTime(nluTime);
ocrIdentifyDetail.setImageName(image);//图片名称
ocrIdentifyDetail.setImageUrl(uploadFilePath + "/" + image);//图片地址
ocrIdentifyDetail.setSemanticResult(semanticResponseJson.toJSONString());//ocr识别结果
ocrIdentifyDetailList.add(ocrIdentifyDetail);
//累计时间

@ -1003,7 +1003,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
} else if (StringUtils.isBlank(inputText)) {
//没有输入值.
fieldRightMap.put(field, true);
ocrResultAdd(ocrResultList, value.getFieldName(), field, inputText, text, probability, imgPath, "没有输入值不做匹配", true,null);
ocrResultAdd(ocrResultList, value.getFieldName(), field, inputText, text, probability, imgPath, "没有输入值不做匹配", true,ruleInfo);
} else if ("0".equals(ruleInfo)) {
//不必校验,有识别到就行,通过
fieldRightMap.put(field, true);
@ -1049,7 +1049,12 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
for (OcrResult result : ocrResultList) {
System.out.println(result.toString());
}
//获取最小
ocrResultList.stream().sorted((a,b)->a.getTextRate().compareTo(b.getTextRate())).findFirst().get();
//获取最大
//ocrResultList.stream().sorted((a,b)->a.getTextRate()-b.getTextRate()).findAny().get();
//.sorted(OcrResult::getTextRate).findFirst();
}
}

Loading…
Cancel
Save