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

Status
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:

SS-2013-03-07_16.27.37.png


Recognized html:

SS-2013-03-07_16.26.38.png


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: https://www.b4x.com/android/forum/t...-android-application.27080/page-2#post-656725
 
Last edited:

laviniut

Active Member
Licensed User
Longtime 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 ?
 

laviniut

Active Member
Licensed User
Longtime User
i use this <code
Sub Camera1_Ready (Success As Boolean)
If Success Then
CamEx.SetContinuousAutoFocus
CamEx.SetJpegQuality(90)
CamEx.SetPictureSize(380, 480)
CamEx.CommitParameters
CamEx.StartPreview
Else
ToastMessageShow("Cannot open camera.", True)
End If
End Sub
code/>
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).
 

laviniut

Active Member
Licensed User
Longtime 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 ?
 

laviniut

Active Member
Licensed User
Longtime 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.
 

Magics

Member
Licensed User
Longtime User
Hi,
I followed this guide and i am registered on Ocrwebservice.com, but i can not figure out how to configure the application with my profile registered in ocrwebservice.com

I found this code in the project source:

B4X:
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
 

sconlon

Active Member
Licensed User
Longtime 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.

Thanks,
SC
 

Attachments

  • 1.jpg
    1.jpg
    8.5 KB · Views: 990

sconlon

Active Member
Licensed User
Longtime 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.

Thanks.
 

Tadeu Botelho

Member
Licensed User
Longtime 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
 

Attachments

  • Err.PNG
    Err.PNG
    76.6 KB · Views: 616

GMan

Well-Known Member
Licensed User
Longtime 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
 
Status
Not open for further replies.
Top