halcon求矩形Length1或者length2所在中线的起止点

        为了配合halcon卡尺的使用,我们需要先知道测量直线的起止点。这个函数就是为了求一个矩形两边的起止点使用的,可以更方便的根据矩形去变化点位,而不用手动的给起止点。

Lenght1边: 

函数代码: 

*通过矩形测量可以获得要测量直线的起止点

gen_empty_obj (Point)
RowBegin := 0
ColumnBegin := 0
RowEnd := 0
ColumnEnd := 0
try   
    smallest_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
    orientation_region (Rectangle, RecPhi)
    RowBegin := Row + Length1 * sin(RecPhi)
    ColumnBegin := Column - Length1 * cos(RecPhi)
    gen_cross_contour_xld (Cross, RowBegin, ColumnBegin, 60, rad(45))
    RowEnd := Row - Length1 * sin(RecPhi)
    ColumnEnd := Column + Length1 * cos(RecPhi)
    gen_cross_contour_xld (Cross1, RowEnd, ColumnEnd, 60, rad(45))
    
    
    *轮廓
    concat_obj (Point, Cross, Point)
    concat_obj (Point, Cross1, Point)
catch (Exception)
endtry

return ()

Lebgth2边: 

 

函数代码:

*通过矩形测量可以获得要测量直线的起止点

gen_empty_obj (Point)
RowBegin := 0
ColumnBegin := 0
RowEnd := 0
ColumnEnd := 0
try
    smallest_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
    RowBegin := Row - Length2 * cos(Phi)
    ColumnBegin := Column - Length2 * sin(Phi)
    gen_cross_contour_xld (Cross, RowBegin, ColumnBegin, 60, rad(45))
    RowEnd := Row + Length2 * cos(Phi)
    ColumnEnd := Column + Length2 * sin(Phi)
    gen_cross_contour_xld (Cross1, RowEnd, ColumnEnd, 60, rad(45))
    
    *轮廓
    concat_obj (Point, Cross, Point)
    concat_obj (Point, Cross1, Point)
catch (Exception)
endtry

return ()

 

 

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值