halcon學習筆記 例項篇(2)長度和角度測量

2021-07-13 20:15:47 字數 2300 閱讀 6293

例項二:長度和角度測量

素材:

halcon**:

2: dev_close_window()
3: read_image (image, 'd:/myfile/halcon/長度和角度測量/圖.png')
4: crop_rectangle1 (image, imagepart, 75, 0, 400, 400)
5: get_image_size (imagepart, width, height)
6: dev_open_window (0, 0, width, height, 'black', windowhandle)
7: dev_display (imagepart)
8:
9: *獲取圖形的邊界
10: threshold (imagepart, regions, 0, 112)
11:
12: *分離三角形和圓形
13: connection(regions,connectedregions)
14: sort_region(connectedregions,sortedregions,'upper_left','true','column')
15: select_obj(sortedregions,circle,1)
16: select_obj(sortedregions,********,2)
17:
18: *獲取三角形各邊的資訊
19: skeleton(********,********skeleton)
20: gen_contours_skeleton_xld(********skeleton,********contours,1,'filter')
21: segment_contours_xld(********contours,contourssplit,'lines_circles', 5, 4, 2)
22: select_contours_xld(contourssplit,selectedcontours, 'contour_length',100, 999, -0.5, 0.5)
23: fit_line_contour_xld (selectedcontours, 'tukey', -1, 10, 5, 2, rowbegin, colbegin, rowend, colend, nr, nc, dist)
24:
25: *計算三角形角度
26: angle_ll (rowbegin[0], colbegin[0], rowend[0], colend[0], rowbegin[1], colbegin[1], rowend[1], colend[1], angle1)
27: angle_ll (rowbegin[0], colbegin[0], rowend[0], colend[0], rowbegin[2], colbegin[2], rowend[2], colend[2], angle2)
28: angle_ll (rowbegin[1], colbegin[1], rowend[1], colend[1], rowbegin[2], colbegin[2], rowend[2], colend[2], angle3)
29: angle1:=abs(deg(angle1))
30: angle2:=abs(deg(angle2))
31: angle3:=abs(deg(angle3))
32:
33: *獲取圓的資訊
34: area_center(circle,areacircle, rowcircle, columncircle)
35:
36: *計算圓心到三角形各邊的距離
37: distance :=
38:

for index := 0 to 2 by 1

39:     distance_pl (rowcircle, columncircle, rowbegin[index], colbegin[index], rowend[index], colend[index], thisdistance)
40:     distance := [distance,thisdistance]
41: endfor
韓兆新

出處:

halcon學習筆記 例項篇(2)長度和角度測量

例項二 長度和角度測量 素材 halcon 2 dev close window 3 read image image,d myfile halcon 長度和角度測量 圖.png 4 crop rectangle1 image,imagepart,75,0,400,400 5 get image s...

C Templates學習筆記 例項化

一 on demand例項化 有時候也被稱為隱式例項化或者自動例項化。on demand例項化表明 在使用模板 特化 的地方,編譯器通常需要訪問模板和某些模板成員的整個定義。例子 templateclass c 前置宣告 c p 0 正確,因為這裡不需要知道c的定義 template class c...

Python基礎學習筆記例項

最近在學習python,看了黑馬老師課程裡的名片管理,自己寫了一遍,感覺還比較有用。用字典存名片內容,包括名片的新增 修改 顯示全部。主函式 import crad def 無限迴圈,0退出 while true 顯示功能選單 card def.show menue action str input...