[Copied from "Google Play Vision Services or Android Vision API wrapper" in "Bugs and wishlist" forum]
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
Permisions
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
Cheers,
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")
- 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
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
- android.permission.READ_EXTERNAL_STORAGE
- Extract "BSTextOCRMin.jar" and "BSTextOCRMin.xml" to B4A Additional Libraries folder.
- Extract "add-res" onto project's folder.
B4X:
#AdditionalRes: ..\add-res
#Extends: android.support.v7.app.AppCompatActivity
"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.
Cheers,