HALCON示例程序inspect_solar_fingers.hdev太阳能电池板电路缺陷检测
生活随笔
收集整理的這篇文章主要介紹了
HALCON示例程序inspect_solar_fingers.hdev太阳能电池板电路缺陷检测
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
HALCON示例程序inspect_solar_fingers.hdev太陽能電池板電路缺陷檢測
示例程序源碼(加注釋)
- 關(guān)于顯示類函數(shù)解釋
dev_update_off ()
dev_close_window ()
ImageName := ‘solar_cell/solar_cell_’
read_image (Image, ImageName + ‘01’)
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
set_display_font (WindowHandle, 14, ‘mono’, ‘true’, ‘false’)
dev_set_color (‘red’)
dev_set_draw (‘margin’)
dev_set_line_width (2)
NumImages := 6
for Index := 1 to NumImages by 1
read_image (Image, ImageName + Index$‘02’)- 彩色圖像分成RGB三個(gè)通道
decompose3 (Image, ImageR, ImageG, ImageB) - 二值化
threshold (ImageR, Region, 0, 159)
*分割連通域
connection (Region, ConnectedRegions) - 使用寬度、高度、面積對區(qū)域進(jìn)行篩選
select_shape (ConnectedRegions, GoodSmallParts, [‘a(chǎn)rea’,‘width’], ‘a(chǎn)nd’, [3500,130], [5000,300])
select_shape (ConnectedRegions, GoodLongParts, [‘a(chǎn)rea’,‘width’], ‘a(chǎn)nd’, [6000,350], [10000,550])
select_shape (ConnectedRegions, Clutter, [‘width’,‘height’,‘a(chǎn)rea’], ‘or’, [900,900,0], [1000,1000,100]) - 求取篩選出的與合格的不同的區(qū)域
difference (ConnectedRegions, GoodSmallParts, Difference)
difference (Difference, GoodLongParts, Difference)
difference (Difference, Clutter, BrokenParts) - 對不合格區(qū)域進(jìn)行形狀變換,變換為矩形
shape_trans (BrokenParts, BrokenPartsTrans, ‘rectangle1’) - 合格的部分高度大概在19,用高為25的矩形進(jìn)行腐蝕,那么斷開區(qū)域就能被篩選出來了
erosion_rectangle1 (BrokenParts, RegionErosion, 1, 25)
connection (RegionErosion, ConnectedBreaks) - 求區(qū)域的最小外接圓
shape_trans (ConnectedBreaks, Breaks, ‘outer_circle’) - 膨脹一下
dilation_circle (Breaks, Breaks, 6) - 刪除空區(qū)域
select_shape (Breaks, Breaks, ‘a(chǎn)rea’, ‘a(chǎn)nd’, 1, 99999999)
count_obj (Breaks, CountBreaks)
dev_display (Image)
dev_display (BrokenPartsTrans)
dev_display (Breaks)
disp_message (WindowHandle, ‘Cell OK’, ‘window’, 12, 12, ‘black’, ‘true’)
else
disp_message (WindowHandle, ‘Cell not OK’, ‘window’, 12, 12, ‘red’, ‘true’)
endif
*
if (Index != NumImages)
disp_continue_message (WindowHandle, ‘black’, ‘true’)
stop ()
endif- 如果只有一處缺陷,放大顯示
if (CountBreaks == 1)
dev_open_window (0, 610, 300, 300, ‘black’, WindowHandle1)
area_center (Breaks, Area, Row, Column)
dev_set_part (Row[0] - 50, Column[0] - 50, Row[0] + 50, Column[0] + 50)
dev_display (Image)
dev_display (BrokenPartsTrans)
dev_display (Breaks)
stop ()
dev_set_window (WindowHandle1)
dev_close_window ()
endif
endfor
- 彩色圖像分成RGB三個(gè)通道
處理思路
這個(gè)例子是主要講解了太陽能電池板的電路完整性檢測。靈活的應(yīng)用了select_shape 與difference ;shape_trans完成了缺陷區(qū)域的框選;erosion_rectangle1 腐蝕缺陷區(qū)域以提取斷點(diǎn)。
后記
大家有什么問題可以向我提問哈,我看到了第一時(shí)間回復(fù),希望在學(xué)習(xí)的路上多多結(jié)交良師益友。
總結(jié)
以上是生活随笔為你收集整理的HALCON示例程序inspect_solar_fingers.hdev太阳能电池板电路缺陷检测的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在latex或者mathtype中如何输
- 下一篇: Opening My World——ES