在Linux下运行tess4j(tessreact java包装器)

时间:2014-08-20 12:16:20

标签: java linux tesseract tess4j

在Linux服务器上tesseract 3.0.2正确安装了库:

[root@XXX as]# rpm -qa | grep ".*tess.*"
tesseract-3.02-alt1.r723

尝试运行tess4j包装器时,遇到此异常:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'TessBaseAPICreate': /usr/lib64/libtesseract.so.3.0.2: undefined symbol: TessBaseAPICreate
        at com.sun.jna.Function.<init>(Function.java:208)
        at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:536)
        at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:513)
        at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:499)
        at com.sun.jna.Library$Handler.invoke(Library.java:199)
        at com.sun.proxy.$Proxy0.TessBaseAPICreate(Unknown Source)
        at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:284)
        at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:219)
        at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:200)
        at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:184)
        (... private code ...)

在异常文件中提到:

[root@XXX as]# test -e /usr/lib64/libtesseract.so.3.0.2  && echo "Found" || echo "Not found"
Found

tess4j代码中抛出异常的地方如下:

/**
 * Initializes Tesseract engine.
 */
private void init() {
    pageNum = 0;
    api = TessAPI.INSTANCE;
    handle = api.TessBaseAPICreate();  // ERROR HERE, line #184
    api.TessBaseAPIInit2(handle, datapath, language, ocrEngineMode);
    api.TessBaseAPISetPageSegMode(handle, psm);
}

我不知道如何解决它,因为所有库版本都相同,它在windows下完美运行。

1 个答案:

答案 0 :(得分:0)

嗯,这是使用过的操作系统(“ALT Linux Centaurus 6.0”)中的软件包的特殊问题。从该操作系统下的源重建tesseract包后,一切都变好了。