我已将 tess4j 测试应用程序配置为http://tess4j.sourceforge.net/tutorial/。
但是当我运行项目时,它给出了这个错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't obtain updateLastError method for class com.sun.jna.Native
at com.sun.jna.Native.initIDs(Native Method)
at com.sun.jna.Native.<clinit>(Native.java:148)
at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(Unknown Source)
at net.sourceforge.tess4j.TessAPI.<clinit>(Unknown Source)
at net.sourceforge.tess4j.Tesseract.init(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at tstest.Main.main(Main.java:22)
Java Result: 1
我找不到任何与 tesseract 相关的评论,如果有人在这个项目中做过,请帮忙。
这是我正在使用的示例代码:
import java.io.*;
import net.sourceforge.tess4j.*;
public class Main {
public static void main(String[] args) {
File imageFile = new File(System.getProperty("user.dir") + "\\images\\1.png");
Tesseract instance = Tesseract.getInstance(); //
try {
String result = instance.doOCR(imageFile);
System.out.println(result);
} catch (TesseractException e) {
System.err.println(e.getMessage());
}
}
}