需求
最近要做保单识别,调研了下很多收费的服务,本着开源的精神,打算使用开源tesseract来做个服务。使用JAVA+IDEA+MACOS开发;
安装tesseract
- 执行
brew reinstall tesseract
- 验证
tesseract --version
显示
安装成功!
下载中文库
- 下载中文训练库
- 放到/usr/local/share/tessdata目录下
测试图片识别
执行tesseract 图片地址 输出文件 -l chi_sim
在生成的解析文件中可以看到识别结果;
引用maven包
<!-- https://mvnrepository.com/artifact/net.sourceforge.tess4j/tess4j -->
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>5.2.1</version>
</dependency>
编写java样例
package com.hiklife.server.util;
import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import java.io.File;
/**
* @program: device-manager
* @description: 图片文字识别
* @author: HuiZhong
* @create: 2022-06-27 10:37
**/
public class OCRUtils {
public static String DATA_PATH;
public static String DEFAULT_LANG;
/**
* 根据图片文件进行识别
*
* @param imageFile 图片文件
* @param lang 指定语言库
* @return 识别文本信息
*/
public static String doOCRFromFile(File imageFile, String lang) throws Exception {
ITesseract instance = new Tesseract();
instance.setDatapath(DATA_PATH); //指定语言库目录
instance.setTessVariable("user_defined_dpi", "300");
instance.setLanguage(lang);
String result = instance.doOCR(imageFile);
return result;
}
/**
* main method
*/
public static void main(String[] args) {
//SpringApplication.run(OxOcrApp.class, args); //测试不用启用springboot
System.out.println("OxOcrApp 已启动");
try {
//设置训练库的位置
OCRUtils.DATA_PATH="/usr/local/share/tessdata/";
OCRUtils.DEFAULT_LANG="chi_sim"; //eng :英文 chi_sim :简体中文
String ocrText = OCRUtils.doOCRFromFile(new File("/Users/chz/Downloads/800.jpeg"),"chi_sim"); //指定要识别的图片文件
System.out.println("识别文本信息:"+ocrText); //OCR识别结果:图像转文本
//testCapture();
} catch (Exception e) {
e.printStackTrace();
}
}
}
运行调试
一般会出现无法找到文件的错误,只要从tesseract的安装目录/usr/local/Cellar/tesseract下,把对应的文件COPY到对应的目录下即可解决.
错误信息:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'tesseract':
dlopen(libtesseract.dylib, 0x0009): tried: '/Library/Java/JavaVirtualMachines/jdk-17.0.3.1.jdk/Contents/Home/bin/./libtesseract.dylib' (no such file), '/Library/Java/JavaVirtualMachines/jdk-17.0.3.1.jdk/Contents/Home/bin/../lib/libtesseract.dylib' (no such file), 'libtesseract.dylib' (no such file), '/usr/lib/libtesseract.dylib' (no such file), '/Users/chz/workspace/device-manager/libtesseract.dylib' (no such file)
dlopen(libtesseract.dylib, 0x0009): tried: '/Library/Java/JavaVirtualMachines/jdk-17.0.3.1.jdk/Contents/Home/bin/./libtesseract.dylib' (no such file), '/Library/Java/JavaVirtualMachines/jdk-17.0.3.1.jdk/Contents/Home/bin/../lib/libtesseract.dylib' (no such file), 'libtesseract.dylib' (no such file), '/usr/lib/libtesseract.dylib' (no such file), '/Users/chz/workspace/device-manager/libtesseract.dylib' (no such file)
dlopen(/Users/chz/Library/Frameworks/tesseract.framework/tesseract, 0x0009): tried: '/Users/chz/Library/Frameworks/tesseract.framework/tesseract' (no such file), '/System/Library/Frameworks/tesseract.framework/tesseract' (no such file)
dlopen(/Library/Frameworks/tesseract.framework/tesseract, 0x0009): tried: '/Library/Frameworks/tesseract.framework/tesseract' (no such file), '/System/Library/Frameworks/tesseract.framework/tesseract' (no such file)
dlopen(/System/Library/Frameworks/tesseract.framework/tesseract, 0x0009): tried: '/System/Library/Frameworks/tesseract.framework/tesseract' (no such file)
Native library (darwin-x86-64/libtesseract.dylib) not found in resource path (/Users/chz/workspace/device-manager/target/classes:/Users/chz/.m2/repository/com/google/zxing/core/3.1.0/core-3.1.0.jar:/Users/chz/.m2/repository/com/google/zxing/javase/3.1.0/javase-3.1.0.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot-starter/2.6.3/spring-boot-starter-2.6.3.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot/2.6.3/spring-boot-2.6.3.jar:/Users/chz/.m2/repository/org/springframework/spring-context/5.3.15/spring-context-5.3.15.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.6.3/spring-boot-autoconfigure-2.6.3.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.6.3/spring-boot-starter-logging-2.6.3.jar:/Users/chz/.m2/repository/ch/qos/logback/logback-classic/1.2.10/logback-classic-1.2.10.jar:/Users/chz/.m2/repository/ch/qos/logback/logback-core/1.2.10/logback-core-1.2.10.jar:/Users/chz/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.17.1/log4j-to-slf4j-2.17.1.jar:/Users/chz/.m2/repository/org/apache/logging/log4j/log4j-api/2.17.1/log4j-api-2.17.1.jar:/Users/chz/.m2/repository/org/slf4j/jul-to-slf4j/1.7.33/jul-to-slf4j-1.7.33.jar:/Users/chz/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/Users/chz/.m2/repository/org/springframework/spring-core/5.3.15/spring-core-5.3.15.jar:/Users/chz/.m2/repository/org/springframework/spring-jcl/5.3.15/spring-jcl-5.3.15.jar:/Users/chz/.m2/repository/org/yaml/snakeyaml/1.29/snakeyaml-1.29.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.6.3/spring-boot-starter-web-2.6.3.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.6.3/spring-boot-starter-json-2.6.3.jar:/Users/chz/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.13.1/jackson-databind-2.13.1.jar:/Users/chz/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.13.1/jackson-annotations-2.13.1.jar:/Users/chz/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.13.1/jackson-core-2.13.1.jar:/Users/chz/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.13.1/jackson-datatype-jdk8-2.13.1.jar:/Users/chz/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.13.1/jackson-datatype-jsr310-2.13.1.jar:/Users/chz/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.13.1/jackson-module-parameter-names-2.13.1.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.6.3/spring-boot-starter-tomcat-2.6.3.jar:/Users/chz/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.56/tomcat-embed-core-9.0.56.jar:/Users/chz/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.56/tomcat-embed-el-9.0.56.jar:/Users/chz/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.56/tomcat-embed-websocket-9.0.56.jar:/Users/chz/.m2/repository/org/springframework/spring-web/5.3.15/spring-web-5.3.15.jar:/Users/chz/.m2/repository/org/springframework/spring-beans/5.3.15/spring-beans-5.3.15.jar:/Users/chz/.m2/repository/org/springframework/spring-webmvc/5.3.15/spring-webmvc-5.3.15.jar:/Users/chz/.m2/repository/org/springframework/spring-aop/5.3.15/spring-aop-5.3.15.jar:/Users/chz/.m2/repository/org/springframework/spring-expression/5.3.15/spring-expression-5.3.15.jar:/Users/chz/.m2/repository/com/alibaba/fastjson/1.2.79/fastjson-1.2.79.jar:/Users/chz/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar:/Users/chz/.m2/repository/com/github/dozermapper/dozer-spring-boot-starter/6.5.2/dozer-spring-boot-starter-6.5.2.jar:/Users/chz/.m2/repository/com/github/dozermapper/dozer-core/6.5.2/dozer-core-6.5.2.jar:/Users/chz/.m2/repository/commons-beanutils/commons-beanutils/1.9.4/commons-beanutils-1.9.4.jar:/Users/chz/.m2/repository/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar:/Users/chz/.m2/repository/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar:/Users/chz/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.33/jcl-over-slf4j-1.7.33.jar:/Users/chz/.m2/repository/org/objenesis/objenesis/2.6/objenesis-2.6.jar:/Users/chz/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.5/jaxb-runtime-2.3.5.jar:/Users/chz/.m2/repository/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar:/Users/chz/.m2/repository/org/glassfish/jaxb/txw2/2.3.5/txw2-2.3.5.jar:/Users/chz/.m2/repository/com/sun/istack/istack-commons-runtime/3.0.12/istack-commons-runtime-3.0.12.jar:/Users/chz/.m2/repository/com/sun/activation/jakarta.activation/1.2.2/jakarta.activation-1.2.2.jar:/Users/chz/.m2/repository/com/github/dozermapper/dozer-spring4/6.5.2/dozer-spring4-6.5.2.jar:/Users/chz/.m2/repository/com/github/dozermapper/dozer-spring-boot-autoconfigure/6.5.2/dozer-spring-boot-autoconfigure-6.5.2.jar:/Users/chz/.m2/repository/org/projectlombok/lombok/1.18.22/lombok-1.18.22.jar:/Users/chz/.m2/repository/com/baomidou/mybatis-plus-boot-starter/3.4.1/mybatis-plus-boot-starter-3.4.1.jar:/Users/chz/.m2/repository/com/baomidou/mybatis-plus/3.4.1/mybatis-plus-3.4.1.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/2.6.3/spring-boot-starter-jdbc-2.6.3.jar:/Users/chz/.m2/repository/com/zaxxer/HikariCP/4.0.3/HikariCP-4.0.3.jar:/Users/chz/.m2/repository/org/springframework/spring-jdbc/5.3.15/spring-jdbc-5.3.15.jar:/Users/chz/.m2/repository/org/springframework/spring-tx/5.3.15/spring-tx-5.3.15.jar:/Users/chz/.m2/repository/com/baomidou/mybatis-plus-extension/3.4.1/mybatis-plus-extension-3.4.1.jar:/Users/chz/.m2/repository/com/baomidou/mybatis-plus-core/3.4.1/mybatis-plus-core-3.4.1.jar:/Users/chz/.m2/repository/com/baomidou/mybatis-plus-annotation/3.4.1/mybatis-plus-annotation-3.4.1.jar:/Users/chz/.m2/repository/com/github/jsqlparser/jsqlparser/3.2/jsqlparser-3.2.jar:/Users/chz/.m2/repository/org/mybatis/mybatis/3.5.6/mybatis-3.5.6.jar:/Users/chz/.m2/repository/org/mybatis/mybatis-spring/2.0.5/mybatis-spring-2.0.5.jar:/Users/chz/.m2/repository/io/springfox/springfox-boot-starter/3.0.0/springfox-boot-starter-3.0.0.jar:/Users/chz/.m2/repository/io/springfox/springfox-oas/3.0.0/springfox-oas-3.0.0.jar:/Users/chz/.m2/repository/io/swagger/core/v3/swagger-annotations/2.1.2/swagger-annotations-2.1.2.jar:/Users/chz/.m2/repository/io/swagger/core/v3/swagger-models/2.1.2/swagger-models-2.1.2.jar:/Users/chz/.m2/repository/io/springfox/springfox-spi/3.0.0/springfox-spi-3.0.0.jar:/Users/chz/.m2/repository/io/springfox/springfox-schema/3.0.0/springfox-schema-3.0.0.jar:/Users/chz/.m2/repository/io/springfox/springfox-core/3.0.0/springfox-core-3.0.0.jar:/Users/chz/.m2/repository/net/bytebuddy/byte-buddy/1.11.22/byte-buddy-1.11.22.jar:/Users/chz/.m2/repository/io/springfox/springfox-spring-web/3.0.0/springfox-spring-web-3.0.0.jar:/Users/chz/.m2/repository/io/github/classgraph/classgraph/4.8.83/classgraph-4.8.83.jar:/Users/chz/.m2/repository/io/springfox/springfox-spring-webmvc/3.0.0/springfox-spring-webmvc-3.0.0.jar:/Users/chz/.m2/repository/io/springfox/springfox-spring-webflux/3.0.0/springfox-spring-webflux-3.0.0.jar:/Users/chz/.m2/repository/io/springfox/springfox-swagger-common/3.0.0/springfox-swagger-common-3.0.0.jar:/Users/chz/.m2/repository/org/mapstruct/mapstruct/1.3.1.Final/mapstruct-1.3.1.Final.jar:/Users/chz/.m2/repository/io/springfox/springfox-data-rest/3.0.0/springfox-data-rest-3.0.0.jar:/Users/chz/.m2/repository/io/springfox/springfox-bean-validators/3.0.0/springfox-bean-validators-3.0.0.jar:/Users/chz/.m2/repository/io/springfox/springfox-swagger2/3.0.0/springfox-swagger2-3.0.0.jar:/Users/chz/.m2/repository/io/swagger/swagger-annotations/1.5.20/swagger-annotations-1.5.20.jar:/Users/chz/.m2/repository/io/swagger/swagger-models/1.5.20/swagger-models-1.5.20.jar:/Users/chz/.m2/repository/io/springfox/springfox-swagger-ui/3.0.0/springfox-swagger-ui-3.0.0.jar:/Users/chz/.m2/repository/com/fasterxml/classmate/1.5.1/classmate-1.5.1.jar:/Users/chz/.m2/repository/org/slf4j/slf4j-api/1.7.33/slf4j-api-1.7.33.jar:/Users/chz/.m2/repository/org/springframework/plugin/spring-plugin-core/2.0.0.RELEASE/spring-plugin-core-2.0.0.RELEASE.jar:/Users/chz/.m2/repository/org/springframework/plugin/spring-plugin-metadata/2.0.0.RELEASE/spring-plugin-metadata-2.0.0.RELEASE.jar:/Users/chz/.m2/repository/com/hiklife/info/attachment-biz/1.0.0/attachment-biz-1.0.0.jar:/Users/chz/.m2/repository/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar:/Users/chz/.m2/repository/com/alibaba/druid/1.2.8/druid-1.2.8.jar:/Users/chz/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/Users/chz/.m2/repository/mysql/mysql-connector-java/8.0.28/mysql-connector-java-8.0.28.jar:/Users/chz/.m2/repository/cn/hutool/hutool-all/5.7.20/hutool-all-5.7.20.jar:/Users/chz/.m2/repository/net/sourceforge/tess4j/tess4j/5.2.1/tess4j-5.2.1.jar:/Users/chz/.m2/repository/net/java/dev/jna/jna/5.11.0/jna-5.11.0.jar:/Users/chz/.m2/repository/com/github/jai-imageio/jai-imageio-core/1.4.0/jai-imageio-core-1.4.0.jar:/Users/chz/.m2/repository/org/apache/pdfbox/pdfbox/2.0.26/pdfbox-2.0.26.jar:/Users/chz/.m2/repository/org/apache/pdfbox/fontbox/2.0.26/fontbox-2.0.26.jar:/Users/chz/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar:/Users/chz/.m2/repository/org/apache/pdfbox/pdfbox-tools/2.0.26/pdfbox-tools-2.0.26.jar:/Users/chz/.m2/repository/org/apache/pdfbox/pdfbox-debugger/2.0.26/pdfbox-debugger-2.0.26.jar:/Users/chz/.m2/repository/org/apache/pdfbox/jbig2-imageio/3.0.4/jbig2-imageio-3.0.4.jar:/Users/chz/.m2/repository/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar:/Users/chz/.m2/repository/net/sourceforge/lept4j/lept4j/1.16.1/lept4j-1.16.1.jar:/Users/chz/.m2/repository/org/jboss/jboss-vfs/3.2.16.Final/jboss-vfs-3.2.16.Final.jar:/Users/chz/.m2/repository/org/jboss/logging/jboss-logging/3.4.3.Final/jboss-logging-3.4.3.Final.jar:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:301)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:461)
at com.sun.jna.Library$Handler.<init>(Library.java:192)
at com.sun.jna.Native.load(Native.java:622)
at com.sun.jna.Native.load(Native.java:596)
at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(LoadLibs.java:83)
at net.sourceforge.tess4j.TessAPI.<clinit>(TessAPI.java:42)
at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:441)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:237)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:209)
at com.hiklife.server.util.OCRUtils.doOCRFromFile(OCRUtils.java:31)
at com.hiklife.server.util.OCRUtils.main(OCRUtils.java:45)
Suppressed: java.lang.UnsatisfiedLinkError: dlopen(libtesseract.dylib, 0x0009): tried: '/Library/Java/JavaVirtualMachines/jdk-17.0.3.1.jdk/Contents/Home/bin/./libtesseract.dylib' (no such file), '/Library/Java/JavaVirtualMachines/jdk-17.0.3.1.jdk/Contents/Home/bin/../lib/libtesseract.dylib' (no such file), 'libtesseract.dylib' (no such file), '/usr/lib/libtesseract.dylib' (no such file), '/Users/chz/workspace/device-manager/libtesseract.dylib' (no such file)
at com.sun.jna.Native.open(Native Method)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:191)
... 11 more
Suppressed: java.lang.UnsatisfiedLinkError: dlopen(libtesseract.dylib, 0x0009): tried: '/Library/Java/JavaVirtualMachines/jdk-17.0.3.1.jdk/Contents/Home/bin/./libtesseract.dylib' (no such file), '/Library/Java/JavaVirtualMachines/jdk-17.0.3.1.jdk/Contents/Home/bin/../lib/libtesseract.dylib' (no such file), 'libtesseract.dylib' (no such file), '/usr/lib/libtesseract.dylib' (no such file), '/Users/chz/workspace/device-manager/libtesseract.dylib' (no such file)
at com.sun.jna.Native.open(Native Method)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:204)
... 11 more
Suppressed: java.lang.UnsatisfiedLinkError: dlopen(/Users/chz/Library/Frameworks/tesseract.framework/tesseract, 0x0009): tried: '/Users/chz/Library/Frameworks/tesseract.framework/tesseract' (no such file), '/System/Library/Frameworks/tesseract.framework/tesseract' (no such file)
at com.sun.jna.Native.open(Native Method)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:248)
... 11 more
Suppressed: java.lang.UnsatisfiedLinkError: dlopen(/Library/Frameworks/tesseract.framework/tesseract, 0x0009): tried: '/Library/Frameworks/tesseract.framework/tesseract' (no such file), '/System/Library/Frameworks/tesseract.framework/tesseract' (no such file)
at com.sun.jna.Native.open(Native Method)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:248)
... 11 more
Suppressed: java.lang.UnsatisfiedLinkError: dlopen(/System/Library/Frameworks/tesseract.framework/tesseract, 0x0009): tried: '/System/Library/Frameworks/tesseract.framework/tesseract' (no such file)
at com.sun.jna.Native.open(Native Method)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:248)
... 11 more
Suppressed: java.io.IOException: Native library (darwin-x86-64/libtesseract.dylib) not found in resource path (/Users/chz/workspace/device-manager/target/classes:/Users/chz/.m2/repository/com/google/zxing/core/3.1.0/core-3.1.0.jar:/Users/chz/.m2/repository/com/google/zxing/javase/3.1.0/javase-3.1.0.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot-starter/2.6.3/spring-boot-starter-2.6.3.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot/2.6.3/spring-boot-2.6.3.jar:/Users/chz/.m2/repository/org/springframework/spring-context/5.3.15/spring-context-5.3.15.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.6.3/spring-boot-autoconfigure-2.6.3.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.6.3/spring-boot-starter-logging-2.6.3.jar:/Users/chz/.m2/repository/ch/qos/logback/logback-classic/1.2.10/logback-classic-1.2.10.jar:/Users/chz/.m2/repository/ch/qos/logback/logback-core/1.2.10/logback-core-1.2.10.jar:/Users/chz/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.17.1/log4j-to-slf4j-2.17.1.jar:/Users/chz/.m2/repository/org/apache/logging/log4j/log4j-api/2.17.1/log4j-api-2.17.1.jar:/Users/chz/.m2/repository/org/slf4j/jul-to-slf4j/1.7.33/jul-to-slf4j-1.7.33.jar:/Users/chz/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/Users/chz/.m2/repository/org/springframework/spring-core/5.3.15/spring-core-5.3.15.jar:/Users/chz/.m2/repository/org/springframework/spring-jcl/5.3.15/spring-jcl-5.3.15.jar:/Users/chz/.m2/repository/org/yaml/snakeyaml/1.29/snakeyaml-1.29.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.6.3/spring-boot-starter-web-2.6.3.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.6.3/spring-boot-starter-json-2.6.3.jar:/Users/chz/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.13.1/jackson-databind-2.13.1.jar:/Users/chz/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.13.1/jackson-annotations-2.13.1.jar:/Users/chz/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.13.1/jackson-core-2.13.1.jar:/Users/chz/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.13.1/jackson-datatype-jdk8-2.13.1.jar:/Users/chz/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.13.1/jackson-datatype-jsr310-2.13.1.jar:/Users/chz/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.13.1/jackson-module-parameter-names-2.13.1.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.6.3/spring-boot-starter-tomcat-2.6.3.jar:/Users/chz/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.56/tomcat-embed-core-9.0.56.jar:/Users/chz/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.56/tomcat-embed-el-9.0.56.jar:/Users/chz/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.56/tomcat-embed-websocket-9.0.56.jar:/Users/chz/.m2/repository/org/springframework/spring-web/5.3.15/spring-web-5.3.15.jar:/Users/chz/.m2/repository/org/springframework/spring-beans/5.3.15/spring-beans-5.3.15.jar:/Users/chz/.m2/repository/org/springframework/spring-webmvc/5.3.15/spring-webmvc-5.3.15.jar:/Users/chz/.m2/repository/org/springframework/spring-aop/5.3.15/spring-aop-5.3.15.jar:/Users/chz/.m2/repository/org/springframework/spring-expression/5.3.15/spring-expression-5.3.15.jar:/Users/chz/.m2/repository/com/alibaba/fastjson/1.2.79/fastjson-1.2.79.jar:/Users/chz/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar:/Users/chz/.m2/repository/com/github/dozermapper/dozer-spring-boot-starter/6.5.2/dozer-spring-boot-starter-6.5.2.jar:/Users/chz/.m2/repository/com/github/dozermapper/dozer-core/6.5.2/dozer-core-6.5.2.jar:/Users/chz/.m2/repository/commons-beanutils/commons-beanutils/1.9.4/commons-beanutils-1.9.4.jar:/Users/chz/.m2/repository/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar:/Users/chz/.m2/repository/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar:/Users/chz/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.33/jcl-over-slf4j-1.7.33.jar:/Users/chz/.m2/repository/org/objenesis/objenesis/2.6/objenesis-2.6.jar:/Users/chz/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.5/jaxb-runtime-2.3.5.jar:/Users/chz/.m2/repository/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar:/Users/chz/.m2/repository/org/glassfish/jaxb/txw2/2.3.5/txw2-2.3.5.jar:/Users/chz/.m2/repository/com/sun/istack/istack-commons-runtime/3.0.12/istack-commons-runtime-3.0.12.jar:/Users/chz/.m2/repository/com/sun/activation/jakarta.activation/1.2.2/jakarta.activation-1.2.2.jar:/Users/chz/.m2/repository/com/github/dozermapper/dozer-spring4/6.5.2/dozer-spring4-6.5.2.jar:/Users/chz/.m2/repository/com/github/dozermapper/dozer-spring-boot-autoconfigure/6.5.2/dozer-spring-boot-autoconfigure-6.5.2.jar:/Users/chz/.m2/repository/org/projectlombok/lombok/1.18.22/lombok-1.18.22.jar:/Users/chz/.m2/repository/com/baomidou/mybatis-plus-boot-starter/3.4.1/mybatis-plus-boot-starter-3.4.1.jar:/Users/chz/.m2/repository/com/baomidou/mybatis-plus/3.4.1/mybatis-plus-3.4.1.jar:/Users/chz/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/2.6.3/spring-boot-starter-jdbc-2.6.3.jar:/Users/chz/.m2/repository/com/zaxxer/HikariCP/4.0.3/HikariCP-4.0.3.jar:/Users/chz/.m2/repository/org/springframework/spring-jdbc/5.3.15/spring-jdbc-5.3.15.jar:/Users/chz/.m2/repository/org/springframework/spring-tx/5.3.15/spring-tx-5.3.15.jar:/Users/chz/.m2/repository/com/baomidou/mybatis-plus-extension/3.4.1/mybatis-plus-extension-3.4.1.jar:/Users/chz/.m2/repository/com/baomidou/mybatis-plus-core/3.4.1/mybatis-plus-core-3.4.1.jar:/Users/chz/.m2/repository/com/baomidou/mybatis-plus-annotation/3.4.1/mybatis-plus-annotation-3.4.1.jar:/Users/chz/.m2/repository/com/github/jsqlparser/jsqlparser/3.2/jsqlparser-3.2.jar:/Users/chz/.m2/repository/org/mybatis/mybatis/3.5.6/mybatis-3.5.6.jar:/Users/chz/.m2/repository/org/mybatis/mybatis-spring/2.0.5/mybatis-spring-2.0.5.jar:/Users/chz/.m2/repository/io/springfox/springfox-boot-starter/3.0.0/springfox-boot-starter-3.0.0.jar:/Users/chz/.m2/repository/io/springfox/springfox-oas/3.0.0/springfox-oas-3.0.0.jar:/Users/chz/.m2/repository/io/swagger/core/v3/swagger-annotations/2.1.2/swagger-annotations-2.1.2.jar:/Users/chz/.m2/repository/io/swagger/core/v3/swagger-models/2.1.2/swagger-models-2.1.2.jar:/Users/chz/.m2/repository/io/springfox/springfox-spi/3.0.0/springfox-spi-3.0.0.jar:/Users/chz/.m2/repository/io/springfox/springfox-schema/3.0.0/springfox-schema-3.0.0.jar:/Users/chz/.m2/repository/io/springfox/springfox-core/3.0.0/springfox-core-3.0.0.jar:/Users/chz/.m2/repository/net/bytebuddy/byte-buddy/1.11.22/byte-buddy-1.11.22.jar:/Users/chz/.m2/repository/io/springfox/springfox-spring-web/3.0.0/springfox-spring-web-3.0.0.jar:/Users/chz/.m2/repository/io/github/classgraph/classgraph/4.8.83/classgraph-4.8.83.jar:/Users/chz/.m2/repository/io/springfox/springfox-spring-webmvc/3.0.0/springfox-spring-webmvc-3.0.0.jar:/Users/chz/.m2/repository/io/springfox/springfox-spring-webflux/3.0.0/springfox-spring-webflux-3.0.0.jar:/Users/chz/.m2/repository/io/springfox/springfox-swagger-common/3.0.0/springfox-swagger-common-3.0.0.jar:/Users/chz/.m2/repository/org/mapstruct/mapstruct/1.3.1.Final/mapstruct-1.3.1.Final.jar:/Users/chz/.m2/repository/io/springfox/springfox-data-rest/3.0.0/springfox-data-rest-3.0.0.jar:/Users/chz/.m2/repository/io/springfox/springfox-bean-validators/3.0.0/springfox-bean-validators-3.0.0.jar:/Users/chz/.m2/repository/io/springfox/springfox-swagger2/3.0.0/springfox-swagger2-3.0.0.jar:/Users/chz/.m2/repository/io/swagger/swagger-annotations/1.5.20/swagger-annotations-1.5.20.jar:/Users/chz/.m2/repository/io/swagger/swagger-models/1.5.20/swagger-models-1.5.20.jar:/Users/chz/.m2/repository/io/springfox/springfox-swagger-ui/3.0.0/springfox-swagger-ui-3.0.0.jar:/Users/chz/.m2/repository/com/fasterxml/classmate/1.5.1/classmate-1.5.1.jar:/Users/chz/.m2/repository/org/slf4j/slf4j-api/1.7.33/slf4j-api-1.7.33.jar:/Users/chz/.m2/repository/org/springframework/plugin/spring-plugin-core/2.0.0.RELEASE/spring-plugin-core-2.0.0.RELEASE.jar:/Users/chz/.m2/repository/org/springframework/plugin/spring-plugin-metadata/2.0.0.RELEASE/spring-plugin-metadata-2.0.0.RELEASE.jar:/Users/chz/.m2/repository/com/hiklife/info/attachment-biz/1.0.0/attachment-biz-1.0.0.jar:/Users/chz/.m2/repository/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar:/Users/chz/.m2/repository/com/alibaba/druid/1.2.8/druid-1.2.8.jar:/Users/chz/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/Users/chz/.m2/repository/mysql/mysql-connector-java/8.0.28/mysql-connector-java-8.0.28.jar:/Users/chz/.m2/repository/cn/hutool/hutool-all/5.7.20/hutool-all-5.7.20.jar:/Users/chz/.m2/repository/net/sourceforge/tess4j/tess4j/5.2.1/tess4j-5.2.1.jar:/Users/chz/.m2/repository/net/java/dev/jna/jna/5.11.0/jna-5.11.0.jar:/Users/chz/.m2/repository/com/github/jai-imageio/jai-imageio-core/1.4.0/jai-imageio-core-1.4.0.jar:/Users/chz/.m2/repository/org/apache/pdfbox/pdfbox/2.0.26/pdfbox-2.0.26.jar:/Users/chz/.m2/repository/org/apache/pdfbox/fontbox/2.0.26/fontbox-2.0.26.jar:/Users/chz/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar:/Users/chz/.m2/repository/org/apache/pdfbox/pdfbox-tools/2.0.26/pdfbox-tools-2.0.26.jar:/Users/chz/.m2/repository/org/apache/pdfbox/pdfbox-debugger/2.0.26/pdfbox-debugger-2.0.26.jar:/Users/chz/.m2/repository/org/apache/pdfbox/jbig2-imageio/3.0.4/jbig2-imageio-3.0.4.jar:/Users/chz/.m2/repository/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar:/Users/chz/.m2/repository/net/sourceforge/lept4j/lept4j/1.16.1/lept4j-1.16.1.jar:/Users/chz/.m2/repository/org/jboss/jboss-vfs/3.2.16.Final/jboss-vfs-3.2.16.Final.jar:/Users/chz/.m2/repository/org/jboss/logging/jboss-logging/3.4.3.Final/jboss-logging-3.4.3.Final.jar:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar)
at com.sun.jna.Native.extractFromResourcePath(Native.java:1145)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:275)
... 11 more
tesseract.framework 缺失错误
mkdir -p /Users/chz/Library/Frameworks/tesseract.framework/
cp /usr/local/Cellar/tesseract/5.1.0/bin/tesseract /Users/chz/Library/Frameworks/tesseract.framework/
libtesseract.dylib缺失错误
cp -r /usr/local/Cellar/tesseract/5.1.0/lib /usr/lib/
或者copy到jdk的lib目录下
最终结果
效果不是特别好!下一篇带来如何使用机器学习提高识别率。
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。