Tesseract implementing a web service to trigger OCR actions

无人久伴 提交于 2019-12-13 05:09:19

问题


I am trying to implement a web service which triggers OCR actions of the server side.

Client code:

...
    sy = belgeArsivle(testServisIstegi, ab);
...    
      private static ServisYaniti belgeArsivle(com.ocr.ws.ServiceRequest serviceRequest,com.ocr.ws.Document document) {
            com.ocr.ws.ServiceRequest  service = new com.ocr.ws.OCRArsivWSService();
            com.ocr.ws.OCRArsivWS port = service.getOCRArsivWSPort();
            return port.docArchive(serviceRequest, document);
        }

When I run the code on the server side there is no problem. But whenever I call the web service method from the client I got this error code:

Exception: javax.xml.ws.soap.SOAPFaultException: Unable to load library 'libtesseract302': The specified module could not be found.

The working server-side code is:

public static void main(String[] args) {
        // TODO code application logic here

        File imageFile = new File("...OCR\\testTurWithBarcodeScanned.png");
        Tesseract instance = Tesseract.getInstance();
        try {
            String lang = "tur";
            instance.setLanguage(lang);

            String result = instance.doOCR(imageFile);
            System.out.println(result);

            // write in a file
            try {
                File file = new File("...MyOutputWithBarcode.txt");
                BufferedWriter out = new BufferedWriter(new FileWriter(file));
                out.write(result);
                out.close();
            } catch (IOException ex) {
            }

        } catch (TesseractException ep) {
            System.err.println(ep.getMessage());
        }

    }

I know that this error code is about Tesseract libraries. I put the corresponding .dll files (liblept168 and libtesseract302) under the client project's folder, added corresponding libraries (jna, jai_imageio, ghost4j_0.3.1), did neccessary changes in classpath but still getting this error.

I run a test code on the server side, it works fine. But the client side code is not working. Do I need to make some extra adjustment on the client side to run this web service?


回答1:


I found out that the actual problem was with the Tomcat Server. I had to put the jar files to the Tomcat's Sources under Properties, than voila!



来源:https://stackoverflow.com/questions/18890117/tesseract-implementing-a-web-service-to-trigger-ocr-actions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!