Issue
I'm trying to use Tesseract OCR in a web application. The code runs fine when I run it as a JAVA application. But as soon as I put the same code in my web application, it doesn't work anymore. If put the function in the servlet, tomcat doesnt start at all. 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
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());
}
Solution
Just some pointers I think you should check, in case if you are using Tess4j in Web Based Project:
- Put all your jars in WEB-INF > lib folder.
- The *.dll files that are provided along Tess4j must be in system32 folder (Windows). I don't know for other OS.
- Set the instance path using
instance.setDataPath()method. It must point to folder containing tessdata folder. - Set the language using
instance.setLanguage()in case your tessdata has multiple languages training data in them.
Crosscheck above steps and try running again.
Answered By - DarkHorse
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.