Skip to content

Commit

Permalink
add: fix pic executor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarrettluo committed Feb 17, 2024
1 parent 5c36d61 commit e44b9e3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ read [open issues](https://github.com/othneildrew/Best-README-Template/issues)

You can join our Wechat group if you are interested.

<img src="https://github.com/Jarrettluo/document-sharing-site/blob/main/images/WechatIMG112.jpeg" alt="imGroup" width="200">
<img src="https://github.com/Jarrettluo/all-docs-vue/blob/master/images/WechatIMG349.jpg" alt="imGroup" width="200">

> If you have any requirements for customization or private deployment, please feel free to contact me.
Expand Down Expand Up @@ -188,8 +188,7 @@ Jarrett Luo - [email protected]

If you find the project valuable, your support and appreciation are welcome!

<img src="https://github.com/Jarrettluo/document-sharing-site/blob/main/images/wechat.jpg" alt="wechat" width="200">
<img src="https://github.com/Jarrettluo/document-sharing-site/blob/main/images/wechat.jpg" alt="wechat" width="200">
<img src="https://github.com/Jarrettluo/all-docs-vue/blob/master/images/WechatIMG351.jpg" alt="imGroup" width="200">



Expand Down
10 changes: 3 additions & 7 deletions README_CH.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,9 @@ https://github.com/Jarrettluo/document-sharing-site.git
<!-- CONTRIBUTING -->
## 提交代码

目前仍然存在很多问题,欢迎一起来贡献!
欢迎加入微信交流群,一起玩😄,如果微信群二维码失效,可以加我微信拉你进群。

加入微信群,一起玩😄

<img src="https://github.com/Jarrettluo/document-sharing-site/blob/main/images/WechatIMG112.jpeg" alt="imGroup" width="200">
<img src="https://github.com/Jarrettluo/all-docs-vue/blob/master/images/WechatIMG349.jpg" alt="imGroup" width="200">

> 如果有二次开发或者私有部署需求,请联系我
Expand Down Expand Up @@ -193,9 +191,7 @@ https://github.com/Jarrettluo/document-sharing-site.git
Jarrett Luo - [email protected]

如果您觉得项目不错,欢迎赞赏支持!

<img src="https://github.com/Jarrettluo/document-sharing-site/blob/main/images/wechat.jpg" alt="wechat" width="200">
<img src="https://github.com/Jarrettluo/document-sharing-site/blob/main/images/wechat.jpg" alt="wechat" width="200">
<img src="https://github.com/Jarrettluo/all-docs-vue/blob/master/images/WechatIMG351.jpg" alt="imGroup" width="200">



Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/jiaruiblog/util/OcrUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
/**
* 如果未将tessdata放在根目录下需要指定绝对路径
* instance.setDatapath("the absolute path of tessdata");
* 对应的动态连接库下载地址:
* Downloads are available here https://github.com/ollydev/libtesseract/releases
* @ClassName OCRUtil
* @Description orc 离线识别
* @Author luojiarui
Expand Down Expand Up @@ -50,6 +52,28 @@ private static void tess4j() throws TesseractException, IOException {

}

public static void xx() {
try {
// TODO 该种方法只支持在windows下进行,而linux下需要so的动态连接库
// https://blog.csdn.net/qq_62357662/article/details/132430352
//获取本地图片
File file = new File("D:\\测试\\测试.png");
//创建Tesseract对象
ITesseract tesseract = new Tesseract();
//设置字体库路径 (你的chi_sim.traineddata放的个文件夹
tesseract.setDatapath("D:\\Tess4J\\tessdata");
//中文识别 chi_sim.traineddata的前缀
tesseract.setLanguage("chi_sim");
//执行ocr识别
String result = tesseract.doOCR(file);
//替换回车和tal键 使结果为一行
result = result.replaceAll("\\r|\\n","-").replaceAll(" ","");
System.out.println("识别的结果为:"+result);
} catch (Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) throws TesseractException, IOException {
tess4j();
}
Expand Down

0 comments on commit e44b9e3

Please sign in to comment.