Skip to content

Micro QR Code parameters🔗

Symbol shape and size🔗

Parameters related to the symbol size set the minimum and maximum number of rows and columns allowed for a searched symbol. For matrix codes like Micro QR Codes, rows and columns correspond to modules. Micro QR Codes are always square and therefore have the same number for rows and columns. Instead of setting the number explicitly, it can also be set implicitly by specifying the version number.

set_data_code_2d_param (DataCodeHandle, 'symbol_size', 11)

Figure 1: Examples for symbol sizes 11x11 and 17x17.

Module appearance🔗

Polarity🔗

The parameter 'polarity' determines if the foreground modules are darker or brighter than the background or if both polarities are checked. By default, the value 'dark_on_light' is set. If it is set to 'any', both polarities are checked. In the program we change it to 'light_on_dark' to adapt it to our specific symbols.

set_data_code_2d_param (DataCodeHandle, 'polarity', 'light_on_dark')

Figure 2: Symbols with different polarity: (left) dark on light and (right) light on dark.

Mirrored🔗

Especially when reading symbols on transparent surfaces, it may occur that the symbol’s representation is mirrored. By default, the parameter 'mirrored' is set to 'any', i.e., mirrored and non-mirrored symbols are searched for. If you have only mirrored symbols you can restrict the search by setting the parameter to 'yes'. Here, all of our symbols are not mirrored, so we restrict the search by setting the parameter to 'no'.

set_data_code_2d_param (DataCodeHandle, 'mirrored', 'no')

Figure 3: Alignment of rows and columns: (left) non-mirrored and (right) mirrored symbol.

Contrast🔗

The contrast roughly corresponds to the difference between the gray values of the foreground and the background of a symbol. Internally, the contrast is calculated using the gradient amplitude between foreground and background. This implies that the contrast is lower for symbols with blurry edges, e.g., if the camera is out of focus or the symbol is printed badly.

Figure 4: Exemplary symbols of different contrast: (left) 11, (center) 8, and (right) varying contrast.

Minimum contrast🔗

The minimum contrast value must be set lower than the contrast of the data code. In standard mode, the minimum contrast is set to 30. If the contrast is lower, e.g because the symbol is blurred or because the lighting conditions are bad, we have to set the parameter 'contrast_min'. In this case we use the default value of the enhanced mode, i.e., a value of 10.

set_data_code_2d_param (DataCodeHandle, 'contrast_min', 10)

Module size🔗

Parameters related to the module size restrict the size of a module in pixels to speed up the search process. This is useful if the modules of all symbols are of similar size. The size is described by the width and height of a module.

set_data_code_2d_param (DataCodeHandle, ['module_size_min', 'module_size_max'], [4, 7])

Note that for modules that are smaller than two pixels, i.e., if 'module_size_min' is set to 1, the parameter 'small_modules_robustness' must be set to 'high' to enable a successful reading. But then, the run time and the needed memory increases significantly.

Module gap🔗

The modules of a matrix code are not necessarily connected. If a gap between the modules exists, you can specify the range of its size for both x- and y-direction, 'small' (≤ 10% of the module size) or 'big' (≤ 50% of the module size; not available for DotCode). In standard mode no or only a small gap is allowed. In the example program, we have no gaps in all directions of our symbols, so we restrict the parameter 'module_gap' to 'no'. See the figure below for exemplary module gaps.

set_data_code_2d_param (DataCodeHandle, 'module_gap', 'no')

Figure 5: Size of module gaps: no gaps , small gaps , big gaps .

Strict quiet zone🔗

All code standards (except Aztec Code) require a quiet zone (i.e. a region with undisturbed background) around the code symbol. Nevertheless, HALCON is able to read codes, even if the quiet zone shows defects. The reading of such codes can be suppressed by setting the parameter 'strict_quiet_zone' to 'yes'.

Model control parameter🔗

Besides the size and appearance of the symbol, you can also specify the general behavior of a 2D data code model.

Persistence🔗

The parameter 'persistence' determines how intermediate results, obtained while searching for symbols by the operator find_data_code_2d, are stored in the 2D data code model. By default, they are stored only temporarily ('persistence' set to 0) in order to reduce the allocated memory. Setting the parameter 'persistence' to '1', the results are stored persistently. Due to the high memory requirements, we recommend to do this only if some of the intermediate results are to be visualized or used for debugging purposes, e.g., when a symbol can not be read. Further information about debugging is given here. If only the decoded 2D data code and no further information is needed, 'persistence' can also be set to '-1'. Then, only the data that is necessary for retrieving the decoded data is stored in the model and the allocated memory is reduced to a minimum.

Strictness🔗

Sometimes, symbols can be read but nevertheless do not fit the model restrictions on the size of the symbols. The parameter 'strict_model' controls if the operator find_data_code_2d rejects such symbols or returns them as a result independent of their size and the size specified in the model. For the first case the parameter is set to 'yes'. This is reasonable if only symbols of a certain size are to be found and other symbols, which may be contained in the image as well, should be ignored. If you set the parameter 'strict_model' to 'no', it may occur that also symbols that do not strictly fulfill the restrictions are found.

Timeout🔗

It may be necessary to interrupt find_data_code_2d after a defined period, for example, when a maximum cycle time has to be ensured. This period can be defined with the parameter 'timeout' in milliseconds. All results gained until the interrupt can be accessed by get_data_code_2d_results. Passing values less or equal to zero implies a deactivation of the timeout, which is the default. The temporal accuracy is about 10 ms. It depends on several factors including the speed of your computer and the 'timer_mode' set via set_system. find_data_code_2d does not raise an exception if a timeout occurs. To check whether find_data_code_2d has been interrupted, check the parameter 'timeout_occurred' in get_data_code_2d_results. Note that the timeout is ignored if find_data_code_2d runs in training mode.