本文介绍了Tesseract MacOS 打开数据文件时出错 ./tessdata/eng.traineddata的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

安装 Tesseract 以使用 Selenium WebDriver (Java) 进行一些 OCR 测试.

Installed Tesseract to do some OCR testing with Selenium WebDriver (Java).

这是我对 Tess4J 的 Maven 依赖

This is my maven dependency for Tess4J

<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId`enter code here`>tess4j</artifactId>
<version>2.0.0</version>
<scope>test</scope>
</dependency>

通过 brew 安装 Tesseract 3.03.00.设置 TESSDATA_PREFIX 到路径

Installed Tesseract 3.03.00 via brew. Setup TESSDATA_PREFIX to the path

/usr/local/Cellar/tesseract/3.04.00/share/tessdata

但是,实际上,当我执行以下命令时

But, actually, when I did the following command

sudo find / -name tessdata

我发现 tessdata 文件夹位于 4 个不同的位置.

I found that tessdata folder in 4 different locations.

/Users/<username>/Downloads/Tess4J/tessdata
/Users/<username>/tesseract-ocr/tessdata
/usr/local/Cellar/tesseract/3.04.00/share/tessdata
/usr/local/share/tessdata

现在我是否正确设置了 TESSDATA_PREFIX 感到困惑,因为我在尝试运行 junit 测试时收到以下错误

Confused now if I have setup my TESSDATA_PREFIX correctly or not since I am getting the following error when tried to run my junit test

    Error opening data file ./tessdata/eng.traineddata
    Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "tessdata" directory.`enter code here`
    Failed loading language 'eng'
    Tesseract couldn't load any languages!
    AdaptedTemplates != NULL:Error:Assert failed:in file adaptmatch.cpp, line 174

推荐答案

TESSDATA_PREFIX 应设置为tessdata的父目录,即/usr/local/Cellar/tesseract/3.04.00/share/.

TESSDATA_PREFIX should be set to the parent directory of tessdata, i.e., /usr/local/Cellar/tesseract/3.04.00/share/.

这篇关于Tesseract MacOS 打开数据文件时出错 ./tessdata/eng.traineddata的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 11:08