IDAutomation.com, Inc., Computers Hardware, Software & Services, Tampa, FL Contact IDAutomationView your cart in the IDAutomation Store  
Loading
Home > Barcode Components > Barcode Recognition > User Guide and Tutorial

Barcode Recognition User Guide & Tutorial

Barcode Image Recognition Decoder API Support for the Barcode Image Recognition Decoder SDK

Installation & Compatibility

Application Compatibility

IDAutomation's .NET Barcode Recognition Decoder SDK is compatible with the .NET Framework 1.1 or greater.

Barcode Symbology Compatibility
Linear Symbology Compatibility Code 39, Extended Code 39, Code 128 (with character sets Auto, A, B and C), GS1-128 (aka: UCC/EAN-128), USS-128, Interleaved 2 of 5, Codabar, UPC-A, MSI, EAN-13 and Industrial 2 of 5.
Installing The Barcode Recognition Decoder Software
  1. Download and unzip the package into a directory on the development computer.
  2. Copy BarcodeDecoder.dll to the project directory. In Visual Studio, select Project - Add Reference and choose the DLL. Do not copy the DLL to the bin directory. Upon compiling the project, the DLL in the project folder will be copied to the appropriate bin folder with the associated EXE file automatically.
  3. These Examples should help with the various methods of using the product.
Properties and Methods
Consider using default values for all properties unless requirements dictate otherwise.
Name Default Description
ReadBarcode N/A This is the main entry point for most implementations, this method returns a string array where address 0 is the decoded data, 1 is the symbology, and 3 is the bar pattern. If no barcode is detected, address 1 and 2 are set to "No Barcode Found" and address 3 is set to null.
Angle 0 An integer value in the range from 0 to 359 that represents the number of degrees the decoder will rotate clockwise on the image for recognition. This is most useful when decoding images that are already rotated. Images should be decoded from left to right.
AngleTolerance 20 Rotates the decoder on the image (plus and minus the given value) using the Angle property for the center reference. For example, if Angle is set to 45 and the AngleTolerance is 5, the decoder will be rotated on the image 45 degrees to attempt a scan, if no barcode is decoded after the first scan, it will be rotated to 46, 44, 47, 43, etc. until it either successfully decodes a symbol or uses up the allowed tolerance (40 to 50 degrees.) Setting this value too high may increase processor utilization.
Code39FullAscii false If set to True, decodes the Code 39 barcode in the Extended Code 39 character set.
DecodeCode128 true Attempts to decode the Code 128 barcode type.
DecodeCode39 true Attempts to decode the Code 39 barcode type.
DecodeUpcEan false Attempts to decode the UPC-A and EAN-13 barcode type.
DecodeCode93 false Attempts to decode the Code 93 barcode type.
DecodeCodabar false Attempts to decode the Codabar barcode type.
DecodeCode11 false Attempts to decode the Code 11 barcode type.
DecodeMSI false Attempts to decode the MSI Plessey barcode type.
DecodeInterleaved2of5 true Attempts to decode the Interleaved 2 of 5 barcode type.
DecodeCode2of5 false Attempts to decode the Code 2 of 5 (aka industrial 2 of 5) barcode type.
ExpandToEAN13 false If set to true, this will expand a UPC-A or EAN 13 barcode to thirteen digits.
DecodedFNC1First* ]C1 A string that will be substituted for the first FNC1 character.*
DecodedFNC1Additional* Group Separator A string that will be substituted for the second FNC1 character.*
DecodedFNC2* ]C2 A string that will be substituted for the FNC2 character.*
DecodedFNC3* ]C3 A string that will be substituted for the FNC3 character.*
DecodedFNC4* ]C4 A string that will be substituted for the FNC4 character.*

*Properties utilize the tilde character as a method of inputting special characters. The ~ followed by three numeric values will set property to the ASCII equivalent. For example, setting the DecodedFNC2 property to "~202" all FNC2 characters will be represented as a "Ê" character in the decoded string.

Tutorial and Source Code Examples

The source code below assumes that the BarcodeDecoder object is named "reader" and a picture box control named "barcode" has been added to the form.

Displaying The Decoded Data in Text Boxes

Visual Basic .NET:
    Dim barcodeData() As String
    barcodeData= reader.ReadBarcode(barcode.Image)
    txtDecodedData.Text = barcodeData(0)
    txtSymbology.Text = barcodeData(1)
    txtBarPattern.Text = barcodeData(2)
C# .NET:    
    string [] barcodeData= reader.ReadBarcode((Bitmap)barcode.Image);
    txtDecodedData.Text = barcodeData[0];
    txtSymbology.Text = barcodeData[1];
    txtBarPattern.Text = barcodeData[2];

Passing a Piece of an Image to The ReadBarcode Method (this example checks the upper left region for a barcode)

