HALCON

1. 语法范式 Syntax Style

1.1. 基本格式

1.1.1. 算子格式

算子(输入图像参数:输出图像参数:输入控制参数:输出控制参数)

其中四个参数任意一个可以为空

e.g.1.threshold(Image : Region : MinGrayMaxGray : )

** 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 : : : PointerTypeWidthHeight)

** threshold算子,1 Image Para input : Image ; 2 Image Para output :无;

**  3 Control Para input : 无 4 Control Para output : PointerTypeWidthHeight

1.1.2. 程序结构

HDEV即HALCON Develop,相当于VC中sln,solution。dev下面有很多窗口。

dev_update_pc

Switches the update of the PC during program execution on or off.

dev_update_time

Switch time measurement for operators on or off.

dev_update_var

Switches the update of the variable window during program execution on or off.

dev_update_window

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:

gen_circle

Create a circle.

gen_ellipse

Create an ellipse.

gen_rectangle2

Create a rectangle of any orientation.

以画圆为例,含有Row,Col,R,且这些都是输入量:

gen_circle( : Circle : RowColumnRadius : )

l draw_ 属于Table of Contents/Graphics/Drawing和我们平常理解的不同,这里的draw是指交互式地在窗口上画图,而不是直接按参数画图

draw_circle

Interactive drawing of a circle.

draw_ellipse

Interactive drawing of an ellipse.

draw_line

Draw a line.

以画圆为例,虽然也有Row,Col,R,但这些都是输出量:

draw_circle( : : WindowHandle : RowColumnRadius)

l disp_ 属于Table of Contents/Graphics/Output

disp_arc

Displays circular arcs in a window.输出显示一段弧

disp_arrow

Displays arrows in a window.输出显示一个箭头

disp_circle

Displays circles in a window.

disp_cross

Displays crosses in a window.

以画弧为例,虽然也有CRow,CCol,而且这些都是输入的控制参数:

disp_arc( : : WindowHandleCenterRowCenterColAngleBeginRowBeginCol : )

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( : : TupleIndex : Selected)

e.g.tuple_select( RowsEdges, 0,RowSelectedPoint)

tuple_select_range( : : TupleLeftindexRightindex : Selected)

Select several elements of a tuple between the left index and the right index.

③ Tuple的初始化,包含分配内存需要的长度以及初始值

tuple_gen_const

gen_tuple_const(NumHoles,0)

2.1.2. tuple的操作符

tuple的操作除了调用函数,还可以直接访问元素,或者使用操作符

① Tuple的长度

Length:= |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 : MinGrayMaxGray : )

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(ImageRegion : ImageReduced : : )

Reduce the domain of an image.提取ROI中的图像部分

region_to_bin(Region : BinImage : ForegroundGrayBackgroundGrayWidthHeight : )

Convert a region into a binary byte-image。将区域转化为二值图

region_to_label(Region : ImageLabel : TypeWidthHeight : ) Convert regions to a label image.

region_to_mean(RegionsImage : ImageMean : : )

Paint regions with their average gray value.  结合原图Image将区域内所有像素点转换为它的中值。

2.2.2. Region  Contour

① Region  Contour

gen_circle_contour_xld

Create XLD contours corresponding to circles or circular arcs.

gen_contour_nurbs_xld

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).

gen_contour_polygon_xld

Generate an XLD contour from a polygon (given as tuples).

gen_contour_region_xld

Generate XLD contours from regions.

gen_contours_skeleton_xld

Convert a skeleton into XLD contours.

gen_cross_contour_xld

Generate one XLD contour in the shape of a cross for each input point.

gen_ellipse_contour_xld

Creation of an XLD contour corresponding to an elliptic arc.

gen_nurbs_interp

Create control data of a NURBS curve that interpolates given points.

gen_parallels_xld

Extract parallel XLD polygons.

gen_polygons_xld

Approximate XLD contours by polygons.

gen_rectangle2_contour_xld

Create an XLD contour in the shape of a rectangle.

mod_parallels_xld

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 : FilterAlphaLowHigh : )

