Common Vision Blox-Tool
C-Style | C++ | .Net API (C#, VB, F#) | Python |
CVCBarcode.dll | Cvb::Barcode | Stemmer.Cvb.Barcode | cvb.barcode |
Image Processing Tool for reading Barcodes
CVB Barcode is a library of functions for decoding one- and two-dimensional barcodes which is used within the Common Vision Blox environment.
It offers a powerful algorithm to accurately decode common barcode symbologies reliably and at high speed.
The algorithm locates the codes automatically within the camera image, irrespective of position or rotation and can even read codes when they have poor contrast, are printed on uneven surfaces, or need to be viewed in a challenging environment or orientation.
CVB Barcode allows the secure and positive identification and tracking of components and products throughout their life cycle based on a wide range of codes.
Supported barcode symbologies:
Two-dimensional barcodes:
One-dimensional barcodes:
Not supported barcode symbologies:
ECI Encoding is not supported with CVB Barcode.
Special Barcode features:
All 1D and 2D barcodes can:
For all barcodes you can:
Code grading:
In addition to pure barcode reading, CVB Barcode also offers verification (grading) of 1D-barcodes, Datamatrix and QR-Codes.
Standardised measurement procedures are used to objectively evaluate the print quality of the code under predefined conditions. This level of quality control is common in industrial environments to ensure the printing of the bar code is of sufficient quality to ensure the elimination of reading errors when tracking the code later in the production process.
When you first start the Barcode library, you will be asked to enter a license number for Barcode.
You can obtain this from STEMMER Imaging.
To test the library, select Cancel to close the entry form. This automatically starts the demo version of Barcode.
From time to time you will be asked to enter your license number and Evaluation Mode hint is displayed.
In addition, the following substitutions will be made in all decoded Barcodes within the Demo version:
e
-> x
E
-> X
0
-> 5
Apart from these restrictions, the demo version is in every respect identical to the licensed version.
Barcodes encode information by means of a pattern consisting of light and dark structures.
Classical one-dimensional barcodes consist of dark lines of differing widths separated by bright gaps of constant or variable width.
The figure below illustrates the principle of this structure:
The width of the narrowest line or the narrowest gap is known as the module width and is assigned the letter X.
The width of the other lines and gaps are specified as multiples of this module width.
The unit millimeter or mil is used as the unit of measurement for the module width, where:
1 mil = 1/1000 inch = 0.0254 mm
Commonly used barcodes have module widths of 6.7 to 40 mil (0.17 mm to 1 mm).
Before the first or after the last line in the barcode there is a bright quiet zone. This is usually at least 10 module widths in size.
The height depends on the type of application. The basic rule is: the higher the barcode, the easier it is to decode.
There is a whole range of differing barcode symbologies. Basically these can be subdivided into two-level codes and multi-level codes.
Two-level codes simply consist of two elements of different width (line or gap). Narrow elements have the width X while wide elements are generally 2X and 3X wide.
In the case of multi-level codes, there are four or more different widths which are generally whole multiples of the module width. The internal structure also differs in the different symbologies. However, the principle is very similar for most symbologies.
The standards DIN/EN 796 to DIN/EN 801 determine the precise specifications of barcodes in Germany and Europe.
In the following, we explain the structure of barcodes using the example of Code 39.
Code 39 is a two-level code. Here the wide elements are 2.5 times as wide as the narrow elements. In Code 39, there is a gap between the characters.
In some other symbologies, this gap is not needed since in these a character ends with a gap, not with a line.
The illustration below presents a Code 39, which contains the data digits 1234
The code also contains a check digit.
The code consists of the following components, listed from left to right:
*
,1234
,A
,*
andThis structure – quiet zone, start digit, data digits, check digit if necessary, stop digit and quiet zone - is typical of almost all 1D barcodes.
The start and stop digits are used to differentiate between the different symbologies. They are thus different for each symbology. In many symbologies, such as Codebar, the start and stop digits contain additional data information; in others, such as Code 39, they are always the same. In some symbologies, such as EAN, no start or stop codes are depicted.
The data digits are sequenced from the symbology's character set. This character set differs from symbology to symbology. Some define digits only, others digits and a number of special characters while others, such as Code 39, define alphanumeric characters or the entire ASCII character set.
Each data digit does not necessarily always correspond to a specific sequence of lines and gaps. Many symbologies combine characters or append additional control digits. For the purposes of differentiation, the designation code word is used for a given sequence of lines and gaps. The way in which data digits are then translated into code words and how code words are then interpreted as data digits depends on the symbology. This process is clarified in an example below.
The check digit is a further character from the symbology's character set. A special procedure is applied to calculate it from the data digits and it is then appended to these. When the barcode is decoded, this character can be regenerated from the data digits and compared with the appended check digit. If a variance is detected, the barcode has not been read correctly and rejected as "not recognized": This procedure makes the reading of barcodes considerably more reliable.
Check digits are not specified in all symbologies. In many they are optional and in many there is more than one procedure for the calculation of check digits.
If a barcode cannot be read even it is of a good quality, the first thing to do is to deactivate internal checking and instead check the transferred check digit manually.
To achieve maximum speed of evaluation, you should:
To achieve maximum read reliability, you should:
If a barcode is not read, check the following:
Memory requirements:
Matching barcodes consists of several steps, of which the first one is scanning the image for the occurence and position of barcode patterns.
This scanning can be imagined like a search along a number of particularly arranged lines drawn over the image.
The arrangement and number of profile lines can be configured by setting the Readout Mode.
The selected CVC_BC_DIRECTION
determines the parameters affecting the readout stage:
CVC_BC_OMNI | Angles and stripes (Number of equiangular rotations of an absolute number of equidistant parallels) |
CVC_BC_FENCE | Range only (distance in pixels between horizontal profiles) |
CVC_BC_LADDER | Range only (distance in pixels between vertical profiles) |
CVC_BC_BOTH | Range only (distance of both horizontal and vertical profiles) |
CVC_BC_SMALL_CODES | Special BC_DIRECTION mode, no readout parameters valid |
The speed of barcode recognition can be increased by reducing these search profiles, ie. the number of search operations, to the minimum of necessary steps.
If, for example, the orientation of the barcodes is well known and consistent, the complexity and thus the overall processing time of the reading step decreases.
The example below illustrates the effect of the library settings on the result of the read operation.
The following Code 39 with check digit is to be read:
This code is an extended Code 39, i. e. certain character combinations stand for other characters.
Thus +A
stands for the character a
which is not defined in the normal Code 39. This code therefore actually contains ab
plus a check digit.
The library defines the function CvcBcSetCode39()
which determines the read parameters for Code 39.
These include the following parameters:
min_digits | minimum number of Code 39 code words |
max_digits | maximum number of Code 39 code words |
checkdigit | evaluate/ignore check digit |
transmit_checkdigit | append/do not append check digit to data |
transmit_start_stop | transmit/do not transmit start and stop digit with data |
full_ascii | enable/disable complete ASCII code |
The min_digits
and max_digits
parameters are used to restrict the number of code words which are to be read.
The code in the example contains the 5 code words +
, A
, +
, B
and H
.
Here, the start and stop digits do not count as code words.
For example, by specifying min_digits = 5
and max_digits = 5
it is possible to restrict Code 39 read operations to this size.
How many and which characters the library returns following decoding nevertheless depends on the other settings.
The table below provides an overview of the influence of the settings.
full_ascii | checkdigit | transmit_checkdigit | transmit_start_stop | Returned code | Number of characters |
---|---|---|---|---|---|
TRUE | TRUE | FALSE | FALSE | ab | 2 |
TRUE | TRUE | TRUE | FALSE | abH | 3 |
FALSE | TRUE | FALSE | FALSE | +A+B | 4 |
FALSE | TRUE | TRUE | FALSE | +A+BH | 5 |
FALSE | FALSE | – | FALSE | +A+BH | 5 |
FALSE | FALSE | – | TRUE | *+A+BH* | 7 |
In all these cases the element num_digits
from the structure CVC_BC_INFO
would have the value 5.
The table contains two settings which return the same code.
The difference is that in the first setting the check digit is evaluated and transmitted while in the second setting the check digit is treated as a normal data digit.
The transmit_start_stop
setting depends on all the other settings.
The parameters have a similar significance in all other symbologies.
One-dimensional barcodes are the classical barcodes which embrace a whole range of different symbologies.
The most important of these are: Code 128, Code 39, Code 93, EAN 13, EAN 8, UPC A, UPC E, 2/5 interleaved, 2/5 discrete.
Others are being prepared.
Two-dimensional barcodes are an extension of the classical one-dimensional barcode.
They have been developed in order to accommodate more information within a limited surface area.
Not supported Barcodes:
ECI Encoding is not supported with CVB Barcode.
A variety of barcode symbologies have been developed for different types and sectors of application.
The EAN 8 and EAN 13 code types tend to dominate in the retail sector. In industrial applications, the codes "2 of 5", Code 128, Codabar or Code 39 are frequently encountered.
The following table lists all available 1D codes in CVB Barcode and presents examples and typical areas of application:
Barcode symbology | Example | Area of application | Character set | Length | Checksum |
---|---|---|---|---|---|
2 of 5 Interleaved | industry | numerical | variable | Modulo 10 | |
2 of 5 Discrete | |||||
Codabar | blood database, industry | numerical with special characters | variable | Modulo 16 | |
Code 11 | numerical, hyphen | ||||
Code 39 | industry | alphanumerical | variable | Modulo 43 | |
Code 32 | pharmaceutical | numerical | |||
Code 93 | ASCII incl. space | variable | Modulo 47 | ||
Code 128 | industry | full ASCII incl. non-printables | variable | Modulo 103 | |
EAN 8 | retail Europe | numerical code | 8 | Modulo 10 | |
EAN13 | retail Europe | numerical code | 13 | Modulo 10 | |
Pharmacode | numerical | ||||
Sonycode | alphanumerical | ||||
UPC A | retail USA/Canada | numerical | 12 | Modulo 10 | |
UPC E | retail USA/Canada | numerical | 8 | Modulo 10 | |
MSI Plessey | books, food | numerical | variable | N/A | |
Planet | postal | numerical | 12 | ||
PostNet | postall | numerical | variable | Difference to next decade after padding | |
4-state KIX | postal | alphanumeric | variable | ||
4-state Royal Mail | postal | alphanumeric with brackets | variable | weighted | |
4-state Australian Post | postal | alphanumeric with space and # | variable | Reed Solomon | |
4-state USPS | postal | 31 |
Additional descriptions regarding the SonyCode
The SonyCode specification "Attachment III" has been extended with the following definitions.
Regarding point 6: Description of SONY-Barcode (Coding/Decoding)
CvcBcSetSonyCode
structure.code_interpretation
is active the following definitions also hold:code_interpretation
is active.CVC_BC_DATA_FORMAT_ERROR
may not be passed on to the user.#
.CVC_BC_DATA_FORMAT_ERROR
will be returned.See the descriptions of the elements of the infostructure.
The Standard and Miniature one-track Pharmacode, originally established by the company Laetus, is one of the oldest stripe codes still in use.
It differs from other 1D codes in that it specifies the widths and heights of a code's component in absolute measures and that it allows for a fairly generous range of values (see table below).
Also, there are no consistency markers like those used by e.g. EAN codes defined for a Pharmacode.
Because of these peculiarities it is essential to define the code reading parameters accurately, which often makes reading Pharmacodes challenging.
The dimensions of 1D Pharmacodes are defined as follows:
Standard one-track Pharmacode:
Minimum | Standard | Maximum | |
---|---|---|---|
a | 0.4 mm | 0.5 mm | 0.7 mm |
b | 1.3 mm | 1.5 mm | 2.5 mm |
c | 0.9 mm | 1.0 mm | 2.5 mm |
d | 1.2 mm | 1.5 mm | 2.5 mm |
e | undefined | 8.0 mm | undefined |
z | 1.3 mm | 1.5 mm | 2.5 mm |
b/a | 3 |
Miniature one-track Pharmacode:
Minimum | Standard | Maximum | |
---|---|---|---|
a | 0.30 mm | 0.35 mm | 0.45 mm |
b | 0.90 mm | 1.00 mm | 1.50 mm |
c | 0.55 mm | 0.65 mm | 1.65 mm |
d | 0.80 mm | 1.00 mm | 1.70 mm |
e | undefined | 6.00 mm | undefined |
z | 0.90 mm | 1.00 mm | 1.70 mm |
b/a | 3 |
Recommendations and Information
In order to read a Pharmacode successfully, it is essential to use appropriate settings in the CVC_BC_CONFIG
structure:
pixel_reference
parameter of the CvcBcSetPharmacode
function: This parameter defines how many 1/10 pixels there are to one millimeter.pixel_reference
setting, switching between Standard and Miniature size can be achieved through the scale_factor
parameter of CvcBcSetPharmacode
.Example
For testing it is recommended to use one of the Barcode Control Tutorials because they provide direct access to all the relevant parameters through the Barcode OCX's property page.
As described previously a matching configuration is an essential precondition.
run_direction
(orientation of the code) has to be set: e.g. from right to left (setting the orientiation is crucial - the Pharmacode is readable in both directions, but usually with very different results depending on read direction).pixelreference
is according to the reproduction scale in 1/10 pixel per millimeter.scale_factor
of the Pharmacode has default value 100% but must be set for Miniature-Pharmacodes to 66% (or other vales if used).treshold
value has to be set for colored Pharmacodes digitalisation to define the value for bar acceptance in the range from 0 to 100.min_digits
and max_digits
the real bar count values should be used.quietzone
value in 10th of a millimeter value is to be configured.General notes
Since the library tries to read all supported postal codes at once, all codes share a number of common parameters. It is however also possible to configure each type individually.
As a side effect, the latter can lead to failed reads if more than one type is active at a time.
To prevent this, the following parameters should be identical for all postal codes: threshold, invert, mirror and quiet zone. This is also the default configuration.
The direction parameter is CVC_BC_FENCE
by default.
When a more differentiated configuration is desired, the following chain of analysis should be considered:
PostNet > Planet > 4-state USPS > 4-state KIX > 4-state Royal Mail > 4-state Australia
PostNet, Planet and 4-state USPS (Intelligent Mail)
The POSTNET (POSTal Numeric Encoding Technique) code was developed by the U.S. Postal Service to encode information on postal codes.
The PLANET (Postal Alpha Numeric Encoding Technique) code is used to identify and track pieces of mail during delivery.
The barcode symbology of the PLANET code is inverse to the POSTNET code. Every POSTNET code word is a combination of two full-height and three half-height bars whereas every PLANET code word uses three full-height and two half-height bars. Both codes always start and end with a full "start/stop bar".
For Postnet- and Planet codes following restrictions apply:
The successor of both codes is the "OneCode 4-State Customer Barcode" (4-state USPS in CVB Barcode), which combines the capabilities of PostNet and Planet. It combines ZIP code and tracking data in one barcode symbol.
4-state Royal Mail (RM4SCC with option for Singapore)
This is the barcode symbology the British Royal Mail is using for machine readable UK postcodes and Delivery Points. It is also referred to as CBC (Customer Bar Code) in the documents provided by the Royal Mail.
4-state KIX
KIX (Klant index) is the Dutch equivalent to RM4SCC, with a slight difference in the character set. It can be used to encode a complete address.
4-state Australian Postal
The Australian postcode is currently the most elaborated one. It covers all common postal usage patterns, encoding them in a so-called Format Control Code (FCC).
Initially developers interleaved one-dimensional barcodes. This resulted in the so-called stacked barcodes which were able to integrate a lot more information on a comparable surface area.
The most elaborate stacked barcode is the PDF 417. Apart from its high information density, this symbology also permits error correction, meaning that partially destroyed barcodes can still be read.
Matrix codes represent a different type of development. They depart totally from the classic barcode concept and present the information in the form of rectangular matrices with black and white areas. In this way, they achieve an even higher information density, but they cannot be read with laser-based read systems. A typical example of matrix codes is the Data Matrix.
A 2D barcode can accommodate significantly more information than the familiar standard barcodes on a comparable area. They also permit the coding of alphanumeric characters and binary data, offering the possibility to store an actual description of the recorded object (e.g. name or identifier). The figures below compare a Code128 and a PDF417 barcode using the same resolution and a comparable surface area. The PDF417 is able to store the same numerical combination 13 times.
In addition, 2D barcodes can offer a very high level of reliability. A Reed-Solomon code with up to 9 reliability levels was implemented in the development of the PDF417. For this reason, the code can still be evaluated correctly even if it is damaged or partly illegible.
2D barcodes are widely used in all kinds of applications. They are particularly interesting for fields like medical engineering, the electronics industry and in post and package routing.
2D barcodes can be distinguished into 3 groups:
Codablock
PDF 417
Micro PDF 417
Micro PDF 417 is similar to standard PDF 417 except for the size, which provides improved area efficiency.
CVC_BC_BOTH
RSS (Reduced Space Symbology)
RSS-14 Stacked | RSS-14 Stacked Omnidirectional |
RSS-14 Truncated with CC-A | RSS Limited with CC-B |
2D Pharmacode
L
as search patternAdditional information can be found in chapter 2D Pharmacode.
Data Matrix
L
as search patternQR Code
Like other matrix codes, the QR code requires a minimum module size of 5 pixels. The module size should ideally be at least 7 pixels for optimum reading results.
The 2D Pharmacode is described with the other 2D barcodes. Here are some more information and recommendations.
Recommendations and information
The option 2D Pharmacode makes only sense for codes which have bars (color or grey value bars) around the code.
Please activate the bars which are present.
Please choose a threshold for the bars in % (sometimes the image is monochrome and therefore the bars also. In other cases it is a color image and the bars have different colors.)
Please take care that the Barcode Tool is working only on single planes! Please choose a plane a check there the values of your thresholds.
Examples
For testing this it is recommended to use one of the Barcode Control Tutorials (Barcode OCX Tutorial) because you have direct access to all the Barcode parameters via the Property Page:
The 1D Code Grading in CVC Barcode is based on Norm ICO/IEC 15416.
The 2D Code Grading in CVC Barcode is related to the relevant norms as listed below:
| graded |
| grading optional |
Norm | CVB | |||
---|---|---|---|---|
Parameter | IEC 16022 | IEC 15415 | AS 9132 | Barcode |
Decode |
|
|
| |
Symbol Contrast |
|
|
| |
Fixed Pattern Damage |
| |||
Axial Nonuniformity |
|
|
| |
Grid Nonuniformity |
|
| ||
Unused Error Correction |
|
|
| |
Print Growth |
|
|
| |
Modulation |
| |||
Additional Reflectance |
|
| ||
Angle of Distortion (Skew) |
| |||
Dot Size |
| |||
Dot Center Offset |
|
Barcode contains functionality for decoding one and two-dimensional barcodes within the Common Vision Blox environment.
It works with Common Vision image objects (of type IMG) with 8 bit image depths.
The image objects can contain multiple planes.
The core function for barcode decoding is CvcBcDecodeBarcode()
. It is solely responsible for reading barcodes.
The simplest way to call CvcBcDecodeBarcode()
is:
The function searches plane 0 of the image Image in any barcode in any direction and then decodes it.
Following the call, the code field contains the decoded information which is terminated with the null character.
In addition the function returns the number of characters read as the result of the function or returns the value null if no barcode was found.
All the other library functions are used to influence which barcodes are read and the conditions which are to apply.
This is achieved by so-called configurations. Multiple configurations may exist in parallel.
The Barcode Control is a tool which makes it possible to read in barcodes.
It is an Control which can be easily incorporated in a variety of visual development environment.
After you have linked the Barcode Control into your project, a Barcode object can be added to your application using the icon below.
The control is based on the Barcode library and encapsulates its range of functions.
As a result, more detailed information can be found in the documentation for Barcode library.
The Barcode Control allows you to decode a large number of different types of barcodes.
It is very flexible in terms of orientation, size and distortion of barcodes.
A better level of performance can be achieved by optimizing recognition based on individual needs.
There are several Example programs as source codes and executables in different current compilers under \cvb\Tutorial\Barcode
directory for the
All barcode applications can be tested without barcode license, there will be an evaluation mode label in the display and in some cases result substitution only.
This VCBarcode demo program is a demonstration program for the barcode library.
The algorithm locates the codes automatically within the camera image, irrespective of position or rotation and can even read codes when they have poor contrast, are printed on uneven surfaces, or need to be viewed in a challenging environment or orientation.
Once started, you can use Open Image to load
You can use the Read Barcode button to decode a barcode in the loaded image. The processing time for every decoding is shown.
To speed up the processing time be sure that you activate only the types of barcodes you expect.
See also Hints on using Barcode.
You can use the Save Config Buttons to write the current settings to a file or use Open Config to read the current settings from a file.