Skip to content

About the general workflow🔗

In the following, the required steps to read data codes are described briefly.

  1. 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.

  2. 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, use get_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_2d with 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.
  3. 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 operators get_data_code_2d_results and get_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_results allows you to access several alphanumerical results that were calculated while searching and reading the symbols, and get_data_code_2d_objects allows you to access iconic objects that were created during the last call of find_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.