无法加载库&libcesseract302':无法找到模块(Windows10)

时间:2016-06-09 07:59:26

标签: java exception-handling ocr tesseract

我们正在尝试使用图像处理为停车系统制作软件。我们使用OCR。我们打算在车辆离开和进入时使用网络摄像头获取车牌图像。然后我们将使用该数字来计算在公园内花费的时间和基于此的价格。 这是我的代码:

import java.io.File;
import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract1;
import net.sourceforge.tess4j.TesseractException;
public class TestOCR {

    public static void main(String[] args) {

                File imageFile = new File("C:"+File.separator+"projects"+File.separator+"plate.tif");
                //ITesseract instance = new Tesseract();  // JNA Interface Mapping
                ITesseract instance = new Tesseract1(); // JNA Direct Mapping

                try {
                    //String result = instance.doOCR(imageFile);
                    //stem.out.println(result);
                } catch (Exception e) {
                    System.err.println(e.getMessage());
                }


    }

}

当我运行时,我收到此错误:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'libtesseract302': The specified module could not be found.

    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:145)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:188)
    at com.sun.jna.Library$Handler.<init>(Library.java:123)
    at com.sun.jna.Native.loadLibrary(Native.java:255)
    at com.sun.jna.Native.loadLibrary(Native.java:241)
    at net.sourceforge.tess4j.TessAPI.<clinit>(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 net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
    at com.nadeem.app.ocr.TesseractExample.main(TesseractExample.java:16)

最初我们有一个NoSuchFieldError,在使用Maven修复后我们遇到了这个问题。

1 个答案:

答案 0 :(得分:0)

基本上,这个错误可能来自以下原因

  1. 未正确指定dll路径。您可以添加vm参数,如下所示。 -Djna.library.path=<folder_contains_dll>,此文件夹应该有三个dll文件gsdll64.dll,liblept168.dll和libtesseract302.dll
  2. 您应该安装VS2012的Visual C ++ Redistributable。 Windows 10默认情况下没有安装此功能。
  3. 您可以执行以下步骤以

    开头
    1. 如果未安装,则为VS2012安装Visual C ++ Redistributable
    2. https://github.com/mnadeem/ocr-tess4j-example
    3. 克隆项目
    4. 在eclipse中导入maven项目
    5. 运行Java类TesseractExample.java
相关问题