Reading Bar Codes
Bar code (EAN 13 symbology)
EasyBarCode can locate and read bar codes automatically.
Location can be performed manually for prototyping or when automatic mode results are unsatisfactory.
A bar code is a 2D pattern of parallel bars and spaces of varying thickness that represents a character string. It is arranged according to an encoding convention (symbology) that specifies the character set and encoding rules.
- The bar code may be black ink on white background or inverted (white ink on black background).
- The bar code should be preceded and followed by a quiet zone of at least ten times the module width (smallest bar or space thickness).
- Bars should be surrounded below and above by a quiet zone of a few pixels.
- Bar and space widths must be greater than or equal to 2 pixels.
A symbology defines the way a bar code is encoded.
Symbologies can be enabled in StandardSymbologies or AdditionalSymbologies parameters.
The standard symbologies are enabled by default:
- Code 39
- Code 128
- Code 2/5 5 Interleaved
- Codabar
- EAN 13*
- EAN 128
- MSI
- UPC A*
- UPC E
* EAN 13 and UPC A only differ by the layout of surrounding digits.
Additional symbologies that are supported:
- ADS Anker
- Binary code
- Code 11
- Code 13
- Code 32
- Code 39 Extended (a super-set of Code 39)
- Code 39 Reduced (a subset of Code 39)
- Code 93
- Code 93 Extended
- Code 412 SEMI
- Code 2/5 3 Bars Datalogic
- Code 2/5 3 Bars Matrix
- Code 2/5 5 Bars IATA
- Code 2/5 5 Bars Industry
- Code 2/5 5 Compressed
- Code 2/5 5 Inverted
- Code BCD Matrix
- Code C.I.P
- Code STK
- EAN 8
- IBM Delta Distance A
- Plessey
- Telepen
A checksum character enables the reader to check the barcode validity depending on the symbology:
- The checksum may be mandatory and must be checked by the reader.
- The checksum may be mandatory but may not need to be checked.
- The checksum and its verification may both be optional.
VerifyChecksum enables or disables (default) checksum verification.
Bar code structure (Code 39)
The Automatic mode reading algorithm locates a bar code in the field of view and Reads it.
If several bar codes are present, only one is located, like a straightforward hand-held bar code reader.
Before reading, the decoding symbologies must be specified in the StandardSymbologies, or AdditionalSymbologies properties.
Mono-symbology mode reads the bar code using the expected symbology type(s) and reports the encoded information (if readable) or the reason for failure (if not readable). There is only one interpretation for the character string.
Decoded bar code
Note: When the bar code contains \0x00 characters, the std::.string::.c_str method should not be used (since C-strings are terminated by the \0x00 character). An iterator over the characters should be used instead of a C-string.
If automatic localization fails or for prototyping purposes, the user can provide the bar code position and reading area to manually locate the code.
- Bar code position can be provided graphically by a bounding box around the bar code or by its parameters. If several symbols appear in the image, they can be processed one after the other.
- The reading area of the bar code is the area that is read. It should be wider than the bar code bounding box width, and less high than the bar code bounding box height. It may also be rotated relatively to the bar code bounding box, to take into account slanting bars (Advanced mode!).
Bounding box — graphical appearance (manual location) | Reading area — graphical appearance (manual location) |
Use Detect to report the number of possible symbologies in the NumEnabledSymbologies property, and list the data contents by decreasing likeliness.
Then call the Decode method in a loop, using GetDecodedSymbology to walk through the list of successful symbologies in decreasing order of likelihood.