【发布时间】:2013-09-05 14:11:38
【问题描述】:
我试图让 tess4j 在一个简单的测试应用程序中工作以对 pdf 文件执行 OCR,但收到以下错误并且无法弄清楚如何解决它:
Exception in thread "main" java.lang.RuntimeException: Unable to load library 'gs': dlopen(libgs.dylib, 9): image not found
Please download, install GPL Ghostscript from http://sourceforge.net/projects/ghostscript/files and/or set the appropriate environment variable.
at net.sourceforge.vietocr.PdfUtilities.convertPdf2Tiff(Unknown Source)
at net.sourceforge.vietocr.ImageIOHelper.getIIOImageList(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at Test.main(Test.java:11)
我已经让 eclipse 打印出我看到的路径文件,它包含 /usr/loca/bin/gs(根据需要使用 which gs 检查是否正确),我可以愉快地从终端运行 gs。关于如何让它发挥作用的任何想法?
代码显示在图片中https://dl.dropboxusercontent.com/u/61920208/Screen%20Shot%202013-09-02%20at%2013.44.24.png
提前感谢您的帮助
【问题讨论】:
-
您在 OSX 上安装的 GS 是否包含“libgs.dylib”文件?确保 Path 变量包含该文件的父目录的路径。
-
我已经搜索了我的整个 mac,但在任何地方都找不到 libgs.dylib 文件。如果有帮助,我正在运行 GPL Ghostscript 9.07 (2013-02-14)
-
Ghost4J,Tess4J 用于将 PDF 转换为图像的 Ghostscript API 的 Java 包装器,需要 GS 动态库,在 Windows 上以 DLL 形式提供,在 Linux 上以 SO 形式提供,在 OSX 上以 DYLIB 形式提供。您可能需要重新安装 GS 才能获取该文件。
-
或build它。
-
感谢 nguyenq,我设法通过重新安装摆脱了这个错误。将添加这样的答案
标签: java eclipse macos path tesseract