Issue met when using Tess4j

658 Views Asked by At

I am trying to create the TessBaseAPI using TessBaseAPICreate() and met the error as below:

java.lang.UnsatisfiedLinkError: Error looking up function 'TessPDFRendererCreateTextonly': dlsym(0x7fc93f349590, TessPDFRendererCreateTextonly): symbol not found
    at com.sun.jna.Function.<init>(Function.java:212)
    at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:541)
    at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:518)
    at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:504)
    at com.sun.jna.Native.register(Native.java:1655)
    at com.sun.jna.Native.register(Native.java:1529)
    at com.sun.jna.Native.register(Native.java:1252)
    at net.sourceforge.tess4j.TessAPI1.<clinit>(TessAPI1.java:41)
    at com.mail.service.Tess4jServiceImpl.<init>(Tess4jServiceImpl.java:23)

My code is as below

public class Tess4jServiceImpl {
    private String imageFilePath;
    private TessAPI1.TessBaseAPI tessBaseAPI;
    private static String tessDataPath = "***/tessdata/";
    public Tess4jServiceImpl(String imageFilePath){
        this.imageFilePath = imageFilePath;
        tessBaseAPI = TessAPI1.TessBaseAPICreate();
    }

I have excluded com.sun.jna in the dependency of net.sourceforge.tess4j and added new jna dependency as

<dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <version>4.2.1</version>
        </dependency>

Is there anything special i have to notice for this issue? Thanks.

1

There are 1 best solutions below

1
On BEST ANSWER

I had the same problem with tesseract version 4.0 (compiled from source) and tess4j version 3.4.0 on Ubuntu 16.4 LTS. As I couldn't find any solution, I have uninstalled tesseract version 4 and installed the version 3.04 from the Ubuntu repositories. I changed the tess4j version in my pom.xml to 3.0.0 and the problem was solved.

I guess, tess4j with version 3.4.0 is not compatible with tesserct version 4, which is, after all, still in alpha.

I hope this helps.