master
周文涛 2 years ago
parent 3eafba9df1
commit 0309321d26

@ -47,6 +47,6 @@ public class OcrConstant {
//目前仅支持的字段
public static List<String> SUPPORTED_FIELDS= Arrays.asList("hospitalName","doctorName","departmentName","time");
//目前仅支持的字段中文名
public static List<String> SUPPORTED_FIELD_NAMES= Arrays.asList("医院名称","医生名称","科室","时间");
public static List<String> SUPPORTED_FIELD_NAMES= Arrays.asList("医院名称","医生名称","姓名","科室","时间");
}

@ -976,6 +976,14 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
sourceJson.add(JSONObject.parseObject(String.format("{\"tag\":\"time\", \"inputText\":\"%s\"}", time)));
}
JSONObject semanticResult = JSONObject.parseObject(ocrIdentifyDetail.getSemanticResult());
//判断是不是网络图片
Boolean onlineFile = FileOUtils.isOnlineFile(imgPath);
if (onlineFile) {
//如果是网络图片,则将图片下载
imgPath = FileOUtils.downLoadFromUrl(imgPath, FileOUtils.getFileName(imgPath), OcrConstant.FILE_DOWNLOAD_URL_PREFIX);
}
File file = new File(imgPath);
//当原图片存在时.
if (file.exists()) {
@ -995,14 +1003,16 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
}*/
//绘制虚线
if (true) {
JSONObject semanticResult2 = JSONObject.parseObject(ocrIdentifyDetail.getSemanticResult()).getJSONObject("semantic_result");
JSONObject semanticResult2 = semanticResult.getJSONObject("semantic_result");
String fileUrl = "/data/ocrImage/drawDashed" + imgPath.substring(0, i);
//判断新目录是否存在,不存在则新建
FileOUtils.folderCreate(fileUrl);
String outputImagePath = fileUrl + imgPath.substring(i + 1, imgPath.length());
if (semanticResult2!=null) {
List<List<Point>> resultToPoints = ImageUtils.semanticResultToPoints(semanticResult2);
if (resultToPoints.size() > 0) {
if (CollectionUtils.isNotEmpty(resultToPoints)) {
ImageUtils.drawDashedRectangleOnImages(file.getAbsolutePath(), resultToPoints, outputImagePath);
imgPath = outputImagePath;
}

Loading…
Cancel
Save