【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)
相关推荐
Ziky学习记录2 分钟前
从零到实战:React Router 学习与总结
前端·学习·react.js
sensen_kiss26 分钟前
INT303 Coursework1 爬取影视网站数据(如何爬虫网站数据)
爬虫·python·学习
red_redemption1 小时前
自由学习记录(116)
学习
r i c k2 小时前
数据库系统学习笔记
数据库·笔记·学习
野犬寒鸦3 小时前
从零起步学习JVM || 第一章:类加载器与双亲委派机制模型详解
java·jvm·数据库·后端·学习
浅念-3 小时前
C语言编译与链接全流程:从源码到可执行程序的幕后之旅
c语言·开发语言·数据结构·经验分享·笔记·学习·算法
ZH15455891314 小时前
Flutter for OpenHarmony Python学习助手实战:API接口开发的实现
python·学习·flutter
爱吃生蚝的于勒4 小时前
【Linux】进程信号之捕捉(三)
linux·运维·服务器·c语言·数据结构·c++·学习
奶茶精Gaaa4 小时前
工具分享--F12使用技巧
学习
久邦科技4 小时前
奈飞工厂中文官网入口,影视在线观看|打不开|电脑版下载
学习