Error msg when running the tess4j:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'tesseract':
dlopen(/opt/homebrew/Cellar/tesseract/5.3.0_1/lib/libtesseract.dylib, 9): no suitable image found. Did find:
/opt/homebrew/Cellar/tesseract/5.3.0_1/lib/libtesseract.dylib: mach-o, but wrong architecture
ENV:
MacBookPro, Apple M1, macOS BigSur, version: 11.6.4
Tesseract Version:
% brew info tesseract
==> tesseract: stable 5.3.0 (bottled), HEAD
tess4j version:5.5.0, and jna version:5.12.1
% mvn dependency:tree
... ...
[INFO] org.example:try:jar:1.0-SNAPSHOT
[INFO] +- net.sourceforge.tess4j:tess4j:jar:5.5.0:compile
[INFO] | +- net.java.dev.jna:jna:jar:5.12.1:compile
java code as your example:
ITesseract instance = new Tesseract();
String result = instance.doOCR(imageFile);
Thoughts:
the dynamic lib is right
tess4j or jna think that they should not load arm64/M1 version dynamic lib, they are wrong. Because in fact, it's correct to load arm64/M1 version dynamic lib.
Error msg when running the tess4j: Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'tesseract': dlopen(/opt/homebrew/Cellar/tesseract/5.3.0_1/lib/libtesseract.dylib, 9): no suitable image found. Did find: /opt/homebrew/Cellar/tesseract/5.3.0_1/lib/libtesseract.dylib: mach-o, but wrong architecture
ENV: MacBookPro, Apple M1, macOS BigSur, version: 11.6.4
Tesseract Version: % brew info tesseract ==> tesseract: stable 5.3.0 (bottled), HEAD
and it works well on command line
file /opt/homebrew/Cellar/tesseract/5.3.0_1/lib/libtesseract.5.dylib /opt/homebrew/Cellar/tesseract/5.3.0_1/lib/libtesseract.5.dylib: Mach-O 64-bit dynamically linked shared library arm64
tess4j version:5.5.0, and jna version:5.12.1 % mvn dependency:tree ... ... [INFO] org.example:try:jar:1.0-SNAPSHOT [INFO] +- net.sourceforge.tess4j:tess4j:jar:5.5.0:compile [INFO] | +- net.java.dev.jna:jna:jar:5.12.1:compile
java code as your example: ITesseract instance = new Tesseract();
String result = instance.doOCR(imageFile);
Thoughts: