# Halcon中的坐标系特点及XLD的镜像转换

 1 gen_image_const (Image, 'byte', 512, 512)
2 dev_set_draw ('margin')
3
4 *点1
5 gen_circle (Circle1, 10, 10, 3)
6 disp_message (3600, '(10 ,10)', 'image', 2, 18, 'white', 'false')
7 *点2
8 gen_circle (Circle2, 100, 200, 3)
9 disp_message (3600, '(100 ,200)', 'image', 92, 208, 'white', 'false')
10 *点3
11 gen_circle (Circle3, 400, 100, 3)
12 disp_message (3600, '(400 ,100)', 'image', 392, 108, 'white', 'false')
13
14 union2 (Circle1,Circle2, RegionUnion)
15 union2 (RegionUnion,Circle2, RegionUnion)
16 union2 (RegionUnion,Circle3, RegionUnion)
17 gen_contour_region_xld (RegionUnion, Contours, 'border')
18 write_contour_xld_dxf (Contours,'C:/Users/happy xia/Desktop/XLD的镜像变换/threePoint.dxf')

1 gen_image_const (Image, 'byte', 7000, 5000)
2 read_contour_xld_dxf (Contours,'unionContour.dxf', [], [], DxfStatus)
3
4 *方法1：先转换为Region，再镜像Region，最后转回到XLD
5 gen_region_contour_xld (Contours, Region, 'margin')
6 mirror_region (Region, RegionMirror, 'row', 6000)
7 gen_contour_region_xld (RegionMirror, ContoursMirror, 'border')

 1 gen_image_const (Image, 'byte', 7000, 5000)
2 read_contour_xld_dxf (Contours,'unionContour.dxf', [], [], DxfStatus)
3
4 *方法2：点对点镜像重绘
5 count_obj (Contours, Num)
6 Step := 5
7 axisValue := 6000
8
9 gen_empty_obj (Contour2)
10 for i := 1 to Num by 1
11     select_obj (Contours, Contour, i)
12     get_contour_xld (Contour, Row, Col)
13     Row1 := []
14     Col1 := []
15     for j := 0 to |Row|-1 by Step
16
17         Row1:=[Row1,axisValue - Row[j]]
18         Col1:=[Col1,Col[j]]
19
20     endfor
21
22     test_closed_xld (Contour, IsClosed)
23     if (IsClosed = 1)
24         Row1:=[Row1,axisValue - Row[0]]
25         Col1:=[Col1,Col[0]]
26
27     endif
28
29     gen_contour_polygon_xld (Contour1, Row1, Col1)
30     smooth_contours_xld (Contour1, SmoothedContours, 3)
31     concat_obj (Contour2, SmoothedContours, Contour2)
32 endfor

1 gen_image_const (Image, 'byte', 7000, 5000)
2 read_contour_xld_dxf (Contours,'unionContour.dxf', [], [], DxfStatus)
3
4 *方法3：使用仿射变换镜像
5 hom_mat2d_identity (HomMat2DIdentity)
6 hom_mat2d_reflect (HomMat2DIdentity, 3000, 0, 3000, 100, HomMat2DReflect)
7 affine_trans_contour_xld (Contours, ContoursAffinTrans, HomMat2DReflect)

posted on 2017-08-31 21:43  xh6300  阅读(13926)  评论(0编辑  收藏  举报