2.3.1   HALCON/Python

The Python interface stands out for its simplicity and its ability for rapid prototyping. HALCON operators are called directly as standalone functions, after importing the HALCON/Python module. Note also that operator parameters in HALCON/Python are split into function parameters (inputs) and return values (output).

Example

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

  img = ha.read_image('pcb')

  region = ha.threshold(img, 0, 122)
  num_regions = ha.count_obj(ha.connection(region))

  printf('Number of Regions: {num_regions}')

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