为什么tessdata会引发异常? [英] Why is tessdata throwing Exceptions?

查看:459
本文介绍了为什么tessdata会引发异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有事情都在部署在Tomcat中的SpringBoot WAR文件中的 MAC 上进行:

All is happening on MAC in SpringBoot WAR file deployed in Tomcat:

我已经安装了tesseract 4.1.0(通过Mac上的brew).

I have tesseract 4.1.0 installed (via brew on Mac).

对于Tessdata-Mac上的OCR

For Tessdata - OCR on Mac

    <dependency>
        <groupId>net.sourceforge.tess4j</groupId>
        <artifactId>tess4j</artifactId>
        <version>4.4.0</version>
    </dependency>

我今天还将SpringBoot更新为:

I also updated SpringBoot today to:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.6.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>


现在,当我尝试在tessdata(SpringBoot中的Service方法)中运行OCR逻辑时,我首先遇到此错误(在Mac上):


Now, when I try to run the OCR logic in tessdata (Service method in SpringBoot), I am first getting this error (on the mac):

java.lang.NoSuchMethodError: com.sun.jna.Native.load(Ljava/lang/String;Ljava/lang/Class;)Lcom/sun/jna/Library;

然后,如果我再次尝试对西班牙png文件进行OCR,则会得到以下结果:

Then, if I try to OCR the Spanish png file again, I get this result:

"Could not initialize class net.sourceforge.tess4j.TessAPI"

发生崩溃的Tessdata代码似乎是:

The Tessdata code where the crash occurs seems to be:

public String doOCR(BufferedImage var1) throws TesseractException {
    return this.doOCR((BufferedImage)var1, (Rectangle)null);

我已经在这里看到有关此问题的帖子,但是我看到的所有帖子都是针对Windows的.我还尝试为jna加载依赖项,以防万一,但这没什么区别.

I've seen postings here about this problem, but all the ones I've seen are for Windows. I also tried to load the dependency for jna just in case, but that made no difference.

有人遇到并解决了这个问题吗?

Has anyone faced and fixed this issue?

问题似乎出在tess4j 4.4.0上.如果我将其恢复为最新版本,则一切都会恢复正常.

The problem appears to be with the tess4j 4.4.0. If I back it out to the last version, then things work again.

真的很感谢一些想法.

推荐答案

似乎您的应用程序正在加载旧的JNA版本. com.sun.jna.Native.load是JNA 5.x.x中的新增功能.因此,请确保您使用最新的JNA版本.

It seems your application is loading an old JNA version. com.sun.jna.Native.load is new in JNA 5.x.x. So make sure you use the latest JNA version.

https://groups.google.com/forum/# !topic/jna-users/VKbCGUcotkg

这篇关于为什么tessdata会引发异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