This is a "shortcut" wrap for this project. I have zipped the complete B4A project (and it includes the aar, jar, and xml files). Copy the aar, jar, and xml files to your additional library folder.
The zipped project is here:
https://drive.google.com/file/d/0B4g9tud5lvjgSHE3VFc0aEZjUHc/view?usp=sharing
Libraries enabled:
Take note of the B4A manifest file:
Take note of the "resource" and "DemoRes" folders and contents that are on the same folder level as that of the B4A project's /Files and /Objects folders
What does this project do?
1. It starts the native camera
2. Take a photo of text
3. Save or discard the photo taken that has the text
3. If (3) = Save it returns the Blocks, Lines, and Words identified in the picture to the B4A project via events else it starts the camera again for you to take another photo of text.
Sample B4A code:
Have done this with B4A V6.80 and on a KitKat device.
Library:
MobileVisionText
Version: 1
MobileVisionText
Events:
To compile the Java code setup:
1. Create a libs folder on the same level as that of the src folder
2. Copy android-support-v4.jar, android-support-v7-appcompat.jar, constraint-layout-1.0.1.jar, and play-services-vision-9.4.0.jar into the libs folder that you have created.
The zipped project is here:
https://drive.google.com/file/d/0B4g9tud5lvjgSHE3VFc0aEZjUHc/view?usp=sharing
Libraries enabled:
Take note of the B4A manifest file:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="22"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
AddApplicationText(<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.gms.vision.DEPENDENCIES"
android:value="ocr" />
<activity android:name="com.truiton.mobile.vision.ocr.MainActivity">
</activity>)
Take note of the "resource" and "DemoRes" folders and contents that are on the same folder level as that of the B4A project's /Files and /Objects folders
What does this project do?
1. It starts the native camera
2. Take a photo of text
3. Save or discard the photo taken that has the text
3. If (3) = Save it returns the Blocks, Lines, and Words identified in the picture to the B4A project via events else it starts the camera again for you to take another photo of text.
Sample B4A code:
B4X:
#Region Project Attributes
#ApplicationLabel: b4aMobileVisionText
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: landscape
#CanInstallToExternalStorage: False
#End Region
#AdditionalRes: ..\DemoRes
#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.
Dim mvt As MobileVisionText
Private Button1 As Button
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")
mvt.Initialize("mvt")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
mvt.startMobileVisionText
End Sub
Sub mvt_blocks_result(blocks As String)
Log("B4A Blocks = " & blocks)
End Sub
Sub mvt_lines_result(lines As String)
Log("B4A Lines = " & lines)
End Sub
Sub mvt_words_result(words As String)
Log("B4A Words = " & words)
End Sub
Sub mvt_error_result(error As String)
Log("B4A ERROR = " & error)
End Sub
Have done this with B4A V6.80 and on a KitKat device.
Library:
MobileVisionText
Version: 1
MobileVisionText
Events:
- blocks_result (blocks As String)
- error_result (error As String)
- lines_result (lines As String)
- words_result (words As String)
- Initialize (paramString As String)
- IsInitialized As Boolean
- startMobileVisionText
- android.permission.CAMERA
- android.permission.WRITE_EXTERNAL_STORAGE
To compile the Java code setup:
1. Create a libs folder on the same level as that of the src folder
2. Copy android-support-v4.jar, android-support-v7-appcompat.jar, constraint-layout-1.0.1.jar, and play-services-vision-9.4.0.jar into the libs folder that you have created.
Attachments
Last edited: