halcon rectangle2的四个顶点并生成矩形

halcon rectangle2的四个顶点并生成矩形_第1张图片 

*rectangle2的四个顶点
read_image (Image2020090611045988id1, 'C:/Users/ytg18/Desktop/2020090611045988ID1.bmp')
get_image_size (Image2020090611045988id1, Width, Height)
dev_set_draw ('margin')
gen_rectangle2 (Rectangle,  Height/2, Width/2,0, Height/3, Width/4)
reduce_domain (Image2020090611045988id1, Rectangle, ImageReduced)
binary_threshold (ImageReduced, Region, 'max_separability', 'dark', UsedThreshold)
connection (Region, ConnectedRegions)
select_shape_std (ConnectedRegions, SelectedRegions, 'max_area', 70)
smallest_rectangle2 (SelectedRegions, Row16, Column16, Phi3, Length1, Length2)
dev_set_color('red')
tuple_cos (Phi3, Cos)
tuple_sin (Phi3, Sin)
dev_set_color('red')
a:= -Length1*Cos - Length2*Sin
b := -Length1*Sin + Length2*Cos
gen_cross_contour_xld(Cross1, Row16-b,  Column16+a, 56, Phi3)
gen_rectangle2 (Rectangle1, Row16-b, Column16+a, Phi3, Length1/3, Length2/2)
c := Length1*Cos - Length2*Sin
d := Length1*Sin + Length2*Cos
gen_cross_contour_xld(Cross2, Row16-d, Column16+c, 56, Phi3)
gen_rectangle2 (Rectangle2, Row16-d, Column16+c, Phi3, Length1/3, Length2/2)
e:= Length1*Cos + Length2*Sin
f := Length1*Sin - Length2*Cos
gen_cross_contour_xld(Cross3, Row16-f, Column16+e, 56, Phi3)
 gen_rectangle2 (Rectangle2, Row16-f, Column16+e, Phi3, Length1/3, Length2/2)
g := -Length1*Cos + Length2*Sin
h := -Length1*Sin - Length2*Cos
gen_cross_contour_xld(Cross4, Row16-h, Column16+g, 56, Phi3)
 gen_rectangle2 (Rectangle2, Row16-h, Column16+g, Phi3, Length1/3, Length2/2)

 

你可能感兴趣的:(Halcon)