Android Question [B4XPages] Barcode Reader with Camera2

fbritop

Active Member
Licensed User
Longtime User
Hi
I was testing [B4XPages] Barcode Reader from:


I could not get to enable/disable the flash, because I understand Camera library methods are deprecated according to Google


Is it possible to update the barcode reader to work with CamEx2?

Thanks
FBP
 

fbritop

Active Member
Licensed User
Longtime User
SetFlashMode does not work on Camera class, but do operates ok from Camera2.I finaly manage to adapt the Barcode Reader to Camera2 class, having a timer to scan every 100ms and changing the frameBuilder to setBitmap:

B4X:
                Dim frameBuilder As JavaObject
                frameBuilder.InitializeNewInstance("com/google/android/gms/vision/Frame.Builder".Replace("/", "."), Null)
                frameBuilder.runmethod("setBitmap", Array( camEx.GetPreviewBitmap(pnlPreview.Width, pnlPreview.Height) ))
 
Upvote 0

Pedro Caldeira

Active Member
Licensed User
Longtime User
SetFlashMode does not work on Camera class, but do operates ok from Camera2.I finaly manage to adapt the Barcode Reader to Camera2 class, having a timer to scan every 100ms and changing the frameBuilder to setBitmap:

B4X:
                Dim frameBuilder As JavaObject
                frameBuilder.InitializeNewInstance("com/google/android/gms/vision/Frame.Builder".Replace("/", "."), Null)
                frameBuilder.runmethod("setBitmap", Array( camEx.GetPreviewBitmap(pnlPreview.Width, pnlPreview.Height) ))
Hello @fbritop I am using the Camera and CameraExClass with BarcodeScanner but need to change to camera2 and CamEx2, since I am already using these late modules in the app to take pictures. How did you adapted the barcode class, since we no longer have ScanCamera_preview event in CamEx2 ?
A timer to call the previous code that was in ScanCamera_preview ? and how to you use a bitmap instead of the data() ?

Thanks in advance.
 
Upvote 0

fbritop

Active Member
Licensed User
Longtime User
Hello @fbritop I am using the Camera and CameraExClass with BarcodeScanner but need to change to camera2 and CamEx2, since I am already using these late modules in the app to take pictures. How did you adapted the barcode class, since we no longer have ScanCamera_preview event in CamEx2 ?
A timer, how ?

Thanks in advance.
Here I attach both classes, one for reading barcodes, and the other for OCR, both of them which I use.
 

Attachments

  • auxClsScannerPPU.bas
    16.4 KB · Views: 115
  • auxClsScannerQR.bas
    16.7 KB · Views: 94
Upvote 0
Top