使用tess4j时TessAPI1的UnsatisfiedLinkError

时间:2016-03-01 09:43:57

标签: java tesseract tess4j

我在Mac OS上工作,使用tesseract进行OCR。

我用自制软件安装了tesseract。

tesseract适用于命令行,java程序适用于Tesseract.getInstance()的基本示例。

但是因为我想获得每个字符的置信度值,所以我切换到使用TessAPI1并出现以下错误:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'TessResultRendererAddError': dlsym(0x7f9df9c38c20, TessResultRendererAddError): symbol not found
at com.sun.jna.Function.<init>(Function.java:208)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:536)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:513)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:499)
at com.sun.jna.Native.register(Native.java:1509)
at com.sun.jna.Native.register(Native.java:1396)
at com.sun.jna.Native.register(Native.java:1156)
at net.sourceforge.tess4j.TessAPI1.<clinit>(Unknown Source)
at TesseractWrapper.doOCR(TesseractWrapper.java:71)
at OCR.main(OCR.java:6)

错误发生在

handle = TessAPI1.TessBaseAPICreate();

代码如下所示:

            TessAPI1.TessBaseAPI handle;

            handle = TessAPI1.TessBaseAPICreate();
            new File(this.path);
            BufferedImage image = ImageIO.read(

            new FileInputStream(tiff)); // require jai-imageio lib to read TIFF
            ByteBuffer buf = ImageIOHelper.convertImageData(image);

            int bpp = image.getColorModel().getPixelSize();
            int bytespp = bpp / 8;
            int bytespl = (int) Math.ceil(image.getWidth() * bpp / 8.0);
            TessAPI1.TessBaseAPIInit3(handle,

            "tessdata", lang);
            TessAPI1.TessBaseAPISetPageSegMode(handle, TessAPI1.TessPageSegMode.

            PSM_AUTO);
            TessAPI1.TessBaseAPISetImage(handle, buf, image.getWidth(), image.getHeight(), bytespp, bytespl);

            TessAPI1.TessBaseAPIRecognize(handle,

            null);
            TessAPI1.TessResultIterator ri = TessAPI1.TessBaseAPIGetIterator(handle);

            TessAPI1.TessPageIterator pi = TessAPI1.TessResultIteratorGetPageIterator(ri);

            TessAPI1.TessPageIteratorBegin(pi);

我从其他一些问题中找到了这段代码,我想我需要的是获取和## iterator&#39;然后我可以逐个获得具有置信度值的角色。

0 个答案:

没有答案