diff --git a/Cigarette/CaptureThreadBasler.cpp b/Cigarette/CaptureThreadBasler.cpp index cdd6de3..e5045c2 100644 --- a/Cigarette/CaptureThreadBasler.cpp +++ b/Cigarette/CaptureThreadBasler.cpp @@ -24,33 +24,34 @@ void CaptureThreadBasler::process(void) { bool last_high = false; bool last_result = false; - try - { - CSampleConfigurationEventHandler *CfgEvent=NULL; - CfgEvent = new CSampleConfigurationEventHandler; - CfgEvent->channel_ = Local_Num; - pDev_->RegisterConfiguration(CfgEvent, Pylon::RegistrationMode_Append, Pylon::Cleanup_None); - CSampleImageEventHandler ImageEvent; - ImageEvent.p_image_queue_ = p_image_queue; - ImageEvent.p_unit_queue_ = p_unit_queue; - ImageEvent.p_shooted_queue_ = p_shooted_queue; - ImageEvent.p_debug_queue_ = p_debug_queue; - ImageEvent.m_cntGrabbedImages_ = &m_cntGrabbedImages; - ImageEvent.Shoot_Num_ = Shoot_Num; - ImageEvent.pDev__ = pDev_; - pDev_->RegisterImageEventHandler(&ImageEvent, Pylon::RegistrationMode_Append, Pylon::Cleanup_None); + CSampleConfigurationEventHandler* CfgEvent = NULL; + CfgEvent = new CSampleConfigurationEventHandler; + CfgEvent->channel_ = Local_Num; + pDev_->RegisterConfiguration(CfgEvent, Pylon::RegistrationMode_Append, Pylon::Cleanup_None); - CSampleCameraEventHandler BurstEvent; - BurstEvent.p_unit_queue_ = p_unit_queue; - BurstEvent.p_result_wait_queue_ = p_result_wait_queue; - BurstEvent.p_result_queue_ = p_result_queue; - BurstEvent.p_shooted_queue_ = p_shooted_queue; - BurstEvent.p_double_queue_ = p_double_queue; - BurstEvent.p_image_queue_ = p_image_queue; - BurstEvent.pDev__ = pDev_; - BurstEvent.pCaptureThreadBasler = this; + CSampleImageEventHandler ImageEvent; + ImageEvent.p_image_queue_ = p_image_queue; + ImageEvent.p_unit_queue_ = p_unit_queue; + ImageEvent.p_shooted_queue_ = p_shooted_queue; + ImageEvent.p_debug_queue_ = p_debug_queue; + ImageEvent.m_cntGrabbedImages_ = &m_cntGrabbedImages; + ImageEvent.Shoot_Num_ = Shoot_Num; + ImageEvent.pDev__ = pDev_; + pDev_->RegisterImageEventHandler(&ImageEvent, Pylon::RegistrationMode_Append, Pylon::Cleanup_None); + CSampleCameraEventHandler BurstEvent; + BurstEvent.p_unit_queue_ = p_unit_queue; + BurstEvent.p_result_wait_queue_ = p_result_wait_queue; + BurstEvent.p_result_queue_ = p_result_queue; + BurstEvent.p_shooted_queue_ = p_shooted_queue; + BurstEvent.p_double_queue_ = p_double_queue; + BurstEvent.p_image_queue_ = p_image_queue; + BurstEvent.pDev__ = pDev_; + BurstEvent.pCaptureThreadBasler = this; + + try + { m_threadFunc.pDev__ = pDev_; m_threadFunc.p_result_queue_ = p_result_queue; m_threadFunc.p_double_queue_ = p_double_queue; @@ -89,11 +90,9 @@ void CaptureThreadBasler::process(void) /*Set here*/ if (pDev_->TriggerSelector.TrySetValue(Basler_UniversalCameraParams::TriggerSelector_FrameBurstStart)) { - DEBUG(" TriggerSelector_FrameBurstStart\n"); pDev_->TriggerMode.SetValue(Basler_UniversalCameraParams::TriggerMode_Off); if(pDev_->EventSelector.TrySetValue(Basler_UniversalCameraParams::EventSelector_FrameBurstStart)) { - DEBUG(" EventSelector_FrameBurstStart\n"); pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off); } } @@ -144,18 +143,38 @@ void CaptureThreadBasler::process(void) if (m_Timer) delete m_Timer; pDev_->StopGrabbing(); pDev_->Close(); - pDev_->GrabCameraEvents = false; pDev_->DeregisterConfiguration(CfgEvent); pDev_->DeregisterImageEventHandler(&ImageEvent); #ifndef USB_BASLER_NEW_FW pDev_->DeregisterCameraEventHandler(&BurstEvent, "EventFrameBurstStartData"); +#else + pDev_->DeregisterCameraEventHandler(&BurstEvent, "EventLine1RisingEdgeData"); + pDev_->DeregisterCameraEventHandler(&BurstEvent, "EventLine1FallingEdgeData"); #endif } catch(const Pylon::GenericException& e) { emit error( QString::fromStdString( e.GetDescription()) ); std::cout << e.GetSourceLine()<StopGrabbing(); + if (pDev_->IsCameraDeviceRemoved()) + { + cout << "The camera has been removed from the computer." << endl; + } + else + { + pDev_->StopGrabbing(); + pDev_->GrabCameraEvents = false; + pDev_->Close(); + pDev_->DeregisterConfiguration(CfgEvent); + pDev_->DeregisterImageEventHandler(&ImageEvent); +#ifndef USB_BASLER_NEW_FW + pDev_->DeregisterCameraEventHandler(&BurstEvent, "EventFrameBurstStartData"); +#else + pDev_->DeregisterCameraEventHandler(&BurstEvent, "EventLine1RisingEdgeData"); + pDev_->DeregisterCameraEventHandler(&BurstEvent, "EventLine1FallingEdgeData"); +#endif + } + } } diff --git a/Cigarette/baslercamera.h b/Cigarette/baslercamera.h index 43fa4c2..6018bfc 100644 --- a/Cigarette/baslercamera.h +++ b/Cigarette/baslercamera.h @@ -12,6 +12,13 @@ #define BaslerClassID 0x02 #define c_maxCamerasToUse (size_t)2 +//5:灰色 +//6:黑色 +//1:红色 +//2:黄色 +//3:白色 +//4:绿色 + class BaslerCamera: public BaseCamera { public: