Download HALCON Extension Package Programmer`s Manual

Transcript
CHAPTER 5. HANDLING ICONIC OBJECTS AND CONTROL PARAMETERS
78
(DBFreeProc) HXLDFreeContour
for XLD contours and
(DBFreeProc) HXLDFreePolygon
for XLD polygons allocated based on HAlloc.
Finally, HCrXLD not only creates a new data base object, but also appends this object to the
output object parameter with number par num. Fig. 5.24 and 5.25 show two typical applications
of HCrXLD.
5.5 Reading and Writing Control Parameters
This section describes routines for reading and writing in-/output control parameters, see
Fig. 5.26. Interchanging control data with the host language is done via the data type Hcpar
(see section 4.4).
5.5.1
HGetCPar
HGetCPar (see Fig. 5.26) reads the parameter values of the input control parameter number
par num (1 : : : n) and writes them to the array val of Hcpar structures, that must has been
allocated before with a suitable size (note, that ).
Note, that for every input value, its type (LONG PAR, FLOAT PAR, STRING PAR ) is also stored
within the Hcpar structure. Thus, it is possible to pass different control data types within one
control parameter of a HALCON operator. The current number of values is returned in num.
HGetCPar allows to restrict the parameter access in two respects:
The expected type can be specified by type. This also includes type combinations such
as LONG_PAR | FLOAT_PAR.
The expected number of values can be specified by the interval (min,max), whereas max
should not exceed the number of allocated Hcpar elements within the array val.
If the specified number or types of values are violated, HGetCPar exits the supply procedure
with an appropriate error message. Fig. 5.27 shows an application of HGetCPar.
Note, that in case of string parameters, memory has to be allocated for val[i].par.s. The
easiest way to do this is to use HAllocStringMem specifying the expected number of characters
for all input strings, see section 5.5.7.
5.5.2
HGetSPar
HGetSPar (see Fig. 5.26) is a simplified version of HGetCPar. In contrast to the latter a fixed
number of parameter values is read, see Fig. 5.28. Therefore, the routine does not return the
actual number7 of values.
7
This number is fixed. If more or less values are passed to the HALCON operator, HGetSPar exits the supply
HALCON Extension Package Interface / 2000-11-16