Halcon数据类型.docx

上传人:b****5 文档编号:3729644 上传时间:2022-11-25 格式:DOCX 页数:13 大小:237.04KB
下载 相关 举报
Halcon数据类型.docx_第1页
第1页 / 共13页
Halcon数据类型.docx_第2页
第2页 / 共13页
Halcon数据类型.docx_第3页
第3页 / 共13页
Halcon数据类型.docx_第4页
第4页 / 共13页
Halcon数据类型.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

Halcon数据类型.docx

《Halcon数据类型.docx》由会员分享,可在线阅读,更多相关《Halcon数据类型.docx(13页珍藏版)》请在冰豆网上搜索。

Halcon数据类型.docx

Halcon数据类型

Halcon学习笔记

1、Halcon的自我描述

ProgramLogic

ØEachprogramconsistsofasequenceofHALCONoperators

ØTheprogramcanbestructuredintoprocedures

ØThesequencecanbeextendedbyusingcontroloperatorslikeif,for,repeat,orwhile

ØTheresultsoftheoperatorsarepassedviavariables

ØNoimplicitdatapassingisapplied

ØInputparametersofoperatorscanbevariablesorexpressions

ØOutputparametersarealwaysvariables

ØHDevelophasnofeaturestodesignagraphicaluserinterface

ØAnHDevelopprogramisconsideredasaprototypicsolutionofthevisionpartofanapplication

ØHDevelopistypicallynotusedforthefinalapplication

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

Halcon的初学者也应当从参考Halcon的程序入手,熟悉Halcon类库,也即HDevelop-BasedProgramming;在此基础上,进入ORClass-OrientedProgramming。

这也是Halcon推荐的开发方式:

ThevisionpartissolvedwithHDevelop,andtheapplicationisdevelopedwithC++orVisualBasic。

2、HDevelop界面的学习

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

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

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

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

Ø本地过程(LocalProcedue)与外部过程(ExternelProcedue)

3、基本语法结构

Halcon的语法结构

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

不允许单独声明变量;

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

C++(算子模式)

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

C++(面向对象)

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

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

其他语言(略)

4、Halcon数据结构

两类参数:

图形参数Iconic(image,region,XLD)与控制参数Control(string,integer,real,handle),在Halcon算子的参数中,依次为:

输入图形参数、输出图形参数、输入控制参数、输出控制参数;并且其输入参数不会被算子改变。

图形参数Iconic:

Images

ØMultiplechannels

ØArbitraryregionofinterest

ØMultiplepixeltypes(byte,(u)int1/2/4,real,complex,direction,cyclic,vector_field)

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

int1,int2//Differenceoftwoimagesorderivateswithintegerprecision(?

)int4//两幅灰度图的频谱

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

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

complex//图片频率分布

cyclic//Assigningone"gray"valuetoeachcolor(?

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

Regions

ØEfficientdatastructure(runlengthencoding)//高效的数据结构

ØExtensivesetofoperators

ØFastestmorphologyonthemarket

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

ExtendedLineDescription(XLD)

ØSubpixelaccuratelineandedgedetection

ØGenericpointlistbaseddatastructure

ØHandlingofcontours,polygons,lines,parallels,etc.

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

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

5、Halcon语言

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

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

Boolean型变量包括true(=1)、false(=0);不为零的整数将被认为true;但绝大多数的Halcon函数接受字符串型的表达:

’true’‘false’,而非逻辑型表达;

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

ØH_MSG_TRUEnoerror2

ØH_MSG_FALSElogicalfalse3

ØH_MSG_FAILoperatordidnotsucceed5

可以放在try…catch…endtry块中,也可以用dev_error_var()与dev_set_check()来捕获;

控制语句结构:

(与一般语言略有不同,它们也有输入输出变量)

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

Øfor...endfor

Øwhile...endwhile

Ørepeat...until

此外,也有关键字break、continue、return、exit、stop用来控制语句的执行;

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

标准赋值

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

ØResultVariable:

=Expression//代码形式

元组插入赋值

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

ØTuple[Index]:

=NewValue//代码形式

控制变量元组操作

Ø[t,t]concatenationoftuples//元组串联

Ø|t|numberofelements//元素数目

Øt[i]selectionofanelement//选中的元素

Øt[i:

j]selectionofapartofatuple//選擇一個元組的一部分(i和J是index?

Øsubset(t1,t2)selectionfromt1byindicesint2//選擇從T1在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)

元组的数学运算,如:

A*B,令m=|A|,n=|B|;//矩阵乘法?

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

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

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

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

Halcon的数学运算

算术运算

Øa/adivision

Øa%arestoftheintegerdivision

Øa*amultiplication

Øv+vadditionandconcatenationofstrings//加法和字符串串联。

Øa-asubtraction

Ø-anegation//取反。

位运算

Ølsh(i,i)leftshift

Ørsh(i,i)rightshift

Øibandibit-wiseand

Øiboribit-wiseor

Øibxoribit-wisexor

Øbnotibit-wisecomplement

字符串操作

Øv$sconversiontostring//字符串的格式化,有很丰富的参数

Øv+vconcatenationofstringsandaddition

Østrchr(s,s)searchcharacterinstring

Østrstr(s,s)searchsubstring

Østrrchr(s,s)searchcharacterinstring(reverse)

Østrrstr(s,s)searchsubstring(reverse)

Østrlen(s)lengthofstring

Øs{i}selectionofonecharacter

Øs{i:

i}selectionofsubstring//选择子串

Øsplit(s,s)splittingtosubstrings

比较操作符

Øt

Øt>tgreaterthan

Øt<=tlessorequal

Øt>=tgreaterorequal

Øt=tequal

Øt#tnotequal//不等

逻辑操作符

