Detect barcode regions using AI in .NET application
In This Topic
VintaSoft Barcode .NET SDK 16.0+ can use a neural network (artificial intelligence) to find barcode regions in an image.
If SDK should find regions of 1D barcodes using a neural network, the following steps should be made:
- Add a reference to the nuget-package Microsoft.ML.OnnxRuntime, Version=1.23.0 to your .NET-application.
- Add a reference to the nuget-package Microsoft.ML.OnnxRuntime.Managed, Version=1.23.0 to your .NET-application.
- Add a reference to the .NET-assembly Vintasoft.Barcode.AI.1D.dll to your .NET-application.
-
Copy file Vintasoft.Barcode.AI.1D.vsres to the "Bin" folder of your .NET-application.
If file Vintasoft.Barcode.AI.1D.vsres should be stored in a custom folder, set the path to the custom folder using the ResourcesPath property.
- Initialize the use of the neural network using the code "Vintasoft.Barcode.Ai1DAssembly.Init();".
If SDK should find regions of 2D barcodes using a neural network, the following steps should be made:
- Add a reference to the nuget-package Microsoft.ML.OnnxRuntime, Version=1.23.0 to your .NET-application.
- Add a reference to the nuget-package Microsoft.ML.OnnxRuntime.Managed, Version=1.23.0 to your .NET-application.
- Add a reference to the .NET-assembly Vintasoft.Barcode.AI.2D.dll to your .NET-application.
-
Copy file Vintasoft.Barcode.AI.2D.vsres to the "Bin" folder of your .NET-application.
If file Vintasoft.Barcode.AI.1D.vsres should be stored in a custom folder, set the path to the custom folder using the ResourcesPath property.
- Initialize the use of the neural network using the code "Vintasoft.Barcode.Ai2DAssembly.Init();".
When should a neural network be used to recognize barcode regions in an image?
Enable the usage of neural network in your .NET application if one of the following conditions is met:
- you need to recognize 2D barcodes on images of unknown size, which may include images of medium size - 2 megapixels or more
- you need to recognize 1D barcodes on images of unknown size, which may include images of medium size - 15 megapixels or more
- you need to recognize an unknown number of barcodes in an image
- you need to recognize a large number of 2D and/or 1D barcodes in an image
The detection of barcode regions using a neural network takes between 30 and 70 milliseconds per image. The AIbarcode region detector (
Ai1DBarcodeRegionDetector,
Ai2DBarcodeRegionDetector) contains settings that only activate the neural network when it is expected to improve performance.
How is the barcode recognition process accelerated?
If the SDK uses a neural network to find barcode regions in an image, the SDK first finds barcode regions in the image using a neural network (30 to 70 milliseconds per image) and then performs multi-threaded barcode recognition in the found regions. Using multi-threading accelerates the barcode recognition process.
What to do when I do not know number of barcodes in an image?
If you do not know the number of barcodes in image, please use the neural network and set the
ReaderSettings.ExpectedBarcodes property to 0.
I know where the barcodes are located in the image. Is there a way to speed up the barcode recognition process?
Use the
BarcodeLayoutInfo class to define the image layout - this will allow the barcode recognizer to perform recognition only in the required regions and use multithreading effectively.