"Need to install JAI Image I/O package." 在 IntelliJ IDEA Scala SBT 项目中使用 tess4j 时出错

"Need to install JAI Image I/O package." error when using tess4j in IntelliJ IDEA Scala SBT project

下面的 tess4j JAR 是我在 IntelliJ IDEA 中的 Scala SBT 项目的一部分,也作为模块依赖项添加:

但是,我在尝试 运行 Scala 工作表中的以下代码时遇到 java.lang.RuntimeException: Need to install JAI Image I/O package. https://java.net/projects/jai-imageio/ 异常:

import java.io.File
import net.sourceforge.tess4j._

val imageFile = new File("LinkToJPGFile")
val instance = new Tesseract()
instance.setDatapath("MyTessdataFolder")

val result = instance.doOCR(imageFile)
print(result)

即使 jai-imageio-core-1.3.1.jar 已正确包含在项目中。

与其尝试单独添加 JAR,不如将以下行添加到您的 build.sbt:

// https://mvnrepository.com/artifact/net.sourceforge.tess4j/tess4j
libraryDependencies += "net.sourceforge.tess4j" % "tess4j" % "3.3.1"

或者您在 https://mvnrepository.com/artifact/net.sourceforge.tess4j/tess4j

找到的任何版本