【issue-halcon例程学习】ball.hdev

例程功能

 检测球形焊盘的直径。

代码如下

* ball.hdev: Inspection of Ball Bonding
* 
dev_update_window ('off')
dev_close_window ()
dev_open_window (0, 0, 728, 512, 'black', WindowID)
read_image (Bond, 'die/die_03')
dev_display (Bond)
set_display_font (WindowID, 14, 'mono', 'true', 'false')
disp_continue_message (WindowID, 'black', 'true')
stop ()
threshold (Bond, Bright, 100, 255)
shape_trans (Bright, Die, 'rectangle2')
dev_set_color ('green')
dev_set_line_width (3)
dev_set_draw ('margin')
dev_display (Die)
disp_continue_message (WindowID, 'black', 'true')
stop ()
reduce_domain (Bond, Die, DieGrey)
threshold (DieGrey, Wires, 0, 50)
fill_up_shape (Wires, WiresFilled, 'area', 1, 100)
dev_display (Bond)
dev_set_draw ('fill')
dev_set_color ('red')
dev_display (WiresFilled)
disp_continue_message (WindowID, 'black', 'true')
stop ()
opening_circle (WiresFilled, Balls, 15.5)
dev_set_color ('green')
dev_display (Balls)
disp_continue_message (WindowID, 'black', 'true')
stop ()
connection (Balls, SingleBalls)
select_shape (SingleBalls, IntermediateBalls, 'circularity', 'and', 0.85, 1.0)
sort_region (IntermediateBalls, FinalBalls, 'first_point', 'true', 'column')
dev_display (Bond)
dev_set_colored (12)
dev_display (FinalBalls)
disp_continue_message (WindowID, 'black', 'true')
stop ()
smallest_circle (FinalBalls, Row, Column, Radius)
NumBalls := |Radius|
Diameter := 2 * Radius
meanDiameter := mean(Diameter)
minDiameter := min(Diameter)
dev_display (Bond)
disp_circle (WindowID, Row, Column, Radius)
dev_set_color ('white')
disp_message (WindowID, 'D: ' + Diameter$'.4', 'image', Row - 2 * Radius, Column, 'white', 'false')
dev_update_window ('on')

要点

  1. 通过亮暗区域分割并将转换为最小的周围矩形来定位芯片;
	threshold (Bond, Bright, 100, 255)
	shape_trans (Bright, Die, 'rectangle2')

shape_trans 会比smallest_xxx来的方便
2. 填充区域中的孔、裂缝——fill_up/fill_up_shape
fill_up实现对区域的完整填充;
fill_up_shape按指定区域特征的范围填充;
3. opening_circle进行第一轮筛选,比”connection + select_shape“高级;

	opening_circle (WiresFilled, Balls, 15.5)
	connection (Balls, SingleBalls)
	select_shape (SingleBalls, IntermediateBalls, 'circularity', 'and', 0.85, 1.0)
	sort_region (IntermediateBalls, FinalBalls, 'first_point', 'true', 'column')
	smallest_circle (FinalBalls, Row, Column, Radius)

相关推荐

  1. issue-halcon学习】ball.hdev

    2024-01-20 14:06:01       29 阅读
  2. issue-halcon学习】fin.hdev

    2024-01-20 14:06:01       47 阅读
  3. issue-halcon学习】measure_arc.hdev

    2024-01-20 14:06:01       22 阅读
  4. issue-halcon学习】fuzzy_measure_pin.hdev

    2024-01-20 14:06:01       31 阅读
  5. issue-halcon学习】edge_segments.hdev

    2024-01-20 14:06:01       35 阅读
  6. issue-halcon学习】edges_color.hdev

    2024-01-20 14:06:01       34 阅读
  7. issue-halcon学习】lines_gauss.hdev

    2024-01-20 14:06:01       26 阅读
  8. issue-halcon学习】rim_simple.hdev

    2024-01-20 14:06:01       30 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-20 14:06:01       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-20 14:06:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-20 14:06:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-20 14:06:01       18 阅读

热门阅读

  1. 动态sql,关联查询

    2024-01-20 14:06:01       31 阅读
  2. Webpack打包vue项目

    2024-01-20 14:06:01       36 阅读
  3. 173. 二叉搜索树迭代器

    2024-01-20 14:06:01       33 阅读
  4. x86 和 x64 arm的区别

    2024-01-20 14:06:01       34 阅读
  5. JUnit 5 单元测试框架

    2024-01-20 14:06:01       35 阅读
  6. C Primer Plus(第六版)12.9 编程练习 第2题

    2024-01-20 14:06:01       27 阅读
  7. C语言变量和全局变量能否重名?

    2024-01-20 14:06:01       34 阅读