java - tess4j jna dll报错,求助
PHP中文网
PHP中文网 2017-04-18 10:50:47
0
0
905

使用最新的tess4j 3.3.0包,这个版本的dll文件应该是集成在jar包里面的,环境是win10,vc环境健全,使用eclips
代码:

import java.io.File;

import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

public class MainTest {

    public static void main(String[] args) {
        try {
            File imageFile = new File("C:\\Users\\Administrator\\Desktop\\eurotext.png");//图片位置
            ITesseract instance = new Tesseract();  // JNA Interface Mapping
            instance.setDatapath("C:\\javaTool\\Tess4J\\tessdata");//设置tessdata位置
            instance.setLanguage("eng");//选择字库文件(只需要文件名,不需要后缀名)
            String result = instance.doOCR(imageFile);//开始识别
            System.out.println(result);//打印图片内容
        } catch (TesseractException e) {
            e.printStackTrace();
        }

    }

}
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\Administrator\AppData\Local\Temp\jna-146731693\jna6221012064005976035.dll: 拒绝访问。
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1938)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1821)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1086)
    at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:761)
    at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:736)
    at com.sun.jna.Native.<clinit>(Native.java:131)
    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 MainTest.main(MainTest.java:15)

这是报错,在百度和google都查了很久,似乎都没有我这样的问题的。
一个简单的tess4j折腾了半天还是没解决,求助~

PHP中文网
PHP中文网

认证0级讲师

Antworte allen(0)
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage