B4i Library iBarcode library

This library allows you to use the device camera to scan for all kinds of barcodes.
It is based on this open source project: https://github.com/mikebuss/MTBBarcodeScanner
License: https://github.com/mikebuss/MTBBarcodeScanner/blob/master/LICENSE

The attached example demonstrates how to use this library.
The main steps are:
1. Initialize the BarcodeScanner and set the preview panel.
2. In the panel resize event call scanner.Resize to resize the preview layer when needed.
3. The ready event will be raised when the scanner is ready. If Success is true then you can start scanning.
4. Call scanner.Start to start scanning.
5. The Detected event will be raised when a code is detected.



Edit: You need to add this line to the example:
B4X:
#PlistExtra:<key>NSCameraUsageDescription</key><string>Read barcodes</string>
 

Attachments

  • BarcodeExample.zip
    2.6 KB · Views: 434
Last edited:

jaraiza

Active Member
Licensed User
WOW, thanks!! Now it works :) You've the best product support I've seen in ages :) Thanks again!
 

jo1234

Member
Licensed User
Unfortunately, the library has serious problems after several quick start/stop cycles.

You can test this in the example if you add
B4X:
scanner.Stop
btnStart.Enabled = True
btnStop.Enabled = False
to Sub scanner_Detected.

Resulting code:
B4X:
Sub scanner_Detected (Codes As List)
   Dim sb As StringBuilder
   sb.Initialize
   sb.Append("Detected code:").Append(CRLF)
   For Each code As BarcodeCode In Codes
     sb.Append(code.Value).Append(CRLF)
   Next
   Label1.Text = sb.ToString
   scanner.Stop
   btnStart.Enabled = True
   btnStop.Enabled = False
End Sub

Start the example, scan a QR code, and quickly press start again to scan the next QR code.
After several cycles, the autofocus gets slower, and the screen stays blank or freezes.

I had one occasion where after the scan it displayed the read code correctly as value, but always showed the same wrong image of a previous scan.

I have the same problem in my app: I start the scanner, read a barcode, stop the scanner, process the barcode, start the scanner again to scan the next barcode.
If this is repeated several times, the app freezes.

Any chance to fix this?
 

jo1234

Member
Licensed User
My app needs to stop after each detection, because it jumps to a results page and shows detailed information. The user can then decide to scan the next barcode.

A continuous scan is not an option for me.
 
Last edited:

jaraiza

Active Member
Licensed User
My app needs to stop after each detection, because it jumps to a results page and shows detailed information. The user can then decide to scan the next barcode.

A continuous scan is not an option for me.

Mmmm... What happens if you try to leave the scanner in "started" mode and only hide the scanner panel when done? Only call scanner.Stop when the user choose not to scan any other code (an exit button) or when the app is closed?
 

incendio

Well-Known Member
Licensed User
Does this library support bulk scan? It means scan continuosly and returns all results when user stop scanning.
 

Douglas Farias

Expert
Licensed User
@Erel
on github description have this
Controlling the Torch
To control the torch, set the torchMode property or call the toggleTorch method.

Available values include:

MTBTorchModeOff,
MTBTorchModeOn,
MTBTorchModeAuto

this lib have option for torch?

thx




edit i have made this with phone lib thx
 
Last edited:

Christian Abate

Member
Licensed User
Exactly, I take the scanned result from the label and pass it to a txtfield. when that happens It has an empty space at the beginning. my question is how to avoid that.
 
Top