简体   繁体   English

Halcon - 变量标志性变量名

[英]Halcon - Variable iconic variable name

I have follwoing code:我有以下代码:

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

In the last few lines, I create a rectangle named Str .在最后几行中,我创建了一个名为Str的矩形。 Is there a way to create names on the fly, so that i have a variable for each rectangle?有没有办法即时创建名称,以便每个矩形都有一个变量? Str1, Str2... Str1,Str2...

Unfortunately, there isn't a direct way to do this.不幸的是,没有直接的方法可以做到这一点。 There are a few workarounds:有一些解决方法:

Concatenating objects:连接对象:

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)

Using vectors (Halcon 12+ version required)使用向量(需要 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)

It is also possible to use vectors as structures and adding multiple levels, where one level would be the names and other objects or values.也可以使用向量作为结构并添加多个级别,其中一个级别是名称和其他对象或值。 If you'd like to read more about it, I wrote an article: https://subpixel.hr/halcon-is-like-a-box-of-chocolates/如果你想了解更多,我写了一篇文章: https://subpixel.hr/halcon-is-like-a-box-of-chocolates/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM