BarCodeReader

BarCodeReader class

BarCodeReader encapsulates an image which may contain one or several barcodes, it then can perform ReadBarCodes operation to detect barcodes.

public class BarCodeReader : Component

Constructors

Name Description
BarCodeReader() Initializes a new instance of the BarCodeReader class with default values. Requires to set image (SetBitmapImage()) before to call ReadBarCodes() method.
BarCodeReader(Bitmap) Initializes a new instance of the BarCodeReader class from an image.
BarCodeReader(Stream) Initializes a new instance of the BarCodeReader class.
BarCodeReader(string) Initializes a new instance of the BarCodeReader class from file.
BarCodeReader(Bitmap, BaseDecodeType) Initializes a new instance of the BarCodeReader class.
BarCodeReader(Bitmap, params BaseDecodeType[]) Initializes a new instance of the BarCodeReader class.
BarCodeReader(Stream, BaseDecodeType) Initializes a new instance of the BarCodeReader class.
BarCodeReader(Stream, params BaseDecodeType[]) Initializes a new instance of the BarCodeReader class.
BarCodeReader(string, BaseDecodeType) Initializes a new instance of the BarCodeReader class.
BarCodeReader(string, params BaseDecodeType[]) Initializes a new instance of the BarCodeReader class.
BarCodeReader(Bitmap, Rectangle, BaseDecodeType) Initializes a new instance of the BarCodeReader class.
BarCodeReader(Bitmap, Rectangle, params BaseDecodeType[]) Initializes a new instance of the BarCodeReader class.
BarCodeReader(Bitmap, Rectangle[], BaseDecodeType) Initializes a new instance of the BarCodeReader class.
BarCodeReader(Bitmap, Rectangle[], params BaseDecodeType[]) Initializes a new instance of the BarCodeReader class.

Properties

Name Description
BarcodeSettings { get; } The main BarCode decoding parameters. Contains parameters which make influence on recognized data.
FoundBarCodes { get; } Gets recognized BarCodeResults array
FoundCount { get; } Gets recognized barcodes count
QualitySettings { get; set; } QualitySettings allows to configure recognition quality and speed manually. You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality, HighQuality, MaxBarCodes or you can manually configure separate options. Default value of QualitySettings is NormalQuality.
Timeout { get; set; } Gets or sets the timeout of recognition process in milliseconds.
static ProcessorSettings { get; } Gets a settings of using processor cores.

Methods

Name Description
static ImportFromXml(Stream) Imports BarCode properties from the xml-stream specified and applies them to the current BarCodeReader instance.
static ImportFromXml(string) Imports BarCode properties from the xml-file specified and applies them to the current BarCodeReader instance.
Abort() Function requests termination of current recognition session from other thread. Abort is unblockable method and returns control just after calling. The method should be used when recognition process is too long.
ExportToXml(Stream) Exports BarCode properties to the xml-stream specified
ExportToXml(string) Exports BarCode properties to the xml-file specified
ReadBarCodes() Reads BarCodeResults from the image.
SetBarCodeImage(Bitmap) Sets bitmap image for recognition. Must be called before ReadBarCodes() method.
SetBarCodeImage(Stream) Sets image stream for recognition. Must be called before ReadBarCodes() method.
SetBarCodeImage(string) Sets image file for recognition. Must be called before ReadBarCodes() method.
SetBarCodeImage(Bitmap, Rectangle) Sets bitmap image and area for recognition. Must be called before ReadBarCodes() method.
SetBarCodeImage(Bitmap, Rectangle[]) Sets bitmap image and areas for recognition. Must be called before ReadBarCodes() method.
SetBarCodeReadType(BaseDecodeType) Sets decode type for recognition. Must be called before ReadBarCodes() method.
SetBarCodeReadType(params SingleDecodeType[]) Sets SingleDecodeType type array for recognition. Must be called before ReadBarCodes() method.

Examples

This sample shows how to detect Code39 and Code128 barcodes.

[C#]
using (BarCodeReader reader = new BarCodeReader(@"c:\test.png", DecodeType.Code39Standard, DecodeType.Code128))
{
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine("BarCode Type: " + result.CodeTypeName);
        Console.WriteLine("BarCode CodeText: " + result.CodeText);
    }
}
[VB.NET]
Using reader As New BarCodeReader("c:\test.png", DecodeType.Code39Standard, DecodeType.Code128)
    For Each result As BarCodeResult In reader.ReadBarCodes()
        Console.WriteLine("BarCode Type: " + result.CodeTypeName)
        Console.WriteLine("BarCode CodeText: " + result.CodeText)
    Next
End Using

See Also