dev
parent
13fe0d2ed9
commit
e7f9103739
@ -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;
|
||||||
|
// }
|
||||||
|
}
|
@ -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;
|
||||||
|
// }
|
||||||
|
}
|
Loading…
Reference in new issue