大恒水星相机硬触发测试

2018-11-17  本文已影响104人  张王李刘赵孙杨

大恒水星相机硬触发测试:

c++实现:

class CSampleCaptureEventHandler : public ICaptureEventHandler
{
public:
    void DoOnImageCaptured(CImageDataPointer&objImageDataPointer, void* pUserParam) //回调函数处理
    {
        cout << "收到一帧图像!" << endl;
        cout << "ImageInfo: " << objImageDataPointer->GetStatus() << endl;
        cout << "ImageInfo: " << objImageDataPointer->GetWidth() << endl;
        cout << "ImageInfo: " << objImageDataPointer->GetHeight() << endl;
        cout << "ImageInfo: " << objImageDataPointer->GetPayloadSize() << endl;
    }
};

void run()
{
    //声明事件回调对象指针
    IDeviceOfflineEventHandler* pDeviceOfflineEventHandler = NULL;///<掉线事件回调对象
    IFeatureEventHandler* pFeatureEventHandler = NULL;///<远端设备事件回调对象
    ICaptureEventHandler* pCaptureEventHandler = NULL;///<采集回调对象

        //初始化
    IGXFactory::GetInstance().Init();

    //枚举设备
    gxdeviceinfo_vector vectorDeviceInfo;
    IGXFactory::GetInstance().UpdateDeviceList(1000, vectorDeviceInfo);

    int a = 0;
    if (0 == vectorDeviceInfo.size())
    {
        cout << "无可用设备!" << endl;
        cin >> a;

        //反初始化库
        IGXFactory::GetInstance().Uninit();
        return;
    }

    //打开第一台设备以及设备下面第一个流
    CGXDevicePointer ObjDevicePtr = 
        IGXFactory::GetInstance().OpenDeviceBySN(vectorDeviceInfo[0].GetSN(), GX_ACCESS_EXCLUSIVE);
    CGXStreamPointer ObjStreamPtr = ObjDevicePtr->OpenStream(0);

    //获取远端设备属性控制器
    CGXFeatureControlPointer ObjFeatureControlPtr = ObjDevicePtr->GetRemoteFeatureControl();
    ObjFeatureControlPtr->GetEnumFeature("TriggerMode")->SetValue("On");
    ObjFeatureControlPtr->GetEnumFeature("TriggerSource")->SetValue("Line0");
    ObjFeatureControlPtr->GetEnumFeature("TriggerActivation")->SetValue("RisingEdge");
    ObjFeatureControlPtr->GetFloatFeature("TriggerDelay")->SetValue(500000);
    ObjFeatureControlPtr->GetFloatFeature("TriggerFilterRaisingEdge")->SetValue(5000);

    //注册回调采集
    pCaptureEventHandler = new CSampleCaptureEventHandler();
    ObjStreamPtr->RegisterCaptureCallback(pCaptureEventHandler, NULL);

    //发送开采命令
    ObjStreamPtr->StartGrab();
    ObjFeatureControlPtr->GetCommandFeature("AcquisitionStart")->Execute();

    Sleep(10000);

    //发送停采命令
    ObjFeatureControlPtr->GetCommandFeature("AcquisitionStop")->Execute();
    ObjFeatureControlPtr->GetEnumFeature("TriggerMode")->SetValue("Off");

    ObjStreamPtr->StopGrab();

    //注销采集回调
    ObjStreamPtr->UnregisterCaptureCallback();

    //释放资源
    ObjStreamPtr->Close();
    ObjDevicePtr->Close();

    //反初始化库
    IGXFactory::GetInstance().Uninit();

    //销毁事件回调指针
    if (NULL != pCaptureEventHandler)
    {
        delete pCaptureEventHandler;
        pCaptureEventHandler = NULL;
    }
    cin >> a;
}

结果图:


结果图
上一篇 下一篇

猜你喜欢

热点阅读