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. C 接口是 HALCON 支持的最简单的接口。每个算子由一个或两个全局函数表示,其中算子名称和参数顺序与 HDevelop 语言相同。

示例

以下代码读取图像并计算其中 连接区域 的数量。

  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.有关前提条件和详细说明,请参阅 程序员指南,第 5 部分,第一个示例。