-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path获取轮廓的几种方式.hdev
59 lines (59 loc) · 2.37 KB
/
获取轮廓的几种方式.hdev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?xml version="1.0" encoding="UTF-8"?>
<hdevelop file_version="1.2" halcon_version="19.11.0.0">
<procedure name="main">
<interface/>
<body>
<l>read_image (Image, 'rings_and_nuts')</l>
<c></c>
<l>threshold (Image, Regions, 0, 128)</l>
<c></c>
<c>* 获取轮廓</c>
<c>*1、通过边缘提取轮廓 *亚像素</c>
<l>edges_sub_pix (Image, Edges, 'canny', 1, 20, 40)</l>
<c></c>
<l>edges_image (Image, ImaAmp, ImaDir, 'canny', 1, 'nms', 20, 40)</l>
<c></c>
<c>*2、region->轮廓</c>
<l>gen_contour_region_xld (Regions, Contours, 'center')</l>
<c></c>
<c>* 筛选圆度大于0.9的圆弧</c>
<l>circularity_xld (Edges, Circularity)</l>
<l>tuple_greater_elem(Circularity, 0.9, Greater)</l>
<l>tuple_find (Greater, 1, Indices)</l>
<c></c>
<l>dev_set_line_width (4)</l>
<l>dev_set_color ('red')</l>
<l>select_obj (Edges, ObjectSelected, Indices+1)</l>
<c></c>
<c></c>
<c>* 轮廓的拟合</c>
<c as_id="image_acquisition" as_name="Image Acquisition 01" as_grp="[1,1]" as_ord="1">* Image Acquisition 01: Code generated by Image Acquisition 01</c>
<l as_id="image_acquisition" as_name="Image Acquisition 01" as_grp="[2,1]" as_ord="1">read_image (Image1, 'C:/Users/Public/Documents/MVTec/HALCON-19.11-Progress/examples/images/tooth_rim.png')</l>
<l>edges_sub_pix (Image1, Edges1, 'canny', 1, 30, 35)</l>
<l>union_cocircular_contours_xld (Edges1, UnionContours, 0.5, 0.1, 0.2, 30, 10, 10, 'true', 1)</l>
<c></c>
<c></c>
<l>dev_display (Image)</l>
<l>dev_display (ObjectSelected)</l>
<l>fit_circle_contour_xld (Contours, 'algebraic', -1, 0, 0, 3, 2, Row, Column, Radius, StartPhi, EndPhi, PointOrder)</l>
<l>dev_display (Contours)</l>
<l>dev_display (Image)</l>
<c></c>
<l>gen_circle_contour_xld (ContCircle, Row, Column, Radius, StartPhi, StartPhi, 'negative', 1)</l>
<c></c>
<c>* 从点转换到轮廓</c>
<l>select_obj (Contours, ObjectSelected1, 2)</l>
<l>get_contour_xld (ObjectSelected1, Row1, Col)</l>
<c></c>
<l>dev_display (Image)</l>
<l>tuple_select_range (Row1, 0, 300, SelectedRow) // 取300个点</l>
<l>tuple_select_range (Col, 0, 300, SelectedCol)</l>
<l>gen_contour_polygon_xld (Contour, SelectedRow, SelectedCol)</l>
<l>fit_circle_contour_xld (Contour, 'algebraic', -1, 0, 0, 3, 2, Row2, Column1, Radius1, StartPhi1, EndPhi1, PointOrder1)</l>
<l>gen_circle_contour_xld (ContCircle1, Row2, Column1, Radius1, StartPhi1, StartPhi1, 'negative', 1)</l>
</body>
<docu id="main">
<parameters/>
</docu>
</procedure>
</hdevelop>