2.3.3   HALCON/C++

The C++ interface is much more sophisticated than the C interface. Here, the advantages of C++ and object-oriented programming are used, i.e., automatic type conversion, construction and destruction, or grouping functions together with their data into classes. Like in the C interface, global functions for each HALCON operator are provided for a procedural style of programming.

Example

The following code reads an image and computes the number of connected regions in it.

  HImage img{"pcb"};

  HRegion region = img.Threshold(0, 122);
  Hlong numRegions = region.Connection().CountObj();

  std::cout << "Number of Regions: " << numRegions << '\n';

For prerequisites and a detailed walk-through, please see Programmer's Guide, Part 2, A First Example.