将 Tess4J 作为 Eclipse 中的库包含在 Java 项目中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10815978/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 02:42:32  来源:igfitidea点击:

Including Tess4J to a Java project as library in Eclipse

javaandroidocrtesseract

提问by sschrass

I have an so far empty and clean Eclipse Java project. What do I have to do to use Tess4Jas library for my web service that I want to develop? Is it even possible to use it as library for an Android project? (would be shortcutting a lot)There is an issue regarding .tifwith android that I came across.

到目前为止,我有一个空的、干净的 Eclipse Java 项目。我需要做什么才能Tess4J将我要开发的 Web 服务用作库? 甚至可以将它用作 Android 项目的库吗?(会捷径很多).tif我遇到了一个关于android的问题。

Tess4J is a wrapper for native code, because tesseract-ocr is written in C/C++. That I've got so far. But how to include this wrapper into my project?

Tess4J 是原生代码的包装器,因为 tesseract-ocr 是用 C/C++ 编写的。我到目前为止。但是如何将此包装器包含到我的项目中?

I've googled a lot until I have decided to drop tesseract.Net, beacuse this project is badly maintained/documented and would force me to C# (which would be okay), but I didn't manage to get it to work, so I had to default to C/C++ (which is not okay) ;)

我在谷歌上搜索了很多,直到我决定放弃tesseract.Net,因为这个项目维护/记录不善,会迫使我使用 C#(这没关系),但我没能让它工作,所以我不得不默认为 C/C++(这不好);)

I'm kind of lost right now, so any help is welcome. regards.

我现在有点迷茫,所以欢迎任何帮助。问候。

Edit: followed the steps mentioned here(answer from nguyenq)

编辑:按照这里提到的步骤操作(来自 nguyenq 的回答)

1: new Eclipse workspace

1:新建Eclipse工作区

2: created a new dir called lib

2:创建一个名为的新目录 lib

3: copied \Tess4J\dist\tess4j.jar, \Tess4J\lib\jna.jarand \Tess4J\lib\jai_imageio.jarinto lib(2)

3:复制\Tess4J\dist\tess4j.jar\Tess4J\lib\jna.jar\Tess4J\lib\jai_imageio.jar进入lib(2)

4: created a new Java project in Eclipse

4:在Eclipse中新建一个Java项目

5: in project properties (4) I added the .jars from (3) to Java build path as external jars under libraries

5:在项目属性(4)中,我将(3)中的.jars添加到Java构建路径作为库下的外部jar

6: I copied the dir \tessdataand libtesseract302.dllinto the project root dir \workspace\project\

6:我复制的目录\tessdata,并libtesseract302.dll到项目的根目录\workspace\project\

7: I created a new class Mainand instantiated a Tesseract1 tesseract = new Tesseract1();for testing

7:我创建了一个新类Main并实例化了一个Tesseract1 tesseract = new Tesseract1();用于测试

8: I run the application but an Exception was thrown: Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'libtesseract302' Module not found

8:我运行应用程序但抛出异常: Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'libtesseract302' Module not found

Edit2:

编辑2:

7.1: I created a new class Mainand instantiated a Tesseract tesseract = new Tesseract.getInstance();for testing (source: here)

7.1:我创建了一个新类Main并实例化了一个Tesseract tesseract = new Tesseract.getInstance();用于测试(来源:这里

8.1: looked okay so far, but no logic implemented, just tried to build it.

8.1:目前看起来还不错,但没有实现逻辑,只是尝试构建它。

Edit3:

编辑3:

9: nope, doesn't work. Still UnsatisfiedLinkError. Could it may be an issue regarding 32-bit vs. 64-bit? I'am working on Win7 64bit.

9:不,不起作用。仍然不满意链接错误。这可能是 32 位与 64 位的问题吗?我正在使用 Win7 64 位。

采纳答案by nguyenq

Follow the steps described in the following link to get Tess4J to run in Eclipse:

按照以下链接中描述的步骤让 Tess4J 在 Eclipse 中运行:

http://sourceforge.net/projects/tess4j/forums/forum/1202294/topic/4506433

http://sourceforge.net/projects/tess4j/forums/forum/1202294/topic/4506433

I'm not sure the library would run on Android because it seems JNA support on the platform is not there yet.

我不确定该库是否会在 Android 上运行,因为平台上似乎还不支持 JNA。

If you want a .NET wrapper for Tesseract 3.01, take a look at https://github.com/charlesw/tesseract-ocr-dotnet.

如果您想要 Tesseract 3.01 的 .NET 包装器,请查看https://github.com/charlesw/tesseract-ocr-dotnet

回答by Sathirar

This problem causes because the .dll libraries does not support for 64bit version of Eclipse and JDK(with JRE). You have to install 32bit version of JDK and the Eclipse and repeat this process again. Working fine for me.

这个问题是因为 .dll 库不支持 64 位版本的 Eclipse 和 JDK(带有 JRE)。您必须安装 32 位版本的 JDK 和 Eclipse,然后再次重复此过程。对我来说工作得很好。