您好,登錄后才能下訂單哦!
*圖片來自Halcon自帶,Halcon2012版本
for Index := 1 to 6 by 1
read_image (Image, 'blister/blister_' + Index$'02')
decompose3 (Image, ImageR, ImageG, ImageB)
threshold (ImageR, Region1, 128, 255)
shape_trans (Region1, RegionTrans, 'convex')
reduce_domain (ImageB, RegionTrans, ImageReduced)
var_threshold ( ImageReduced, Region, 7, 7, 0.2, 2, 'dark')
connection (Region, ConnectedRegions0)
closing_rectangle1 (ConnectedRegions0, ConnectedRegions, 3, 3)
fill_up (ConnectedRegions, RegionFillUp)
select_shape (RegionFillUp, SelectedRegions, 'area', 'and', 1000, 99999)
opening_circle (SelectedRegions, RegionOpening, 4.5)
connection (RegionOpening, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 1000, 99999)
shape_trans (SelectedRegions, Pills, 'convex')
area_center (Pills, Area, Row, Column)
Mes:=0
*少藥丸
Miss:=15-|Area|
min_max_gray (Pills, ImageG, 0, Min, Max, Range)
*錯藥丸
for i:=0 to |Min|-1 by 1
if(Area[i]<3800)
Mes:=Mes+1
endif
if(Min[i]<80)
Mes:=Mes+1
endif
endfor
*OK藥丸
Res:=15-Miss-Mes
dev_display (Image)
disp_message (3600, '缺少藥丸個數:'+Miss, 'window', 12, 12, 'black', 'true')
disp_message (3600, '錯誤藥丸個數:'+Mes, 'window', 42, 12, 'black', 'true')
disp_message (3600, '正確藥丸個數:'+Res, 'window', 72, 12, 'black', 'true')
stop ()
endfor
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。