I am implementing an OCR system. When I placed dll files on the java class path it gives the following error.
Exception in thread \"main\" java.lang.UnsatisfiedL
Find below a small working example application. From there you could start to investigate and pick the parts you need.
Assuming the following structure and files
pom.xml
sample.gif
src/main/java/sub/optimal/tess4j/Demo.java
tessdata/eng.traineddata
pom.xml
4.0.0
sub.optimal
Tess4JDemo
1.0-SNAPSHOT
jar
UTF-8
1.8
1.8
2.3
net.sourceforge.tess4j
tess4j
3.0.0
jar
org.ghost4j
ghost4j
1.0.0
org.apache.maven.plugins
maven-shade-plugin
${maven.shade.version}
org.codehaus.mojo
exec-maven-plugin
1.4.0
java
sub.optimal.tess4j.Demo
sample.gif
src/main/java/sub/optimal/tess4j/Demo.java
package sub.optimal.tess4j;
import java.io.File;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;
public class Demo {
public static void main(String[] args) {
File imageFile = new File("sample.gif");
Tesseract instance = new Tesseract();
try {
String result = instance.doOCR(imageFile);
System.out.println(result);
} catch (TesseractException e) {
e.printStackTrace(System.err);
}
}
}
tessdata/eng.traineddata
was downloaded from https://tesseract-ocr.googlecode.com/files/eng.traineddata.gz (don't forget to uncompress the file)
Running this small example with mvn exec:java
produce the following output
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ Tess4JDemo ---
Hello OCR!