初始化git 基础代码
This commit is contained in:
29
heima-leadnews-test/tess4j-demo/pom.xml
Normal file
29
heima-leadnews-test/tess4j-demo/pom.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.heima</groupId>
|
||||
<artifactId>heima-leadnews</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>tess4j-demo</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.tess4j</groupId>
|
||||
<artifactId>tess4j</artifactId>
|
||||
<version>4.1.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.heima;
|
||||
|
||||
import net.sourceforge.tess4j.Tesseract;
|
||||
import net.sourceforge.tess4j.TesseractException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) throws TesseractException {
|
||||
|
||||
// 创建实例
|
||||
Tesseract tesseract = new Tesseract();
|
||||
|
||||
// 设置字体库路径
|
||||
tesseract.setDatapath("D:\\workspace\\tessdata");
|
||||
|
||||
// 设置语言
|
||||
tesseract.setLanguage("chi_sim");
|
||||
|
||||
File file = new File("D:\\143.png");
|
||||
|
||||
// 识别图片
|
||||
String result = tesseract.doOCR(file);
|
||||
|
||||
System.out.println("识别结果:" + result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user