【问题标题】:Halcon - Variable iconic variable nameHalcon - 变量标志性变量名
【发布时间】:2020-09-27 07:14:57
【问题描述】:

我有以下代码:

for i:=0 to num_stripes by 1
        R := Row1 + 5*i
        gen_rectangle1(TransStripe, R,Column1,R+4, Column2)
        intersection(TransStripe, LabelSelcted, RegionIntersection)
        smallest_rectangle1(RegionIntersection, dummy, BeginCol, dummy, EndCol)
        inizio := BeginCol - 5
        fine := EndCol + 5
        area_center(RegionIntersection, dummy, centro_row, centro_col)
        gen_rectangle1(Str, R, inizio, R+4, fine)
        dev_set_color('red')
        dev_display(Str)
    endfor

在最后几行中,我创建了一个名为Str 的矩形。有没有办法即时创建名称,以便每个矩形都有一个变量? Str1,Str2 ...

【问题讨论】:

    标签: variables variable-names halcon iconic


    【解决方案1】:

    很遗憾,没有直接的方法可以做到这一点。有一些解决方法:

    连接对象:

    gen_empty_obj (EmptyObject)
    for Index := 1 to 5 by 1
        gen_rectangle1 (Rectangle, 30, 20, 100, 200*Index)
        concat_obj (EmptyObject, Rectangle, EmptyObject)
    endfor
    
    ** Selecting
    select_obj (EmptyObject, ObjectSelected, 3)
    

    使用向量(需要 Halcon 12+ 版本)

    for Index := 0 to 4 by 1
        gen_rectangle1 (Rectangle.at(Index), 30, 20, 100, 200*(Index+1))
    endfor
    
    ** Selecting
    Object := Rectangle.at(2)
    

    还可以将向量用作结构并添加多个级别,其中一个级别是名称和其他对象或值。如果你想了解更多,我写了一篇文章:https://subpixel.hr/halcon-is-like-a-box-of-chocolates/

    【讨论】:

    • 非常感谢!如何在您的第一个示例 Rectangle 中通过添加对象而不是覆盖来增加?
    • 少了一行:) 现已修复
    • 谢谢!顺便说一句,不错的文章.. 今天读了一些.. :)
    猜你喜欢
    • 2020-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多