Functions

The image processing algorithms are encapsulated in functions. More complex algorithms have been implemented as function blocks and can be found at ImageProcessing.

Structure of a function call

Functions are structured as follows:

Functions 1:

hr

Status variable of the type HRESULT. The execution status of every function can be followed with this.

Parameter <...>

Function parameters essentially fulfill the following purpose:

  • Input parameters (e.g. images or containers) that are to be processed.
  • Parameters for setting the algorithm
  • Parameters as reference for returning the results

Optional parameter <...>

These parameters are initialized with default values, so the specification is optional.

Grouping of functions

All functions of the TwinCAT Vision library are sorted thematically into the following groups:

Images

Container

Contours

Measurement

Code quality

Code reading

Optical character recognition (OCR)

Drawing and text

Machine Learning

Advanced Functions

Miscellaneous

Expert functions

Expert versions exist for many functions. These contain additional parameters and are identified in the PLC library by the name suffix "Exp". In C++, these additional parameters are assigned default values and can be omitted when called if not required.

Runtime behavior

The execution duration of some image processing algorithms depends on their parameterization and also the image content. It is therefore not deterministic. In order to guarantee real-time behavior despite that, watchdogs can be applied to these functions or function groups that abort the functions after a specified time.

WARNING

TwinCAT crash when functions are used incorrectly

If some functions are used incorrectly, this can lead to errors (and to resulting TwinCAT crashes). These are not intercepted within the function, as corresponding checks would considerably lengthen the execution time. Therefore, you must take care to use the functions properly! For example, we recommend carrying out a validation of the input parameters.