全部 - 我正在尝试在我的 Java 项目中使用 tess4j。我已按照以下步骤操作 -
- 在创建项目时将/dist 和/lib 中的 jar 文件复制为外部 jar 文件。
- 将/tessdata 和 libtesseract302.dll 复制到项目根目录,甚至复制到项目的 src 文件夹中。
下面是代码(sf 中的 tess4j 示例代码)-
import java.io.File; import net.sourceforge.tess4j.*; public class ReadingImage { public static void main(String[] args) { File imageFile = new File("C:\\Documents and Settings\\T9SAUR\\My Documents\\Downloads\\Tess4J-1.1-src\\Tess4J\\eurotext.tif"); Tesseract instance = Tesseract.getInstance(); try { String result = instance.doOCR(imageFile); System.out.println(result); } catch (TesseractException e) { System.err.println(e.getMessage()); } } }
但是我的代码出错了。根据同一主题的另一篇文章,我检查了 JVM 版本(32 位)和 Eclipse 版本(32 位)。请让我知道哪里出错了。
最佳答案
如果您使用 Eclipse 启动,那么您需要指定与 Tesseract jar 关联的 native 库的位置。参见 How to set the java.library.path from Eclipse
关于java - 无法加载库 'libtesseract302' : The specified module could not be found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18200258/