尝试在Java上运行tesseract项目,但是在字节上有一些奇怪的异常:
public static void main(String[] args) throws IOException {
File image = new File("/Users/user/Desktop/file.tiff");
BufferedImage ima = ImageIO.read(image);
ITesseract ocrEngine = new Tesseract();
ocrEngine.setDatapath("/Users/user/Downloads/Tess4J/tessdata");
try {
String text = ocrEngine.doOCR(ima);
System.out.println(text);
} catch (TesseractException e) {
System.err.println(e.getMessage());
}
}
有这个错误:
Picked up _JAVA_OPTIONS: -Xverify:none
Exception in thread "main" java.lang.UnsatisfiedLinkError: dlopen(/var/folders/fd/7093p25178n6_b8kp7qlfdhr0000gn/T/jna--1680431912/jna3169952727692915541.tmp, 9): no suitable image found. Did find:
/var/folders/fd/7093p25178n6_b8kp7qlfdhr0000gn/T/jna--1680431912/jna3169952727692915541.tmp: unknown file type, first eight bytes: 0x4D 0x5A 0x90 0x00 0x03 0x00 0x00 0x00
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(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 net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at autotest.OCR.main(OCR.java:23)