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.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)
@ -271,5 +274,4 @@ public class ApiController {
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(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;
}
}

@ -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
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 设置

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

Loading…
Cancel
Save