//官方案例
read_image (Image, 'food/hazelnut_wafer_01')
dev_close_window ()
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
dev_update_window ('off')
dev_set_line_width (3)
dev_set_draw ('margin')
set_display_font (WindowHandle, 20, 'mono', 'true', 'false')
*
for Index := 1 to 24 by 1
read_image (Image, 'food/hazelnut_wafer_' + Index$'.2')
// *$'.02' $'02d' $'02' 以上皆可表示Index为两位数。
binary_threshold (Image, Foreground, 'smooth_histo', 'light', UsedThreshold)
//用二元阈值分割图像
opening_circle (Foreground, FinalRegion, 8.5)
//开运算,消除小于半径8.5的圆
area_holes (FinalRegion, AreaHoles)
//统计圆面积
rectangularity (FinalRegion, Rectangularity)
//矩阵度
dev_display (Image)
if (AreaHoles > 300 or Rectangularity < 0.92) //逻辑判断!
dev_set_color ('red')
Text := 'Not OK'
else
dev_set_color ('forest green')
Text := 'OK'
endif
dev_display (FinalRegion)
disp_messa
Halcon饼干案例
最新推荐文章于 2021-12-27 11:43:34 发布