的端口
LineIn :相机输入的多路转接器
AcqHandle:图像获取设备的Handle
3.grab_image( :
Image :
AcqHandle : )
从
AcqHandle指定的图像获取设备中获取图像,输出为获得的图像
4.set_framegrabber_param( : :
AcqHandle,
Param,
Value : )
为
AcqHandle指定的图像获取设备设置参数
Param : 'color_space','continuous_grabbing', 'external_trigger', 'grab_timeout','image_height', 'image_width', 'port', 'start_column', 'start_row','volatile'
注意:能够设置的参数不仅仅是上述建议的参数。也可以一次设定多个参数值。
例如:set_framegrabber_param (AcqHandle, 'port', Port0)
set_framegrabber_param (AcqHandle, ['image_width','image_height'],[256, \256])
对DaHengCams能设置的常用额外参数包括:
'adc_level' ---设置A/D转换的级别;
'color_space' ---设置颜色空间
'gain' ---设置相机增益
'grab_timeout' ---设置采集超时终止的时间
'resolution' ---设定相机的采相分辨率,MOD0为最大的分辨率。
'shutter' ---设定相机的曝光时间。
'shutter_unit' ---设定相机曝光时间的单位。
'white_balance' ---相机是否打开白平衡模式,默认为关闭白平衡
5.info_framegrabber( : :
Name,
Query :
Information,
ValueList)
查询指定的图像采集接口的信息。
Name为图像采集设备的名称
Query为需要查询的参数名称
Information是指输出的文本信息
ValueList为该图像采集接口的参数值
6.get_image_pointer1(
Image: : :
Pointer,
Type,
Width,
Height)
获取一个图像通道的指针,输出指针以及图像类型和尺寸。
7.dev_set_part( : :
Row1,
Column1,
Row2,
Column2 : )
修改图像显示部分的尺寸。
8.close_all_framegrabbers( : : : )
关闭图像采集设备。
9.count_seconds( : : :
Seconds)
测试算子实行时间
* general configuration of HDevelop
set_system ('do_low_error', 'true') //设置系统参数,在输出窗口只立即显示图像//
dev_update_window ('off')
stop ()
* step 1: connect to the image acquisition device
* -> Please adapt the following lines for your own imageacquisition device.
AcqName := 'DaHengCam'
open_framegrabber (AcqName, 1, 1, 0, 0, 0, 0, 'default', -1,'gray', -1, 'false', 'ntsc', 'default', -1, -1, AcqHandle)//打开并配置图像采集设备//
stop ()
* step 2: grab a first image and adjust the window size
grab_image (Image, AcqHandle) //获取图像//
get_image_pointer1 (Image, Pointer, Type, Width, Height)//获取图像通道指针//
dev_close_window ()
dev_open_window (0, 0, Width/2, Height/2, 'black', WindowHandle)//开新窗口//
dev_set_part (0, 0, Height-1, Width-1)
dev_display (Image)
stop ()
* step 3: grab and process images in a loop (exit with left mousebutton)
dev_open_window (0, Width/2 + 8, Width/2, Height/2, 'black',WindowHandleProcess)
dev_set_colored (12)
dev_open_window (Height/2 + 68, 0, Width/2, Height/16, 'lightgray', WindowHandleButton)
dev_set_part (0, 0, Height/16 - 1, Width/2 -1)
write_string (WindowHandleButton, ' click here with left mousebutton to exit loop')//写字符
进入窗口//
dev_set_window (WindowHandle)
dev_set_part (0, 0, Height-1, Width-1)
Button := 0
while (Button # 1)
grab_image (Image, AcqHandle)
dev_set_window (WindowHandle)
dev_display (Image)
* -> process image (segment with an automatically determinedthreshold)
auto_threshold (Image, Regions, 4)//高斯平滑图像并利用直方图分割图像输出区域//
connection (Regions, ConnectedRegions)
dev_set_window (WindowHandleProcess)
dev_display (ConnectedRegions)
* -> check for a click into the window (error handling switchedoff, otherwise the cursor must always be in the window)
dev_set_check ('~give_error')
get_mposition (WindowHandleButton, Row, Column, Button)
dev_set_check ('give_error')
endwhile
dev_set_window (WindowHandleButton)
dev_close_window ()
dev_set_window (WindowHandleProcess)
dev_close_window ()
stop ()
* clean up
dev_update_window ('on')
close_all_framegrabbers ()