我刚刚从 http://tess4j.sourceforge.net/ 下载了 Tess4J并将其导入 netbeans。我正在关注 this url我正确地遵循了每一步,但是当我尝试执行时,我遇到了以下错误。
错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: The specified module could not be found.
at com.sun.jna.Native.open(Native Method)
at com.sun.jna.Native.open(Native.java:1759)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:260)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
at com.sun.jna.Library$Handler.<init>(Library.java:147)
at com.sun.jna.Native.loadLibrary(Native.java:412)
at com.sun.jna.Native.loadLibrary(Native.java:391)
at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(LoadLibs.java:75)
at net.sourceforge.tess4j.TessAPI.<clinit>(TessAPI.java:42)
at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:367)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:280)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:212)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:196)
at recognizer.Recognizer.main(Recognizer.java:17)
Java Result: 1
我搜索了一下,发现有人建议更新到 Visual Visual C++ Redistributable Packages for Visual Studio 2013我这样做了,但结果没有帮助,我仍然遇到同样的问题。我不知道我在下面做错了什么是我的代码。
代码:
import java.io.*;
import net.sourceforge.tess4j.*;
public class Recognizer {
public static void main(String[] args) {
File imageFile = new File("image.jpg");
Tesseract instance = new Tesseract();//
try {
String result = instance.doOCR(imageFile);
System.out.println(result);
} catch (TesseractException e) {
System.err.println(e.getMessage());
}
}
}
最佳答案
似乎它没有加载 native Dll。
Tesseract DLL 是使用 VS2015 构建的,因此依赖于 Visual C++ 2015 Redistributable Packages .安装它。
Tesseract、Ghostscript 和 Leptonica Windows 32 位和 64 位 DLL 分别嵌入在 tess4j.jar 和 lept4j.jar 中。因此,请确保将它们放在类路径中。
确保类路径上有所有依赖库(库可以在 Your_downloaded_Tess4J_folder\lib 中找到)
确保类路径上有“tessdata”文件夹(“tessdata”文件夹可以在 Your_downloaded_Tess4J_folder 中找到)。
请阅读Tess4J Tutorial以便更好地理解。
关于java.lang.UnsatisfiedLinkError : The specified module could not be found 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43522582/