You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Cigarette/Cigarette/CaptureThreadHIK.h

103 lines
2.6 KiB
C++

//-----------------------------------------------------------------------------
#ifndef CaptureThreadHIKH
#define CaptureThreadHIKH CaptureThreadHIKH
//-----------------------------------------------------------------------------
#include "hikcamera.h"
#include <QThread>
#include <QMutex>
#include <functional>
#include <QTimer>
#include "SyncQueue.h"
#include "ASyncQueue.h"
#include <opencv2/opencv.hpp>
class CaptureThreadHIK_Func
{
public:
void *CamHandle_;
ASyncQueue<bool> *p_result_queue_;
ASyncQueue<bool> *p_double_queue_;
void SendFeedBack(int OpID)
{
bool send_ng=false;
bool send_ok=false;
if(OpID == EdgeEvent)
{
#if defined DOUBLE_FEED_BACK
if(p_double_queue_->count() > 0)
{
bool temp;
p_double_queue_->take(temp);
send_ng=true;
}
#endif
}
if (p_result_queue_->count() > 0)
{
bool result;
p_result_queue_->take(result);
if (!result)
{
#if defined DOUBLE_FEED_BACK
p_double_queue_->put(true);
#endif
send_ng=true;
}
}
if(send_ng)
{
MV_CC_SetEnumValue(CamHandle_, "LineSelector", 1);
MV_CC_SetCommandValue(CamHandle_, "LineTriggerSoftware");
}
}
};
//-----------------------------------------------------------------------------
class CaptureThreadHIK : public QObject
//-----------------------------------------------------------------------------
{
Q_OBJECT
public:
explicit CaptureThreadHIK(void *camhandle, bool boTerminated,int Num);
CaptureThreadHIK::~CaptureThreadHIK(void);
void terminate( void )
{
boTerminated_ = true;
}
signals:
void error( QString err );
void finished( void );
void requestReady( void );
void updateStatistics( const QString& data ,int Num);
private slots:
void process( void );
void fpsTimeout(void);
public:
int Local_Num;
SyncQueue<std::pair<int, cv::Mat> > *p_image_queue;
ASyncQueue<cv::Mat> *p_unit_queue;
ASyncQueue<bool> *p_result_queue;
ASyncQueue<bool> *p_result_wait_queue;
ASyncQueue<bool> *p_double_queue;
ASyncQueue<bool> *p_shooted_queue;
SyncQueue<cv::Mat> *p_debug_queue;
void* CamHandle;
QTimer* m_Timer;
uint64_t m_cntGrabbedImages = 0;
uint64_t m_cntLastGrabbedImages = 0;
bool Ready = false;
CaptureThreadHIK_Func m_threadFunc;
private:
MV_FRAME_OUT_INFO_EX stFrameInfo;
unsigned char* g_pImage_buf;
volatile bool boTerminated_;
QMutex lock_;
};
#endif // CaptureThreadHIKH