lzCodeGarden 11 months ago
parent 13fe0d2ed9
commit e7f9103739

@ -28,6 +28,7 @@ import org.jeecg.modules.ocr.utils.ImageUtils;
import org.jeecg.modules.ocr.dto.OcrIdentifyDTO; import org.jeecg.modules.ocr.dto.OcrIdentifyDTO;
import org.jeecg.modules.ocr.dto.OcrRuleCheckDTO; import org.jeecg.modules.ocr.dto.OcrRuleCheckDTO;
import org.jeecg.modules.system.service.ISysDictService; import org.jeecg.modules.system.service.ISysDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
@ -37,6 +38,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.awt.*; import java.awt.*;
import java.io.File; import java.io.File;
import java.rmi.RemoteException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -66,7 +69,7 @@ public class ApiController {
@Value("${system.project.wlyCallback}") @Value("${system.project.wlyCallback}")
private String wlyCallback; private String wlyCallback;
@ApiOperation(value = "通用识别") @ApiOperation(value = "通用识别")
@RequestMapping("/identify") @PostMapping("/identify")
@Transactional @Transactional
@ResponseBody @ResponseBody
@AutoLog(value = "api接口-通用识别",logType = CommonConstant.LOG_TYPE_2,operateType=CommonConstant.OPERATE_TYPE_1) @AutoLog(value = "api接口-通用识别",logType = CommonConstant.LOG_TYPE_2,operateType=CommonConstant.OPERATE_TYPE_1)
@ -257,7 +260,7 @@ public class ApiController {
@ApiOperation(value = "调试101") @ApiOperation(value = "调试101")
@PostMapping(value = "/test_101") @PostMapping(value = "/test_101")
public Result test101(@RequestBody JSONObject jsonObject){ public Result test101(@RequestBody JSONObject jsonObject) {
//ocrIdentifyService.callbackWly("1688915746261848065"); //ocrIdentifyService.callbackWly("1688915746261848065");
//OcrIdentifyDTO byId = ocrIdentifyService.findById("1692068694831755265"); //OcrIdentifyDTO byId = ocrIdentifyService.findById("1692068694831755265");
//ocrIdentifyService.updateTaskResultInfo(byId.getId()); //ocrIdentifyService.updateTaskResultInfo(byId.getId());
@ -267,9 +270,8 @@ public class ApiController {
Map<String, String> configRuleMap = ocrRuleCheckVo.getConfigRuleMap();*/ Map<String, String> configRuleMap = ocrRuleCheckVo.getConfigRuleMap();*/
OcrIdentifyDTO identifyDTO = ocrIdentifyService.findById("1702560400245035009"); OcrIdentifyDTO identifyDTO = ocrIdentifyService.findById("1702560400245035009");
List<OcrIdentifyDetail> identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(identifyDTO.getId()); List<OcrIdentifyDetail> identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(identifyDTO.getId());
CallBackWlyUtils.callbackWly(wlyCallback,identifyDTO,identifyDetailList); CallBackWlyUtils.callbackWly(wlyCallback, identifyDTO, identifyDetailList);
return Result.OK(""); return Result.OK("");
} }
} }

@ -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;
// }
}

@ -101,7 +101,7 @@ public class CallBackWlyUtils {
log.error("请求无量云回调接口失败-拒绝连接 (Connection refused)"); log.error("请求无量云回调接口失败-拒绝连接 (Connection refused)");
log.error(e.getMessage()); log.error(e.getMessage());
} catch (Exception e) { } catch (Exception e) {
log.info("请求无量云回调接口失败"); log.error("请求无量云回调接口失败:{}",e);
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
log.info("回调返回------------------"); log.info("回调返回------------------");
@ -109,7 +109,7 @@ public class CallBackWlyUtils {
log.info(semanticResponseJson.toJSONString()); log.info(semanticResponseJson.toJSONString());
return true; return true;
} else { } else {
log.info("回调返回-----:null"); log.error("回调返回-----:null");
return false; return false;
} }
} }

@ -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;
// }
}

@ -131,9 +131,9 @@ spring:
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource: datasource:
master: 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 username: root
password: Wang5322570.. password: root
driver-class-name: com.mysql.cj.jdbc.Driver 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 # 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 # username: root
@ -148,7 +148,7 @@ spring:
#redis 配置 #redis 配置
redis: redis:
database: 3 database: 3
host: 47.103.213.109 host: localhost
port: 6379 port: 6379
password: '' password: ''
#mybatis plus 设置 #mybatis plus 设置

@ -165,7 +165,6 @@
<artifactId>jeecg-system-biz</artifactId> <artifactId>jeecg-system-biz</artifactId>
<version>${jeecgboot.version}</version> <version>${jeecgboot.version}</version>
</dependency> </dependency>
<!-- jeecg tools --> <!-- jeecg tools -->
<dependency> <dependency>
<groupId>org.jeecgframework.boot</groupId> <groupId>org.jeecgframework.boot</groupId>

Loading…
Cancel
Save