6.2   Control Parameters

HALCON/C++ can handle different types of control parameters for HALCON operators:

A special form of control parameters are the so-called handles, which provide access to more complex data structures like windows, image acquisition connections, or models for shape-based matching. Internally, handles are represented by a distinct control data type. They are “magic” values that must not be changed and can differ from execution to execution and version to version. Once all instances of the handle are overwritten or cleared, the handle and its content will be destroyed and will become invalid. For handles there exist corresponding classes, which are described in section “Classes Encapsulating Handles”.

With the class HTuple, HALCON/C++ provides a container class for control parameters. HTuple may contain arrays of control parameters of mixed type.

6.2.1   Tuples

The class HTuple implements an array of dynamic length. The default constructor constructs an empty array (Length() == 0). This array can dynamically be expanded via assignments. The memory management, i.e., reallocation, freeing, is also managed by the class. The index for accessing the array is in the range between 0 and Length() − 1.

The class HTuple is thread safe. Copies of a HTuple instance can be used in different threads concurrently.

The following member functions reflect only a small portion of the total. For further information please refer to the file HTuple.h in %HALCONROOT%\include\halconcpp.

String Encoding

The class HTuple always stores raw char pointer strings in the interface encoding. This is important especially when accessing the internal raw pointer via the methods HTuple::SArr() and HTupleElement::C().

Under Windows it is possible to initialize a HTuple or a HTupleElement with a wide character string (wchar_t*, UTF-16). That wide character string is converted into the current interface encoding (default: UTF-8). If that interface encoding is not UTF-8, the conversion can involve transcoding errors, i.e., the stored string may not contain all characters of the input wide character string. The class HTuple does not allow to access the string in a different encoding or as wide character string.

6.2.2   Strings

The class HString can be used when transcoding or access to a wide character raw pointer is needed. Like HTuple, the class can be initialized with a wchar_t pointer string (Windows only) or with a raw char pointer string with the current interface encoding. HString allows to create a string with a specific encoding via HString::FromUtf8(const char*) or HString::FromLocal8bit(const char*).

Furthermore, this class allows to store the same string in UTF-8, local-8-bit encoding, and wide character string at the same time. Thus it is save to use the required raw pointer, as long as the HString instance is not modified or destroyed. The string remains the owner of the string memory for all representations.

The following methods for accessing raw pointers are provided:

6.2.3   Classes Encapsulating Handles

The perhaps most prominent handle class is HWindow, which is described in section “Windows”. HALCON/C++ also provides classes for handles to files or functionality like access to image acquisition devices, measuring, or shape-based matching. See section “Other Handle Classes” for an overview.

6.2.3.1   Windows

The class HWindow provides the management of HALCON windows in a very convenient way. The properties of HALCON windows can be easily changed, images, regions, and polygons can be displayed, etc. Besides those operators that can be called via HWindow (see also section “Calling Operators via Classes”), HWindow provides the following member functions:

6.2.3.2   Other Handle Classes

HALCON/C++ provides the so-called handle classes like HFramegrabber, HBarCode, or HClassBoxMlp. These are based on the class HHandle.

Besides the default constructor, the classes typically provide additional constructors based on suitable operators as described in section “Constructors and Halcon Operators”; e.g., the class HBarCode provides a constructor based on the operator CreateBarCodeModel.

The reference manual provides short overview pages for these classes, listing the operators that can be called via them.