2.3.2   HALCON/C

The C interface is the simplest interface supported by HALCON. Each operator is represented by either one or two global functions where the operator name and the parameter sequence are identical to the HDevelop language.

Example

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

  Hobject img;
  read_image(&img, "pcb");

  Hobject region;
  threshold(img, &region, 0, 122);

  Hobject connected_regions;
  connection(region, &connected_regions);

  Hlong num_regions = 0;
  count_obj(connected_regions, &num_regions);

  printf("Number of Regions: %" PRIdPTR "\n", num_regions);

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