简体   繁体   English

Tesseract OCR在Web项目中不起作用

[英]Tesseract OCR not working in Web Project

I'm trying to use Tesseract OCR in a web application. 我正在尝试在Web应用程序中使用Tesseract OCR。 The code runs fine when I run it as a JAVA application. 当我将其作为JAVA应用程序运行时,代码运行良好。 But as soon as I put the same code in my web application, it doesn't work anymore. 但是,一旦我将相同的代码放入Web应用程序中,它就不再起作用。 If put the function in the servlet, tomcat doesnt start at all. 如果将函数放在servlet中,tomcat根本不会启动。 If I call it from a separate class by creating an object, On debugging I find that the object does not get created at all. 如果我通过创建对象从单独的类中调用它,那么在调试时,我发现该对象根本不会被创建。 I have included all the jars necessary. 我已经包括了所有必要的罐子。

Code in servlet Servlet中的代码

OCRFullTrial ot = new OCRFullTrial();
ot.imgOCR();

Inside other class 在其他班级内

public void imgOCR(){
    File imageFile = new File("D:\\OCRTesting\\0.jpg");

try {
     ITesseract instance = new Tesseract();  //            
    System.out.println("1");

} catch (Exception e) {
    System.err.println(e.getMessage());
}

Just some pointers I think you should check, in case if you are using Tess4j in Web Based Project: 我认为应该检查一下一些指针,以防万一,如果您在基于Web的项目中使用Tess4j:

1) Put all your jars in WEB-INF > lib folder.
2) The *.dll files that are provided along Tess4j must be in system32 folder (Windows). I don't know for other OS.
3) Set the instance path using instance.setDataPath() method. It must point to folder containing tessdata folder. 
4) Set the language using instance.setLanguage() incase your tessdata has multiple languages training data in them.

Crosscheck above steps and try running again. 交叉检查上述步骤,然后尝试再次运行。 Hope it works 希望能奏效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM