HALCON offers functions for the interactive drawing of regions of interest such as draw_rectangle2. These functions are often used to enable a production engineer to train new parts or define new measurements. Because these functions block the calling thread, no image processing can be done while the user is modifying the region of interest. Therefore no feedback is provided as to whether the user achieves the desired results while drawing.
In HALCON 12 MVTec introduced drawing objects that can be attached and detached from a graphics window and modified asynchronously. To create a drawing object and attach it to a window, call:
create_drawing_object_circle (Row, Column, Radius, DrawID)
attach_drawing_object_to_window (WindowHandle, DrawID)
The drawing object appears on top of the graphics window until it is detached. Until then, you can reposition and resize it as you wish. To display an image behind the drawing object, use:
attach_background_to_window (Image, WindowHandle)
The shape parameters can be queried asynchronously with:
get_drawing_object_params (DrawID, ParamNames, ParamValues)
Additionally, it is possible to register a callback function that is invoked each time the user modifies the drawing object. Inside that callback function you can access the shape parameters and process the region of interest so that the user gets live feedback while drawing.
To remove the shape overlay from the window, simply call:
detach_drawing_object_from_window (WindowHandle, DrawID)
The example program create_drawing_object_rectangle2.hdev, available in HALCON, shows you how to create an interactive measure tool using this functionality.