« MBS Xojo Plugins, ver… | Home | Omegabundle for Xojo … »

Using zbar library with Xojo

You may know that MBS Xojo Barcode Plugin has classes for barcode generation and recognition. The zxing classes based on the open source zxing library can recognize various types, but sadly not all QRCodes recently.

To solve this we add support for the zbar open source library with our new ZBarMBS class. Since the library is GPL, you have to include the library file with the application and load it at runtime. You may get a zbar library from the project website or from our Libs folder in download section. Our example project shows how to load the library at startup of application. On Linux you may just be able to install libzbar0 package and get libzbar installed.

When you like to scan a barcode, get a picture for the barcode. Make sure contrast is good and your barcodes are fully visible with a bit of border space around. Since scanning is done in black and white, you can preprocess the image to increase visibility with auto leveling, e.g. AutoLevelMBS function. You call Scan() function and pass the picture and you receive an array with barcodes found. You may get multiple result with different quality values, so you may pick the highest one. Sometimes a few lines or some text is recognized as a barcode. To increase reliability you may limit the list of barcodes types you like to have and thus ignore all others.

Supported types includes EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, Interleaved 2 of 5 and QR Code.

Our tests show that zbar can recognize a few barcodes, which didn't work with zxingQRCodeReaderMBS class. But since we also found EAN and UPC barcodes recognized in zxing (see zxingMultiFormatUPCEANReaderMBS or zxingMultiFormatOneDReaderMBS class), but not in zbar. Well, you may eventually use both to see what recognizes what.

Please ty with 21.3pr3 or later and please don't hesitate to contact us with your questions.

For macOS and iOS see also VNDetectBarcodesRequestMBS and VNBarcodeObservationMBS classes to use vision framework. The biggest plugin in space...
17 06 21 - 12:44