《Dalsa 相机参数设置以及采集.docx》由会员分享,可在线阅读,更多相关《Dalsa 相机参数设置以及采集.docx(4页珍藏版)》请在第一文库网上搜索。
1、Dalsa相机参数设置以及采集1.定义成员变量SapAcqDevice*m_pAcq Device;SapBufferWithTrash *m_pBuffers;SapTransfer*m_pAcqDeviceToBuf;BayerEncode m_bayer_encode;static void NanoXferCallback(SapXferCallbackInfo *plnfo);2、Oninitidialog中设置参数以及连接相机连接m-pAcqDevice = new SapAcqDevice(SapLocation(lrO)/ FALSE);m_pBuffers = new Sap
2、BufferWithTrash(10,m_pAcqDevice);mpAcqDeviceToBuf = new SapAcqDeviceToBuf(m_pAcqDevice,m_pBuffers,NanoXferCallback,this);BOOL b=m_pAcqDevice-CreateQ;if(b)InsertListBoxC相机连接成功!);elseInsertListBoxC相机连接失败!);m_pAcqDevice-SetFeatureValue(Width,1280);m_pAcqDevice-SetFeatureValue(nHeight/1024);b=m_pBuffers
3、- Create();b=m_pAcq DeviceToBuf-Create();m_pAcqDevice-SetFeatureValue(nTriggerMode,1/0);b = m_pAcqDevice-SetFeatureValue(HExposureTime,/(double)200);if(b)InsertListBoxC曝光时间设置成功!);elseInsertListBox。曝光时间设置失败!);m_pAcqDevice-SetFeatureValue(nGainn/ (double)3);b = m-pAcqDevice-SetFeatureValue(,Acquisitio
4、nFrameRateMl (double)theApp.mJHZ);if(b)InsertListBox(帧率设置成功!);elseInsertListBoxC帧率设置失败!);3、回调函数中保存图片void CTrainNumberIdentificationDlg:NanoXferCallback(SapXferCallbacklnfo *plnfo)(CTrainNumberldentificationDIg *p =(CTrainNumberldentificationDIg * )plnfo-GetContext();BYTE *pData = NULL;CString strCur
5、lmageName = _T(n);if(theApp.m_strDeviceName = 1)strCurImageName.Format(%s%d.jpg,theApp.m_strPicPath,theApp.m_nPicorder);elsestrCurImageName.Format(%s2-%d.jpgztheApp.m_strPicPath,theApp.m_nPicorder);if (!pInfo-IsTrash()(p-m_pBuffers-GetAddress(void *)&pData);BYTE *pDataJPGIn = new BYTE4000000;/m_imag
6、e_compress.PushImageData(pData,m_pBuffers-GetWidth(),m_pBuffers-GetHeight(),/(m_pBuffers-GetPixelDepth()/8),strCurImageName);p-mbayer_encode.gp_bayerdecode(pData/1280/1024/pDataJPGIn/BAYER_TILE_RGGB);JSAMPROW row_pointerl = NULL;int row_stride = 0;struct jpeg_compress_structjcs;struct jpeg_error_mgr
7、jem;FILE *pSaveFile = NULL;fopen_s(&pSaveFile/strCurImageName/wbM);jcs.err = jpeg_std_error(&jem);jpeg_create_compress(&jcs);jpeg_stdio_dest(&jcsz pSaveFile);jcs.image_width = 1280;jcs.image-height = 1024;jcs.input_components = 3;/if (1 = pImageInfo-m_nChannel)/ jcs.in_color_space = JCS_GRAYSCALE;/)
8、/else(jcs.in_color_space = JCS.RGB;jpeg_set_defaults(&jcs);jpeg_set_quality(&jcs/80/true);jpeg_start_compress(&jcs/TRUE);row_stride = jcs.image_width*(3);/if(MirrorImage(pImageInfo/pImageInfo-m_nFlip)(while (jcs.next_scanline m_cameraJog.LogErrCT(nCamera UserID = %s,出现丢帧:%dn),/pCamCtrl-m_strUserID/pInfo-GetEventCount();入队列EnterCriticalSection(&(theApp.m_CS);theApp.g_grab_image_queue.push(strCurImageName);LeaveCriticalSection(&(theApp.m_CS);strCurImageName+=n;gJogQueue.Log(strCurlmageName);theApp.m_nPicorder+ +;)