Java图片OCR识别方案,Tess4j在mac m1 pro下部署踩坑以及示例代码
使用homebrew安装tesseract
brew install tesseract
验证版本
ivan@localhost tesseract.framework %tesseract --version
tesseract 5.4.1
leptonica-1.84.1
libgif 5.2.2 : libjpeg 8d (libjpeg-turbo 3.0.3) : libpng 1.6.44 : libtiff 4.7.0 : zlib 1.2.12 : libwebp 1.4.0 : libopenjp2 2.5.2
Found NEON
Found libarchive 3.7.7 zlib/1.2.12 liblzma/5.6.3 bz2lib/1.0.8 liblz4/1.10.0 libzstd/1.5.6
Found libcurl/8.7.1 SecureTransport (LibreSSL/3.3.6) zlib/1.2.12 nghttp2/1.62.0
导入maven依赖
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>5.6.0</version>
</dependency>
demo
@SpringBootTest(classes = Main.class)
@RunWith(SpringRunner.class)
public class MainTest {
@Autowired
private ResourceLoader resourceLoader;
@Autowired
private FileStorageService fileStorageService;
/**
* 识别本地图片中的文字
*/
@Test
public void test1() throws IOException, TesseractException {
String tessdata = Main.class.getClassLoader().getResource("tessdata").getPath();
ITesseract instance = new Tesseract();
instance.setDatapath(tessdata);
instance.setLanguage("chi_sim");
// 本地文件识别
Resource resource = resourceLoader.getResource("classpath:ocr_img/img1.jpg");
File file = resource.getFile();
String text = instance.doOCR(file);
System.out.println("text = " + text);
}
/**
* 识别MinIO图片中的文字
*/
@Test
public void test2() throws IOException, TesseractException {
String tessdata = Main.class.getClassLoader().getResource("tessdata").getPath();
ITesseract instance = new Tesseract();
instance.setDatapath(tessdata);
instance.setLanguage("chi_sim");
// 本地文件识别
// Resource resource = resourceLoader.getResource("classpath:ocr_img/img1.jpg");
// MinIO中图片识别
byte[] bytes = fileStorageService.downLoadFile("http://localhost:9000/black/2024/10/14/222.png");
BufferedImage bufferedImage = ImageIO.read(new ByteArrayInputStream(bytes));
String text = instance.doOCR(bufferedImage);
System.out.println("text = " + text);
}
}
如果报错
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
则可以把他需要的文件夹创建出来
mkdir -p /Users/ivan/Library/Frameworks/tesseract.framework/
拷贝找不见的文件到刚创建的目录
cp /opt/homebrew/Cellar/tesseract/5.4.1_1/bin/tesseract /Users/ivan/Library/Frameworks/tesseract.framework
libtesseract.dylib缺失错误
cp -r /usr/local/Cellar/tesseract/5.1.0/lib /usr/lib/
再试下就可以了
chi_sim.traineddata中文识别下载地址
https://raw.githubusercontent.com/tesseract-ocr/tessdata/main/chi_sim.traineddata