应用背景:晶体表面疵病工业检测,导轨运动的光栅尺反馈系统产生的脉冲用于外触发Dalsa相机进行图像采集。
解决问题:Dalsa线阵CCD直接采集的图像是当前一行的图像,配套的采集卡中用于存储图像的缓冲区有限,当平台连续长距离运动时,如果不及时读取缓冲区的图像,新采集的图像将覆盖之前采集的图像。
阅读Dalsa相机的开发文档中的继承图,如下:
我们最为关心的是缓冲区的内容SapBuffer和将采集内容转运到缓冲区的SapAcqToBuf,细心一点的话还能看到采集内容转运到缓冲区的回调函数的Info。
查看官方提供的一些开发Demo
// Transfer callback function is called each time a complete frame is transferred.
// The function below is a user defined callback function.
void XferCallback(SapXferCallbackInfo *pInfo)
{
// Display the last transferred frame
SapView *pView = (SapView *) pInfo->GetContext();
pView->Show();
}
// Example program
//
main()
{
// Allocate acquisition object
SapAcquisition *pAcq =
new SapAcquisition(SapLocation (“X64-CL_1”, 0), “MyCamera.ccf”);
// Allocate buffer object, taking settings directly from the acquisition
SapBuffer *pBuffer = new SapBuffer(1, pAcq);
// Allocate view object, images will be displayed directly on the desktop
SapView *pView = new SapView(pBuffer, SapHwndDesktop);
// Allocate transfer object to link acquisition and buffer
SapTransfer *pTransfer = new SapTransfer(XferCallback, pView);
pTransfer->AddPair(SapXferPair(pAcq, pBuffer));
// Create resources for all objects
BOOL success = pAcq->Create();
succ