Wish [SOLVED] Google Play Vision Services or Android Vision API wrapper

Xenno

Member
Licensed User
Hi,

Today, I just created an app using Google Play Service Vision in Android Studio. The text detection is done by processing the image produced by intent of ACTION_IMAGE_CAPTURE. The result is impressive compared to just-in-time detection using the API's CameraSource. I am unable to use this gms.vision in eclipse; which I still prefer to use than Android Studio. I really wish B4A could have the wrapper for this since B4A is an awesome Android development tool that really boost Android developers productivity.


Thanks,
 

Xenno

Member
Licensed User
Hi, moster67

Thank you for your response.

Yes, I am aware OpenCV and also Tesseract. From what I had learned, OpenCV and Tesseract can be complimentary in text detection: OpenCV does pre-processing to an image and hands off the result to Tesseract for text recognition. Google Play Service Vision offers simpler usage and without increasing app size cause the API is built in Google Play Services. The speed and detection result are good. Whenever pre-processing is needed I can just let the camera app in the phone to do that; so far I've never had a need to do that. Perhaps, Google Play Service Vision is just OpenCV + Tesseract. I don't know.


Thanks,
 

Xenno

Member
Licensed User
Hi again,

I found a solution by writing a wrapper library for my modified code written in Android Studio; thanks to tutorials and example code in this forum. This wrapper only performs text recognizing/scanning on an existing image file. It does not display anything.

BSTextOCRMin 1.0

Methods
  • Initialize(prmEventName As String)
  • Run(prmFileName As String)
    prmFileName should contains full file name, example value:
    B4X:
    fname = File.Combine(File.Combine(File.DirRootExternal, "Pictures"), "tmpscan.jpg")
Events
  • onSuccess(prmBlocks As String, prmLines As String, prmWords As String)
    They are the results in comma separated. Note: They may contain empty values.
  • onError(prmErrMsg As String)
  • onDone
Dependencies
B4X:
constraint-layout-1.0.1.aar
com.android.support:support-v4
com.android.support:appcompat-v7
com.android.support:design
com.google.android.gms:play-services-vision
Permisions
  • android.permission.READ_EXTERNAL_STORAGE
Installation
  • Extract "BSTextOCRMin.jar" and "BSTextOCRMin.xml" to B4A Additional Libraries folder.
  • Extract "add-res" onto project's folder.
Additional code
B4X:
#AdditionalRes: ..\add-res
#Extends: android.support.v7.app.AppCompatActivity
Put it below "#Region Activity Attributes".
"add-res" is a folder containing a few files required and the name might be changed to whatever you'd like. This folder should be placed in the same folder with "Files" and "Objects".

Recommended implementation
  • Call camera intent to get a picture file.
  • Enhance the picture (resize, sharpen, contrast, greyscale, or other) to expect better scan accuracy.
  • Scan the picture with this library and get result.
  • Optionally, delete the picture file after done.
I share this for B4A community to be used freely. Comments are welcomed. Thank you.


Cheers,
 

Attachments

  • BSTextOCRMin.zip
    50.2 KB · Views: 328
Cookies are required to use this site. You must accept them to continue using the site. Learn more…