当前位置:
文档之家› Halcon在机器视觉中的典型应用
Halcon在机器视觉中的典型应用
HALCON实际应用:形状模板匹配
模板匹配支持旋转 • 建模时的角度范围
AngleStart AngleExtent
• 角度用弧度表示,可通过函数rad()转换 • 为了表示旋转角度±x, 赋值如下
AngleStart = -x AngleExtent = 2x
Replace this box with your logo
Replace this box with your logo
基于相关的模板匹配(conrelationbased)
能克服纹理 背景和聚焦 不清带来的 影响
基于描述符的模板匹配(descriptorbased)
Replace this box with your logo
通过特征点进 行描述匹配
Replace this box with your logo
中国大恒(集团)有限公司北京图像视觉技术分公司
HALCON软件在机器视觉 中的典型应用
主讲人:刘伟
软件层次
Replace this box with your logo
Replace this box with your logo
HALCON的实际应用
获取图像
分割图像
提取特征
初始分割、 形态学处理等
Replace this box with your logo
HALCON实际应用: Blob分析
一个简单的例子(非常理想的情况)
read_image (Image, ’particle’) threshold (Image, BrightPixels, 120, 255) connection (BrightPixels, Particles) area_center (Particles, Area, Row, Column)
Replace this box with your logo
HALCON实际应用: Blob分析
• • • threshold定义 R ( x , y ) R | g min g ( x , y ) g max threshold算子HALCON中速度最快使用频率最高的分 割算法 如果目标体与背景之间存在灰度差,则threshold首先被 使用 如果环境稳定,阈值可在离线状态下一次确定
Replace this box with your logo
HALCON实际应用: Blob分析
Blob分析的基本思想:图像中相关联物体(前景)的像素可以通过其灰度值来标 识
Replace this box with your logo
HALCON实际应用: Blob分析
Blob分析主要流程:获取图像、分割图像、提取特征
…………
Replace this box with your logo
HALCON实际应用:图像获取
应用程序 HALCON 库 加载动态库 图像处理 图像获取接口 数据管理 采集设备管理 采集设备驱动 采集设备硬件 SDK 采集设备生产商
Replace this box with your logo
HALCON实际应用:模板匹配
模板匹配
参考图像
搜索图像
Replace this box with your logo
HALCON实际应用:形状模板匹配
* Generate ROI * read image from file or frame grabber inspect_shape_model(Image,ModelImage,ModelRegion,1, Contrast) dev_display(Image) dev_display(ModelRegion)
Replace this box with your logo
HALCON实际应用:图像获取
• 打开采集设备,如果是序列磁盘文件,设备为'File'
open_framegrabber ('DahengCAM', , 1, 1, 0, 0, 0, 0, 'default‘, -1, 'gray', -1, 'false', 'default', 'default', -1, -1, FGHandle)
•
Replace this box with your logo
HALCON实际应用: Blob分析
HALCON实际应用:形状模板匹配
• 对于对称物体,建模时需限制角度的旋转范围
180°
120°
90° 180°
0 °
90 °
Replace this box with your logo
HALCON实际应用:形状模板匹配
模板匹配支持缩放 • 一般缩放范围取值
ScaleMin = 0.3; ScaleMax = 2
Contrast太低
Contrast 理想
Contrast 太高
Replace this box with your logo
模板生成: 金字塔层
inspect_shape_model(Image,ModelImages,ModelRegions,5,40) dev_display(Image) dev_display(ModelRegions)
匹配助手
Replace this box with your logo
Replace this box with your logo
HALCON实际应用:形状模板匹配(定位)
从路径获得图像 生成芯片的感兴趣区域 检测模型 检测感兴趣区域
Replace this box with your logo
基于变形模板的模板匹配 (deformable)
车门检测, 即使车门在 三维空间内 变动,仍然 能匹配
Replace this box with your logo
基于点的模板匹配(point-based)
Replace this box with your logo
多用于镶嵌 图像时, 大场景拼 接
HALCON实际应用:图像获取
HALCON
Replace this box with your logo
HALCON实际应用:图像获取
HALCON实际应用:模板匹配
模板匹配的优势
应用于多数的应用 不需要太多参数调整 不需要分割 健壮
Replace this box with your logo
图像金字塔
Replace this box with your logo
Level 4
Level 3
Level 2
Level 1
图像金字塔
金字塔中的模板
Replace this box with your logo
Level 4
3
2
1
Replace this box with your logo
不需要任何的机器视觉知识
HALCON实际应用:模板匹配
模板匹配分类
•
Replace this box with your logo
•
•
基于灰度的模板匹配(gray-value-based) -利用模板图像的所有灰度值,不能适应光照变化、缩放变化、多通道 图像等 -用于简单图像 基于形状的模板匹配(shape-based) -使用边缘特征定位物体 -对于很多干扰因素不敏感,例如光照变化、聚焦模糊,缩放变化等, 适用于多通道图像 -不适用于纹理图像 基于组件的模板匹配(component-based) -适用于组成部件有相对运动的物体,使用边缘特征定位物 -对于很多干扰因素不敏感,例如光照变化、混乱无序等,适用于多通 道图像 -不适用于纹理图像,聚焦不清的图像和形状变形
Replace this box with your logo
Template
Accepted objects
模板匹配中的极性问题
Polarity mode: ignore_global_polarity
Replace this box with your logo
Template
Accepted objects
Replace this box with your logo
基于相关的模板匹配(conrelation-based) -适用于纹理图像,聚焦不清的图像和形状变形 -不是适用于光照变化、混乱无序等,也不适用于多通道图像 基于描述符的模板匹配(descriptor-based) -对于很多干扰因素不敏感,例如光照变化、混乱无序,缩放 变化等 -不适用于纹理图像,聚焦不清的图像和多通道图像 基于变形模板的模板匹配(deformable) -对于很多干扰因素不敏感,例如光照变化、混乱无序,缩放 变化等 -适用于多通道图像 -对于纹理图像比较困难 基于点的模板匹配(point-based) -利用关键点的特征
HALCON实际应用:图像获取
图像获取接口特点 • 图像获取链接库独立于其它图像处理链接库 • 一致的代码模板(磁盘文件和图像采集设备) • 支持多个采集设备 • 同步和异步采集 • 支持外触发 • 图像尺寸、图像位数、颜色空间可调 • 支持颜色查找表 • 支持与设备相关的参数调整
Replace this box with your logo
Replace this box with your logo
模板匹配中的极性问题
模板匹配: ignore_local_polarity
模板
匹配目标
匹配: 允许一定程度上交叠
模型和它的外接轮廓框(bounding boxes) 外接轮廓框可以任意方向
Replace this box with your logo
车牌字符识别