您好,登录后才能下订单哦!
*图片来自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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。