B4A Library OCR

NJDude

Expert
Licensed User
This library will extract text from images via OCR.

Requirements:

1- B4A 3.82.

2- Get an API Key HERE (you need to create an account).

3- Internet connection.


How to install:

- Copy the OCR.jar and OCR.xml to your additional libraries directory.

Usage:
B4X:
Private myOCR As OCR

myOCR.Initialize(Me, "myOCR", "<YOUR_API_KEY>")

myOCR.ExtractFromImage(File.Combine(File.DirAssets, "sample.gif"), "", "scene", 20000)
That's it.

You can upload an image or reference one via a URL, the service will return the extracted text (if any).


NOTES:

- OCR is not perfect, so, expect some weird results or no results at all.

- It is a free service but some quotas apply.


For more details, see the attached project.
 

Attachments

Last edited:

NJDude

Expert
Licensed User
The default is "photo", but in some cases you have to use the other ones depending on what kind of picture you are submitting, you will see that in some cases the default (photo) will not return any text and by changing it to scan (or any other) it will, you will have to try.
 

NJDude

Expert
Licensed User
I don't think that the language has anything to do but I will add the timeout parameter anyway.
 

NJDude

Expert
Licensed User
Very cool! I fed it a php source code file saved as a gif. It did a great job for a work in progress. Do you know if it works better with a particular Windows font and size? I'd like to play around with it some more.
It is hard to say, OCR can be very picky, but, so far, during testing it did a decent job.
 

NJDude

Expert
Licensed User
One thing I can tell you is that any OCR works better if the image (text especially) is using high contrast, the extraction is better, there's no perfect OCR.
 

Robert Vermulen

Member
Licensed User
Hi,

I have tested in android 2.3.6 it is working fine, but in 4.0.4 its showing error " javax.net.ssl.sslpeerunverifiedexception no peer certificate ".

plz help me to fix this.

Thanks
 

NJDude

Expert
Licensed User
Are you trying on a real device or the emulator?, I don't have that problem on any of my devices.
 

LucaMs

Expert
Licensed User
I obviously appreciate (and "Like"d) this in your library and your job, NJDude.

But I'm thinking about how many times we rest to external sites for our apps: and if the site in question shut?

I should open a thread for this, although I do not know exactly where.

I'll do it in chit-chat with a reference in the questions
 

josmaroal

Member
Licensed User
Saludos NJDude, I can run your program, get this message:
Generating R file. Error
AndroidManifest.xml:10: error: No resource identifier found for attribute 'xlargeScreens' in package 'android'
Please help
 
Top