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: 435
Last edited:

ToolboxZX

Member
Licensed User
Hi,
Is there any changes necessary to the example to use it with the latest IDE? With an ipad air I am having a similar experience to another user. The applications crashes when it comes to the line: scanner.Initialize("scanner", Panel1). No errors in the log. Thank you.
 

Erel

B4X founder
Staff member
Licensed User
Screenshot 2021-07-12 at 9.45.11-50%-50%.jpg

iBarcode v1.21 released. It allows setting the scan window.

It should be done after the scanner is started:
B4X:
Sub Page1_BarButtonClick (Tag As String)
    Select Tag
        Case "Start"
            scanner.Start
            Sleep(100)
            Dim scanrect As Rect
            scanrect.Initialize(50, 10, 250, 210)
            scanner.ScanRect = scanrect
            btnStop.Enabled = True
            btnStart.Enabled = False
        Case "Stop"
            scanner.Stop
            btnStart.Enabled = True
            btnStop.Enabled = False
    End Select
End Sub

 

Attachments

  • Barcode.zip
    2.8 KB · Views: 25

aeric

Expert
Licensed User
View attachment 116211

iBarcode v1.21 released. It allows setting the scan window.

It should be done after the scanner is started:
B4X:
Sub Page1_BarButtonClick (Tag As String)
    Select Tag
        Case "Start"
            scanner.Start
            Sleep(100)
            Dim scanrect As Rect
            scanrect.Initialize(50, 10, 250, 210)
            scanner.ScanRect = scanrect
            btnStop.Enabled = True
            btnStart.Enabled = False
        Case "Stop"
            scanner.Stop
            btnStart.Enabled = True
            btnStop.Enabled = False
    End Select
End Sub

Is this mean outside the rectangle, barcode will not be scan? So I can use opaque panels to cover the transparent area.
 

yiankos1

Active Member
Licensed User
Good morning Erel,

Could you please add the last type:
B4X:
AVMetadataObjectTypeAztecCode

Moreover, my IDE still has 1.20 version (just updated to 7.80 beta)

Thank you for your time.
 
Last edited:
Top