第一种:
-
ImagePath :=
[]
-
ImagePath[
0] := 'D:/halcon_test/读取多张图片的方式/
1.jpg'
-
ImagePath[
1] := 'D:/halcon_test/读取多张图片的方式/
2.jpg'
-
ImagePath[
2] := 'D:/halcon_test/读取多张图片的方式/
3.jpg'
-
ImagePath[
3] := 'D:/halcon_test/读取多张图片的方式/
4.jpg'
-
ImagePath[
4] := 'D:/halcon_test/读取多张图片的方式/
5.jpg'
-
-
for Index :=
0 to
4 by
1
-
dev_close_window ()
-
read_image (Image, ImagePath[Index])
-
get_image_size (Image, Width, Height)
-
dev_open_window (
0,
0, Width, Height, 'black', WindowHandle)
-
dev_display (Image)
-
endfor
第二种:
-
for
i := 1 to 5 by 1
-
dev_close_window
()
-
read_image
(Image, 'D:/halcon_test/读取多张图片的方式/'+i+'.jpg')
-
get_image_size
(Image, Width, Height)
-
dev_open_window
(0, 0, Width, Height, 'black', WindowHandle)
-
dev_display
(Image)
-
endfor
第三种:
-
for I
:=
1 to
5 by
1
-
dev_close_window ()
-
*I$表示引用I的值,而
'1d'的
'd'则表示采用十进制数表示,取一位数,如
1、
2、
3此类,
-
*故
'3d'则表示为取三位十进制数,如
001、
002、
003诸如此类
-
read_image (Image,
'D:/halcon_test/读取多张图片的方式/'+I$'
1d
')
-
get_image_size (Image, Width, Height)
-
dev_open_window (0, 0, Width, Height, 'black
', WindowHandle)
-
dev_display (Image)
-
endfor
第四种:
第四种方法 (读取一个文件夹下的所有图片)
【助手】-->【打开新的image acquisition 】-->【图像助手】-->【选择路径】-->【代码生成】-->【插入代码】