Halcon的图像来源有两种,一种是通过相机采集,一种是读取图片。Halcon不仅是一个图像处理包它还包括相机采集。
相机采集
Halcon 目前已支持50多个图像采集卡和数百种工业相机,HALCON图像采集接口库构成了图像采集设备制造商提供的软件与HALCON之间的桥梁。它们形成一个通用的通用接口,仅需要少量的运算符。
如果您成功安装了图像采集设备,则需要从HALCON对其进行访问,只需调用 operatoropen_framegrabber
,指定图像采集接口的名称和一些其他信息,例如有关已连接摄像机的信息。
使用例子如下:
* Select a suitable image acquisition interface name AcqName
info_framegrabber(AcqName,'port',Information,Values)
* Open image acquisition device using the default settings, see
* documentation of the actually used interface for more details
open_framegrabber(AcqName,1,1,0,0,0,0,'default',-1,'default',-1.0, \
'default','default','default',-1,-1,AcqHandle)
grab_image(Image,AcqHandle)
close_framegrabber(AcqHandle
本地文件读取
读取单张图片
* Set Image Path
set_system('image_dir','D:/TestImage')
* Read Image
read_image(Image,'BAT0001.PNG')
循环读取图片
list_files ('D:/TestImage', ['files','follow_links'], ImageFiles)
for imgIndex := 0 to |ImageFiles| - 1 by 1
read_image (Image, ImageFiles[imgIndex])
//do something
endfor