码迷,mamicode.com
首页 > 其他好文 > 详细

Halcon拟合直线

时间:2018-08-09 18:25:45      阅读:1806      评论:0      收藏:0      [点我收藏+]

标签:col   rect   alc   bsp   ros   distance   ict   rectangle   measure   

read_image(Image,'C:/Users/研发/Pictures/Saved Pictures/qq.bmp')

dev_set_draw ('margin')

get_image_size(Image, Width, Height)

Row:=[479,479,479,479,479]

Col:=[450,455,460,465,470]

RowAfter:=[]

ColAfter:=[]

RowSelect:=[]

ColSelect:=[]

for Index:=0 to 4 by 1

    gen_measure_rectangle2(Row[Index],Col[Index],rad(-90), 20, 2, Width, Height, 'nearest_neighbor', MeasureHandle)

    gen_rectangle2(Rectangle,Row[Index],Col[Index],rad(-90), 20, 2)

    measure_pos (Image, MeasureHandle, 3, 30, 'positive', 'first', RowEdge, ColumnEdge, Amplitude, Distance)

    gen_cross_contour_xld(Cross, RowEdge, ColumnEdge, 6, 0.785398)

    RowAfter[Index]:=RowEdge

    ColAfter[Index]:=ColumnEdge

endfor

*所有点拟合直线

gen_contour_polygon_xld(Contour,RowAfter,ColAfter)

fit_line_contour_xld(Contour, 'tukey', -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)

gen_contour_polygon_xld (ContourD, [RowBegin,RowEnd], [ColBegin,ColEnd])

distance_pl(RowAfter,ColAfter,RowBegin,ColBegin,RowEnd,ColEnd,Distance1)

i:=0

for Index:=0 to 4 by 1

    if(Distance1[Index]<0.4)

        RowSelect[i]:=RowAfter[Index] 

        ColSelect[i]:=ColAfter[Index]

        i:=i+1

    endif

endfor

dev_set_color('green')

*筛选后的点再拟合直线

gen_contour_polygon_xld(Contour1,RowSelect,ColSelect)

fit_line_contour_xld(Contour1, 'tukey', -1, 0, 5, 2, RowBegin1, ColBegin1, RowEnd1, ColEnd1, Nr, Nc, Dist)

gen_contour_polygon_xld (ContourRet, [RowBegin1,RowEnd1], [ColBegin1,ColEnd1])


Halcon拟合直线

标签:col   rect   alc   bsp   ros   distance   ict   rectangle   measure   

原文地址:http://blog.51cto.com/green906/2156893

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!