Halcon学习 资料归总

1Halcon的自我描述

Program Logic

Ø Each program consists of sequence of HALCON operators

Ø The program can be structured into procedures

Ø The sequence can be extended by using control operators like if, for, repeat, or while

Ø The results of the operators are passed via variables

Ø No implicit data passing is applied

Ø Input parameters of operators can be variables or expressions

Ø Output parameters are always variables

Ø HDevelop has no features to design graphical user interface

Ø An HDevelop program is considered as prototypic solution of the vision part of an application

Ø HDevelop is typically not used for the final application

由此可以看出,Halcon的定位是一个类库,有着完整、快速实现函数,同时提供了HDevelop作为快速开发的图形化(IDE)界面;但是,Halcon程序并不是一个完整的最终应用软件,它没有用户界面,也不提供显示的数据(公用的数据格式)。

Halcon的初学者也应当从参考Halcon的程序入手,熟悉Halcon类库,也即HDevelop-Based Programming;在此基础上,进入ORClass-Oriented Programming。这也是Halcon推荐的开发方式:

The vision part is solved with HDevelopand the application is developed with C++ or Visual Basic

 

2HDevelop界面的学习

通过阅读HalconPPT,学到了下面一些有用的信息:

Ø 文件——浏览示例,可以看到很多有用的例子;

Ø 程序窗体中,可以浏览与编辑Procedues(过程),这个其实就是自定义函数咯~还可以自己修改这些过程,并添加说明文档;

Ø F4——将函数语句注释掉;F3——激活;

Ø 本地过程(Local Procedue)与外部过程(Externel Procedue

 

3、基本语法结构

Halcon的语法结构

类似于Pascal 与 Visual Basic,大部分的语句是Halcon提供的算子,此外也包含了少部分的控制语句;

不允许单独声明变量;

提供自动的内存管理(初始化、析构及OverWrite),但句柄则需要显示释放;

C++(算子模式)

通过代码导出,以C++为例,默认导出为算子型的语法结构,而非面向对象的;在此模式下,全部函数声明为全局类型,数据类型只需要用HobjectHTuple两类类型进行声明;

C++(面向对象)

可以以面向对象的方式重写代码,也即利用类及类的成员函数;

在这种模式下,控制变量的类型仍未HTuple,而图形数据可以由多种类型,如HImage等;

其他语言(略)

 

4Halcon数据结构

两类参数:图形参数Iconic (image, region, XLD)与控制参数Control (string, integer, real, handle),在Halcon算子的参数中,依次为:输入图形参数、输出图形参数、输入控制参数、输出控制参数;并且其输入参数不会被算子改变。

图形参数Iconic

Images

Ø Multiple channels

Ø Arbitrary region of interest

Ø Multiple pixel types(byte, (u)int1/2/4,real, complex, direction, cyclic, vector_field)

byte, uint2 //灰度图像的标准编码

int1, int2 //Difference of two images or derivates with integer precision(??)int4 //两幅灰度图的频谱

direction //图片边缘的梯度方向

real //边缘提取及特定灰度值的轮廓

complex //图片频率分布

cyclic //Assigning one "gray" value to each color(??)

vector_field //连续图形的光学流分布

Regions

Ø Efficient data structure (runlength encoding)

Ø Extensive set of operators

Ø Fastest morphology on the market

图形编码中,需要了解 row 和 run 两个术语;也是Halcon Region存储的方式

Extended Line Description (XLD)

Ø Subpixel accurate line and edge detection

Ø Generic point list based data structure

Ø Handling of contours, polygons, lines, parallels, etc.

此外,Halcon支持的类型还包括图形元组、控制变量元组及句柄:

元组的概念,使得可以用一个变量传递数个对象,可以由重载后的函数来进行处理;图形元组的下标从1开始,控制变量元组下标从0开始;句柄则可以用来描述窗体、文件等等,句柄不能是常量。

 

5Halcon语言

输入控制参数可以是表达式,但图形参数、输出参数均应为变量;

String类型变量由单引号括起来;此外还有一些特殊字符;

Boolean型变量包括 true )、 false ;不为零的整数将被认为true;但绝大多数的Halcon函数接受字符串型的表达:true’‘false,而非逻辑型表达;

函数返回常量用于标识错误:

Ø H_MSG_TRUE no error 2

Ø H_MSG_FALSE logical false 3

Ø H_MSG_FAIL operator did not succeed  5

可以放在trycatchendtry块中,也可以用dev_error_var() dev_set_check() 来捕获;

控制语句结构:(与一般语言略有不同,它们也有输入输出变量)

Ø if  ...  endif if ... else  ... endif if ... elseif ... else ... endif 

Ø for  ...  endfor

Ø while  ...  endwhile

Ø repeat ... until

此外,也有关键字 breakcontinuereturnexitstop 用来控制语句的执行;

赋值语句在Halcon中也被当作函数来使用:

标准赋值

Ø assign(Expression, ResultVariable) //编辑形式,永远都是输入在前,输出在后

Ø ResultVariable := Expression //代码形式

元组插入赋值

Ø insert(Tuple, NewValue, Index, Tuple) //编辑形式

Ø Tuple[Index] := NewValue //代码形式

控制变量元组操作

Ø [t,t] concatenation of tuples

Ø |t|  number of elements

Ø t[i]  selection of an element

Ø t[i:j]  selection of part of tuple

Ø subset(t1,t2) selection from t1 by indices in t2 

图形元组操作对应函数

Ø []  gen_empty_obj ()

Ø |t|  count_obj (p, num)

Ø [t1,t2]  concat_obj (p1, p2, q)

Ø t[i]  select_obj (p, q, i+1)

Ø t[i:j]  copy_obj (p, q, i+1, j-i+1)

Ø subset(t1,t2) select_obj (p, q, t2+1)

元组的数学运算,如:B,令 |A|, |B|

mn不相等,且都大于1,则错误;否则返回三种情况:

Ø m=n=1,返回一个值;

Ø m=n>1,返回一个包含m个数的元组,值为两元组各对于值的操作结果;

Ø m>1,n=1,返回一个包含m个数的元组,值为第二个数与第一元组各值的操作结果;

Halcon 的数学运算

算术运算

Ø a division

Ø a rest of the integer division

Ø a multiplication

Ø v addition and concatenation of strings

Ø a subtraction

Ø -a  negation

位运算

Ø lsh(i,i)  left shift

Ø rsh(i,i)  right shift

Ø band  bit-wise and

Ø bor  bit-wise or

Ø bxor  bit-wise xor

Ø bnot  bit-wise complement

字符串操作

Ø v$s  conversion to string //字符串的格式化,有很丰富的参数

Ø  concatenation of strings and addition

Ø strchr(s,s)  search character in string

Ø strstr(s,s)  search substring

Ø strrchr(s,s)  search character in string (reverse)

Ø strrstr(s,s)  search substring (reverse)

Ø strlen(s)  length of string

Ø s{i} selection of one character

Ø s{i:i}  selection of substring

Ø split(s,s)  splitting to substrings

比较操作符

Ø  less than

Ø  greater than

Ø <=   less or equal

Ø >=  greater or equal

Ø  equal

Ø  not equal

逻辑操作符

Ø not  negation

Ø and  logical ’and’

Ø or l logical ’or’

Ø xor  logical ’xor’

数学函数

Ø sin(a)  sine of a

Ø cos(a)  cosine of a

Ø tan(a)  tangent of a

Ø asin(a)  arc sine of in the interval [-p/2, p2], Î [-1, 1]

Ø acos(a)  arc cosine in the interval [-p/2, p/2], Î [-1, 1]

Ø atan(a)  arc tangent in the interval [-p/2, p/2], Î [-1, 1]

