VintaSoft Barcode .NET SDK v10.0
Get an extended information about barcode in ASP.NET

1. Basic information about barcode

Vintasoft.Barcode.Web.Services.BarcodeRecognitionResult class is a base class that stores information about recognized barcode. The class stores the type of recognized barcode, barcode value, barcode region on image, barcode recognition confidence, quality test results, etc. For 1D barcodes is defined Vintasoft.Barcode.Web.Services.BarcodeRecognition1DResult class to which is added information specific for 1D barcodes only. The same way is defined Vintasoft.Barcode.Web.Services.BarcodeRecognition2DResult class for 2D barcodes.

2. Extended information about barcode

If the barcode information provided by classes described in previous paragraph is not enough (for example, if it is necessary an information about search patterns of QR Code barcode), then it is necessary to perform the following steps:
1. Create a system-independent web service for barcode recognition, which returns extended information about recognized barcode. 2. Create a system-dependent web service (HttpHandlers, ApiControllers, WcfService), which returns extended information about recognized barcode. 3. Recognize barcodes using created system-dependent web service and process the extended information about the barcode on client-side.

2.1. Creation of system-independent web service for barcode recognition, which returns extended information about recognized barcode

At beginning it is necessary to create a class, for example, MyVintasoftBarcodeWebService, which is derived from Vintasoft.Barcode.Web.Services.VintasoftBarcodeWebService class. Then override the CreateBarcodeRecognitionResult method in the class. In the method code it is necessary to add additional information about barcode to additionalInfo property of Vintasoft.Barcode.Web.Services.BarcodeRecognitionResult class.

Here is an example of system-independent web service for barcode recognition, which returns extended information about recognized barcode:

2.2. Creation of system-dependent web service (HttpHandlers, ApiControllers, WcfService), which returns extended information about recognized barcode

At beginning it is necessary to create a class derived from VintasoftBarcodeApiController, VintasoftBarcodeHandler or VintasoftBarcodeWcfService class. Then override the CreateWebService method in the class. The overridden method must return a new instance of MyVintasoftBarcodeWebService class.

Here is an example of system-dependent web service based on Web API controller:

Here is an example of system-dependent web service based on HTTP handler:

2.3. Recognition of barcodes using system-dependent web service and processing the extended information about the barcode on client-side

At beginning it is necessary to specify that we want to use the created earlier system-dependent web service for barcode recognition. Then is necessary to process the received from service information about the barcode.
Here is an example that demonstrates how to recognize barcodes from the image and get the an extended information about the recognized barcodes:
// web service (Web API controller), which is used for barcode recognition
var _barcodeService = new Vintasoft.Shared.WebServiceControllerJS("vintasoft/api/MyVintasoftBarcodeApi/");

// the source of barcode image
var barcodeImage Source = new Vintasoft.Shared.WebUrlImageSourceJS("UploadedImageFiles/AllSupportedBarcodes.png");
// barcode image
var barcodeImage = new Vintasoft.Shared.WebImageJS(barcodeImage Source, 0);

// barcode reader
var _barcodeReader = new Vintasoft.Barcode.WebBarcodeReaderJS(_barcodeService);
// barcode reader settings
var _barcodeReaderSettings = new Vintasoft.Barcode.WebBarcodeReaderSettingsJS();

// specify that barcode reader must recognize Code39, Code128, EAN-13 and QR barcodes
var barcodeTypes = new Vintasoft.Barcode.WebBarcodeTypeEnumJS("Code39");
barcodeTypes = _defaultBarcodeTypes.add("Code128");
barcodeTypes = _defaultBarcodeTypes.add("EAN13");
barcodeTypes = _defaultBarcodeTypes.add("QR");
_barcodeReaderSettings.set_BarcodeType(barcodeTypes);

// set the barcode recognition settings
_barcodeReader.set_Settings(_barcodeReaderSettings);

// send a request for recognizing barcodes
var request = _barcodeReader.readBarcodes(barcodeImage, __readBarcodes_success, __readBarcodes_fail);


// Barcodes are recognized successfully.
function __readBarcodes_success(data) {
    // get information about recognized barcodes
    var barcodes = data.results;
    // for each barcode
    for (var i = 0; i < barcodes.length; i++) {
        var barcode = barcodes[i];
        // add information about barcode type and value to the log
        console.log("Barcode type:" + barcode.barcodeType);
        console.log("Barcode value:" + barcode.value);
        // if barcode has additional information
        if (barcode.additionalInfo != undefined) 
        {
            console.log("Additional Information:");
            // for each additional property
            for (var name in barcode.additionalInfo)
                // add information about property name and property value to the log
                console.log("Name: " + name + " Value: " + barcode.additionalInfo[name]);
        }
    }
}

// Barcode recognition is failed.
function __readBarcodes_fail(data) {
    // process the error
}