尝试解决basler关不掉的问题

main
Jeffrey_Li 2 years ago
parent fc8f54c7d3
commit 03444ed917

@ -24,33 +24,34 @@ void CaptureThreadBasler::process(void)
{ {
bool last_high = false; bool last_high = false;
bool last_result = 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; CSampleConfigurationEventHandler* CfgEvent = NULL;
ImageEvent.p_image_queue_ = p_image_queue; CfgEvent = new CSampleConfigurationEventHandler;
ImageEvent.p_unit_queue_ = p_unit_queue; CfgEvent->channel_ = Local_Num;
ImageEvent.p_shooted_queue_ = p_shooted_queue; pDev_->RegisterConfiguration(CfgEvent, Pylon::RegistrationMode_Append, Pylon::Cleanup_None);
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; CSampleImageEventHandler ImageEvent;
BurstEvent.p_unit_queue_ = p_unit_queue; ImageEvent.p_image_queue_ = p_image_queue;
BurstEvent.p_result_wait_queue_ = p_result_wait_queue; ImageEvent.p_unit_queue_ = p_unit_queue;
BurstEvent.p_result_queue_ = p_result_queue; ImageEvent.p_shooted_queue_ = p_shooted_queue;
BurstEvent.p_shooted_queue_ = p_shooted_queue; ImageEvent.p_debug_queue_ = p_debug_queue;
BurstEvent.p_double_queue_ = p_double_queue; ImageEvent.m_cntGrabbedImages_ = &m_cntGrabbedImages;
BurstEvent.p_image_queue_ = p_image_queue; ImageEvent.Shoot_Num_ = Shoot_Num;
BurstEvent.pDev__ = pDev_; ImageEvent.pDev__ = pDev_;
BurstEvent.pCaptureThreadBasler = this; 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.pDev__ = pDev_;
m_threadFunc.p_result_queue_ = p_result_queue; m_threadFunc.p_result_queue_ = p_result_queue;
m_threadFunc.p_double_queue_ = p_double_queue; m_threadFunc.p_double_queue_ = p_double_queue;
@ -89,11 +90,9 @@ void CaptureThreadBasler::process(void)
/*Set here*/ /*Set here*/
if (pDev_->TriggerSelector.TrySetValue(Basler_UniversalCameraParams::TriggerSelector_FrameBurstStart)) if (pDev_->TriggerSelector.TrySetValue(Basler_UniversalCameraParams::TriggerSelector_FrameBurstStart))
{ {
DEBUG(" TriggerSelector_FrameBurstStart\n");
pDev_->TriggerMode.SetValue(Basler_UniversalCameraParams::TriggerMode_Off); pDev_->TriggerMode.SetValue(Basler_UniversalCameraParams::TriggerMode_Off);
if(pDev_->EventSelector.TrySetValue(Basler_UniversalCameraParams::EventSelector_FrameBurstStart)) if(pDev_->EventSelector.TrySetValue(Basler_UniversalCameraParams::EventSelector_FrameBurstStart))
{ {
DEBUG(" EventSelector_FrameBurstStart\n");
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off); pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off);
} }
} }
@ -144,18 +143,38 @@ void CaptureThreadBasler::process(void)
if (m_Timer) delete m_Timer; if (m_Timer) delete m_Timer;
pDev_->StopGrabbing(); pDev_->StopGrabbing();
pDev_->Close(); pDev_->Close();
pDev_->GrabCameraEvents = false;
pDev_->DeregisterConfiguration(CfgEvent); pDev_->DeregisterConfiguration(CfgEvent);
pDev_->DeregisterImageEventHandler(&ImageEvent); pDev_->DeregisterImageEventHandler(&ImageEvent);
#ifndef USB_BASLER_NEW_FW #ifndef USB_BASLER_NEW_FW
pDev_->DeregisterCameraEventHandler(&BurstEvent, "EventFrameBurstStartData"); pDev_->DeregisterCameraEventHandler(&BurstEvent, "EventFrameBurstStartData");
#else
pDev_->DeregisterCameraEventHandler(&BurstEvent, "EventLine1RisingEdgeData");
pDev_->DeregisterCameraEventHandler(&BurstEvent, "EventLine1FallingEdgeData");
#endif #endif
} }
catch(const Pylon::GenericException& e) catch(const Pylon::GenericException& e)
{ {
emit error( QString::fromStdString( e.GetDescription()) ); emit error( QString::fromStdString( e.GetDescription()) );
std::cout << e.GetSourceLine()<<e.GetDescription() << std::endl; std::cout << e.GetSourceLine()<<e.GetDescription() << std::endl;
pDev_->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
}
} }
} }

@ -12,6 +12,13 @@
#define BaslerClassID 0x02 #define BaslerClassID 0x02
#define c_maxCamerasToUse (size_t)2 #define c_maxCamerasToUse (size_t)2
//5:灰色
//6:黑色
//1:红色
//2:黄色
//3:白色
//4:绿色
class BaslerCamera: public BaseCamera class BaslerCamera: public BaseCamera
{ {
public: public:

Loading…
Cancel
Save