Ø atan2(a,b)  arc tangent a/b in the interval [-pp]

Ø sinh(a)  hyperbolic sine of a

Ø cosh(a)  hyperbolic cosine of a

Ø tanh(a)  hyperbolic tangent of a

Ø exp(a)  exponential function

Ø log(a)  natural logarithm, a> 0

Ø log10(a)  decade logarithm, a> 0

Ø pow(a1,a2)  power

Ø ldexp(a1,a2)  a1 pow(2,a2)

其他操作(统计、随机数、符号函数等)

Ø min(t)  minimum value of the tuple

Ø max(t)  maximum value of the tuple

Ø min2(t1,t2)  element-wise minimum of two tuples 

Ø max2(t1,t2)  element-wise maximum of two tuples 

Ø find(t1,t2) indices of all occurrences of t1 within t2 

Ø rand(i) create random values from 0..1 (number specified by i

Ø sgn(a) element-wise sign of tuple 

Ø sum(t)  sum of all elements or string concatenation

Ø cumul(t) cumulative histogram of tuple

Ø mean(a)  mean value

Ø deviation(a)  standard deviation

Ø sqrt(a)  square root of a

Ø deg(a)  convert radians to degrees

Ø rad(a)  convert degrees to radians

Ø real(a)  convert integer to real

Ø int(a) convert real to integer

Ø round(a)  convert real to integer

Ø number(v)  convert string to number

Ø is_number(v)  test if value is number

Ø abs(a)  absolute value of (integer or real)

Ø fabs(a)  absolute value of (always real)

Ø ceil(a)  smallest integer value not smaller than a

Ø floor(a)  largest integer value not greater than a

Ø fmod(a1,a2) fractional part of a1/a2, with the same sign as a1

Ø sort(t)  sorting in increasing order

Ø uniq(t) eliminate duplicates of neighboring values(typically used in combination with sort)

Ø sort_index(t)  return index instead of values

Ø median(t) Median value of tuple (numbers)

Ø select_rank(t,v) Select the element (number) with the given rank

Ø inverse(t)  reverse the order of the values

Ø subset(t1,t2) selection from t1 by indices in t2

Ø remove(t1,t2) Remove of values with the given indices

Ø environment(s)  value of an environment variable

Ø ord(a)  ASCII number of character

Ø chr(a)  convert an ASCII number to character

Ø ords(s)  ASCII number of tuple of strings

Ø chrt(i)  convert tuple of integers into string

 

6Halcon名称解释

Ø Operator: procedure of  the HALCON library used in HDevelop or one of the language interfaces.

Ø Procedure (of HDevelop): subroutine defined for the use inside HDevelop.

Ø Region: Result of segmentation like threshold. In other systems called blob, area, binary image, or island. Implemented using runlength encoding.

Ø XLD: Extended Line Description. Universal data structure used to handle contour based data. Mainly used in the context of subpixel precise measurement.

Ø Domain: Part of the image which is used for processing. In other systems called ROI (region of interest).

Ø Channel: One image matrix of multi-spectral image. One example is the red channel of an RGB image.

Ø Iconic data: Overall term for images, regions, and XLD data. In object oriented languages (C++ and COM) and in HDevelop iconic data is represented by polymorphic data type. In object oriented languages iconic data is also called iconic object.

Ø Control data: All non iconic data. Examples are single values (integer, real, and string), coordinates, arrays of values.

Ø Tuple: an array of values where each element can be of different type. One can have both iconic and control tuples.

Ø HALCON object: Synonym for Iconic object data

Ø Image acquisition interface: Interface between the frame grabber /camera driver (SDK) and the HALCON library. The Image acquisition interface is DLL which is dynamically loaded when calling open_framegrabber.

Ø Language interface: Software that enables the programmer to use the HALCON library in given language (e.g., C++).

Ø Extension Package: mechanism that enables the user to fully integrate user-defined procedures into the HALCON environment. The extension package concept gives full access to the internal data structures of HALCON.

Ø License file: File “license.dat“ in the directory “license“.  This file is used together with hardware components (dongle or Ethernet card) to check if correct license is available.

Ø Help files: Files in the directory “help“ which are used to get online information about all HALCON operators. This is extensively used by HDevelop.

Ø Shape-Based Matching: Finding of an object in an image based on predefined model. The shape based matching uses features to quickly locate objects very precisely.

Ø Variation Model: method to do print checking by presenting multiple good patterns to the system. The variation model learns the normal variation good pattern and based on this information can detect real defects.

Ø Measure Tool: set of operators to find the exact location of edges along lines or circular arcs. Other systems call the similar tool, e.g., caliper.

Ø Accuracy: The deviation from the true value

Ø Precision: The standard deviation of the measurement

 

7Halcon函数

典型函数

Ø Filtering (noise, smoothing, edge, bit, arithmetic, enhancement)

Ø Segmentation (thresholding, topology, region growing, classification, comparison)

Ø Region processing

Ø Morphology

Ø Feature extraction

Ø Edge detection

Ø Color processing and classification

Ø OCR OCV

Ø Bar code data code

Ø Measurement

Ø Rectification

Ø Gray value matching

 

8Halcon HDevEngine

HDevEngine允许用户在应用程序中直接调用Halcon程序(*.hdvp),适用范围包括C++COM.NET语言。具体功能为:

Ø 载入并执行Halcon程序(HDevelop programs

Ø 载入、删除、执行HDevelop过程(HDevelop procedures

Ø 查询以载入的HDevelop过程的接口

Ø 将正确的参数值传递给HDevelop过程,执行并获得结果

Ø 重新实现了HDevelop的某些内部算子(operator),例如dev_display

Ø HDevEngine错误处理

C++中,使用HDevEngine需要包括头文件#include "HDevEngineCpp.h",并包含附加的可执行文件hdevenginecpp.lib,具体见示例。

利用HDevEngine,可以很方便得实现多线程。

 

9Halcon数据结构(2

Halcon中,Image Channel Domain 像素点存放在Channel矩阵中,根据ROI来描述Image

Image相关操作:

Ø 输入:从文件、从设备

Ø 生成:外部图像数据、空内存区域;

Ø 显示:disp_image()图像首通道灰度图;disp_color() 彩色图;disp_channel()某特定通道;disp_obj() 自动判别类别;

Ø 缩放:set_part() 设置显示区域;set_part_style() 设置显示参数;

Ø 3D显示:(略)

Rules to Display Gray Images没特别懂

边界点的处理:镜像、常数、延续、周期(略):

域的局限性:一些算子总是要处理周围的矩形区域,比如mean_image(),并且总是先处理小的区域;

测量工具中的ROIs比较特殊,这种ROIs并不依附于Image上,而是在算子gen_measure_*()后产生,并且也只能是任意朝向的矩形、圆弧形区域;

处理多通道图像:

Ø 分割:Gray operators仅适用第一通道,Color operators: 使用前三个通道,Multi channel operator会使用全部通道;

//对“Gray operators仅适用第一通道”的解释:实际上,灰度图,就是用第一通道(Red)像素点值所构建出来的那幅图。

Ø 过滤:所有通道被处理时均使用相同的参数,并且结果的通道数与处理的图片相同;

Ø 可以将域的处理结果,与原图像结合在一起作为输入图像;

Ø 通道处理:count_channels(),decompose*(), compose*(), access_channel(), append_channel(), channels_to_image(), image_to_channels()

图像金字塔中,第一个图像为最大的图像,各图像有各自的区域

标准图形(Shape):circleellipserectangle1rectangle2linepolygon

特殊区域图形:gen_grid_region(): gridlinespoints, gen_checker_region()

图像处理:

Ø 修改:set_grayval() Modify one or more pixels of the input image;paint_gray()Paint part of an image into another imageoverpaint_gray()Paint part of an image into the input imagepaint_region()Paint the region with constant gray value into an imageoverpaint_region() Paint the region with constant gray value into the input image

Ø 复制:crop_part()Crop rectangle, given by upper left corner and sizecrop_rectangle1()Crop rectangle, given by upper left and lower right cornercrop_domain()Crop area of the smallest rectangle1 of the domaincrop_domain_rel()Like crop_domain but with the possibility to change the size of bounding boxchange_format()Limit the size of the image at the lower or the right partget_grayval()Access one or multiple pixel values

Ø Tile: tile_images(), tile_images_offset(), tile_channels()

 

10Halcon数据结构(3

区域运算:

Ø 并:union1()union2()

Ø 交:intersection();

Ø 差:difference();

Ø 补:complement()

图形显示参数设置:

Ø 显示模式:set_draw(); 参数:marginfilled

Ø 线宽线形:set_line_width(); set_line_style();

Ø 颜色:set_color(); set_colored(); set_rgb(); set_gray();

Ø 显示图形:set_shape(); 参数:originalouter circleinner circlerectangle1rectangle2ellipseicon

Ø set_icon

 

11Halcon数据结构(4

关于XLD,简要写一下:

图像均用像素点保存,而像素点是整型的,不连续的;Halcon做了拓展,定义了亚像素(subpixel)的对象:xld;其实xld已经用过了,比如提取边缘、构建轮廓等等,xld在模板匹配、图形校准等多方面有重要的用途。

 

12、色彩 color

在视网膜底部,有三类感光细胞,它们分别探测不同频率的光,产生RGB神经冲动,并把这些神经冲动传递下去;经过另外的细胞的处理,转换成1个亮度通道、两个色彩通道。

Ø The RGB stimulus is converted to luminance and chrominance channels

所以,RGB图是原始的感光图,而人眼的感觉,却不是RGB三通道的叠加;更直观地描述人的感觉,需要用到其他的色彩空间,比如hsv空间。

不同频率的光,会产生不同的颜色;而光只有三种颜色,这是因为人眼只有三种光感受器。

所以有,任何光产生的颜色,都能够由这三种纯色来合成,这就是光的三元色。

Halcon学习(二十四)总结(一)

 

对于相机来说,能够检测到的光谱范围比人眼要宽泛,比如红外相机等;为了获得人眼类似的图像,可以加上过滤装置,滤去超出400-700nm范围的光线。

 

13、色彩空间及 Halcon颜色处理

CCD彩色相机有RGB三种感光芯片,捕捉不同颜色,然后转换为RGB三通道。

颜色空间:

Ø RGB RedGreenBlue三色通道,对光来说,犹如在黑暗中点亮各分色。

Ø CMY CyanMagentaYellow 三颜色通道,犹如在白纸上图颜料

Ø YUVYIQ Y描述亮度、其余两通道描述颜色(的差值),用于电视转播

Ø ARgYb 与上类似,A描述亮度,其余两者描述颜色差值

Ø I1i2i3 与上类似,i1描述亮度

Ø HSI HueSaturationIntensity 分别描述颜色、饱和度、亮度

Ø HSV 与上类似,这里的V描述亮度,方法与上不同

Ø HSL HSI类似,L描述亮度,但Hue与之不同

Ø HIS HIS类似

Ø Uniform Color SpaceCIE uv 用二维图描述色彩

Ø CIE Lab 高级色彩空间,较少使用

 

颜色空间的转换,依靠GPU进行运算:trans_from_rgb(),速度快

Scale_image() 可以对单通道(RGB、或HSV中的)进行重新渲染;

颜色的选取,通过对Hue通道进行threshold()

2D Histogram 可用来描述两通道(RGBHSV等中的)相应值对应关系,可用来选取颜色相近区域:histo_2dim()

N维像素分类:learn_ndim_norm()learn_ndim_box() 

LUTMLPSVMGMM

彩色过滤器:用于彩色图像的分割等:edges_color()edges_color_sub_pix()lines_color()

 

14Halcon 窗体

Halcon窗体的坐标系统:(Row, Column) (Width, Height)

图形:可以显示灰度图、彩色图、3D;定义要显示的区域,插值

区域:绘图模式(FillMargin),边界、线宽,定义色彩模式,自动图形转换

绘图:点、线、xld

  • 4
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: Halcon是一种高级计算机视觉开发工具,通过其强大的图像处理能力可以实现各种视觉应用。学习Halcon需要掌握其基础知识和应用技巧。其中最有效的学习资料之一就是官方文档提供的CHM文件。 Halcon的CHM文件包含了完整的文档和API参考,可以帮助开发人员快速理解和掌握Halcon的各项功能和应用。该文件适用于初学者或者进阶者。对于初学者来说,可以通过详细的介绍了解Halcon的组成,语言特点、数据类型、类型转换、变量等基础知识。对于进阶者,可以通过文档中的实例代码、算法描述、函数用法和参数解释等详细内容,不断提升自己的开发技能。 Halcon的CHM文件非常实用,因为它可以离线使用。无需访问互联网,只要下载到本地即可随时随地使用,特别适合在没有互联网的环境下使用,如机器人、相机或计算机视觉系统。 总之,Halcon的CHM学习资料Halcon开发者必不可少的资料之一,对于初学者或者进阶者都可以快速提高技术水平,提高开发效率,达到预期的结果。 ### 回答2: Halcon 学习资料chm 是一个包含了Halcon学习资料的CHM文件。Halcon是一款计算机视觉软件,用于图像处理及分析。对于Halcon使用者来说,学习资料是十分重要的,可以帮助他们更快地掌握软件的技能和知识,从而更好地使用Halcon进行图像处理。 Halcon 学习资料CHM文件中包含了Halcon的软件安装和使用手册、编程手册、算法手册等相关的文档。这些文档详细地介绍了Halcon的各个方面,包括各种图像处理技术和算法的应用,编程方法和规范等等。 通过阅读Halcon 学习资料CHM文件,用户可以更好地理解Halcon软件的工作原理和使用方法,并能够掌握一些实用的技巧和知识,提高图像处理的效率和质量。此外,Halcon学习资料CHM文件还提供了一些实例程序和工程,可以让用户在实际应用中更好地理解和掌握Halcon的各项功能和特性。 总之,Halcon 学习资料CHM文件对于Halcon使用者来说是非常重要的,它为用户提供了一系列丰富的知识和技能,帮助用户更好地应用Halcon进行图像处理和分析。 ### 回答3: halcon 学习资料 chm 是一个针对 halcon 软件学习的 chm 文档。Halcon 是由德国 MVTec 公司开发的一款用于图像处理和机器视觉应用的软件,在工业自动化、医疗影像、安防等领域都有广泛的应用。 学习使用 halcon 软件需要掌握其相关的知识体系和技术原理,而 halcon 学习资料 chm 正是为此而设计的。该文档内部包含了丰富的学习资料,包括 halcon 软件的基本介绍、图像处理原理、机器视觉算法以及实例演示等内容,涵盖了 halcon 学习的方方面面,适合初学者和有一定基础的人员使用。 使用 halcon 学习资料 chm 学习,可以帮助初学者迅速掌握 halcon 的基本知识和技术原理,同时也可以帮助有一定基础的人员深入理解 halcon 的高级特性和应用技巧。该文档具有系统性、实用性和可靠性等特点,可以为学习者提供全面的学习资源和指导,助力于其提高专业技能和应用能力。 总之,halcon 学习资料 chm 对于学习者来说是一份宝贵的资料,有助于加快学习进度、巩固知识体系、提高应用水平,值得每位 halcon 学习者使用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值