Visual Basic .NET:
    'declare the beginning and ending pixels of the image on the x and y axis
    Dim xStart As Integer = 0
    Dim yStart As Integer = 0
    Dim xEnd As Integer = barcode.Image.Width
    Dim yEnd As Integer = barcode.Image.Height

    'set the end pixels to the upper left region of the image
    xEnd = xEnd / 2
    yEnd = yEnd / 2
    Dim PartialImgWidth As Integer = xEnd - xStart
    Dim PartialImgHeight As Integer = yEnd - yStart

    'Since picture box controls do not have a GetPixel method, create a bitmap to hold the partial image
    Dim copy As Bitmap
    Dim partialImage As Bitmap
    copy = New Bitmap(barcode.Image, barcode.Image.Width, barcode.Image.Height)
    partialImage = New Bitmap(PartialImgWidth, PartialImgHeight)
    Dim x As Integer
    Dim y As Integer

    'set the pixels of the partial image to the same color of the copied barcode image
    For x = xStart To xEnd - 1
        For y = yStart To yEnd - 1
            partialImage.SetPixel(x - xStart, y - yStart, copy.GetPixel(x, y))
        Next y
    Next x
    barcode.Image = partialImage
C# .NET:    
    //declare the beginning and ending pixels of the image on the x and y axis
    int xStart = 0;
    int yStart = 0;
    int xEnd = barcode.Image.Width;
    int yEnd = barcode.Image.Height;

    //now we will set the end pixels to the upper left region of the image
    xEnd /= 2;
    yEnd /= 2;
    int PartialImgWidth = xEnd - xStart;
    int PartialImgHeight = yEnd - yStart;

    //Since picture box controls do not have a GetPixel method, create a bitmap to hold the partial image
    Bitmap copy = new Bitmap(barcode.Image, barcode.Image.Width, barcode.Image.Height);
    Bitmap partialImage = new Bitmap(PartialImgWidth, PartialImgHeight);

    //set the pixels of the partial image to the same color of the copied barcode image
    for (int x = xStart; x < xEnd; x++)
    {
        for (int y = yStart; y < yEnd; y++)
        {
            partialImage.SetPixel(x - xStart, y - yStart, copy.GetPixel(x, y));
        }
    }
    barcode.Image = partialImage; 
Note: Other regions of the document may be easily specified by using the calculations below for other regions of the image:
    Upper Right:
        xStart = xEnd / 2
        yEnd = yEnd / 2
    Downward Left: 
        xEnd = xEnd / 2
        yStart = yEnd / 2
    Downward Right:
        xStart = xEnd / 2
        yStart = yEnd / 2

Decoding a Rotated Image (assumes the image being passed in is already at 90°)

Visual Basic .NET:
    Dim reader As New IDAutomation.BarcodeDecoder.BarcodeDecoder
    reader.Angle = 90
    Dim barcodeData() As String
    barcodeData= reader.ReadBarcode(barcode.Image)
    txtDecodedData.Text = barcodeData(0)
    txtSymbology.Text = barcodeData(1)
    txtBarPattern.Text = barcodeData(2)
C# .NET:
    IDAutomation.BarcodeDecoder.BarcodeDecoder reader = new BarcodeDecoder();
    reader.Angle = 90;
    string [] barcodeData= reader.ReadBarcode((Bitmap)barcode.Image);
    txtDecodedData.Text = barcodeData[0];
    txtSymbology.Text = barcodeData[1];
    txtBarPattern.Text = barcodeData[2];

Technical Support

Free support for the Barcode Recognition Software may be obtained by reviewing resolved public forum threads. Priority phone, e-mail and forum support is provided up to 30 days after purchase. Additional priority phone, e-mail and forum support may be obtained if a Priority Support and Upgrade Subscription is active.

Common Problems and Solutions

Performance Improvements

  • Decode performance is improved by setting the Angle property to the angle that is most accurate. For example, if scanned barcodes usually appear at 7 degrees (meaning the barcode image is rotated 7 degrees clockwise), the Angle property should be 7. Additional performance is improved by setting all symbologies to false except the type that is being decoded.

EAN-13 Barcodes Return Only 12 Digits

  • The first digit in an EAN 13 barcode is not actually encoded in the barcode. This first digit is produced based on a pattern of the next five digits. To enable this functionality set the ExpandToEAN13 property to true and the first digit will be present in the decoded string.

A Leading Zero is Added to The Decoded Data of UPC-A Barcodes

  • This is a similar problem to the one above. If the ExpandToEAN13 property is set to true, all UPC-A barcodes will contain a leading zero because of the pattern contained in the first five digits. To disable, set the ExpandToEAN13 property to false and the leading zero will be truncated.

Barcode Not Recognized in a Document

  • Too much text in the document containing the barcode can cause this behavior. Refer to the source code example to pass a partial image into the ReadBarcode method of the BarcodeDecoder class.

Back to Top

 © Copyright 2014 IDAutomation.com, Inc., All Rights Reserved. Legal Notices.

 Barcode Fonts | Components | Scanners | Support | Contact Us
Training Videos on YouTube Join us on Google Plus Join us on LinkedIn Follow us on Twitter Like us on Facebook
Over 70% of Fortune 100 companies use IDAutomation's products to automate their businesses.