资源描述
Dalsa-Genie相机二次开发步骤
Genie相机为Coreco公司的产品,因此采集使用CamExpert,开发使用SaperaLT。
用户安装完SaperaLT后可查看安装路径下的帮助文件与例程进行开发(建议使用6.2或以上版本的SaperaLT,其提供更全面的例程)。
函数帮助文档:\DALSA\Sapera\Help - Sapera++Prog
例程:\DALSA\Sapera\Demos\Classes\VC –
GigeCameraDemo:基本单帧采集功能,可更改buffer大小、进行显示设置
GigESeqGrabDemo:连续采集与保存功能
GigEFlatFieldDemo:平场校正等附加功能
一. Sapera++介绍
Sapera++是Sapera LT为用户提供的API. Sapera++ 包含两大类:基础应用类(Basic Classes)和GUI类(GUI Classes)。以下为Sapera应用结构图:
1. 基础应用类:
提供了用户进行图像开发的基本函数,命名方式为Sap+类功能名,其结构如下图所示:
常用类:
SapAcqDevice:读写、控制相机
SapBuffer:操作buffer
SapBufferWith Trash:实时处理时建立trash buffer用于存放转换数据(常用于处理速度跟不上数据采集速度时)
SapTransfer:管理一般的传递过程
SapView:显示buffer中存储的内容至屏幕
2. GUI类:
提供了许多常用设置对话框,用户可根据自己的需要选用;其结构如下图所示。
常用对话框:
CAbortDlg:等待对话框
CAcqConfigDlg:相机配置文件导入对话框
CAcqDlg:动态修改相机设置
CBufDlg:Buffer设置对话框
CLoadSaveDlg:导入与保存对话框
二. Genie相机开发步骤:
与基于Dalsa采集卡开发的CameraLink相机相比,Gig-E相机只在初始化和导入相机配置文件时有不同。
1.加载动态链接库:
(1) 使用Basic Classes:
① 在Project | Settings… | C/C++ | Preprocessor | Additional include directories 中加入路径C:\DALSA\Sapera\Classes\Basic;
② 在Project|Add to Project | Files 中加入C:\DALSA\Sapera\Lib\SapClassBasic.lib 和 SapClassBasicD.lib;
③ 在 Project | Settings…| General中将SapClassBasic.lib 选为Exclude file from build;
④ 在Project | Settings… | C/C++ | Code Generation | Use run-time library中选择choose the option Multithreaded DLL (在release模式下) or Debug Multithreaded DLL (在debug模式下) ;
⑤在头文件中加入SapClassBasic.h。
(2) 使用GUI:
① 在Project | Settings… | C/C++ | Preprocessor | Additional include directories 中加入路径C:\DALSA\Sapera\Classes\Gui;
② 在Project|Add to Project | Files 中加入C:\DALSA\Sapera\Lib\SapClassGui.lib 和 SapClassGuiD.lib;
③ 在 Project | Settings…| General中将SapClassBasic.lib 选为Exclude file from build for Win32 Release;
④ 在In Project | Settings… | C/C++ | Code Generation | Use run-time library中选择choose the option Multithreaded DLL (在release模式下) or Debug Multithreaded DLL (在debug模式下) ;
⑤在头文件中加入SapClassGui.h。
2. 初始化资源:
m_AcqDevice = new SapAcqDevice(dlg.GetLocation(), dlg.GetConfigFile());
m_Buffers = new SapBufferWithTrash(2, m_AcqDevice);
m_Xfer = new SapAcqDeviceToBuf(m_AcqDevice, m_Buffers, XferCallback, this);
m_View = new SapView(m_Buffers, m_viewWnd.GetSafeHwnd());
使用SapAcqDevice类:The SapAcqDevice Class provides the functionality for reading/writing features from/to devices such as a GigE-Vision camera. The class also contains functions for sending commands and registering events to devices.
3.连接相机:
首先在CamExpert中配置好相机参数并保存为.ccf文件,当相机初始化完成后,导入此文件。用户可使用GUI-CAcqConfigDlg对话框方便操作。
使用SapLocation类:The SapLocation Class identifies a Sapera server/resource pair。
4.完成采集与处理功能后释放资源。
三.更改相机参数
获得相机信息:SapAcqDevice::GetFeatureInfo
设置相机信息:SapAcqDevice::SetFeatureValue
常用相机参数信息:
1.相机与芯片信息:
Interface = {GigE Vision = 0}
DeviceVendorName = "DALSA"
DeviceModelName = "Genie M640" for Genie M640
DeviceScanType = {Areascan = 0}
ColorType = {Monochrome Sensor = 0}
SensorWidth = Width of the sensor in pixels
SensorHeight = Height of the sensor in lines
PixelSize = Number of bits per pixel
2.Binning:
BinningHorizontal = {Disabled = 1, 2 pixels = 2}
BinningVertical = {Disabled = 1, 2 lines = 2}
3.曝光控制:
FrameRate = 0.1 Hz up to max.
ExposureMode = {Programmable = 1, Pulse Controlled = 2}
ExposureTime = Exposure duration in µs
4.Trigger:
TriggerDelayToIntegration = Delay in µs from trigger to exposure
TriggerEnable = {FALSE, TRUE}
TriggerSource = {Input 1 = 0, Input 2 = 1, Software = 2}
TriggerSoftware = {FALSE, TRUE}
PolarityInput_x = {Active High = 0, Active Low = 1}
5.Strobe:
OutputSelectorOutput_x = {Open = 0, Close = 1, Strobe On: Start of Exposure = 2, Pulse On: Valid Trigger = 4, Pulse On: Invalid Trigger = 5, Pulse On: Start of Readout = 6, Pulse On: End of Readout = 7, Pulse On: End of Acquisition = 8, Pulse On: Input 1 = 9, Pulse On: Input 2 = 10}
PulseDelayOutput_x = Delay in µs to assert pulse output
PulseDurationOutput_x = Pulse duration in µs
PolarityOutput_x = {Active Close = 0, Active Open = 1}
6.Load:
Power-upConfig = {Factory Default = 0, Camera Configuration 1 = 1}
SaveCameraConfigurationSelector = {Camera Configuration 1 = 1}
LoadCameraConfigurationSelector = {Factory Default = 0, Camera Configuration 1 = 1}
如需更详细的相机参数资料,请见Genie软件安装路径下的“GenieMonoSeries_User.pdf”。
三. 获得图像信息
相机采集完一帧图像后会进入回调函数“XferCallback”,用户可在其中进行自己的图像处理操作。
* 读写buffer数据信息:
用户可通过GetAddress函数得到图像数据首地址,并得到buffer尺寸、格式、偏移量来进行进一步图像处理工作(要首先获得首地址再得到偏移量)。
展开阅读全文