Android Tutorial [Example] Add OCR features to your Android application

Not open for further replies.
This example demonstrates how you can use an OCR web service to recognize text in camera images.

The program allows you to take a picture and then send it to OCRWebService.

OCRWebService returns the recognized text in various formats. This is not a free service, however they offer a free trial and their prices are not high.

Camera picture:


Recognized html:


While the response is not perfect, the text can still be extracted.

The web service is a SOAP web service. The request is created by loading a template file and changing its fields. The response is then parsed and the data file is extracted.

In order to run this example you need to create an account and enter your user name and license key.

Updated example written by DonManfred:
Last edited:


Active Member
Licensed User
I tried OCR example with a trial account on OCRWebService. But the application is never focusing on camera and when send picture, application stopped with error main_buildrequest (java line: 337) and after is java.lang.OutOfMemoryError.
I have Galaxy S2 and android 4.1.2
Why is that ?


Active Member
Licensed User
i use this <code
Sub Camera1_Ready (Success As Boolean)
If Success Then
CamEx.SetPictureSize(380, 480)
ToastMessageShow("Cannot open camera.", True)
End If
End Sub
but the same error.
i think CameraExClass is not working good for me, because autofocus is not working, and the size of picture taken is same (maximum).


Active Member
Licensed User
I updated CameraEx class. Thank you. Now autofocus is working. And yes, size i wanted for picture is not suported. So i have to set other size. But when i use Log(CamEx.GetSupportedPicturesSizes()) the result is [Lb4a.example.cameraexclass$_camerasize;@41240d80
so, how can i get picture sizes ?


Active Member
Licensed User
Now OCR example with my trial account is working.
but CamEx.SetContinuousAutoFocus is not working. only CamEx.FocusAndTakePicture is working.
i can set and get results with 800x480 picture size.


Licensed User
I followed this guide and i am registered on, but i can not figure out how to configure the application with my profile registered in

I found this code in the project source:

Sub BuildRequest (date () As Byte) As String
Dim req As String = template
req.Replace req = ("$ USER $", user)
req.Replace req = ("$ $ LICENSE" license)
req.Replace req = ("$ FILENAME $", tempfile)
Dim about As StringUtils
req.Replace req = ("$ DATE $", su.EncodeBase64 (date))
req.Replace req = ("$ $ LANGUAGE", "ENGLISH")
req.Replace req = ("$ OUTPUT $", "HTML")
Return req
end Sub

The fields "eg: $ USER $ - $ LICENSE $" are to be filled?
Iif the answer is yes.
I could give an example, how do I compile it?

Thanks in advance, Magics


Active Member
Licensed User
I have been trying this example and sending various pictures some with only a few words on them and each in perfect focus. Each time I get a Job successful but no text is displayed and I can see that the 1.XML document contains an error "Recognition failed". It also advises to contact support but before doing that I thought I would ask here in case someone might know what is going wrong. I have attached the latest picture I sent, it is 640x480.



  • 1.jpg
    8.5 KB · Views: 667


Active Member
Licensed User
I contacted their support and got a reply back saying they no longer supported HTML as an output format. I changed it to TXT and it worked fine and the results were quite good.

I will try NJDudes's library as well and see how it performs.


Tadeu Botelho

Licensed User
I'm really in need of a professional OCR service on android.
I'm having a problem trying to compile the APK to use the OCR service in this example.
I did not change the sources. I just included my trial username and registration key to use the service.
Can someone help me identify?
Thank you


  • Err.PNG
    76.6 KB · Views: 303


Well-Known Member
Licensed User
The error message is clear: a class file was not found

Try to uncomment the line (its only a log entry) and try again
Not open for further replies.