About the general workflow🔗
In the following, the required steps to read data codes are described briefly.
-
Create the data code model.
Create a data code model using
This model provides the reader with all necessary information about the structure of the code. For usual printed codes, only the name needs to be provided and HALCON will select suitable default parameters. For special cases, you can modify the model parameters either when creating the data code model or in a later step to adapt the model to a particular symbol appearance.
-
Modify the model parameters for non-standard codes.
Using the default parameters, the data code reader is able to read a wide range of codes. For non-standard codes, the parameters can be modified using
To query the parameters that are valid for the specific data code type, use
query_data_code_2d_params.
To obtain the currently set values of parameters, useget_data_code_2d_param.Do one of the following:
- Select an enhanced set of default parameters using the generic parameter
'default_parameters', for example, with the value'enhanced_recognition'. - Specify the parameter values separately to adapt the model optimally to the conditions of the used print style.
- Instead of modifying the model parameters manually, you can also let HALCON train the model using
find_data_code_2dwith the generic parameter'train'. In this case, HALCON will search for the best parameters needed to extract the given code. To ensure that all variations are covered, applying this to multiple example images is recommended.
- Select an enhanced set of default parameters using the generic parameter
-
Read the data code.
The data code is located and its content is decoded using
For every successfully decoded symbol, the operator returns the surrounding XLD contour, a handle to a result structure, which contains additional information about the symbol as well as about the search and decoding process, and the string that is encoded in the symbol.
With the result handles and the operatorsget_data_code_2d_resultsandget_data_code_2d_objects, additional data about the extraction process can be accessed, which can be used both for process analysis and for displaying.
In particular,get_data_code_2d_resultsallows you to access several alphanumerical results that were calculated while searching and reading the symbols, andget_data_code_2d_objectsallows you to access iconic objects that were created during the last call offind_data_code_2d.
Further operators🔗
In addition to the operators mentioned above, write_data_code_2d_model allows you to write the model into a file, which can later be used to create an identical copy of the model (for example, in a different application).
Such a model copy is created directly by read_data_code_2d_model (without calling create_data_code_2d_model).
Furthermore, you can use serialize_data_code_2d_model and deserialize_data_code_2d_model to serialize and deserialize the data code model.
More Info
For more information, see also Machine vision basics and Data codes.