【Halcon例程】焊点检测实践 ball_seq.hdev

前一篇文章(ball.hdev)已经介绍了焊点检测的大致方法,这篇文章主要介绍(ball_seq.hdev)采用的方法有何改进,以及背后的原因。

方法不同之处1

对比代码发现原来是直接使用size为15.5的圆进行开运算获取焊点圆,而这里size为9.5。

    opening_circle (WiresFilled, Balls, 9.5)
    connection (Balls, SingleBalls)
    select_shape_std (SingleBalls, Rect, 'rectangle1', 90)
    difference (SingleBalls, Rect, IntermediateBalls)
    gen_empty_region (Forbidden)
    expand_gray (IntermediateBalls, Bond, Forbidden, RegionExpand, 4, 'image', 6)
    opening_circle (RegionExpand, RoundBalls, 15.5)

观察图像发现分割后的区域有一个与焊点大小近似的矩形区域(下图蓝色框),而之前的测试图像没有。
在这里插入图片描述
如果这里使用size为15.5的开运算会导致矩形膨胀后为原型不利于后续的分割。所以这里采用size=9.5进行开运算
在这里插入图片描述

方法不同之处2

在获取焊点区域后使用了expand_gray算子(区域外扩到灰度相似区域),认为是通过使用expand_gray提高区域的准确性(但我通过图像看感觉扩展后更差了)。
未扩展前:
在这里插入图片描述
扩展后:在这里插入图片描述

完整代码如下

* ball_seq.hdev: Inspection of Ball Bonding
* 
dev_update_off ()
ImageNames := 'die/' + ['die_02','die_03','die_04','die_07']
dev_set_colored (12)
read_image (Bond, ImageNames[0])
get_image_size (Bond, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_draw ('margin')
dev_set_line_width (3)
NumImages := |ImageNames|
for I := 0 to NumImages - 1 by 1
    read_image (Bond, ImageNames[I])
    dev_display (Bond)
    min_max_gray (Bond, Bond, 0, Min, Max, Range)
    threshold (Bond, Bright, Max - 80, 255)
    shape_trans (Bright, Die, 'rectangle2')
    dev_display (Die)
    reduce_domain (Bond, Die, DieGrey)
    min_max_gray (Die, Bond, 0, Min, Max, Range)
    threshold (DieGrey, Wires, 0, Min + 30)
    fill_up_shape (Wires, WiresFilled, 'area', 1, 100)
    opening_circle (WiresFilled, Balls, 9.5)
    connection (Balls, SingleBalls)
    select_shape_std (SingleBalls, Rect, 'rectangle1', 90)
    difference (SingleBalls, Rect, IntermediateBalls)
    gen_empty_region (Forbidden)
    expand_gray (IntermediateBalls, Bond, Forbidden, RegionExpand, 4, 'image', 6)
    opening_circle (RegionExpand, RoundBalls, 15.5)
    sort_region (RoundBalls, FinalBalls, 'first_point', 'true', 'column')
    smallest_circle (FinalBalls, Row, Column, Radius)
    NumBalls := |Radius|
    Diameter := 2 * Radius
    meanDiameter := sum(Diameter) / NumBalls
    mimDiameter := min(Diameter)
    dev_display (RoundBalls)
    if (I != NumImages)
        disp_continue_message (WindowHandle, 'black', 'true')
    endif
    stop ()
endfor
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Long-Giraffe

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值