为了配合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 ()