1
votes

I am working on core application in blackberry in which I need to perform OCR task.

Till now I have searched and found out that there are few online API's like ABBY which allows to read image and returns text file, but they are not free, after a few trails they charge a amount.

Can I perform Optical character recognition on device end completely with server implementation. Please suggest me for this task.

EDITED: I am working with the following code

public String serverUrl = "http://cloud.ocrsdk.com";
    static final String BOUNDARY = "----------V2ymHFg03ehbqgZCaKO6jy";


    public byte[] send() throws Exception
    {
        HttpConnection hc = null;

        InputStream is = null;

        ByteArrayOutputStream bos = new ByteArrayOutputStream();

        byte[] res = null;

        try
        {
            hc = (HttpConnection) Connector.open(serverUrl+"/processImage/"+"language=en&exportFormat=txt");

            hc.setRequestProperty("Content-Type", "multipart/image-JPG; boundary=" + BOUNDARY);
            /*hc = (HttpConnection) Connector.open(SERVICE_URL);
            hc.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);
            hc.setRequestProperty(PARAM_IMAGE, "");
            hc.setRequestProperty(PARAM_LANGUAGE, lang);
            hc.setRequestProperty(PARAM_APIKEY, key);*/

            hc.setRequestMethod(HttpConnection.POST);

            OutputStream dout = hc.openOutputStream();

            dout.write(raw);

            dout.close();

            int ch;
            StringBuffer sb= new StringBuffer();
            is = hc.openInputStream();

            while ((ch = is.read()) != -1)
            {
                bos.write(ch);
                sb.append(ch);
            }
            System.out.println(sb);
            res = bos.toByteArray();
        }
        catch(Exception e){
            e.printStackTrace();
        }
        finally
        {
            try
            {
                if(bos != null)
                    bos.close();

                if(is != null)
                    is.close();

                if(hc != null)
                    hc.close();
            }
            catch(Exception e2)
            {
                e2.printStackTrace();
            }
        }
        return res;
    }

But even with this code its not working. I am getting 200 as response code after making HTTP request. but not getting perfect response as expected the text. In response I am getting ERROR PAGE of ABBYY. http://cloud.ocrsdk.com/GenericError.htm?aspxerrorpath=/processImage/language=English&exportFormat=txt;connectionhandler=httpc

Please suggest me :(

2

2 Answers

2
votes

If I understand you correctly you want to implement your own OCR application for BlackBerry device, and you want to send image to server, recognize it and send text file back to the device.

There's an open source OCR implementation, check this link: http://en.openocr.org/

Use this information to implement OCR server functionality. BlackBerry client functionality will be trivial. Just use HTTPConnection class and stream classes to upload/download files to and from the server.

EDIT:

Noticed that there's no direct source code download available from openocr.org. They need an email request to be sent to [email protected], and they will consider it. I think it is not a convenient way.

Let's check another sources, for instance Tesseract OCR. By the link you can download source codes and build OCR application. Then implement server-wrapper for this application which works via HTTP, and write blackberry client that uploads image file via HTTP to this server, and gets result text file.

0
votes

I am done with the task OCR.

The code which I get from GitHub for Java is incomplete or may be not working from my side. I have perform the implementation of OCR functionality on my PHP server. And its working successfully.