【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)
相关推荐
Rabitebla22 分钟前
【Linux】文件篇(五):手撕简易 FILE——模拟实现 C 标准 I/O 缓冲机制
linux·服务器·c语言·笔记·学习·ubuntu
电科_银尘2 小时前
【大模型算法与工程 27】训练配方:批量、学习率、精度与梯度裁剪
学习·算法·机器学习
fly_sunnn9 小时前
机械狗的前置学习(python与Linux基础操作)
学习
Rabitebla11 小时前
【Linux】文件篇(六):Shell 实战——从系统调用到命令行重定向
linux·服务器·c++·笔记·学习
Star(up up up)12 小时前
MySQL 事务隔离级别是如何实现的?从 MVCC 到锁机制原理详解
笔记·vscode·sql·学习·程序人生·mysql·学习方法
Z21-X1 天前
云原生运维学习笔记:Kubernetes Volume 与 Secret 实验
运维·笔记·学习·云原生·kubernetes
console.log('npc')1 天前
Python 学习教程 · 第4课:数据结构
数据结构·python·学习
星落梦生1 天前
Docker学习(11)
学习·docker·容器
重生之我是萧炎2 天前
PR安装教程,Adobe Premiere Pro安装教程(含安装包),仅供学习使用
学习·adobe