• [转]Halcon的编程语法与数据处理


    1、跟其他语言不完全一致的表达符号

    赋值符号  :=

    引号      ' ' (一律是单引号)

    求商求余  /   % (一个整数除以另一个数,如何使商是实型的?即浮点型)

    逻辑运算  and  or  not  xor(异或)

    逻辑真假  true  false

    等于      = 和 == 都行

    不等于    != 和 # 都行

     

    2、程序控制语法

    程序语法与Delphi、VB.Net极为类似。例如:

     

    ① for循环

    for i := 1 to 10 by 1  

        ……

    endfor 

     

    ② if/else判断

    if(……)

        ……

    elseif(……)

        ……

    else

        ……

    endif

     

    ③ while循环

    while(……)

        ……

    endwhile

     

     

    break、continue跟其他编程语言一致。

     

     

    3、常见的Tuple函数运算

    min(t)                        tuple中的最小值

    max(t)                       tuple中的最大值

    min2(t1,t2)              求两个值(tuple)中的较小值

    max2(t1,t2)             求两个值(tuple)中的较大值

    sum(t)                       求和

    mean(a)                    求均值

    deviation(a)               标准差( https://www.cnblogs.com/xh6300/p/7413715.html

    sqrt(a)                       平方根

    deg(a)                      将弧度转为角度

    rad(a)                       将角度转为弧度

    real(a)                       将整型转为real型

    int(a)                         将real型转为整型

    round(a)                    转换为最接近的整数元组

    number(v)                 将string类型转为number类型

    abs(a)                       求绝对值

    sort(t)                      升序排列

     

    更多Tuple的操作请参考:

    https://www.cnblogs.com/xh6300/p/6117688.html

     

     可以将下面的例子运行一下,感受一下:

     1 read_image (Image, 'code.png') 2 create_bar_code_model ([], [], BarCodeHandle) 3 dev_set_draw ('margin') 4 **同时查找Code 128码和Code 39码,这种方式消耗的时间只等于只找一种码的时间。 5 **得到的字符串元组str等于 ['123456', '220519140360'] 6 find_bar_code (Image, SymbolRegions, BarCodeHandle, ['Code 128','Code 39'], str) 7  8 num := |str| 9 tuple_strlen (str, Length)  //获得字符串元组中每个字符串的长度,[6,12]10 11 A0 := Length[0]    //等于612 13 A1 := Length[1]    //等于1214 15 AA := A0 + A1      //等于1816 17 B0 :=str[0]        //得到的仍是一个字符串,'123456'18 19 B0_int :=number(str[0])  //貌似没有字符串转int类型,不过可以转成number类型,12345620 21 aa := 3 + B0_int   //转为数字可以进行四则运算了,123456 + 3 = 12345922 23 i :=[590,6]        //这里创建的是一个整型元组24 25 i0 := i[0]         //等于59026 27 *数据转字符串28 aa := 590 + ''

    4、四舍五入、取整、有效数字以及和字符串之间的转换

    https://www.cnblogs.com/xh6300/p/10027998.html

     

     

    5、数据排序算子

    tuple_sort — Sort the elements of a tuple in ascending order.

    tuple_sort_index — Sort the elements of a tuple and return the indices of the sorted tuple.(对元组的元素进行(升序)排序,并返回排序后的元组的索引(相对于输入的tuple)。)

     

    https://www.cnblogs.com/xh6300/p/6417801.html

     

  • 相关阅读:
    为什么要用泛型呢
    sql语句优化
    SQL Server 2008 问题——已成功与服务器建立连接,但是在登录过程中发生错误。
    CHECKFORILLEGALCROSSTHREADCALLS = FALSE
    数据类型 text 和 varchar 在 add 运算符中不兼容
    js中数组对象去重的方法
    json字符串、json对象、数组之间的转换
    如何用jQuery获得select的值
    SQL Server 性能调优
    TSQL 数据类型转换
  • 原文地址:https://www.cnblogs.com/dinghw/p/12678123.html
Copyright © 2020-2023  润新知