【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)
相关推荐
差不多的周周2 小时前
《骨架上下文:基于零镜头骨架的动作识别的骨架侧上下文提示学习》论文核心部分详解
学习
Century_Dragon3 小时前
从挂图到VR:汽修专业的一堂新能源原理课可以怎么上~
学习
知识分享小能手4 小时前
C++ 学习教程,从入门到精通,C++对象和类 — 详细知识点总结(10)
开发语言·c++·学习
New农民工5 小时前
倒立摆训练秘籍:理解训练参数
学习
L@ncor5 小时前
第五章 基于低代码平台的智能体搭建 · 学习笔记(Coze / Dify / FastGPT / n8n)
笔记·学习·低代码·agent·prompt工程
迪丽热爱6 小时前
多媒体应用20-903(补)
学习
传奇开心果编程7 小时前
【Flutter入门练中学】第8课:动画与过渡
android·学习·flutter·ui·ios
程序员yu8 小时前
会编网络:别被入门教程骗了,Python实用能力不在语法本身
开发语言·python·学习·算法
Lintongzg8 小时前
千卡训练的隐形账单:通信不是瓶颈
笔记·学习·性能优化·llm
dadaobusi8 小时前
学习: SIOV
学习