在Java中使用的tesseract

在Java中使用的tesseract

本文介绍了在Java中使用的tesseract API时java.lang.UnsatisfiedLinkError中的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Java JNA包装器的tesseract OCR API,但我不断收到java.lang.UnsatisfiedLinkError中的例外

I'm trying to use the Java JNA wrapper for Tesseract OCR API but I keep getting java.lang.UnsatisfiedLinkError exception

我下载了最新版本的

我确信,我使用32位JVM。以下是异常跟踪。

I made sure that I use a 32 bit JVM. Following is the exception trace.

   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:79)
at net.sourceforge.tess4j.TessAPI.<clinit>(TessAPI.java:40)
at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:360)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:273)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:205)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:189)
at net.sourceforge.tess4j.Main.main(Main.java:12)

这是我做的任何明显的失误?

Any obvious mistakes that I'm doing?

我使用的示例code从

I used the sample code from http://tess4j.sourceforge.net/codesample.html

包net.sourceforge.tess4j.example;

package net.sourceforge.tess4j.example;

进口的java.io.File;
进口net.sourceforge.tess4j *;

import java.io.File;import net.sourceforge.tess4j.*;

公共类TesseractEx​​ample {

public class TesseractExample {

public static void main(String[] args) {
    File imageFile = new File("eurotext.tif");
    Tesseract instance = Tesseract.getInstance();  // JNA Interface Mapping
    // Tesseract1 instance = new Tesseract1(); // JNA Direct Mapping

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

我添加了一个VM参数,如jna.library.path = $ {} pathtodll2,如果我使用的说法得到下面的错误,

I added a VM argument such as jna.library.path=${pathtodll2} and get the below error if I use the argument,

 Error: Could not find or load main class jna.library.path=D:\OCR\Tess4J\lib\win32-x86

我使用的是最新版本从Test4J项目,
2.0版(29 2015年3月)
- 升级到3.03的tesseract(r1050),这是符合的tesseract 3.03RC在Linux兼容
- 重构的tesseract类的扩展性和线程安全
- 对3.02的tesseract更新英文数据

I'm using the latest version from the Test4J project,Version 2.0 (29 March 2015)- Upgrade to Tesseract 3.03 (r1050), which is compatible with Tesseract 3.03RC on Linux- Refactor Tesseract class for extensibility and thread-safety- Update English language data for Tesseract 3.02

我在Windows 7中,32位机上运行它。 Java 7中。

I'm running it on Windows 7, 32 bit machine. Java 7.

在我尝试使用进程管理器,我无法看到的dll加载得到,但我不知道,因为异常被抛出的时候了。

When I try using the process Explorer I'm not able to see the dlls getting loaded but I'm not sure since the exception is thrown right away.

推荐答案

我更新到的包

的Visual C ++可再发行的VS2012是不够的。

Visual C++ Redistributable for VS2012 is not enough.

此工具:帮了我很多,以发现问题

This tool: http://www.dependencywalker.com/ helped me a lot to found the problem.

这篇关于在Java中使用的tesseract API时java.lang.UnsatisfiedLinkError中的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 02:44