Operators |
set_data_code_2d_param — Set selected parameters of the 2D data code model.
set_data_code_2d_param( : : DataCodeHandle, GenParamName, GenParamValue : )
The operator set_data_code_2d_param is used to set or change the different parameters of a 2D data code model in order to adapt the model to a particular symbol appearance. All parameters can also be set while creating a 2D data code model with create_data_code_2d_model. The current configuration of the data code model can be queried with get_data_code_2d_param. A list with the names of all parameters that can be set for the given 2D data code type is returned by query_data_code_2d_params.
For an explanation of the concept of the 2D data code reader see the introduction of chapter Identification / Data Code.
Note that the symbol structure of GS1 DataMatrix, GS1 QR Code, and GS1 Aztec is identical to the structure of ECC 200, QR Code, and Aztec Code, respectively. Therefore, all symbology specific parameters applying to ECC 200, QR Code, or Aztec Code apply to their corresponding GS1 variant as well. In the following, the explicit enumeration of the parameters for any particular GS1 code is omitted for sake of readability. Instead, the relevant parameters names are to be inferred from the parameters for the corresponding non-GS1 code type or can be explicitly queried by query_data_code_2d_params with parameter 'set_model_params' .
The following overview lists the different generic parameters with the respective value ranges and default values in standard mode ('standard_recognition' ). If the default values in enhanced mode ('enhanced_recognition' ) differ from those in the standard mode, they are listed additionally. The same holds, if the default values in the maximum mode 'maximum_recognition' differ from those in the enhanced mode:
Basic default settings:
All data code types:
Reset all model parameters to one of the three basic default settings standard, enhanced, or maximum (see the following summary and create_data_code_2d_model). In addition to the parameter values, the training state of the model is reset. Values: 'standard_recognition' , 'enhanced_recognition' , 'maximum_recognition'
Default: 'standard_recognition'
Attention: If this parameter is set together with a list of other parameters, this parameter must be at the first position.
Set for the given parameters the training state to trained. The next training will not overwrite this parameters. If necessary only the parameter range is extended to cover the already trained symbols. For all possible parameter which can be trained see find_data_code_2d.
Size and shape of the symbol:
Data matrix ECC 200 (including the finder pattern):
Attention: After calling set_data_code_2d_param to change size or shape of the symbol, the parameters are evaluated in the given order. After each parameter, the consistency of the current settings is checked, and if necessary the current settings are adjusted. Therefore the order in which the changes are done may influence the final setting.
Minimum number of module columns in the symbol.
Value range: [10, 12, 14, .. 144]
Attention: Changing 'symbol_cols_min' sets 'symbol_shape' to 'any' . If the size of the current symbol is only consistent with one shape type 'symbol_shape' is restricted to 'rectangle' or 'square' .
Default: 10
Maximum number of module columns in the symbol.
Value range: [10, 12, 14, .. 144]
Attention: Changing 'symbol_cols_max' sets 'symbol_shape' to 'any' . If the size of the current symbol is only consistent with one shape type 'symbol_shape' is restricted to 'rectangle' or 'square' .
Default: 144
Minimum number of module rows in the symbol.
Value range: [8, 10, 12, .. 144]
Attention: Changing 'symbol_rows_min' sets 'symbol_shape' to 'any' . If the size of the current symbol is only consistent with one shape type 'symbol_shape' is restricted to 'rectangle' or 'square' .
Default: 8
Maximum number of module rows in the symbol.
Value range: [8, 10, 12, .. 144]
Attention: Changing 'symbol_rows_max' sets 'symbol_shape' to 'any' . If the size of the current symbol is only consistent with one shape type 'symbol_shape' is restricted to 'rectangle' or 'square' .
Default: 144
Set 'symbol_cols_min' and 'symbol_cols_max' to the given value.
Value range: [10, 12, 14, .. 144]
Attention: Changing 'symbol_cols' sets 'symbol_shape' to 'any' . If the size of the current symbol is only consistent with one shape type 'symbol_shape' is restricted to 'rectangle' or 'square' .
Set 'symbol_rows_min' and 'symbol_rows_max' to the given value.
Value range: [8, 10, 12, .. 144]
Attention: Changing 'symbol_rows' sets 'symbol_shape' to 'any' . If the size of the current symbol is only consistent with one shape type 'symbol_shape' is restricted to 'rectangle' or 'square' .
Possible restrictions on the module shape ('rectangle' and/or 'square' ).
Attention: setting the symbol shape all previously made restrictions concerning the symbol size may change. For 'square' the minimum of 'symbol_cols_min' and 'symbol_rows_min' and the maximum of 'symbol_cols_max' and 'symbol_rows_max' will be used. Additional restrictions can be seen in the following table:
symbol_shape | 'any' | 'rectangle' | 'square' |
---|---|---|---|
'symbol_cols_min' | >= 10 | >= 18 | >= 10 |
'symbol_cols_max' | <= 144 | <= 48 | <= 144 |
'symbol_rows_min' | >= 8 | >= 8 | >= 10 |
'symbol_rows_max' | <= 144 | <= 16 | <= 144 |
Furthermore, if 'symbol_cols_min' is larger than 'symbol_rows_max' , the setting for 'symbol_shape' is ignored and its value set to 'rectangle' .
Since HALCON 7.1.1 the same search algorithm is used for both shapes if 'finder_pattern_tolerance' is set to 'low' . Thus, 'symbol_shape' has no effect for the symbol search in this case. However, if 'finder_pattern_tolerance' is set to 'high' or 'any' , the value of 'symbol_shape' may speed up the symbol search significantly if it is set to 'rectangle' or 'square' .
Values: 'rectangle' , 'square' , 'any'
Set 'symbol_cols_min' and 'symbol_rows_min' to the given value and 'symbol_shape' to 'square' .
Set 'symbol_cols_max' and 'symbol_rows_max' to the given value and 'symbol_shape' to 'square' .
Set 'symbol_cols_min' , 'symbol_cols_max' , 'symbol_rows_min' and 'symbol_rows_max' to the given value and 'symbol_shape' to 'square' .
QR-Code (including the finder pattern):
Type of the QR Code model. The old QR Code Model '1' and the newer Model '2' are supported. With the specification 'any' or '0' both models are carried out.
Values: 1, 2, 'any' , '0'
Default: 'any'
Minimum symbol version. The symbol version is directly linked to the symbol size. Symbols of version 1 are 21x21 moduls in size, version 2 = 25x25 moduls, etc. up to version 40 = 177x177 moduls. The maximum size of Model 1 symbols is 73x73 = version 14.
Value range: [1 .. 40] (Model 1: [1 .. 14])
Default: 1
Maximum symbol version.
Value range: [1 .. 40] (Model 1: [1 .. 14])
Default: 40
Set 'version_min' and 'version_max' to the same value.
Minimum size of the symbol in modules. This parameter can be used as an alternative to 'version_min' .
Value range: [21 .. 177] (Model 1: [21 .. 73])
Default: 21
Maximum size of the symbol in modules. This parameter can be used as an alternative to 'version_max' :
Value range: [21 .. 177] (Model 1: [21 .. 73])
Default: 177
Set 'symbol_size_min' and 'symbol_size_max' to the same value.
Micro QR Code:
Minimum symbol version. The symbol version is directly linked to the symbol size. Symbols are between 11x11 (version M1) and 17x17 (version M4) modules in size.
Value range: [1 .. 4]
Default: 1
Maximum symbol version.
Value range: [1 .. 4]
Default: 4
Set 'version_min' and 'version_max' to the same value.
Minimum size of the symbol in modules. This parameter can be used as an alternative to 'version_min' .
Value range: [11 .. 17]
Default: 11
Maximum size of the symbol in modules. This parameter can be used as an alternative to 'version_max' :
Value range: [11 .. 17]
Default: 17
Set 'symbol_size_min' and 'symbol_size_max' to the same value.
PDF417:
Minimum number of data columns in the symbol in codewords, i.e., excluding the codewords of the start/stop pattern and of the two row indicators.
Value range: [1 .. 30]
Default: 1
Maximum number of data columns in the symbol in codewords, i.e., excluding the two codewords of the start/stop pattern and of the two indicators.
Value range: [1 .. 30]
Default: 20 (enhanced: 30)
Minimum number of module rows in the symbol.
Value range: [3 .. 90]
Default: 5 (enhanced: 3)
Maximum number of module rows in the symbol.
Value range: [3 .. 90]
Default: 45 (enhanced: 90)
Set 'symbol_cols_min' and 'symbol_cols_max' to the same value.
Set 'symbol_rows_min' and 'symbol_rows_max' to the same value.
Aztec Code (including the finder pattern):
Format of the Aztec Code: space separated list with the values 'compact' , 'full_range' , or 'rune' .
Default: 'compact full_range'
Minimum size of the symbol in modules.
Value range: [11 .. 151]
Default: 11
Maximum size of the symbol in modules.
Value range: [11 .. 151]
Default: 151
Set 'symbol_size_min' and 'symbol_size_max' to the same value.
Appearance of the modules in the image:
All data code types:
Describes the polarity of the symbol in the image, i.e., the parameter determines if the symbol appears light on a dark background or dark on a light background.
Values: 'dark_on_light' , 'light_on_dark' , 'any' .
Default: 'dark_on_light' (enhanced: 'any' )
Describes whether the symbol is or may be mirrored (which is equivalent to swapping rows and columns of the symbol).
Values: 'no' , 'yes' , 'any'
Default: 'any'
Minimum contrast between the foreground and the background of the symbol (this measure corresponds with the minimum gradient between the symbol's foreground and the background).
Values: >=1
Default: 30 (enhanced: 10)
Robustness of the decoding of data codes with very small module sizes. Setting the parameter 'small_modules_robustness' to 'high' increases the likelihood of being able to decode data codes with very small module sizes. Additionally, in that case the minimum module size should also be adapted accordingly, thus 'module_size_min' and 'module_width_min' (PDF417) should be set to the expected minimum module size and width, respectively. Setting 'small_modules_robustness' to 'high' can significantly increase the internal memory usage of find_data_code_2d. Thus, in the default case 'small_modules_robustness' should be set to 'low' . If 'small_modules_robustness' is set to 'high' the maximal accepted image size is bisected (see get_system 'halcon_xl' ).
Values: 'low' , 'high'
Default: 'low' (enhanced: 'low' , maximum: 'high' )
Datamatrix ECC 200, QR-Code, Micro QR Code, and Aztec Code:
Minimum size of the modules in the image in pixels. Please note that for optimal reading performance a module size of at least 3-4 pixels is recommended.
Values: [1 .. 100]
Default: 6 (enhanced: 2, maximum: 1)
Maximum size of the modules in the image in pixels.
Values: [2 .. 100]
Default: 20 (enhanced: 100)
Set 'module_size_min' and 'module_size_max' to the same value.
The gap between modules can be set via the 'module_gap*' parameters as explained in the following paragraph:
It is possible to specify whether neighboring foreground modules are connected or whether there is or may be a gap between them. If the foreground modules are connected and fill the module space completely, the gap parameter can be set to 'no' . The parameter is set to 'small' if there is a very small gap between two modules, i.e.,< 10% of the module size. It can be set to 'big' if the gap is bigger (in relation to the module size: < 50%). The last two settings may also be useful if the foreground modules - although being connected - appear thinner as their entitled space (e.g., as a result of blooming caused by a bright illuminant). If the foreground modules appear only as very small dots, in general, an appropriate preprocessing of the image for detecting or enlarging the modules will be necessary (e.g., by gray_erosion_shape or gray_dilation_shape).
Minimum gap.
Values: 'no' , 'small' , 'big'
Default: 'no'
Maximum gap.
Values: 'no' , 'small' , 'big'
Default: 'small' (enhanced: 'big' )
Set 'module_gap_min' and 'module_gap_max' to the same value.
PDF417:
Minimum module width in the image in pixels.
Values: [1 .. 100]
Default: 3 (enhanced: 2, maximum: 1)
Maximum module width in the image in pixels.
Values: [2 .. 100]
Default: 15 (enhanced: 100)
Set 'module_width_min' and 'module_width_max' to the same value.
Minimum module aspect ratio (module height to module width).
Values: [0.5 .. 20.0]
Default: 1.0
Maximum module aspect ratio (module height to module width).
Values: [0.5 .. 20.0]
Default: 4.0 (enhanced: 10.0)
Set 'module_aspect_min' and 'module_aspect_max' to the same value.
Data matrix ECC 200:
Maximum deviation of the angle of the L-shaped finder pattern from the (ideal) right angle (the angle is specified in radians and corresponds to the distortion that occurs when the symbol is printed or during the image acquisition).
Value range: [0.0 .. 0.5235]
Default: 0.1745 = (enhanced: 0.5235 = )
Tolerance of the search with respect to a defect or partially occluded finder pattern. The finder pattern includes the L-shaped side as well as the opposite alternating side. Dependent on this parameter, different algorithms are used during the symbol search in find_data_code_2d. In one case ('low' ), it is assumed that the finder pattern is present to a high degree and shows almost no disturbances. In the other case ('high' ), the finder pattern may be defect or partially occluded without influencing the recognition and the reading of the symbol. Note, however, that in this mode the parameters for the symbol search should be restricted as narrow as possible by using set_data_code_2d_param because otherwise the run-time of find_data_code_2d may significantly increase. Also note that the two algorithms slightly differ from each other in terms of robustness. This may lead to different results depending on the value of 'finder_pattern_tolerance' even if the finder pattern of the symbol is not disturbed. For example, if 'high' is chosen, only symbols with an equidistant module grid can be found (see below), and hence the robustness to perspective distortions is decreased. Finally, if 'finder_pattern_tolerance' is set to 'any' both algorithms are applied.
Values: 'low' , 'high' ,'any'
Default: 'low' (enhanced: 'low' , maximum: 'any' )
Describes the tolerance of the search with respect to local contrast variations (e.g., in the presence of glare or reflections). Depending on the value of the parameter two different algorithms are applied. If 'contrast_tolerance' is set to 'high' the robustness in the presence of strong local contrast variations is improved. In the case where 'contrast_tolerance' is set to 'low' the algorithm less robust in case of strong local contrast variations, however it is faster and still able to handle contrast variations under normal circumstances and therefore should be used in most cases. If 'contrast_tolerance' is set to 'any' both algorithms are applied.
Values: 'low' , 'high' , 'any'
Default: 'low' (enhanced: 'low' , maximum: 'any' )
Describes whether the size of the modules may vary (in a specific range) or not. Dependent on this parameter different algorithms are used for calculating the module's center positions. If it is set to 'fixed' , an equidistant grid is used. Allowing a variable module size ('variable' ), the grid is aligned only to the alternating side of the finder pattern. With 'any' both approaches are tested one after the other. Please note that the value of 'module_grid' is ignored if 'finder_pattern_tolerance' is set to 'high' . In this case an equidistant grid is assumed.
Values: 'fixed' , 'variable' , 'any'
Default: 'fixed' (enhanced: 'any' )
QR Code:
Number of position detection patterns that have to be visible for generating a new symbol candidate.
Value range: [2, 3]
Default: 3 (enhanced: 2)
Aztec Code:
Tolerance of the search with respect to a defect or partially occluded finder pattern. Depending on this parameter, different algorithms are used during the symbol search in find_data_code_2d. In one case ('low' ), it is assumed that all rings of the finder pattern can be extracted. In the other case ('high' ) it is assumed that at least one of the rings of the finder pattern can be extracted. As a consequence the runtime of the reader increases, if this parameter is set to 'high' .
Values: 'low' , 'high'
Default: 'low' (enhanced: 'high' )
To increase the robustness of the Aztec Code reader, a number of additional search levels (in addition to the search levels derived from the minimum and maximum module dimensions) can be specified via this parameter. Be aware that this increases the runtime of the reader, especially if no code is found.
Value range: [0 .. 2]
Default: 0
General model behavior:
All data code types:
Controls whether certain intermediate results of the symbol search with find_data_code_2d are stored temporarily or persistently in the model. The memory requirements of find_data_code_2d are significantly smaller if the data is stored temporarily (default). On the other hand, by using the persistent storage it is possible to access some of the data for debugging reasons after searching for symbols, e.g., to investigate why a symbol could not be read. The memory requirements of find_data_code_2d can further be reduced by setting 'persistence' to -1 such that only the data necessary for retrieving the decoded data is stored with the model. Be aware that print quality inspection cannot be used with this setting of 'persistence' .
Values: -1 (only decoded data), 0 (temporary), 1 (persistent)
Default: 0
Controls whether candidates that could not be successfully decoded are stored in the model. Set this parameter to 'yes' to reduce the amount of memory consumed by the model. Note that in this case information about undecoded candidates cannot be queried by using get_data_code_2d_objects or get_data_code_2d_results.
Values: 'yes' , 'no'
Default: 'no'
Controls the behavior of find_data_code_2d while detecting symbols that could be read but that do not fit the model restrictions on the size of the symbols. They can be rejected (strict model, set to 'yes' ) or returned as a result independent of their size and the size specified in the model (lax model, set to 'no' ).
Values: 'yes' (strict), 'no' (not strict)
Default: 'yes'
By the use of this parameter, it is possible to abort find_data_code_2d after a defined period in milliseconds. This is especially useful in cases where a maximum cycle time has to be ensured. All results gained before the timeout can be accessed by get_data_code_2d_results. Passing values less or equal zero implies a deactivation of the timeout (default).
The temporal accuracy is about 10 ms. It depends on several factors including the speed of your computer, the image size 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 'aborted' in get_data_code_2d_results.
Note that the timeout is ignored if find_data_code_2d runs in training mode.
Typical values: 'false' , -1, 20 .. 100
Default: 'false'
Using this option, it is possible to abort find_data_code_2d from another thread. When set_data_code_2d_param is called with 'abort' , an instance of find_data_code_2d with the model DataCodeHandle running in another thread is requested to abort. If there is no find_data_code_2d running with this model, nothing happens.
The operator find_data_code_2d might not return immediately. It has to reach a cancellation point to ensure a proper cleanup. Depending on different factors like the computer performance this may take up to 10 ms.
All decoded results until this moment, are still returned. Note that the parameter is ignored if find_data_code_2d runs in training mode.
Note: This is the only action with a data code handle, which can be used from different threads without requiring additional synchronization.
Default: 'true' (The value is not processed.)
The reference image, on which the quality grades Symbol Contrast, Modulation, Reflectance Margin, and Fixed Pattern Damage are assessed, is obtained by applying a synthetic aperture (circular mean filter) on the original image. This parameter determines the filter size as the part of the module size. According to the standard, this value should be chosen between 0.5 and 0.8 depending on the application.
For further guidance on selecting the aperture, see ISO/IEC 15415:2011 Annex D.2.
Value range: [0 .. 1]
Default: 0.8
All data code types except Aztec Code:
Controls the behavior of find_data_code_2d while detecting symbols that could be read but show defects in their quiet zone. If 'strict_quiet_zone' is set to 'yes' the quiet zone of all decoded symbol is validated similar to the method used for print quality inspection. Symbols with poor grades for their quiet zone are not returned as a result. Their 'status' is set to 'quiet zone is missing' . If 'strict_quiet_zone' is set to 'no' (this is the default case), all readable symbols are returned as a result.
Values: 'yes' , 'no'
Default: 'no'
Data Matrix ECC 200:
Controls the decoding step of Data Matrix ECC 200. When setting this to 'raw' , this allows to read symbols where the appearance and the error correction step conform to ISO/IEC 16022:2006, but where the encoding is custom. The decoded data are the error corrected data, are retrieved with the 'decoded_data' parameter of get_data_code_2d_results and must be further processed by the user.
Values: 'default' , 'raw'
Default: 'default'
When setting the model parameters, attention should be payed especially to the following issues:
Symbols whose size does not comply with the size restrictions made in the model (with the generic parameters 'symbol_rows*' , 'symbol_cols*' , 'symbol_size*' , or 'version*' ) will not be read if 'strict_model' is set to 'yes' , which is the default. This behavior is useful if symbols of a specific size have to be detected while other symbols should be ignored. On the other hand, neglecting this parameter can lead to problems, e.g., if one symbol of an image sequence is used to adjust the model (including the symbol size), but later in the application the symbol size varies, which is quite common in practice.
The run-time of find_data_code_2d depends mostly on the following model parameters, namely in cases where the requested number of symbols cannot be found in the image: 'polarity' , 'module_size_min' (ECC 200, QR Code, and Micro QR Code) and 'module_size_min' together with 'module_aspect_min' (PDF417), and if the minimum module size is very small also the parameters 'module_gap_*' (ECC 200, Aztec, QR Code, and Micro QR Code), for QR Code also 'position_pattern_min' . For ECC 200 symbols, if 'finder_pattern_tolerance' is set to 'high' or 'any' , the symbol size should be restricted with 'symbol_size_min' , 'symbol_size_max' , 'symbol_size' , and 'symbol_shape' as narrow as possible.
This operator modifies the state of the following input parameter:
The value of this parameter may not be shared across multiple threads without external synchronization.Handle of the 2D data code model.
Names of the generic parameters that shall be adjusted for the 2D data code.
Default value: 'polarity'
List of values: 'abort' , 'additional_levels' , 'contrast_min' , 'contrast_tolerance' , 'decoding_scheme' , 'default_parameters' , 'discard_undecoded_candidates' , 'finder_pattern_tolerance' , 'format' , 'mirrored' , 'model_type' , 'module_aspect' , 'module_aspect_max' , 'module_aspect_min' , 'module_gap' , 'module_gap_max' , 'module_gap_min' , 'module_grid' , 'module_size' , 'module_size_max' , 'module_size_min' , 'module_width' , 'module_width_max' , 'module_width_min' , 'persistence' , 'polarity' , 'position_pattern_min' , 'quality_isoiec15415_aperture_size' , 'slant_max' , 'small_modules_robustness' , 'strict_model' , 'strict_quiet_zone' , 'symbol_cols' , 'symbol_cols_max' , 'symbol_cols_min' , 'symbol_rows' , 'symbol_rows_max' , 'symbol_rows_min' , 'symbol_shape' , 'symbol_size' , 'symbol_size_max' , 'symbol_size_min' , 'timeout' , 'trained' , 'version' , 'version_max' , 'version_min'
Values of the generic parameters that are adjusted for the 2D data code.
Default value: 'light_on_dark'
Suggested values: 'standard_recognition' , 'enhanced_recognition' , 'maximum_recognition' , 'yes' , 'no' , 'any' , 'dark_on_light' , 'light_on_dark' , 'square' , 'rectangle' , 'small' , 'big' , 'fixed' , 'variable' , 'low' , 'high' , 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 30, 50, 70, 90, 12, 14, 16, 18, 20, 22, 24, 26, 32, 36, 40, 44, 48, 52, 64, 72, 80, 88, 96, 104, 120, 132, 144
* This examples shows how a model can be adapted to a specific symbol if * the symbol parameters are known * Create a model for reading Data matrix ECC 200 codes create_data_code_2d_model ('Data Matrix ECC 200', [], [], DataCodeHandle) * Restrict the model by setting the module size set_data_code_2d_param (DataCodeHandle, \ ['module_size_min','module_size_max'], [4,7]) * Change the polarity setting of the model from 'dark_on_light' to * 'light_on_dark' and, at the same time, specify a new minimum contrast set_data_code_2d_param (DataCodeHandle, ['polarity','contrast_min'], \ ['light_on_dark',10]) * Read an image read_image (Image, 'datacode/ecc200/ecc200_cpu_010') * Read the symbol in the image find_data_code_2d (Image, SymbolXLDs, DataCodeHandle, [], [], \ ResultHandles, DecodedDataStrings) * Clear the model clear_data_code_2d_model (DataCodeHandle)
The operator set_data_code_2d_param returns the value 2 (H_MSG_TRUE) if the given parameters are correct. Otherwise, an exception is raised.
create_data_code_2d_model, read_data_code_2d_model
get_data_code_2d_param, find_data_code_2d, write_data_code_2d_model
query_data_code_2d_params, get_data_code_2d_param, get_data_code_2d_results, get_data_code_2d_objects
Data Code
Operators |