【发布时间】:2017-10-13 08:35:50
【问题描述】:
为什么我的 Tesseract 实例要求我显式设置数据路径,但不想读取环境变量?
让我澄清一下:运行代码
ITesseract tesseract = new Tesseract();
String result = tesseract.doOCR(myImage);
抛出错误:
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.
我已经设置了我的环境变量,即做
echo $TESSDATA_PREFIX returns /usr/share/tessdata/
现在,在我的代码中明确设置路径变量,即:
Itesseract tesseract = new Tesseract();
tesseract.setDatapath("/usr/share/tessdata/");
String result = tesseract.doOCR(myImage);
完美运行。为什么? 我正在使用 Manjaro 17.0.5
【问题讨论】: