Halcon 的基础用法
基础语法
- 1. 下载链接
- 2. 赋值
- 3. 判断符
- 4. 循环
- 5. 加载图片
- 6. 读取文件夹下所有图片
1. 下载链接
链接:https://pan.baidu.com/s/1ZhQ_tTcubUtUggbb-OxUGw?pwd=w3rs
提取码:w3rs
2. 赋值
x := 1
s := 'hello'
list2 := ['a', 'b', 'c']
3. 判断符
* 等于比较符
if(x = 1)h := 6
endif* 不等于
if(x # 6) x := 3
endif* 逻辑 与
if(x < 4 and y > 3)x := 5
endif* 逻辑 或
if(x < 4 or y > 3)x := 8
endif* 逻辑 非
if(not(x = 8))x := 9
endif
4. 循环
list2 := ['a', 'b', 'c']
* 获取元组的长度
leng := |list2|* 遍历元组
for Index := 0 to leng-1 by 1x := list2[Index]
endfor* while 循环
c := 1
while (c < 5)c := c+1
endwhile
5. 加载图片
* 加载图片
read_image (Image1, 'C:/001.png')* 二值化处理
threshold (Image1, Region, 10, 100)* 把二值化处理玩的图片进行分割
connection (Region, ConnectedRegions)* 过滤 5000 - 7000 面积
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 5000, 7000)
6. 读取文件夹下所有图片
* 读取文件夹
list_files ('C:/image', 'files', Paths)* 循环展示图片
for Index := 0 to |Paths| - 1 by 1* 读取图片read_image (Image, Paths[Index])* 中断运行stop()
endfor