1.1.2   Internal Structure of HALCON Operators

HALCON operators (like the new operators in halconuser) typically consist of two procedures: One procedure – the supply procedure – receives the input data, tests its consistency, passes it to the processing action procedure and returns the output data after the processing. If the input data contains any composed iconic objects, e.g., image tuples, the supply procedure has to extract the single parts. An iconic object key can represent an unlimited number of iconic objects and every image object may consist of several components (one region and an unlimited number of gray value channels; see also figure 5.2). Generally, a user may assume that a HALCON operator is able to handle single iconic objects as well as composed objects (i.e., multivalue is set to optional; see this page) and that it can work on multi-channel images (i.e., multichannel is set to optional; see this page). So, the author of a new HALCON operator should implement appropriate mechanisms for extracting the needed data from composed iconic objects (or multi-channel images) within the supply procedure. The name of this procedure designates the internal C-procedure name specified in the def-file (cf. section “Short Operator Description” and section “Extended Operator Description”).

After preprocessing the input data, the action procedure is called within the supply procedure. This procedure performs the specific image processing. In most cases the action procedure receives only the already extracted single components (e.g., regions of type Hrlregion, channels of type Himage, or pointers to the raw image data) and parameter values. The results are returned to the supply procedure where they are passed to the generated interface that returns them to the calling system. Every supply procedure returns an error code of type Herror. Thus, it is necessary to return an error code, which is H_MSG_TRUE if no error occurred.

Only one parameter (a so called procedure handle) is passed to a supply procedure. All other input data (iconic objects and control values) is read and written with the help of this identifier. Moreover, it allows the unique identification of a HALCON operator call while running HALCON on parallel hardware. Instead of further parameters, all in- and output to and from the supply procedure is done with the help of several (internal) buffers, as illustrated in figure 1.1.

Figure 1.1: Data flow within HALCON.

The buffer contains input data as well as output data. Control parameters (containing all kind of control values like integers, floating-point values, strings or handles) are stored directly in the buffers, whereas all iconic data (including images, regions and XLDs) are stored in the database and represented by an iconic object key. Iconic data can be accessed with the help of database procedures by using these keys. The Extension Package Interface provides special procedures and macros for reading and writing elements of the parameter buffer within the supply procedure. Every parameter belongs to one of the four classes

that determines the name of the suitable procedures/macros (e.g.: HGetCPar is used to get an input control value). To identify a specific parameter within a class, its number is passed to the procedure/macro. This is the number of the parameter within the parameter-list of a HALCON operator counted for every parameter class (e.g.: to get the value of the second input control parameter, the number 2 must be passed to HGetCPar).

The read-/write access on the buffer is done automatically by the generated interface. The code of this interface is generated by the HALCON compiler hcomp (see this page and section “The HALCON Compiler hcomp”) from a so-called definition file (def-file). Any programmer of a new HALCON operator must provide such a definition file, which contains all relevant information, e.g., concerning in- and output parameters: information about the parameter class (input-/output,iconic object/control), about the parameter type, etc. The syntax and semantics of the definition file is explained in chapter “Operator Description (def-file)”.