Barcode scanning library based on native platform APIs for barcode detection:
This library was inspired by existing MAUI barcode scanning libraries: BarcodeScanner.Mobile & Zxing.Net.MAUI, but comes with many code improvements and uses native ML APIs on both Android and iOS.
- Uses native APIs for maximal performance and barcode readability,
- Optimized for continuous scanning,
- Ability to scan multiple barcodes in one frame,
- Ability to pool multiple scans for better scanning consistency,
- Transformed barcode bounding box for on-screen positioning,
- Code-behind and MVVM compatibility,
- Android ony - Abillity to invert source image to scan natively unsupported inverted barcodes, but at a performance cost.
-
Install Nuget package,
-
Initialize the plugin in your
MauiProgram.cs
:public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder ... .UseBarcodeScanning(); ... return builder.Build(); }
-
Add required permissions:
Edit
AndroidManifest.xml
file (under the Platforms\Android folder) and add the following permissions inside of themanifest
node:<uses-permission android:name="android.permission.CAMERA" />
Edit
info.plist
file (under the Platforms\iOS folder) and add the following permissions inside of thedict
node:<key>NSCameraUsageDescription</key> <string>Enable camera for barcode scanning.</string>
-
In XAML, add correct namespace:
xmlns:scanner="clr-namespace:BarcodeScanning;assembly=BarcodeScanning.Native.Maui"
-
Listen to
OnDetectionFinished
event in Code-behind or bindOnDetectionFinishedCommand
property to a Command in your ViewModel.
An example can be found in BarcodeScanning.Test project.
1D: Codabar, Code 39, Code 93, Code 128, EAN-8, EAN-13, ITF, UPC-A, UPC-E; 2D: Aztec, Data Matrix, PDF417, QR Code
1D: Codabar, Code 39, Code 93, Code 128, EAN-8, EAN-13, GS1 DataBar, ITF, UPC-E; 2D: Aztec, Data Matrix, MicroPDF417, MicroQR, PDF417, QR Code
A list of bindable properties with descriptions can be found in ICameraView.cs interface source file.
Windows and macOS are currently unsupported, but support can be added in the future. Vision framework is compatible with macOS so this implementation wouldn't be difficult. For Windows, barcode detection could be supported through Zxing.Net project.