Halcon查找钢珠个数
* Image Acquisition 02: Code generated by Image Acquisition 02
ImageFiles := []
ImageFiles[0] := 'D:/image/bilibili/photo/找圆 (1).bmp'
ImageFiles[1] := 'D:/image/bilibili/photo/找圆 (2).bmp'
ImageFiles[2] := 'D:/image/bilibili/photo/找圆 (3).bmp'
ImageFiles[3] := 'D:/image/bilibili/photo/找圆 (4).bmp'
for Index := 0 to |ImageFiles| - 1 by 1
read_image (Image, ImageFiles[Index])
* Image Acquisition 02: Do something
binary_threshold (Image, Region, 'max_separability', 'light', UsedThreshold)
opening_circle (Region, RegionOpening, 3.5)
closing_circle (RegionOpening, RegionClosing, 113.5)
smallest_circle (RegionClosing, Row, Column, Radius)
gen_circle (Circle, Row, Column, Radius)
reduce_domain (Image, Circle, ImageReduced)
binary_threshold (ImageReduced, Region1, 'max_separability', 'dark', UsedThreshold1)
opening_circle (Region1, RegionOpening1, 100.5)
connection (RegionOpening1, ConnectedRegions)
shape_trans (ConnectedRegions, RegionTrans, 'outer_circle')
count_obj (RegionTrans, Number)
dev_display (Image)
set_display_font (200000, 40, 'mono', 'true', 'false')
dev_display (RegionTrans)
disp_message (200000, 'total:'+Number, 'Image', 0, 0, 'black', 'true')
wait_seconds (1)
endfor
运行结果
原图