-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path简单1D测量.hdev
57 lines (57 loc) · 2.25 KB
/
简单1D测量.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
<?xml version="1.0" encoding="UTF-8"?>
<hdevelop file_version="1.2" halcon_version="19.11.0.0">
<procedure name="main">
<interface/>
<body>
<l>dev_update_window ('off')</l>
<l>dev_close_window ()</l>
<c>* ****</c>
<c>* step: acquire image</c>
<c>* ****</c>
<l>read_image (Fuse, 'fuse')</l>
<l>get_image_size (Fuse, Width, Height)</l>
<l>dev_open_window_fit_image (Fuse, 0, 0, Width, Height, WindowID)</l>
<l>set_display_font (WindowID, 12, 'mono', 'true', 'false')</l>
<l>dev_set_draw ('margin')</l>
<l>dev_set_line_width (3)</l>
<l>dev_display (Fuse)</l>
<l>Angle := rad(90)</l>
<l>Length2 := 10</l>
<c>* spectify ROI</c>
<l>gen_rectangle2 (ROI, 294, 543, Angle, 80, Length2)</l>
<c></c>
<c>* create measure obj</c>
<l>gen_measure_rectangle2 (294, 543, Angle, 80, Length2, Width, Height, 'bilinear', MeasureHandle)</l>
<l>dev_display (ROI)</l>
<c></c>
<c>* step: measure </c>
<l>measure_pairs (Fuse, MeasureHandle, 1, 1, 'negative', 'all', RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance)</l>
<c></c>
<c>* ****</c>
<c>* step: visualize results</c>
<c>* ****</c>
<l>for i := 0 to |RowEdgeFirst| - 1 by 1</l>
<l> gen_contour_polygon_xld (EdgeFirst, [-sin(Angle + rad(90)) * Length2 + RowEdgeFirst[i],-sin(Angle - rad(90)) * Length2 + RowEdgeFirst[i]], [cos(Angle + rad(90)) * Length2 + ColumnEdgeFirst[i],cos(Angle - rad(90)) * Length2 + ColumnEdgeFirst[i]])</l>
<l> gen_contour_polygon_xld (EdgeSecond, [-sin(Angle + rad(90)) * Length2 + RowEdgeSecond[i],-sin(Angle - rad(90)) * Length2 + RowEdgeSecond[i]], [cos(Angle + rad(90)) * Length2 + ColumnEdgeSecond[i],cos(Angle - rad(90)) * Length2 + ColumnEdgeSecond[i]])</l>
<l> dev_set_color ('cyan')</l>
<l> dev_display (EdgeFirst)</l>
<l> dev_set_color ('magenta')</l>
<l> dev_display (EdgeSecond)</l>
<l> dev_set_color ('blue')</l>
<l> if (i == 0)</l>
<l> set_tposition (WindowID, RowEdgeFirst[i] + 5, ColumnEdgeFirst[i] + 20)</l>
<l> else</l>
<l> set_tposition (WindowID, RowEdgeFirst[i] - 40, ColumnEdgeFirst[i] + 20)</l>
<l> endif</l>
<l> write_string (WindowID, 'width: ' + IntraDistance[i] + ' pix')</l>
<l>endfor</l>
<c></c>
<c></c>
<c></c>
<c></c>
</body>
<docu id="main">
<parameters/>
</docu>
</procedure>
</hdevelop>