You are here: Start » Filter Reference » Computer Vision » Datacodes » ReadMultipleDataCodes (ReadDataCodes Multiple)
Module: | Datacodes |
---|
Reads multiple data codes (1D and 2D).
Applications
Name | Type | Range | Description | |
---|---|---|---|---|
![]() |
inImage | Image | Input image | |
![]() |
inRoi | Rectangle2D* | Region of interest | |
![]() |
inRoiAlignment | CoordinateSystem2D* | Coordinate system for the region of interest | |
![]() |
inMatrixSymbologies | MatrixSymbologies* | Specifies which matrix symbologies the filter should try to read | |
![]() |
inLinearSymbologies | LinearSymbologies* | Specifies which linear symbologies the filter should try to read | |
![]() |
inDetectorParams | DataCodeDetectorParams | Parameters of the code detection algorithm, common for linear and matrix codes | |
![]() |
inMatrixCodeParams | MatrixCodeParams | Parameters specific to matrix (2D) codes | |
![]() |
inLinearCodeParams | LinearCodeParams | Parameters specific to linear (1D) codes | |
![]() |
inComputeScores | Bool | Enables computing of confidence scores (slower) | |
![]() |
inMaxCodeCount | Integer | 0 - ![]() |
Maximum number of codes in one image |
![]() |
inAllowMultipleScales | Bool | Specifies whether to continue search for codes at a higher resolution even when some codes have already been found at a lower resolution | |
![]() |
outDataCodes | DataCodeArray | List of codes that have been correctly detected and decoded | |
![]() |
outCandidates | PathArray | Diagnostic information about detection results | |
![]() |
outAlignedRoi | Rectangle2D | Input ROI after transformation (in the image coordinates) |
Description
The filter locates and decodes data codes (Data Matrix, QR Codes and linear barcodes) in an image within a given region (inRoi).
The parameters can be set automatically (with the Auto-tune Editor) or manually.
Auto-tune GUI
The Auto-tune Editor enables automatic selection of parameters for 2D codes. To open it, in the Properties section, click on the Auto-tune parameter.
More information can be found here.
Manual Settings
Groups of parameters
The tool's default parameters are selected for reading of high- and medium-quality codes at a good speed. If you need to achieve a higher speed, or read damaged or distorted codes, then some parameters may need to be adjusted. There are three main groups:
- inDetectorParams – parameters of the code detector, common for 1D and 2D codes.
- inMatrixCodeParams – parameters related to 2D code reading (Data Matrix and QR Code).
- inLinearCodeParams – parameters related to 1D code reading (Code 128, EAN/UPC etc.).
Symbology selection
The first choice, and one that you must always make, is to select the code symbologies. Use inMatrixSymbologies for reading Data Matrix or QR Codes. Use inLinearSymbologies to read 1D types (Code 128, EAN/UPC etc.).
To assure the maximum possible performance, always select only those symbologies that you do need.
NOTE: If you enable one of these sections but leave all the options set to "False", the tool will still perform code detection (1D or 2D) but will skip the decoding phase. It may be useful for testing detector's execution time but should not be used at production.
Detection methods
The most important detector's setting is the detection algorithm, inDetectorParams.DetectionMethod. The tool offers three options:
Finder Edges (default) | Finder Pattern (basic) | Dot Grid (advanced) | |
---|---|---|---|
Where it looks? | ![]() |
![]() |
![]() |
How it works? | Looks for the edges of the L-shaped pattern. Uses a robust line segment detector internally. | It is a simple method based on blob analysis. Uses dynamic image thresholding to extract the code. | Ignores the finder and timing patterns altogether. Instead, directly recognizes the grid-like structure of the code. |
When to use it? | This method is fast and effective even in challenging conditions, including DPM (direct part marking) but may be confused by additional lines appearing near the code. You can fine-tune it with FinderTradeoff and EdgeTracker parameters. | This method works well only on clearly printed codes with a correct quiet zone. May also handle some dot-codes when setting the inDetectorParams.DotSize properly. | This method can detect codes with highly damaged finder and timing patterns. Works best with dot-printed codes, but can work with fully-printed codes when inDetectorParams.DotSize is set to "Full". |
Works with 1D? | Yes. | Sometimes. | No. |
Pyramid strategy
The tool tries to detect codes at different scale levels. It investigates images at different resolutions, starting with the lowest resolution. If it finds a sufficient number of codes at one level, it may skip looking further, thus achieving shorter execution time. If there are no codes in the input image, it will always scan all the levels, resulting in the highest execution time. For this reason, it is very important to set inMatrixCodeParams.MinModuleSize and/or inLinearCodeParams.MinThinBarSize precisely – setting it too low may significantly increase the tool's execution time.
NOTE: If you experience instable execution times, for example, switching between 10 ms and 20 ms, it may indicate that for some images the tool finds a code at a higher level, while for some others it has to process the higher resolution too. For that reason, we also recommend testing time performance on the ReadMultipleDataCodes tool, with inMaxCodeCount=1000 and inAllowMultipleScales=True. This will assure that no early exit happens, and the execution time will be the maximum of what we may expect with the given settings.
Finder Tradeoff ("FinderEdges" only)
When using the "FinderEdges" method, you should be aware that there is a tradeoff between the ability of the tool to detect rugged (uneven, noised, or dot printed) edges and the ability to detect low contrast edges (or ones neighboring with a very narrow Quite Zone). The default setting is "Balanced". However, if you expect the edges of your code to be relatively straight and clean, but less strong, you may want to change it to "Sensitive". On the other hand, if the edges of the code are highly jagged or the surrounding is noisy, it may be better to choose "Robust". You may also set it to "Auto" and it will test several possibilities at the cost of much higher execution time.
Use "Sensitive" | Use "Balanced" | Use "Robust" |
---|---|---|
![]() |
![]() |
![]() |
Distortions
The tool can deal with various types of code deformations. There are three possible settings, as demonstrated below. Please be aware that when we make the algorithm more robust to distortions, we make it less robust to broken code patterns. For this reason, we should stay with lower settings whenever possible.
Use "Low" | Use "Medium" | Use "High" |
---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Each side is represented with a single line segment. | Each side is represented with a 3-segment line. | Each side is exactly traced with a polyline. |
Module Sizes
- MinModuleSize (for 2D) and MinThinBarSize (for 1D) is the expected lower bound of one module (the smallest unit of the code).
- MaxModuleSize (for 2D) and MaxThinBarSize (for 1D) is the expected upper bound of one module (the smallest unit of the code).
Polarity
inPolarity – while most codes in the world have black modules printed on a bright background, the tool can also read the opposite. What is more, the "Mixed" polarity is an option for reading some difficult DPM codes that have both bright and dark spots within a single module.
Damaged codes and other difficulties
By using appropriate inMatrixCodeParams settings, you can read codes that are partially damaged. See the below table for some of the most common cases.
Use MaxSlant=30 | Use AllowPerspective=High | Use AllowBrokenEdges and AllowBrokenTiming | Use AllowOversizedModules |
---|---|---|---|
![]() |
![]() |
![]() |
![]() |
Hints
- Connect inImage with the output of your image acquisition filter.
- Specify the range of possible codes in an image by setting the inMatrixCodeParams and inLinearCodeParams. The narrower are the settings, the faster the filter works.
- Set inDetectorParams.Polarity to specify whether dark-on-bright or bright-on-dark codes are to be read. If code polarity is inconsistent, use "Mixed" (it may be also a very good option for some DPM codes).
- Specify the range of possible code sizes with inMatrixCodeParams.MinRowCount, inMatrixCodeParams.MaxRowCount, inMatrixCodeParams.MinColumnCount and inMatrixCodeParams.MinColumnCount.
- Specify the range of possible module sizes (in pixels) with inMatrixCodeParams.MinModuleSize and inMatrixCodeParams.MaxModuleSize (for 2D codes), or inLinearCodeParams.MinThinBarSize and inLinearCodeParams.MaxThinBarSize (for 1D codes). Note that the minimum value may highly affect the tool's execution time.
- When using "FinderPattern" or "DotGrid" methods, also set the inDetectorParams.DotSize according to the following rules:
- Full – no gaps between modules (the modules are fully filled).
- Large – module gaps up to 25% of the module size; this is the default setting.
- Medium – module gaps up to 50% of the module size; it may require a bigger Quiet Zone.
- Small – module gaps up to 75%; comes with no guarantee.
- Set inMatrixCodeParams.MaxRectangleRatio to 1 if you expect to work with square codes only. The value specifies maximal ratio between the length of the longer side to the length of the shorter side.
- Pay attention to codes that are bent or unevenly printed.
- For bent codes (e.g. printed on a bottle) use inDetectorParams.AllowDistortion = Medium.
- For unevenly printed codes or ones that are printed on wrinkled material use inDetectorParams.AllowDistortion = High.
- For potentially damaged codes, consider using inDetectorParams.AllowBrokenEdges and inMatrixCodeParams.AllowBrokenTiming. These settings make the tool more robust against missing pieces of Finder Pattern and Timing Pattern respectively.
- If some codes are not detected, try the following procedure:
- In the first place, make sure that the symbologies you are trying to read are selected.
- Also make sure that you have set the right range of module sizes and the code polarity setting.
- Change inDetectorParams.PyramidStrategy and inDetectorParams.DecodeStrategy to Strict or Extended.
- Increase inDetectorParams.MinContrast if the noise is high. Decrease it for dark and low-contrast images.
- Also consider increasing inDetectorParams.MaxSlant and inDetectorParams.AllowPerspective (especially important for very big codes).
- If still nothing works, also set inDetectorParams.FinderTradeoff, inDetectorParams.DotSize and inDetectorParams.AllowDistortion to "Nil". This will work slowly, but should read almost everything.
Examples
![]() Square |
![]() Slanted |
![]() Reflection |
![]() Overexposure |
![]() Simple case. |
![]() Dark and lower quality code. |
![]() Code viewed from an angle. |
Remarks
For maximum reliability of reading codes, we recommend making sure that the image fulfills the following standard requirements:
- Module size should be at least 4.0 pixels. It is possible to read codes with modules as low as 1.25 pixels, but this comes with no guarantee and is highly dependent on the image and printing quality.
- Gaps between dot-printed marks should be not bigger than 50% of the module size, but the less, the better.
- There should be an empty space around the code ("quiet zone"). It should have the width at least equal to the module size. Contamination, additional print, or shadows in this area is the most frequent source of reduced reliability.
- The Finder Pattern slant (angular deviation from 90 degrees) should not be greater than 30 degrees.
For explanation of the used terminology, please refer to the below picture:

Complexity Level
This filter is available on Basic Complexity Level.
Filter Group
This filter is member of ReadDataCodes filter group visible as Multiple.
See Also
- ReadSingleDataCode – Reads a single data code (1D or 2D) in the input image.