3.2.1   Create Prototype in HDevelop

The task of the following example is to read an image and count the number of connected regions it it.

  1. Open HDevelop and enter the following code into the Program Window:

    read_image (Image, 'pcb')
    threshold (Image, Region, 0, 122)
    connection (Region, ConnectedRegions)
    count_obj (ConnectedRegions, Number)
    

  2. Test your program by clicking Run in the toolbar or pressing F5.

To easily integrate this HDevelop code into an actual application, we encapsulate the machine vision part in a local procedure.

  1. Highlight the following code lines:

    threshold (Image, Region, 0, 122)
    connection (Region, ConnectedRegions)
    count_obj (ConnectedRegions, Number)
    

  2. Right-click to open the context menu.
  3. Choose Create New Procedure.
  4. Name it count_regions.
  5. Select Parameters and change Selection Scheme to First In, Last Out.
  6. Confirm with OK.
  7. Save your HDevelop program as hdev_count_regions.hdev.