本文介绍了Tesseract实现Web服务以触发OCR操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现一个触发服务器端OCR动作的Web服务.

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

客户代码:

...
    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);
        }

当我在服务器端运行代码时,没有问题.但是,每当我从客户端调用Web服务方法时,都会收到以下错误代码:

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());
        }

    }

我知道此错误代码与Tesseract库有关.我在客户端项目的文件夹下放置了相应的.dll文件(liblept168和libtesseract302),添加了相应的库(jna,jai_imageio,ghost4j_0.3.1),对类路径进行了必要的更改,但仍然收到此错误.

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.

我在服务器端运行了一个测试代码,它工作正常.但是客户端代码无法正常工作.我是否需要在客户端进行一些额外的调整才能运行此Web服务?

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?

推荐答案

我发现实际问题出在Tomcat服务器上.我不得不将jar文件放到属性"下的Tomcat的源代码"中,而不是瞧!

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!

这篇关于Tesseract实现Web服务以触发OCR操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 11:22
查看更多