Ønotlnegation

Ølandllogical’and’

Ølorllogical’or’

Ølxorllogical’xor’

数学函数

Øsin(a)sineofa

Øcos(a)cosineofa

Øtan(a)tangentofa

Øasin(a)arcsineofaintheinterval[-/2,/2],a[-1,1]

Øacos(a)arccosineaintheinterval[-/2,/2],a[-1,1]

Øatan(a)arctangentaintheinterval[-/2,/2],a[-1,1]

Øatan2(a,b)arctangenta/bintheinterval[-,]

Øsinh(a)hyperbolicsineofa

Øcosh(a)hyperboliccosineofa

Øtanh(a)hyperbolictangentofa

Øexp(a)exponentialfunction

Ølog(a)naturallogarithm,a>0

Ølog10(a)decadelogarithm,a>0

Øpow(a1,a2)power

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

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

Ømin(t)minimumvalueofthetuple

Ømax(t)maximumvalueofthetuple

Ømin2(t1,t2)element-wiseminimumoftwotuples

Ømax2(t1,t2)element-wisemaximumoftwotuples

Øfind(t1,t2)indicesofalloccurrencesoft1withint2

Ørand(i)createrandomvaluesfrom0..1(numberspecifiedbyi)

Øsgn(a)element-wisesignofatuple

Øsum(t)sumofallelementsorstringconcatenation

Øcumul(t)cumulativehistogramofatuple

Ømean(a)meanvalue

Ødeviation(a)standarddeviation

Øsqrt(a)squarerootofa

Ødeg(a)convertradianstodegrees

Ørad(a)convertdegreestoradians

Øreal(a)convertintegertoreal

Øint(a)convertarealtointeger

Øround(a)convertrealtointeger

Ønumber(v)convertstringtoanumber

Øis_number(v)testifvalueisanumber

Øabs(a)absolutevalueofa(integerorreal)

Øfabs(a)absolutevalueofa(alwaysreal)

Øceil(a)smallestintegervaluenotsmallerthana

Øfloor(a)largestintegervaluenotgreaterthana

Øfmod(a1,a2)fractionalpartofa1/a2,withthesamesignasa1

Øsort(t)sortinginincreasingorder

Øuniq(t)eliminateduplicatesofneighboringvalues(typicallyusedincombinationwithsort)

Øsort_index(t)returnindexinsteadofvalues

Ømedian(t)Medianvalueofatuple(numbers)

Øselect_rank(t,v)Selecttheelement(number)withthegivenrank

Øinverse(t)reversetheorderofthevalues

Øsubset(t1,t2)selectionfromt1byindicesint2

Øremove(t1,t2)Removeofvalueswiththegivenindices

Øenvironment(s)valueofanenvironmentvariable

Øord(a)ASCIInumberofacharacter

Øchr(a)convertanASCIInumbertoacharacter

Øords(s)ASCIInumberofatupleofstrings

Øchrt(i)convertatupleofintegersintoastring

6、Halcon名称解释

ØOperator:

AprocedureoftheHALCONlibraryusedinHDeveloporoneofthelanguageinterfaces.//算子:

在HDevelop或语言接口之一使用HALCON库的程序。

ØProcedure(ofHDevelop):

AsubroutinedefinedfortheuseinsideHDevelop.

ØRegion:

Resultofasegmentationlikethreshold.Inothersystemscalledblob,area,binaryimage,orisland.Implementedusingrunlengthencoding.

ØXLD:

ExtendedLineDescription.Universaldatastructureusedtohandlecontourbaseddata.Mainlyusedinthecontextofsubpixelprecisemeasurement.//用于处理基于轮廓数据的通用数据结构。

主要用在子像素精确的测量的情况下。

ØDomain:

Partoftheimagewhichisusedforprocessing.InothersystemscalledROI(regionofinterest).

ØChannel:

Oneimagematrixofamulti-spectralimage.OneexampleistheredchannelofanRGBimage.

ØIconicdata:

Overalltermforimages,regions,andXLDdata.Inobjectorientedlanguages(C++andCOM)andinHDevelopiconicdataisrepresentedbyapolymorphicdatatype.Inobjectorientedlanguagesiconicdataisalsocallediconicobject.

ØControldata:

Allnoniconicdata.Examplesaresinglevalues(integer,real,andstring),coordinates,arraysofvalues.

ØTuple:

anarrayofvalueswhereeachelementcanbeofadifferenttype.Onecanhavebothiconicandcontroltuples.//元组。

ØHALCONobject:

SynonymforIconicobject/data

ØImageacquisitioninterface:

Interfacebetweentheframegrabber/cameradriver(SDK)andtheHALCONlibrary.TheImageacquisitioninterfaceisaDLLwhichisdynamicallyloadedwhencallingopen_framegrabber.

ØLanguageinterface:

SoftwarethatenablestheprogrammertousetheHALCONlibraryinagivenlanguage(e.g.,C++).

ØExtensionPackage:

Amechanismthatenablestheusertofullyintegrateuser-definedproceduresintotheHALCONenvironment.TheextensionpackageconceptgivesfullaccesstotheinternaldatastructuresofHALCON.//拓展包。

ØLicensefile:

File“license.dat“inthedirectory“license“.Thisfileisusedtogetherwithhardwarecomponents(dongleorEthernetcard)tocheckifacorrectlicenseisavailable.

ØHelpfiles:

Filesinthedirectory“help“whichareusedtogetonlineinformationaboutallHALCONoperators.ThisisextensivelyusedbyHDevelop.

ØShape-BasedMatching:

Findingofanobjectinanimagebasedonapredefinedmodel.Theshapebasedmatchingusesfeaturestoquicklylocateobjectsveryprecisely./

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 自然科学 > 化学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1