主要介绍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基础知识的更多相关文章

  1. .NET面试题系列[1] - .NET框架基础知识(1)

    很明显,CLS是CTS的一个子集,而且是最小的子集. - 张子阳 .NET框架基础知识(1) 参考资料: http://www.tracefact.net/CLR-and-Framework/DotN ...

  2. RabbitMQ基础知识

    RabbitMQ基础知识 一.背景 RabbitMQ是一个由erlang开发的AMQP(Advanced Message Queue )的开源实现.AMQP 的出现其实也是应了广大人民群众的需求,虽然 ...

  3. Java基础知识(壹)

    写在前面的话 这篇博客,是很早之前自己的学习Java基础知识的,所记录的内容,仅仅是当时学习的一个总结随笔.现在分享出来,希望能帮助大家,如有不足的,希望大家支出. 后续会继续分享基础知识手记.希望能 ...

  4. selenium自动化基础知识

    什么是自动化测试? 自动化测试分为:功能自动化和性能自动化 功能自动化即使用计算机通过编码的方式来替代手工测试,完成一些重复性比较高的测试,解放测试人员的测试压力.同时,如果系统有不份模块更改后,只要 ...

  5. [SQL] SQL 基础知识梳理(一)- 数据库与 SQL

    SQL 基础知识梳理(一)- 数据库与 SQL [博主]反骨仔 [原文地址]http://www.cnblogs.com/liqingwen/p/5902856.html 目录 What's 数据库 ...

  6. [SQL] SQL 基础知识梳理(二) - 查询基础

    SQL 基础知识梳理(二) - 查询基础 [博主]反骨仔 [原文]http://www.cnblogs.com/liqingwen/p/5904824.html 序 这是<SQL 基础知识梳理( ...

  7. [SQL] SQL 基础知识梳理(三) - 聚合和排序

    SQL 基础知识梳理(三) - 聚合和排序 [博主]反骨仔 [原文]http://www.cnblogs.com/liqingwen/p/5926689.html 序 这是<SQL 基础知识梳理 ...

  8. [SQL] SQL 基础知识梳理(四) - 数据更新

    SQL 基础知识梳理(四) - 数据更新 [博主]反骨仔 [原文]http://www.cnblogs.com/liqingwen/p/5929786.html 序 这是<SQL 基础知识梳理( ...

  9. [SQL] SQL 基础知识梳理(五) - 复杂查询

    SQL 基础知识梳理(五) - 复杂查询 [博主]反骨仔 [原文]http://www.cnblogs.com/liqingwen/p/5939796.html 序 这是<SQL 基础知识梳理( ...

随机推荐

  1. Mime Types

    Mime Types 1.http://www.freeformatter.com/mime-types-list.html 2.http://www.webmaster-toolkit.com/mi ...

  2. poj 3635(bfs+优先队列)

    题目链接:http://poj.org/problem?id=3635 思路:本题主要运用的还是贪心思想,由于要求st->ed的最小花费,那么每经过一个城市,能不加油就尽量不加油,用dp[i][ ...

  3. 【hdu3065-病毒侵袭持续中】AC自动机

    题意:给定一些只含大写字母的病毒串,再给一个文本串,问文本串中每个病毒串各出现了多少次. 题解: 就是用AC自动机,在每个节点末尾有个id记录是哪个单词的末尾,然后如果同时是多个单词的末尾就用一个ne ...

  4. JVM垃圾回收机制总结(2) :基本算法概述

    1.引用计数收集器 (Reference Counting) 引用计数是垃圾收集的早期策略.在这种方法中,堆中每一个对象都有一个引用计数.一个对象被创建了,并且指向该对象的引用被分配给一个变量,这个对 ...

  5. MyBatis学习总结_08_Mybatis3.x与Spring4.x整合

    一.搭建开发环境 1.1.使用Maven创建Web项目 执行如下命令: mvn archetype:create -DgroupId=me.gacl -DartifactId=spring4-myba ...

  6. Android 设置闹铃步骤和基础代码

    主要分三步: 1. 设置闹铃时间; 2. 接收闹铃事件广播; 3. 重开机后重新计算并设置闹铃时间;   1. 设置闹铃时间(毫秒) private void setAlarmTime(Context ...

  7. java Cache框架

    Cache框架乱炖   各类开源的缓存解决方案 JBossCache/TreeCacheJBossCache是一个复制的事务处理缓存,它允许你缓存企业级应用数据来更好的改善性能.缓存数据被自动复制,让 ...

  8. Spring AOP术语

    1.AOP术语     1)连接点(Joinpoint)     程序执行的某个特定位置:如类开始初始化前.类初始化后.类某个方法调用前.调用后.方法抛出异常后.一个类或一段程序代码拥有一些具有边界性 ...

  9. <转Tanky Woo> 字典树

    又称单词查找树,Trie树,是一种树形结构,是一种哈希树的变种.典型应用是用于统计,排序和保存大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本词频统计.它的优点是:利用字符串的公共前缀 ...

  10. Maven概要[转]

    1. Maven介绍 1.1. 简介 java编写的用于构建系统的自动化工具. 目前版本是2.0.9,注意maven2和maven1有很大区别,阅读第三方文档时需要区分版本. 1.2. Maven资源 ...