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 基础知识梳理( ...
随机推荐
- 传说中的WCF(5):数据协定(a)
在第4篇中,咱们了解了发送/接收SOAP头,从本篇开头,我们不妨更深入地去探求一下有关WCF中的消息到底是啥玩意儿.WCF庞大而复杂,而从 MSDN文档中,你会看到许多很专业很抽象的东西,你不禁会问, ...
- JS加载时间线
1.创建Document对象,开始解析web页面.解析HTML元素和他们的文本内容后添加Element对象和Text节点到文档中.这个阶段document.readyState = 'loading' ...
- 检查和收集 Linux 硬件信息的 7 个命令
http://blog.sae.sina.com.cn/archives/3910 在Linux系统中,有许多命令可用于查询主机的硬件信息.一些命令只针对特定的硬件组件,比如CPU.内存,一些命令可以 ...
- Android核心分析之二十Android应用程序框架之无边界设计意图
Android应用程序框架1 无边界设计理念 Android的应用框架的外特性空间的描述在SDK文档(http://androidappdocs.appspot.com/guide/topics/fu ...
- lcd ram/半反穿技术解析【转】
转自:http://bbs.meizu.cn/viewthread.php?tid=3058847&page=1 我的话题应该会比较长一些.但是大致板块如下:1.LCD RAM;-->此 ...
- MYSQL语句中SELECT语句及其子句的执行顺序
SELECT语句的执行的逻辑查询处理步骤:(8)SELECT (9)DISTINCT(11)<TOP_specification> <select_list>(1)FROM & ...
- MySQL 跳过同步错误方法
最近MySQL 遇到了同步问题,现整理一下常遇到的错误的解决方法,备用. 方法一:手动设置动态参数 sql_slave_skip_counter 我常用的脚本: stop slave sql_thre ...
- python 统计文本文件的行数
num_lines = sum(1 for line in open(input_file_name))
- 网易云课堂学习之VS相关
1.为开发好的项目文件瘦身 如:在项目文件ScreenCapture中,只需保留框起来的两个文件即可 而且在框起来的ScreenCapture里的Debug文件也可以删掉,整个文件由75.4 MB变为 ...
- 《OD学hadoop》在LINUX下如何将tar压缩文件解压到指定的目录下
linux下tar命令解压到指定的目录 :#tar zxvf /bbs.tar.zip -C /zzz/bbs //把根目录下的bbs.tar.zip解压到/zzz/bbs下,前提要保证存在/zzz/ ...