diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java index b897df3..4979b1f 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java @@ -28,6 +28,7 @@ import org.jeecg.modules.ocr.utils.ImageUtils; import org.jeecg.modules.ocr.dto.OcrIdentifyDTO; import org.jeecg.modules.ocr.dto.OcrRuleCheckDTO; import org.jeecg.modules.system.service.ISysDictService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.EnableAsync; @@ -37,6 +38,8 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.awt.*; import java.io.File; +import java.rmi.RemoteException; +import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -66,7 +69,7 @@ public class ApiController { @Value("${system.project.wlyCallback}") private String wlyCallback; @ApiOperation(value = "通用识别") - @RequestMapping("/identify") + @PostMapping("/identify") @Transactional @ResponseBody @AutoLog(value = "api接口-通用识别",logType = CommonConstant.LOG_TYPE_2,operateType=CommonConstant.OPERATE_TYPE_1) @@ -257,7 +260,7 @@ public class ApiController { @ApiOperation(value = "调试101") @PostMapping(value = "/test_101") - public Result test101(@RequestBody JSONObject jsonObject){ + public Result test101(@RequestBody JSONObject jsonObject) { //ocrIdentifyService.callbackWly("1688915746261848065"); //OcrIdentifyDTO byId = ocrIdentifyService.findById("1692068694831755265"); //ocrIdentifyService.updateTaskResultInfo(byId.getId()); @@ -267,9 +270,8 @@ public class ApiController { Map configRuleMap = ocrRuleCheckVo.getConfigRuleMap();*/ OcrIdentifyDTO identifyDTO = ocrIdentifyService.findById("1702560400245035009"); List identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(identifyDTO.getId()); - CallBackWlyUtils.callbackWly(wlyCallback,identifyDTO,identifyDetailList); + CallBackWlyUtils.callbackWly(wlyCallback, identifyDTO, identifyDetailList); return Result.OK(""); } - } \ No newline at end of file diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/config/TesseractOcrConfiguration.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/config/TesseractOcrConfiguration.java new file mode 100644 index 0000000..3268487 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/config/TesseractOcrConfiguration.java @@ -0,0 +1,32 @@ +package org.jeecg.modules.ocr.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @Title: + * @Description: + * @Author 郭向斌 + * @Date 2023-10-27 10:21 + * @Version V1.0 + */ +//@Configuration +public class TesseractOcrConfiguration { +// @Value("${tess4j.data-path}") +// private String dataPath; +// +// @Value("${tess4j.language}") +// private String language; + +// @Bean +// public Tesseract tesseract() { +// +// Tesseract tesseract = new Tesseract(); +// // 设置训练数据文件夹路径 +// tesseract.setDatapath(dataPath); +// // 设置为中文简体 +// tesseract.setLanguage(language); +// return tesseract; +// } +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java index f18fc04..5445590 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java @@ -101,7 +101,7 @@ public class CallBackWlyUtils { log.error("请求无量云回调接口失败-拒绝连接 (Connection refused)"); log.error(e.getMessage()); } catch (Exception e) { - log.info("请求无量云回调接口失败"); + log.error("请求无量云回调接口失败:{}",e); e.printStackTrace(); } finally { log.info("回调返回------------------"); @@ -109,7 +109,7 @@ public class CallBackWlyUtils { log.info(semanticResponseJson.toJSONString()); return true; } else { - log.info("回调返回-----:null"); + log.error("回调返回-----:null"); return false; } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/OcrUtils.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/OcrUtils.java new file mode 100644 index 0000000..82816ab --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/OcrUtils.java @@ -0,0 +1,57 @@ +package org.jeecg.modules.ocr.utils; + +//import org.opencv.core.Core; +//import org.opencv.core.CvType; +//import org.opencv.core.Mat; +//import org.opencv.core.Point; +//import org.opencv.imgproc.Imgproc; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +/** + * @Title: + * @Description: + * @Author 郭向斌 + * @Date 2023-10-27 10:43 + * @Version V1.0 + */ +public class OcrUtils { + + public static void main(String[] args) { + + // 此代码示例演示如何使用预处理过滤器应用自动歪斜校正并保存校正后的图像。 + // 创建 AsposeOcr 的实例 + // 添加纠偏过滤器 +// PreprocessingFilter filters = new PreprocessingFilter(); +// filters.add(PreprocessingFilter.AutoSkew()); +// +// // 将预处理后的图像保存到文件 +// BufferedImage imageRes = api.PreprocessImage("C:\\Users\\郭向斌\\Desktop\\识别不出来2.jpg", filters); +// File outputSource = new File("D:\\workspace\\ocr\\data\\jiuzheng\\识别不出来2rest.jpg"); +// try { +// ImageIO.write(imageRes, "png", outputSource); +// } catch (IOException e) { +// throw new RuntimeException(e); +// } + +// String str="C:\\Users\\郭向斌\\Desktop\\识别不出来2.jpg"; +// File file=new File(str); +// +// String s = getBufferedImage().doOCR(file); +// System.out.println(s); + } +// +// private static Tesseract getBufferedImage(){ +// Tesseract tesseract = new Tesseract(); +// // 设置训练数据文件夹路径 +// tesseract.setDatapath("D:\\workspace\\ocr\\data\\tess4j\\tessdata"); +// // 设置为中文简体 +// tesseract.setLanguage("chi_sim+eng+osd"); +// return tesseract; +// } +} diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml b/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml index 3d1354c..78d488b 100644 --- a/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml @@ -131,9 +131,9 @@ spring: connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 datasource: master: - url: jdbc:mysql://47.103.213.109:3306/ocr?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + url: jdbc:mysql://localhost:3306/ocr?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root - password: Wang5322570.. + password: root driver-class-name: com.mysql.cj.jdbc.Driver # url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai # username: root @@ -148,7 +148,7 @@ spring: #redis 配置 redis: database: 3 - host: 47.103.213.109 + host: localhost port: 6379 password: '' #mybatis plus 设置 diff --git a/pom.xml b/pom.xml index e4a0897..978d3c1 100644 --- a/pom.xml +++ b/pom.xml @@ -165,7 +165,6 @@ jeecg-system-biz ${jeecgboot.version} - org.jeecgframework.boot