halcon例程解析一add_metrology_object_generic的应用-手动画矩形,画圆,画线,画圆弧测量

上一篇文章对add_metrology_object_generic例程进行解析,我们发现例程中的圆,圆弧,矩形和直线都是直接给出的(设定好的)。
本文程序对例程进行修改,可以实现自己手动画矩形,画圆,画线,画圆弧,来选定测量范围。只需对上一篇文章例程中如下部分做个更改,具体程序如下:

*添加几个完整圆
*CircleParam := [354,274,53]
*CircleParam := [CircleParam,350,519,53]
*CircleParam := [CircleParam,345,764,52]
*CircleParam := [CircleParam,596,523,53]
dev_display (Image)
draw_circle (WindowHandle, Row3, Column3, Radius)
draw_circle (WindowHandle, Row4, Column4, Radius1)
draw_circle (WindowHandle, Row5, Column5, Radius2)
draw_circle (WindowHandle, Row6, Column6, Radius3)
CircleParam:=[Row3, Column3, Radius,Row4, Column4, Radius1,Row5, Column5, Radius2,Row6, Column6, Radius3]
add_metrology_object_generic (MetrologyHandle, 'circle', CircleParam, 20, 5, 1, 30, [], [], CircleIndices1)
* 
*添加两个部分圆
*CircleParam1 := [583,1010,79]
*CircleParam2 := [336,1005,77]
draw_circle (WindowHandle, Row8, Column8, Radius5)
draw_circle (WindowHandle, Row7, Column7, Radius4)
CircleParam:=[Row7, Column7, Radius4,Row8, Column8, Radius5]
add_metrology_object_generic (MetrologyHandle, 'circle', CircleParam, 20, 5, 1, 30, ['start_phi','end_phi'], [0,rad(185)], CircleIndices2)
add_metrology_object_generic (MetrologyHandle, 'circle', CircleParam, 20, 5, 1, 30, ['start_phi','end_phi'], [rad(45),rad(185)], Index3)
CircleIndices2 := [CircleIndices2,Index3]  //圆指数
* 
*添加一个矩形
*RectangleParam := [599,279,rad(90),62,51]
draw_rectangle2 (WindowHandle, Row9, Column9, Phi, Length1, Length2)
RectangleParam :=[ Row9, Column9, Phi, Length1, Length2]
add_metrology_object_generic (MetrologyHandle, 'rectangle2', RectangleParam, 20, 5, 1, 30, [], [], RectIndices)
* 添加两条线
*Line1 := [143,1122,709,1132]
*Line2 := [151,153,136,1115]
draw_line (WindowHandle, Row11, Column11, Row21, Column21)
draw_line (WindowHandle, Row12, Column12, Row22, Column22)
Line1:=[Row11, Column11, Row21, Column21]
Line2:=[Row12, Column12, Row22, Column22]

你可能感兴趣的:(halcon图像处理)