2.3.4   HALCON/.NET

C# and Visual Basic .NET use HALCON via the .NET interface.

Analogously to C++, two styles of programming are offered: procedural and object-oriented. For the procedural style, the class HOperatorSet provides all HALCON operators, where HObject is used to handle iconic data and HTuple is used for control data. For the object-oriented style, classes like HDataCode2d, HMeasure, or HShapeModel are provided for the central functionality. In addition, classes for iconic data, e.g., HImage or HRegion, are available.

Example

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

  HImage img = new HImage("pcb");

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

  Console.WriteLine("Number of Regions: " + numRegions);

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