Halcon - 测量 - 轮廓到线的距离

Result

Halcon - 测量 - 轮廓到线的距离_第1张图片

Explanation

唯一需要注意的点就是 distance_lc 这个算子测量的是正交位置的点矩

count_obj (UnionContours, CountObj)
tuple_length (RowBegin, CountTuple)
if (CountObj == CountTuple)
    for Index := 1 to CountObj by 1
        dev_display (ImageReduced)
        select_obj (UnionContours, ObjectSelected2, Index)
        * 测量实际轮廓与标准线的距离
        distance_lc (ObjectSelected2, RowBegin[Index-1], ColBegin[Index-1], RowEnd[Index-1], ColEnd[Index-1], DistanceMin, DistanceMax)
        * 显示测量结果
        disp_message (WindowHandle, 'Min: ' + DistanceMin + '\nMax: ' + DistanceMax, 'window', -1, -1, 'black', 'true')
        * 显示实际轮廓
        dev_set_color ('red')
        dev_display (ObjectSelected2)
        * 显示标准线
        dev_set_color ('green')
        disp_line (WindowHandle, RowBegin[Index-1], ColBegin[Index-1], RowEnd[Index-1], ColEnd[Index-1])
        * 等待2s
        wait_seconds (2)
    endfor
endif

转载于:https://www.cnblogs.com/zdfffg/p/11572543.html

你可能感兴趣的:(Halcon - 测量 - 轮廓到线的距离)