OCR Lib to B4A (REAL TIME)

Douglas Farias

Expert
Licensed User
Longtime User
Hi all.
i need a ocr lib (android vision is the best i think), where i can extract all content of one image and send to a server.

comprovante.jpg



i need get all words of this document, save this on a txt file and send to server.

I found some libraries in the forum, but either they are not in real time (offline) or they do not save the full text, only parts when we touch it.

ps: this lib need a button, like a camera, centered on bottom (center), when user press this button i need all content of the image (result string)

ps2: i need a example working

Offer: 50$ via paypal

thx
 

Johan Schoeman

Expert
Licensed User
Longtime User
Hi all.
i need a ocr lib (android vision is the best i think), where i can extract all content of one image and send to a server.

View attachment 53667


i need get all words of this document, save this on a txt file and send to server.

I found some libraries in the forum, but either they are not in real time (offline) or they do not save the full text, only parts when we touch it.

ps: this lib need a button, like a camera, centered on bottom (center), when user press this button i need all content of the image (result string)

ps2: i need a example working

Offer: 50$ via paypal

thx
This is an attempt to take care of your request - not that simple.
You will need to download some library files from here and copy them to your additional library folder:
https://www.dropbox.com/s/h030xduz0iws6gx/LibFilesForOCR.zip?dl=0

Attached the sample B4A project and the B4A library files.

Extract resource.zip and copy it to be on the same folder lever as that of the /Files and /Objects folders of the B4A project.
Take note of the B4A Manifest Files.

It uses the native camera to take a picture of the text and then passes the captured bitmap to be decoded in order to extract the text in the bitmap.

I have created the B4A project with B4A V6.50
You need to have DesignSupport (at least V2.00) installed and enable in the libraries tab of the B4A project

Save the image after it has been captured by clicking on the Save button. The captured bitmap then will be used to extract the text and return it to the B4A project via an event that will be raised (see sample project)

Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aOCR2
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\resource

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
   
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Button1 As Button
    Dim avocr As OCR_2
   
    Private EditText1 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
   
    Activity.LoadLayout("main")
    avocr.Initialize("avocr")
   
End Sub

Sub Activity_Resume
   

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click

    avocr.StartOCRReader

End Sub

Sub avocr_scan_failed(success As String)
   
    Log("Scanned text = " & success)
    EditText1.Text = " " & success
   
End Sub

Sub avocr_scanned_result(result As String)
    Log("Here in scanned_result")
    Log("Scanned text = " & result)
    EditText1.Text = result
   
End Sub

1.png



2.png


3.png


4.png
 

Attachments

  • b4aOCR_2.zip
    8.7 KB · Views: 593
  • OCR_2LibFiles.zip
    7.6 KB · Views: 556
  • resource.zip
    423 bytes · Views: 567

Douglas Farias

Expert
Licensed User
Longtime User
This is an attempt to take care of your request - not that simple.
You will need to download some library files from here and copy them to your additional library folder:
https://www.dropbox.com/s/h030xduz0iws6gx/LibFilesForOCR.zip?dl=0

Attached the sample B4A project and the B4A library files.

Extract resource.zip and copy it to be on the same folder lever as that of the /Files and /Objects folders of the B4A project.
Take note of the B4A Manifest Files.

It uses the native camera to take a picture of the text and then passes the captured bitmap to be decoded in order to extract the text in the bitmap.

I have created the B4A project with B4A V6.50
You need to have DesignSupport (at least V2.00) installed and enable in the libraries tab of the B4A project

Save the image after it has been captured by clicking on the Save button. The captured bitmap then will be used to extract the text and return it to the B4A project via an event that will be raised (see sample project)

Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aOCR2
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\resource

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
 
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Button1 As Button
    Dim avocr As OCR_2
 
    Private EditText1 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
 
    Activity.LoadLayout("main")
    avocr.Initialize("avocr")
 
End Sub

Sub Activity_Resume
 

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click

    avocr.StartOCRReader

End Sub

Sub avocr_scan_failed(success As String)
 
    Log("Scanned text = " & success)
    EditText1.Text = " " & success
 
End Sub

Sub avocr_scanned_result(result As String)
    Log("Here in scanned_result")
    Log("Scanned text = " & result)
    EditText1.Text = result
 
End Sub

View attachment 53706


View attachment 53709

View attachment 53708

View attachment 53707

thx Johan
i will test tomorow, today i have no time here.
but really thx, if works fine i send u the money.

u is saving me :)

thx again
 

Douglas Farias

Expert
Licensed User
Longtime User
This is an attempt to take care of your request - not that simple.
You will need to download some library files from here and copy them to your additional library folder:
https://www.dropbox.com/s/h030xduz0iws6gx/LibFilesForOCR.zip?dl=0

Attached the sample B4A project and the B4A library files.

Extract resource.zip and copy it to be on the same folder lever as that of the /Files and /Objects folders of the B4A project.
Take note of the B4A Manifest Files.

It uses the native camera to take a picture of the text and then passes the captured bitmap to be decoded in order to extract the text in the bitmap.

I have created the B4A project with B4A V6.50
You need to have DesignSupport (at least V2.00) installed and enable in the libraries tab of the B4A project

Save the image after it has been captured by clicking on the Save button. The captured bitmap then will be used to extract the text and return it to the B4A project via an event that will be raised (see sample project)

Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aOCR2
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\resource

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
 
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Button1 As Button
    Dim avocr As OCR_2
 
    Private EditText1 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
 
    Activity.LoadLayout("main")
    avocr.Initialize("avocr")
 
End Sub

Sub Activity_Resume
 

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click

    avocr.StartOCRReader

End Sub

Sub avocr_scan_failed(success As String)
 
    Log("Scanned text = " & success)
    EditText1.Text = " " & success
 
End Sub

Sub avocr_scanned_result(result As String)
    Log("Here in scanned_result")
    Log("Scanned text = " & result)
    EditText1.Text = result
 
End Sub

View attachment 53706


View attachment 53709

View attachment 53708

View attachment 53707


thx again for u lib Johan.
But it did not work very well here

Here is the image scaned (docs what i need send to server) (this photos is from my device, i take with camera app)

20170313_111644.jpg

20170313_111712.jpg



the 2 images show me
scan Failed: Found nothing to scan

i think the best option here is
https://www.b4x.com/android/forum/t...th-google-play-services-android-vision.70417/

- Add continuous auto focus to your lib (above)
- Use camera of your lib, it show the square And shows if the camera detected something, in real time (on the screen) but use this only to know if camera detected something, the scan can be later, with a image file.


Example (I'll try to explain, my English is very bad.)

1- i need open the app and press scan
2- i need see this, The camera detecting words in real time, on the screen. (with auto focus continuous)
1.png
3- i press some button on the camera and it save a image file.
4- later this we can scan the image file to extract the words.

is it possible?

thx again
 
Top