参考文献:https://mp.weixin.qq.com/s/g53wC_J3yJFfYnu0CdOlvw
一、读取单张图片
* (1)-Halcon读取图像--读取单张图片
read_image(Image, './imgs/1.bmp')
二、批量读取图片--有序(命名有序图片)
* i取值为1,2,3,图片路径为'./imgs/1.bmp', './imgs/2.bmp', './imgs/3.bmp'
for i:=1 to 3 by 1
read_image (Image2, './imgs/' + i + '.bmp')
endfor
三、批量读取图片--无序(命名无序图片)
* (3)-Halcon读取图像--批量读取(命名无序图片)
* 列出imgs文件夹下所有文件路径
list_files ('./imgs', 'files', ImageFiles)
* 选择符合条件的文件(jpg/png/bmp)
tuple_regexp_select (ImageFiles, '.*jpg|png|bmp', Selection)
* 循环读取文件夹中的图像
for i:=0 to |Selection| - 1 by 1
read_image (Image_Test, Selection[i])
endfor
* Image Acquisition 01: Code generated by Image Acquisition 01
list_files ('E:/Practice/Halcon/Halcon_Study/Function_Study/imgs', ['files','follow_links'], ImageFiles)
tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles)
for Index := 0 to |ImageFiles| - 1 by 1
read_image (Image, ImageFiles[Index])
* Image Acquisition 01: Do something
endfor