HALCON基础知识
HALCON
1. 语法范式 Syntax Style
1.1. 基本格式
1.1.1. 算子格式
算子(输入图像参数:输出图像参数:输入控制参数:输出控制参数)
其中四个参数任意一个可以为空
e.g.1.threshold(Image : Region : MinGray, MaxGray : )
** threshold算子,1 Image Para input : Image ; 2 Image Para output :Region ;
**3 Control Para input : MinGray , MaxGray 4 Control Para output :无
2.get_image_pointer1(Image : : : Pointer, Type, Width, Height)
** threshold算子,1 Image Para input : Image ; 2 Image Para output :无;
** 3 Control Para input : 无 4 Control Para output : Pointer, Type, Width, Height
1.1.2. 程序结构
HDEV即HALCON Develop,相当于VC中sln,solution。dev下面有很多窗口。
Switches the update of the PC during program execution on or off.
Switch time measurement for operators on or off.
Switches the update of the variable window during program execution on or off.
Switches the automatic output of iconic output objects into the graphics window during program execution on or off.
1.1.3. 符号
这里主要列出一些和C/C++含义不同的符号,以及HALCON中一些重要符号。
|
编号 |
符号 |
符号含义 |
|
1 |
* |
注释符号 |
|
2 |
:= |
赋值符号,和C中不同 |
|
3 |
= |
逻辑符号,判断相等,相对于C中的’==’ |
|
4 |
\ |
转义符号,至少可以在用于换行的转义,’\+Enter’就可以续行了 |
|
5 |
$ |
变量指示符号,e.g. +Distance$'.3'表示将变量Distance写成3个字长的字符串形式 |
|
6 |
F1 |
Help文档,直接看算子 |
|
7 |
F2 |
回滚到程序头 |
|
8 |
F3/F4 |
激活/注销此行代码 |
|
9 |
F5 |
运行程序 |
|
10 |
F6 |
单步执行 |
|
11 |
F10 |
设置断点 |
1.2. 读写文件I/O
1.2.1. 控制变量的I/O
HACLON的输入,输出写法相当灵活。下面三个列子分别是常量字符串,格式化的浮点数,和一个tuple的输出
*字符串和单个浮点数的输出,甚至不需要fnew_line来写下一行,直接用\n,在一般的文本编辑器里就能有比较好的格式。 注意不用写百分号'%d'
'd',' 3d'表示始终为3位输出,'10.3f'表示始终为10位输出,其中小数位占3位
fwrite_string(FileHandle,'\tR1\tx1\ty1\tR2\tx2\ty2\td1\td2\td3\n')
fwrite_string(FileHandle, '\n'+i$'d'+' '+R1$'10.3f'+x1$'10.3f'+y1$'10.3f'+\
R2$'10.3f'+x2$'10.3f'+y2$'10.3f'+\
d1$'10.3f'+d2$'10.3f'+d3$'10.3f')
*在同一行中输出按'7.3f'的格式输出UpRows的所有元素,元素之间有个空格
fnew_line(FileHandle)
fwrite_string(FileHandle,UpRows$'7.3f'+' ') /
1.2.2. 图像变量的I/O
Path:= 'I:/Work/ritz/Piece/data/data_0528/'
read_image (Image, Path+'hgtest1__'+i$'d')
dump_window (WindowHandle, 'png', 'C:/Documents and Settings/Administrator/桌面/sadaharu2_gray.png')
write_image (Amp, 'png', 0 , 'C:/Documents and Settings/Administrator/桌面/sadaharu2_canny2.png')
write_region(Margin,'C:/Documents and Settings/Administrator/桌面/sadaharu2_canny3.tif')
1.3. 图像或形状的生成与显示
这条主要是为了区分三个系列的函数,gen_ , draw_ 和 disp_
l gen_ gen系列跨度很大,一般属于Creation范畴,生成的可以是图像image,匹配模板model,区域region,轮廓Contour,亚像素级轮廓Contour XLD,滤波器filter,HALCON内部描述文件descr(如标定板的表述caltab10mm.descr)等。下面展示的是一些容易混淆的gen_circle等,都是生成区域,属于Table of Contents/Regions/Creation:
Create a circle.
Create an ellipse.
Create a rectangle of any orientation.
以画圆为例,含有Row,Col,R,且这些都是输入量:
gen_circle( : Circle : Row, Column, Radius : )
l draw_ 属于Table of Contents/Graphics/Drawing和我们平常理解的不同,这里的draw是指交互式地在窗口上画图,而不是直接按参数画图
Interactive drawing of a circle.
Interactive drawing of an ellipse.
Draw a line.
以画圆为例,虽然也有Row,Col,R,但这些都是输出量:
draw_circle( : : WindowHandle : Row, Column, Radius)
l disp_ 属于Table of Contents/Graphics/Output
Displays circular arcs in a window.输出显示一段弧
Displays arrows in a window.输出显示一个箭头
Displays circles in a window.
Displays crosses in a window.
以画弧为例,虽然也有CRow,CCol,而且这些都是输入的控制参数:
disp_arc( : : WindowHandle, CenterRow, CenterCol, Angle, BeginRow, BeginCol : )
2. 数据结构 Data Structure
2.1. Tuple元组
HALCON中的元组是一个涵盖范围很广的数据结构,可以表示各种整形浮点,也可以表示字符串。
2.1.1. tuple的函数
① Tuple的长度
tuple_length( : : Tuple : Length)
e.g.tuple_length( RowsEdges, LengthEdge),还有一种更简单的方法,
② Tuple按index取元素
tuple_select( : : Tuple, Index : Selected)
e.g.tuple_select( RowsEdges, 0,RowSelectedPoint)
tuple_select_range( : : Tuple, Leftindex, Rightindex : Selected)
Select several elements of a tuple between the left index and the right index.
③ Tuple的初始化,包含分配内存需要的长度以及初始值
gen_tuple_const(NumHoles,0)
2.1.2. tuple的操作符
tuple的操作除了调用函数,还可以直接访问元素,或者使用操作符
① Tuple的长度
e.g.LengthEdge1 := |RowsEdges|
② Tuple按index取元素
e.g.RowSelectedPoint := RowsEdges[0]
2.2. 常见图像变量数据结构及相互转换:
Image,Region, Contour ,XLD,几何图形
2.2.1. Image
Region
① Image
Region
threshold(Image : Region : MinGray, MaxGray : )
Bin_threshold,char_threshold,dual_threshold,dyn_threshold,fast_threshold,hysteresis_threshold,threshold_sub_pix
var_threshold Threshold an image by local mean and standard deviation analysis
watersheds_threshold— Extract watershed basins from an image using a threshold.
② Image
Region
reduce_domain(Image, Region : ImageReduced : : )
Reduce the domain of an image.提取ROI中的图像部分
region_to_bin(Region : BinImage : ForegroundGray, BackgroundGray, Width, Height : )
Convert a region into a binary byte-image。将区域转化为二值图
region_to_label(Region : ImageLabel : Type, Width, Height : ) Convert regions to a label image.
region_to_mean(Regions, Image : ImageMean : : )
Paint regions with their average gray value. 结合原图Image将区域内所有像素点转换为它的中值。
2.2.2. Region
Contour
① Region
Contour
Create XLD contours corresponding to circles or circular arcs.
Transforms a NURBS curve into an XLD contour.
gen_contour_polygon_rounded_xld
Generate a XLD contour with rounded corners from a polygon (given as tuples).
Generate an XLD contour from a polygon (given as tuples).
Generate XLD contours from regions.
Convert a skeleton into XLD contours.
Generate one XLD contour in the shape of a cross for each input point.
Creation of an XLD contour corresponding to an elliptic arc.
Create control data of a NURBS curve that interpolates given points.
Extract parallel XLD polygons.
Approximate XLD contours by polygons.
Create an XLD contour in the shape of a rectangle.
Extract parallel XLD polygons enclosing a homogeneous area.
3. 函数理解 Understanding the Basic but Essential Functions
3.1. edges_sub_pix
edges_sub_pix (Image, Edges, 'canny', 0.9, 20, 40)
edges_sub_pix(Image : Edges : Filter, Alpha, Low, High : )
主要介绍Canny边缘检测,同hysteresis_threshold,Canny边缘检测时不是单个阈值,而是有个“迟滞效应”设置了双阈值。
hysteresis_threshold performs a hysteresis threshold operation (introduced by Canny) on an image. All points in the input image Image having a gray value larger than or equal to High are immediately accepted (“secure” points). Conversely, all points with gray values less than Low are immediately rejected. “Potential” points with gray values between both thresholds are accepted if they are connected to “secure” points by a path of “potential” points having a length of at most MaxLength points. This means that “secure” points influence their surroundings (hysteresis).
4. 经验谈 Special Tips
4.1. 多使用help 文档中的Content Table:有问题何不往上翻一级
“不是路上真面目,只缘身在此山中”。解决一个问题,就和了解一个山峰所有真正的登山路一样,当我们在山腰中时,自然是很难了解这条路是否能直通山顶的,而当我们处在一个比这座峰更高的一个位置时,很自然就可以观察或者自己构造出一条比较好的登山路。这就是看往上一级,才看Content Table的作用,在这样一个更高的视野我们就可以找到在这个范围内的其他的路,也许刚好可以登上这座峰。如:
Table of Contents/Filter/smooth_image,
eliminate_min_max : Smooth an image in the spatial domain to suppress noise.
HALCON基础知识的更多相关文章
- .NET面试题系列[1] - .NET框架基础知识(1)
很明显,CLS是CTS的一个子集,而且是最小的子集. - 张子阳 .NET框架基础知识(1) 参考资料: http://www.tracefact.net/CLR-and-Framework/DotN ...
- RabbitMQ基础知识
RabbitMQ基础知识 一.背景 RabbitMQ是一个由erlang开发的AMQP(Advanced Message Queue )的开源实现.AMQP 的出现其实也是应了广大人民群众的需求,虽然 ...
- Java基础知识(壹)
写在前面的话 这篇博客,是很早之前自己的学习Java基础知识的,所记录的内容,仅仅是当时学习的一个总结随笔.现在分享出来,希望能帮助大家,如有不足的,希望大家支出. 后续会继续分享基础知识手记.希望能 ...
- selenium自动化基础知识
什么是自动化测试? 自动化测试分为:功能自动化和性能自动化 功能自动化即使用计算机通过编码的方式来替代手工测试,完成一些重复性比较高的测试,解放测试人员的测试压力.同时,如果系统有不份模块更改后,只要 ...
- [SQL] SQL 基础知识梳理(一)- 数据库与 SQL
SQL 基础知识梳理(一)- 数据库与 SQL [博主]反骨仔 [原文地址]http://www.cnblogs.com/liqingwen/p/5902856.html 目录 What's 数据库 ...
- [SQL] SQL 基础知识梳理(二) - 查询基础
SQL 基础知识梳理(二) - 查询基础 [博主]反骨仔 [原文]http://www.cnblogs.com/liqingwen/p/5904824.html 序 这是<SQL 基础知识梳理( ...
- [SQL] SQL 基础知识梳理(三) - 聚合和排序
SQL 基础知识梳理(三) - 聚合和排序 [博主]反骨仔 [原文]http://www.cnblogs.com/liqingwen/p/5926689.html 序 这是<SQL 基础知识梳理 ...
- [SQL] SQL 基础知识梳理(四) - 数据更新
SQL 基础知识梳理(四) - 数据更新 [博主]反骨仔 [原文]http://www.cnblogs.com/liqingwen/p/5929786.html 序 这是<SQL 基础知识梳理( ...
- [SQL] SQL 基础知识梳理(五) - 复杂查询
SQL 基础知识梳理(五) - 复杂查询 [博主]反骨仔 [原文]http://www.cnblogs.com/liqingwen/p/5939796.html 序 这是<SQL 基础知识梳理( ...
随机推荐
- PHP开发入行真功夫 三扬科技
前言与目录 PHP开发入行真功夫 前言 PHP开发入行真功夫 目录 第2章 基本语法 2.1.1 判断闰年程序 2.1.2 我们现在能做的…… 2.2.1 PHP的语言概貌 2.2.2 为我们的程 ...
- eclipse加速
eclipse老是building workspace及自动更新问题,eclipse加速 最近用Eclipse开发oPhone的一个项目,每次打开Eclipse的时候,总是在build workspa ...
- SQL注入攻击
SQL注入攻击是黑客对数据库进行攻击的常用手段之一.随着B/S模式应用开发的发展,使用这种模式编写应用程序的程序员也越来越多.但是由于程序员的水平及经验也参差不齐,相当大一部分程序员在编写代码的时候, ...
- win7 64 + Ubuntu 14.04.1 64双系统安装,详解UEFI ~ GPT和legacy ~ MBR区别
win7 64 + Ubuntu 14.04.1 64双系统安装 背景:我的笔记本之前的系统是window 7 64 + Ubuntu 14.04.1,用UEFI引导系统.安装过程是先装的win7,再 ...
- 获取手机的UUID
获取手机的UUID 01 连接手机到电脑 02 - 在XCOde中,选择Window->Devices
- wordpress学习一: 环境搭建
原来想单独找个linux的机器搞套完整的环境,机器都找好了,环境搞了半天.搞完后,感觉环境什么的不重要,核心是学好php和wordpress,单独的环境维护还开发成本都不小,所以 还是采用 xampp ...
- JVM垃圾回收机制总结(1) :一些概念
数据类型 Java虚拟机中,数据类型可以分为两类:基本类型 和引用类型 .基本类型的变量保存原始值,即:他代表的值就是数值本身:而引用类型的变量保存引用值.“引用值”代表了某个对象的引用,而不是对象本 ...
- AndroidManifest.xml 配置权限大全
问登记属性 android.permission.ACCESS_CHECKIN_PROPERTIES ,读取或写入登记check-in数据库属性表的权限 获取错略位置 android.permissi ...
- 统计MySQL数据表大小
SELECT CONCAT(TRUNCATE(SUM(data_length)/1024/1024,2),'MB') AS data_size,CONCAT(TRUNCATE(SUM(max_data ...
- 【推荐】《Netty in action》书籍
最近准备开始阅读一下<Netty in action>并且准备构架设计一个分布式系统.用于新项目. 貌似压力很大啊.压力就是东西.希望自己能够调节好. Netty in action是Ne ...