@saudet I added this line to my build.gradle file:
javacpp group: 'org.bytedeco', name: 'tesseract-platform', version: '5.3.1-1.5.9-SNAPSHOT'
But I continued to get the same error running the app:
java.lang.UnsatisfiedLinkError: dlopen failed: library "libjnilept.so" not found
Instead of Android Studio, I decided to create an empty directory and put in the pom.xml file and the BasicExample.java file, exactly as they are in your documentation, along with the image file I’m trying to test. I then had to install Maven. I then ran the command from inside that new directory:
mvn compile exec:java -Dexec.args="ocr-01.jpg"
I got the following warning:
The POM for org.bytedeco:tesseract-platform:jar:5.3.1-1.5.9-SNAPSHOT is missing, no dependency information available
I also got the following error:
Failed to execute goal on project BasicExample: Could not resolve dependencies for project org.bytedeco.tesseract:BasicExample:jar:1.5.9-SNAPSHOT: The following artifacts could not be resolved: org.bytedeco:tesseract-platform:jar:5.3.1-1.5.9-SNAPSHOT (absent): Could not find artifact org.bytedeco:tesseract-platform:jar:5.3.1-1.5.9-SNAPSHOT
I adjusted the version numbers from 5.3.1-1.5.9-SNAPSHOT
to 5.2.0-1.5.8
and tried again. This time I got the following errors:
BasicExample.java:[4,44] cannot find symbol
symbol: class lept
location: package org.bytedeco.leptonica.global
BasicExample.java:[19,21] cannot find symbol
symbol: method pixRead(java.lang.String)
location: class BasicExample
BasicExample.java:[28,9] cannot find symbol
symbol: method pixDestroy(org.bytedeco.leptonica.PIX)
location: class BasicExample
I went back to Android Studio and changed my new build.gradle line to:
javacpp group: 'org.bytedeco', name: 'tesseract-platform', version: '5.2.0-1.5.8'
But I still got the following error:
java.lang.UnsatisfiedLinkError: dlopen failed: library "libjnilept.so" not found
I went back to the pom.xml file and added the following dependencies, hoping maybe they would help:
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>openblas-platform</artifactId>
<version>0.3.17-1.5.6</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>opencv-platform</artifactId>
<version>4.5.3-1.5.6</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>ffmpeg-platform</artifactId>
<version>4.4-1.5.6</version>
</dependency>
That changed nothing. I added:
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>leptonica</artifactId>
<version>1.78.0-1.5.1</version>
</dependency>
That changed the error to this:
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.1.0:java (default-cli) on project BasicExample: An exception occurred while executing the Java class. null: ExceptionInInitializerError: Type org.bytedeco.leptonica.presets.leptonica not present
I added this:
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>leptonica</artifactId>
<version>1.77.0-1.4.4</version>
</dependency>
But the error didn’t change.
I switched the version number of one of the dependencies:
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>leptonica</artifactId>
<version>1.82.0-1.5.8</version>
</dependency>
That changed the error to this:
Error opening data file ./eng.traineddata
I copied over my traineddata file from my Android Studio project to the terminal-executed Maven project and ran it again. Then I got these warnings:
Versions of org.bytedeco:javacpp:1.5.6 and org.bytedeco:leptonica:1.82.0-1.5.8 do not match.
Versions of org.bytedeco:javacpp:1.5.6 and org.bytedeco:tesseract:5.2.0-1.5.8 do not match.
Parameter not found: enable_new_segsearch
And I got this error:
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.1.0:java (default-cli) on project BasicExample: An exception occurred while executing the Java class. org/bytedeco/leptonica/global/lept: org.bytedeco.leptonica.global.lept
I really don’t know what versions of your code are compatible with what versions of your code, and I don’t know what libraries of yours need to be included that aren’t, and I’m really just taking shots in the dark with this.
Do you have any more suggestions on making the sample OCR code work? Preferably in an Android Studio app using Gradle?
Thanks – I really appreciate your help!