博客
关于我
初学者Halcon编程的语法资料
阅读量:608 次
发布时间:2019-03-12

本文共 4551 字,大约阅读时间需要 15 分钟。

Halcon编程的语法资料

以下内容是来自;大恒提供的培训资料。希望对大家初学者又所帮助。

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

String类型变量由单引号 ’ 括起来;此外还有一些特殊字符;
Boolean型变量包括 true ( = 1 )、 false ( = 0 ) ;不为零的整数将被认为true;但绝大多数的Halcon函数接受字符串型的表达:’true’ ‘false’,而非逻辑型表达;
函数返回常量用于标识错误:
Ø H_MSG_TRUE no error 2
Ø H_MSG_FALSE logical false 3
Ø H_MSG_FAIL operator did not succeed 5
可以放在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] concatenation of tuples
Ø |t| number of elements
Ø t selection of an element
Ø t[i:j] selection of a part of a 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 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 / a division
Ø a % a rest of the integer division
Ø a * a multiplication
Ø v + v addition and concatenation of strings
Ø a - a subtraction
Ø -a negation
位运算
Ø lsh(i,i) left shift
Ø rsh(i,i) right shift
Ø i band i bit-wise and
Ø i bor i bit-wise or
Ø i bxor i bit-wise xor
Ø bnot i bit-wise complement
字符串操作
Ø v$s conversion to string //字符串的格式化,有很丰富的参数
Ø v + v 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
比较操作符
Ø t < t less than
Ø t > t greater than
Ø t <= t less or equal
Ø t >= t greater or equal
Ø t = t equal
Ø t # t not equal
逻辑操作符
Ø not l negation
Ø l and l logical ’and’
Ø l or l logical ’or’
Ø l xor l logical ’xor’
数学函数
Ø sin(a) sine of a
Ø cos(a) cosine of a
Ø tan(a) tangent of a
Ø asin(a) arc sine of a in the interval [-p/2, p/ 2], a Î [-1, 1]
Ø acos(a) arc cosine a in the interval [-p/2, p/2], a Î [-1, 1]
Ø atan(a) arc tangent a in the interval [-p/2, p/2], a Î [-1, 1]
Ø atan2(a,b) arc tangent a/b in the interval [-p, p]
Ø 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 a tuple
Ø sum(t) sum of all elements or string concatenation
Ø cumul(t) cumulative histogram of a 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 a real to integer
Ø round(a) convert real to integer 四舍五入
Ø number(v) convert string to a number
Ø is_number(v) test if value is a number
Ø abs(a) absolute value of a (integer or real)
Ø fabs(a) absolute value of a (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 a 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 a character
Ø chr(a) convert an ASCII number to a character
Ø ords(s) ASCII number of a tuple of strings
Ø chrt(i) convert a tuple of integers into a string

转载地址:http://aurtz.baihongyu.com/

你可能感兴趣的文章
Mysql Row_Format 参数讲解
查看>>
mysql select, from ,join ,on ,where groupby,having ,order by limit的执行顺序和书写顺序
查看>>
MySQL Server 5.5安装记录
查看>>
mysql server has gone away
查看>>
mysql slave 停了_slave 停止。求解决方法
查看>>
MySQL SQL 优化指南:主键、ORDER BY、GROUP BY 和 UPDATE 优化详解
查看>>
MYSQL sql语句针对数据记录时间范围查询的效率对比
查看>>
mysql sum 没返回,如果没有找到任何值,我如何在MySQL中获得SUM函数以返回'0'?
查看>>
mysql Timestamp时间隔了8小时
查看>>
Mysql tinyint(1)与tinyint(4)的区别
查看>>
mysql union orderby 无效
查看>>
mysql v$session_Oracle 进程查看v$session
查看>>
mysql where中如何判断不为空
查看>>
MySQL Workbench 使用手册:从入门到精通
查看>>
mysql workbench6.3.5_MySQL Workbench
查看>>
MySQL Workbench安装教程以及菜单汉化
查看>>
MySQL Xtrabackup 安装、备份、恢复
查看>>
mysql [Err] 1436 - Thread stack overrun: 129464 bytes used of a 286720 byte stack, and 160000 bytes
查看>>
MySQL _ MySQL常用操作
查看>>
MySQL – 导出数据成csv
查看>>