Chapter 5   Basics of the HALCON/C++ Interface

The HALCON/C++ interface provides two different approaches to use HALCON's functionality within your C++ program: a procedural and an object-oriented approach. The procedural approach corresponds to calling HALCON operators directly as in C or HDevelop, e.g.:

  HObject original_image, smoothed_image;
  ReadImage(&original_image, "monkey");
  MeanImage(original_image, &smoothed_image, 11, 11);

In addition to the procedural approach, HALCON/C++ allows to call HALCON operators in an object-oriented way, i.e., via a set of classes. For example, the code from above can be “translated” into:

  HImage original_image("monkey");
  HImage smoothed_image = original_image.MeanImage(11, 11);

This simple example already shows that the two approaches result in clearly different code: The operator calls differ in the number and type of parameters. Furthermore, functionality may be available in different ways; for example, images can be read from files via a constructor of the class HImage. In general, we recommend using the object-oriented approach. Note, however, that HDevelop can export programs only as procedural C++ code. Section “How to Combine Procedural and Object-Oriented Code” shows how to combine procedural with object-oriented code.

In the following sections, we take a closer look at various issues regarding the use of the HALCON/C++ interface; chapter “The HALCON Parameter Classes” describes the provided classes in more detail.