Have you ever tried to measure the thickness of a bead or the distance between two opposite 2D edges? Since the release of HALCON 12 this task has become much easier.
The operator distance_contours_xld calculates the closest distance between 2 contours and assigns it as an attribute to each point of the first input contour (XLDFrom).
distance_contours_xld(XLDFrom,XLDTo,ContourOut, ‘point_to_segment’)
Suppose your inspection requirements command a certain minimum thickness. You can extract all segments below that minimum thickness with the operator:
segment_contour_attrib_xld (ContourOut, BadContours, ‘distance’, ‘and’, 0, DistanceMin)
You can also get the distance (thickness) profile through the operator:
get_contour_attrib_xld(ContourOut, ‘distance’, Distance)
By right-clicking the ‘Distance’ variable in the Variable View of HDevelop you can visualise it as a function plot. If you right-click into the plot, you can generate code to recreate it in HDevelop or even in your own application by exporting the generated code.
If you want to process the distance profile further, e.g. apply some smoothing or search for local maxima, HALCON’s operators for 1D functions will come in handy (see chapter Tools/Function in the Reference Manual).
If you are interested in learning more about Halcon please contact us.
Like to try out a trail version? Download here