Recognizing Barcodes

This section deals with certain features specific to the recognition of barcodes with ABBYY FineReader Engine 12. The main aspects of barcode recognition are treated in the description of the Barcode Recognition scenario.

In most cases, if a barcode conforms to the specification, it can be recognized with the default settings. In other cases, certain parameters need to be specified. These parameters are specified via the BarcodeParams subobject of the PageAnalysisParams object.

Barcodes with checksum

Barcodes of types Code 39, Interleaved 2 of 5, Codabar, and Matrix 2 of 5 may include a checksum. Checksums are used for error detection. The algorithm of checksum calculation is specified by the standard. You should set the HasChecksum property of the BarcodeParams object to TRUE in order for the barcodes with checksums to be recognized correctly.

Important! The recognition result does not include the barcode checksum if it is provided by the standard.

PDF417, Aztec, Data Matrix, QR Code, MaxiCode barcodes

By default, ABBYY FineReader Engine recognizes PDF417, Aztec, DataMatrix, QR Code, MaxiCode barcodes using the code page, which corresponds to the specification. These are the following code pages:

  • for PDF417 — DOS United States (437) (CP_US_MSDOS)
  • for Aztec, DataMatrix, QR Code, MaxiCode — ISO Latin 1 (8859-1) (CP_Latin_ISO)

Sometimes, these barcodes do not conform to the specification, that is, they were created using a code page different from that defined by the specification. In this case, it is necessary to specify the code page manually via the CodePage property of the BarcodeParams object.

QR Codes in Structured Append mode

QR Codes can be used to encode a large amount of data by joining up to 16 codes in a sequence in structured append format. The BarcodeBlock object provides access to special information of structured-append sequence through QrCodeSequenceId, QrCodeSequenceCount, QrCodeSequenceIndex properties, and you can use it in your program to join the recognized codes together.

Binary data encoded in barcodes

PDF417, Aztec, DataMatrix, QR Code barcodes can encode both text and binary data. ABBYY FineReader Engine represents all recognized barcode data, including binary data, as text. The way how binary data is represented in the form of text depends on the value of the ContainsBinaryData property of the BarcodeParams object:

Value of ContainsBinaryData Binary data representation
FALSE (default value)
  • Each character that contains binary data has the IBarcodeSymbol::IsBinaryData property set to TRUE.
  • Binary data, as well as text data, is represented as a Unicode string (IBarcodeBlock::Text).
  • The data is translated to the Unicode string using the code page specified in the IBarcodeParams::CodePage property. To receive the binary data from the Unicode string, you should decode the string using the corresponding code page.

Note: The binary zero cannot be translated correctly to a Unicode string. The corresponding character in the string will be the "unrecognized character" symbol ("^") and will have the IBarcodeSymbol::IsBinaryZero property set to TRUE.

TRUE
  • Each character that contains binary data has the IBarcodeSymbol::IsBinaryData property set to TRUE.
  • Binary data, as well as text data, is represented as a Unicode string (IBarcodeBlock::Text).
  • The binary data is saved in the Unicode string as a sequence of hexadecimal values for corresponding bytes. For example, the string "00FF02" will be used for the following 3 bytes: 0x00, 0xFF, 0x02.

The recognition procedure

To recognize barcodes that do not conform to the specification or barcodes with checksums, do the following (we presume that the BarcodeRecognition_Accuracy or BarcodeRecognition_Speed predefined profile has already been loaded):

  1. Create a DocumentProcessingParams object using the CreateDocumentProcessingParams method of the Engine object.
  2. Change the default values of the necessary properties of the BarcodeParams subobject (DocumentProcessingParams contains a PageProcessingParams property, which contains PageAnalysisParams, which in turn includes BarcodeParams).
  3. Pass the DocumentProcessingParams object to the Process method of the FRDocument object as an input parameter.
  4. If you are using other methods for processing, they may require a PageAnalysisParams or a PageProcessingParams object as input parameters. Follow the same procedure, changing the values of the BarcodeParams subobject of one of these objects.

C++ code

Tips for working with barcodes

Barcode recognition quality depends on barcode print quality and settings used in the document scanning process. In order for the barcodes to be recognized well, follow these recommendations:

  • A barcode must be separated from other text by a fairly wide white gap.
  • Barcode size and the width of its separate bars or dots must meet the following requirements:
    • The optimal barcode height is more than 10 millimeters. The size of a barcode should be less than size A4.
    • Barcode height must be greater than the double height of a text line.
    • For non-square barcodes, the length must be greater than height.
    • For 1D barcodes, the width of the thinnest bar in the barcode must be at least 3-5 pixels in terms of pixels of the image.
    • For 2D barcodes, the dimensions of their cells should be at least 2x2 pixels; the recommended size is 4x4 pixels or more. Besides, for all 2D barcodes except PDF417, the cells should be square because if the 2D barcode is stretched, it will most likely be recognized incorrectly.
  • We do not recommend compressing images of barcodes using JPEG compression as it makes barcode borders fuzzy.
  • We do not recommend skewing barcodes, i.e., an angle of the barcode should be a multiple of 90 degrees relative to the horizontal axis.
  • The grayscale scanning mode is the best for OCR purposes. When scanning in black-and-white, adjust the brightness setting. If the barcode is "torn" or very light, lower the brightness to make the image darker. If the barcode is distorted or its parts are glued together, increase the brightness to make the image brighter.
  • Avoid printing barcodes in frames.
  • Avoid printing barcodes over text or picture.

In real life, barcodes that do not fit these recommendations can still be recognized; however, the quality of recognition may be poor.

See also

Barcode Recognition

Barcode Types

03.07.2024 8:50:25

Usage of Cookies. In order to optimize the website functionality and improve your online experience ABBYY uses cookies. You agree to the usage of cookies when you continue using this site. Further details can be found in our Privacy Notice.