Halcon知识【5】通过人机交互输入若干个圆

您所在的位置:网站首页 同心圆python编程代码人机交互 Halcon知识【5】通过人机交互输入若干个圆

Halcon知识【5】通过人机交互输入若干个圆

2023-10-08 17:11| 来源: 网络整理| 查看: 265

一、提要

        初学者看到draw_circle这样的语句,可能会一头雾水;无法找到此语句的正确执行,我本人曾经以为是被淘汰的语句。此语句的语法是draw_circle (3600, Rowx, Columnx, Radius)其中,你给上面任何一个变量赋值,将出现语法错误。

二、理解draw_circle算子

        正确理解该语句:该算子类似于控制台输入语句,或者就是python的input语句,input接受一些字符串,而draw_circle是接收你在图形窗口输入的圆的参数,因此,在程序编写draw_circle之前,要打开图像窗口。程序执行到draw_circle将出现阻塞状态,就是要用户在图像窗口用左键画圆,画完后,右键退出。以下小程序帮助你练习这条语句。注意,其它带“draw”的语句都可类似处理。

Row := [] column := [] radiu := [] for index:=0 to 3 by 1 draw_circle (3600, Rowx, Columnx, Radius) Row := [Row,Rowx] column := [column, Columnx] radiu := [radiu,Radius] endfor stop() for index:=0 to 3 by 1 row := Row[index] col := column[index] r := radiu[index] gen_circle( Circle ,row, col, r ) stop() endfor 三、代码解释 

注意,   draw_circle (3600, Rowx, Columnx, Radius)     语句在屏幕画圆图,输出变量是Rowx, Columnx, Radius;

for index:=0 to 3 by 1     draw_circle (3600, Rowx, Columnx, Radius)     Row    := [Row,Rowx]     column := [column, Columnx]     radiu  := [radiu,Radius] endfor

对比之下,gen_circle( Circle ,row, col, r  )是输入中心、半径,得到一个圆区域。

for index:=0 to  3 by 1     row := Row[index]     col := column[index]     r := radiu[index]     gen_circle( Circle ,row, col, r  )     stop() endfor

四、结束语

        通过以上代码,你将学到 1)Halcon的元组变量定义 2)元组追加语句 3)图像任意位置画圆 4)收集所画圆的参数 5)在图像窗口展示所画信息。

参考结果:



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3