使用 Tess4j 时遇到的问题

Issue met when using Tess4j

我正在尝试使用 TessBaseAPICreate() 创建 TessBaseAPI 并遇到如下错误:

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)

我的代码如下

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();
    }

我在 net.sourceforge.tess4j 的依赖项中排除了 com.sun.jna 并添加了新的 jna 依赖项作为

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

这个问题有什么特别需要注意的吗? 谢谢

我在 Ubuntu 16.4 LTS 上的 tesseract 4.0 版(从源代码编译)和 tess4j 3.4.0 版遇到了同样的问题。由于找不到任何解决方案,我卸载了 tesseract 版本 4 并从 Ubuntu 存储库安装了版本 3.04。我把我的pom.xml里面的tess4j版本改成3.0.0,问题就解决了。

我猜,3.4.0 版的 tess4j 与 tesserct 4 版不兼容,毕竟它仍处于 alpha 阶段。

希望对您有所帮助。