实现了大恒相机的单帧采集
#include <GalaxyIncludes.h>
#include <QDebug>
int main(int argc, char* argv[])
{
//初始化
IGXFactory::GetInstance().Init();
try
{
//枚举设备
gxdeviceinfo_vector vectorDeviceInfo;
IGXFactory::GetInstance().UpdateDeviceList(1000, vectorDeviceInfo);
if (0 == vectorDeviceInfo.size())
{
qDebug() << "No Camera Available !";
return 0;
}
qDebug() << vectorDeviceInfo[0].GetVendorName() ;
qDebug() << vectorDeviceInfo[0].GetSN() ;
//打开第一台设备以及设备下面第一个流
CGXDevicePointer m_objDevicePtr = IGXFactory::GetInstance().OpenDeviceBySN(vectorDeviceInfo[0].GetSN(),GX_ACCESS_EXCLUSIVE);
CGXStreamPointer m_objStreamPtr = m_objDevicePtr->OpenStream(0);
//获取远端设备属性控制器
CGXFeatureControlPointer m_objFeatureControlPtr = m_objDevicePtr->GetRemoteFeatureControl();
m_objFeatureControlPtr->GetEnumFeature("TriggerSource")->SetValue("Software");
//设置曝光时间(示例中写死us,只是示例,并不代表真正可工作参数)
//m_objFeatureControlPtr->GetFloatFeature("ExposureTime")->SetValue(50);
//发送开采命令
m_objStreamPtr->StartGrab();
m_objFeatureControlPtr->GetCommandFeature("AcquisitionStart")->Execute();
//采单帧
CImageDataPointer objImageDataPtr;
objImageDataPtr = m_objStreamPtr->GetImage(1000);//超时时间使用500ms,用户可以自行设定
if (objImageDataPtr->GetStatus() == GX_FRAME_STATUS_SUCCESS) //采图成功而且是完整帧,可以进行图像处理...
{
qDebug() << "Receive a Picture!" ;
qDebug() << "ImageInfo: " << objImageDataPtr->GetStatus() ;
qDebug() << "ImageInfo: " << objImageDataPtr->GetWidth() ;
qDebug() << "ImageInfo: " << objImageDataPtr->GetHeight() ;
qDebug() << "ImageInfo: " << objImageDataPtr->GetPayloadSize() ;
}
//此时开采成功,控制台打印信息,直到输入任意键继续
//getchar();
//发送停采命令
m_objFeatureControlPtr->GetCommandFeature("AcquisitionStop")->Execute();
m_objStreamPtr->StopGrab();
//释放资源
m_objStreamPtr->Close();
m_objDevicePtr->Close();
}
catch (CGalaxyException& e)
{
qDebug() << "Error Code: " << e.GetErrorCode() ;
qDebug() << "Error Description: " << e.what() ;
}
catch (std::exception& e)
{
qDebug() << "Error Description:: " << e.what() ;
}
//反初始化库
IGXFactory::GetInstance().Uninit();
return 0;
}