Halcon饼干案例

本文通过实际案例介绍了如何使用Halcon进行饼干质量检测,重点在于利用矩阵度评估饼干的合格性,同时学习并应用了几种关键算子。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//官方案例

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值