B4A Library Barcode reader based on Google Play Services Vision

Status
Not open for further replies.
This is not really a library. It is a modification to CameraEx example that adds barcode detection based on Google Play Services Vision. It uses JavaObject to create the detector and detect barcodes in the Preview event.

You should call CreateDetector with the formats you want to detect. Fewer codes will yield faster detections.
List of formats is available here: https://developers.google.com/andro...d/gms/vision/barcode/Barcode#constant-summary
The implementation is quite simplistic as it is done on the main thread. It works good on Nexus 5X. I haven't tested it on low end devices.

Note that you should add this code to the manifest editor:
B4X:
<meta-data
    android:name="com.google.android.gms.vision.DEPENDENCIES"
    android:value="barcode" />
 

Attachments

  • BarcodeCamera.zip
    13.6 KB · Views: 2,430
Last edited:

Micholl

Member
Licensed User
Longtime User
Hello Erel,
sorry - just discovered another strange behaviour:
It seems that the result array of barcodes in Camera1_Preview always returns
all recognised barcodes - not necessary only those which are currently seen
(when I cover 1 of 3 barcodes I always get the payload of 3 barcodes back).
Should this array be new initialized from preview to preview?

Thank you, Michael
 

john1in2

Member
Licensed User
Hi, I am very new to this- I can successfully use this to read bar codes, but the image/scanning window stays on all the time. How to you exit from the image/preview panel to another screen after a successful detection?

For example after a bar code is detected, add it to a list and switch to another panel that shows the list of bar codes that you have captured, with a button which allows you back to the bar code detection preview
 
Last edited:

Juanmavalero

Member
Licensed User
Longtime User
Hello, the proyect sample put me this library error: Artefacto de Maven no encontrado: com.google.android.gms/play-services-vision
 

Beja

Expert
Licensed User
Longtime User
Hi Erel,

Back to this post.. today I tried it and I found it the same as the camera example.. it didn't raise an event or returned the detected barcode value.
am I missing something? Is it possible that you limit the example just to the barcode.. :)
Thank you

GBarcode.png
 

DonManfred

Expert
Licensed User
Longtime User
Is it possible that you limit the example just to the barcode.. :)
The Example is configured for
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    If FirstTime Then
        CreateDetector (Array("CODE_128", "CODE_93"))
    End If
    cvs.Initialize(pnlDrawing)
End Sub
CODE_128 and CODE_93 Barcodes. You may add other possible Values to the Array.
Check the Google Documentation for a list

Edit to Add:
RTFM In #1 is a Link: https://developers.google.com/andro...d/gms/vision/barcode/Barcode#constant-summary
 

uniplan

Active Member
Licensed User
Longtime User
I try it but I have:
"Is detector operational: false" and I'm not able to scan barcode.
 

uniplan

Active Member
Licensed User
Longtime User

Roberto P.

Well-Known Member
Licensed User
Longtime User
Hello to all
why this example does not work with a Samsung Tab S4 tablet?
thank you
roberto
 

Roberto P.

Well-Known Member
Licensed User
Longtime User
Nothing is happening. With the smartphone it reads the barcodes automatically.
 

Roberto P.

Well-Known Member
Licensed User
Longtime User
of course. does nothing.
It almost seems like you do not hear the camera. while, if I click the photo works.
 

Roberto P.

Well-Known Member
Licensed User
Longtime User
I see the video, but the event that intercepts the reading of the bar code does not start. I ran the same app on both smartphones and tablets. only difference I see is that the app asks me to confirm access to the camera the tablet no.
 
Status
Not open for further replies.
Top