HALCON示例程序measure_grid.hdev使用XLD分割键盘轮廓
HALCON示例程序measure_grid.hdev使用XLD分割鍵盤輪廓
示例程序源碼(加注釋)
- 關于顯示類函數解釋
dev_update_off ()
read_image (Image, ‘keypad’)
get_image_pointer1 (Image, Pointer, Type, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width, Height, ‘white’, WindowHandle)
set_display_font (WindowHandle, 16, ‘mono’, ‘true’, ‘false’)
dev_display (Image)
dev_set_colored (3)
dev_set_draw (‘fill’) - 動態閾值分割,提取連接區域
mean_image (Image, ImageMean, 7, 7)
dyn_threshold (Image, ImageMean, RegionDynThresh, 4, ‘dark’) - 分割連通域
connection (RegionDynThresh, ConnectedRegions) - 使用最大長度和最大直徑篩選區域
select_shape (ConnectedRegions, SelectedRegions, [‘max_diameter’,‘contlength’], ‘and’, [200,800], [99999,99999]) - 使用圓形元素進行閉運算
closing_circle (SelectedRegions, RegionClosing, 1.5)
dev_display (Image)
dev_display (RegionClosing)
disp_continue_message (WindowHandle, ‘black’, ‘true’)
stop () - 提取骨架
skeleton (RegionClosing, Skeleton) - 將骨架轉化為XLD輪廓
gen_contours_skeleton_xld (Skeleton, ContoursSkeleton, 1, ‘filter’) - 分割XLD輪廓
segment_contours_xld (ContoursSkeleton, ContoursSplitSkeleton, ‘lines’, 5, 2, 1) - 使用連續長度篩選XLD輪廓
select_contours_xld (ContoursSplitSkeleton, SelectedContours, ‘contour_length’, 30, 1000, -0.5, 0.5) - union_collinear_contours_xld - 聯合近似共線的輪廓。
union_collinear_contours_xld (SelectedContours, UnionCollinearContours, 100, 10, 20, rad(10), ‘attr_keep’)
dev_display (Image)
dev_display (UnionCollinearContours)
disp_continue_message (WindowHandle, ‘black’, ‘true’)
stop () - 計數
count_obj (UnionCollinearContours, NumberContours)
gen_empty_obj (LinesHorizontal)
gen_empty_obj (LinesVertical)
dev_display (Image)
dev_set_color (‘red’)
dev_display (LinesVertical)
dev_set_color (‘yellow’)
dev_display (LinesHorizontal)
disp_continue_message (WindowHandle, ‘black’, ‘true’)
stop ()
RowJunction := []
ColJunction := []
RowRealJunction := []
ColRealJunction := []
count_obj (LinesHorizontal, NumberLH)
count_obj (LinesVertical, NumberLV)
dev_set_color (‘white’)
gen_cross_contour_xld (Cross, RowJunction, ColJunction, 12, 0.785398)
dev_display (Cross)
disp_continue_message (WindowHandle, ‘black’, ‘true’)
stop ()
dev_display (Image)
dev_set_color (‘gray’)
dev_display (LinesHorizontal)
dev_display (LinesVertical)
dev_set_color (‘white’)
gen_cross_contour_xld (Cross, RowRealJunction, ColRealJunction, 12, 0.785398)
dev_display (Cross)
disp_continue_message (WindowHandle, ‘black’, ‘true’)
stop ()
set_display_font (WindowHandle, 14, ‘mono’, ‘true’, ‘false’)
dev_display (Image)
junctions_skeleton (Skeleton, EndPoints, JuncPoints)
get_region_points (JuncPoints, RowJunctionRegionProcessing, ColumnJunctionRegionProcessing)
gen_cross_contour_xld (CrossCenter, RowJunctionRegionProcessing, ColumnJunctionRegionProcessing, 12, 0.785398)
dev_set_color (‘gray’)
dev_display (Skeleton)
dev_set_color (‘white’)
dev_display (CrossCenter)
disp_message (WindowHandle, ‘Result of corresponding’, ‘window’, 40, 10, ‘white’, ‘false’)
disp_message (WindowHandle, ‘region processing’, ‘window’, 90, 10, ‘white’, ‘false’)
處理思路
這個例子是主要講解了XLD輪廓擬合直線,進而進行測量的例子。之前我們進行便于提取是提取最外邊的輪廓,之后進行sub_edge求取邊緣進行擬合,這次不同,這次使用的是求取區域,提取區域骨架,對骨架進行XLD擬合分析。
后記
大家有什么問題可以向我提問哈,我看到了第一時間回復,希望在學習的路上多多結交良師益友。
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的HALCON示例程序measure_grid.hdev使用XLD分割键盘轮廓的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 金融财务数据分析报告PPT模板
- 下一篇: 程序员的功法