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,432
Last edited:

Gandalf

Member
Licensed User
Longtime User
New version was uploaded. The detected rectangle is drawn.

I've locked the orientation to landscape to make it simpler.

If I set the orientation to portrait, detected rectangle gets incorrect coordinates. Can you please give me a hint how to fix it?
 

figorra

Member
Licensed User
Longtime User
Start with this:
B4X:
If 100%x < 100%y Then
                   r.Initialize(100%x - br.GetField("y"),tl.GetField("x") , 100%x - tl.GetField("y"),  br.GetField("x"))
                   Log(r)
               Else
                   'landscape
                   r.Initialize(tl.GetField("x"), tl.GetField("y"), br.GetField("x"), br.GetField("y"))
               End If

Where?
 
Status
Not open for further replies.
Top