HALCON示例程序novelty_detection_dyn_threshold.hdev紗網缺陷檢測
示例程序源碼(加注釋)
- 關于顯示類函數解釋
dev_update_window (‘off’)
read_image (Image, ‘plastic_mesh/plastic_mesh_01’)
dev_close_window ()
get_image_size (Image, Width, Height)
dev_open_window_fit_image (Image, 0, 0, Width, Height, WindowHandle)
set_display_font (WindowHandle, 18, ‘mono’, ‘true’, ‘false’)
dev_set_draw (‘margin’)
dev_set_line_width (3)
for J := 1 to 14 by 1read_image (Image, 'plastic_mesh/plastic_mesh_' + J$'02')* 動態閾值分割mean_image (Image, ImageMean, 49, 49)dyn_threshold (Image, ImageMean, RegionDynThresh, 5, 'dark')* 分割連通域connection (RegionDynThresh, ConnectedRegions)* 使用面積進行區域篩選select_shape (ConnectedRegions, ErrorRegions, 'area', 'and', 500, 99999)count_obj (ErrorRegions, NumErrors)dev_display (Image)dev_set_color ('red')dev_display (ErrorRegions)if (NumErrors > 0)disp_message (WindowHandle, 'Mesh not OK', 'window', 24, 12, 'black', 'true')elsedisp_message (WindowHandle, 'Mesh OK', 'window', 24, 12, 'black', 'true')endifif (J < 14)disp_continue_message (WindowHandle, 'black', 'true')stop ()endif
endfor
處理思路
這個例子是主要講解了動態閾值在缺陷檢測中的應用。
后記
大家有什么問題可以向我提問哈,我看到了第一時間回復,希望在學習的路上多多結交良師益友。