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

例程功能

 检测球形焊盘的直径。

代码如下

csharp 复制代码
* 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. 通过亮暗区域分割并将转换为最小的周围矩形来定位芯片;
csharp 复制代码
	threshold (Bond, Bright, 100, 255)
	shape_trans (Bright, Die, 'rectangle2')

shape_trans 会比smallest_xxx来的方便

  1. 填充区域中的孔、裂缝------fill_up/fill_up_shape

fill_up实现对区域的完整填充;

fill_up_shape按指定区域特征的范围填充;

  1. opening_circle进行第一轮筛选,比"connection + select_shape"高级;
csharp 复制代码
	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)
相关推荐
何事误红尘8 小时前
全志A40i学习笔记():开发资料、启用串口
学习
for_ever_love__9 小时前
python基础语法学习: 异常的传递性
开发语言·python·学习
PC2005-cloud9 小时前
DeepSeek Harness 创建 skill 指南:结构、安装、使用
笔记·学习
YM52e9 小时前
分页查询的基石:ArkTS 为鸿蒙商品列表设计 LIMIT/OFFSET 的表
android·学习·华为·harmonyos
math_hongfan9 小时前
主从嵌套层次分明:ArkUI 订单卡片内嵌明细的鸿蒙界面
学习·华为·harmonyos
还不秃顶的计科生12 小时前
具身智能论文学习8:Octo: An Open-Source Generalist Robot Policy
人工智能·深度学习·学习·机器学习·语言模型·vla·vlm
woshihuanglaoshi12 小时前
事务加持防超卖:ArkTS 在鸿蒙里玩转 TRANSACTION 出入库
学习·华为·harmonyos
世人万千丶12 小时前
去重插入与超限淘汰:ArkTS 实现鸿蒙搜索历史的 LIMIT 艺术
运维·服务器·学习·华为·harmonyos·鸿蒙
2601_9499506313 小时前
在线练题更方便,用练题簿打造属于自己的移动题库
学习·考研·刷题·小程序推荐
woshihuanglaoshi14 小时前
十二商品二十流水:鸿蒙进销存种子数据装满预警看板
学习·华为·harmonyos