Compare commits
53 Commits
Author | SHA1 | Date |
---|---|---|
Jinhuan | a8d4a359c4 | 3 months ago |
Jinhuan | c10ad02d1a | 3 months ago |
Jinhuan | cc8ce53abc | 9 months ago |
seiyu | ca135833a0 | 10 months ago |
seiyu | b2cba2ee05 | 10 months ago |
seiyu | 096007f412 | 10 months ago |
seiyu | 1864c6cf04 | 10 months ago |
seiyu | c7c63a3b2e | 10 months ago |
seiyu | e376b84212 | 10 months ago |
Jeffrey_Li | 2506ac806e | 10 months ago |
Jeffrey_Li | 03444ed917 | 10 months ago |
seiyu | fc8f54c7d3 | 10 months ago |
seiyu | 215acc558b | 1 year ago |
seiyu | 39f080cdca | 1 year ago |
seiyu | 3f6c64d10c | 1 year ago |
Flamingo | 4c319c9ae5 | 1 year ago |
seiyu | 7d33939aa1 | 1 year ago |
Jeffrey_Li | 2020f6a810 | 1 year ago |
seiyu | 92d931e56d | 1 year ago |
seiyu | 9e2355e2d5 | 1 year ago |
Flamingo | 6dffbbba19 | 1 year ago |
seiyu | 5aa4f78df5 | 1 year ago |
seiyu | d5303e4de1 | 1 year ago |
Flamingo | f565de07a8 | 1 year ago |
seiyu | ed9c76f165 | 1 year ago |
seiyu | dfacffd891 | 1 year ago |
seiyu | a4a9b3f7e1 | 1 year ago |
seiyu | 79d7bb38c5 | 1 year ago |
seiyu | 9fc16465ed | 1 year ago |
Chu Jun | 805cdc855c | 1 year ago |
seiyu | 85d59b3ee9 | 1 year ago |
seiyu | 41fe0fff27 | 1 year ago |
seiyu | 637bbef357 | 1 year ago |
seiyu | 96e94011c4 | 1 year ago |
Jeffrey_Li | 6cc6ed3e76 | 1 year ago |
Jeffrey_Li | 4728a58767 | 1 year ago |
Jeffrey_Li | 3863c89610 | 1 year ago |
seiyu | f5be5614bf | 1 year ago |
Jeffrey_Li | 1ba73b82f2 | 1 year ago |
seiyu | b9d04918b9 | 1 year ago |
18661908385 | 4323f75315 | 1 year ago |
Jeffrey_Li | 1e9c49ec92 | 1 year ago |
Jeffrey_Li | 088f6fb1a0 | 1 year ago |
Jeffrey_Li | b6f0e95103 | 1 year ago |
Jeffrey_Li | 20165d19d2 | 1 year ago |
Jeffrey_Li | a6da5c3b77 | 1 year ago |
Jeffrey_Li | 228e781876 | 1 year ago |
Jeffrey_Li | 8720cce3d4 | 1 year ago |
Flamingo | fc94eea6ae | 1 year ago |
Flamingo | fc3e8de896 | 1 year ago |
CJ980606 | aa9e765f26 | 1 year ago |
18661908385 | e9233bd88c | 1 year ago |
Jeffrey_Li | 521d4d8c2f | 1 year ago |
@ -0,0 +1,68 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"string": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"cctype": "cpp",
|
||||
"chrono": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"compare": "cpp",
|
||||
"complex": "cpp",
|
||||
"concepts": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"deque": "cpp",
|
||||
"list": "cpp",
|
||||
"map": "cpp",
|
||||
"set": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"random": "cpp",
|
||||
"ratio": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"fstream": "cpp",
|
||||
"future": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"numbers": "cpp",
|
||||
"ostream": "cpp",
|
||||
"semaphore": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"thread": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeindex": "cpp",
|
||||
"typeinfo": "cpp"
|
||||
}
|
||||
}
|
Binary file not shown.
@ -0,0 +1,5 @@
|
||||
/* This file was generated by qmake with the info from <root>/src/mqtt/mqtt.pro. */
|
||||
#ifdef __cplusplus /* create empty PCH in C mode */
|
||||
#include <QtCore/QtCore>
|
||||
#include <QtNetwork/QtNetwork>
|
||||
#endif
|
Binary file not shown.
Binary file not shown.
@ -1,3 +1,3 @@
|
||||
#include "ASyncQueue.h"
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
#include "AlarmInfo.h"
|
||||
|
||||
|
||||
|
||||
AlarmInfo::AlarmInfo()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AlarmInfo::~AlarmInfo()
|
||||
{
|
||||
}
|
||||
|
@ -1,150 +0,0 @@
|
||||
#include "CaptureThread.h"
|
||||
#include "common.h"
|
||||
|
||||
extern bool g_debug_mode; //相机调试模式,调试模式必须暂停状态才能打开
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
CaptureThread::CaptureThread( Device* pCurrDev, bool boTerminated, FunctionInterface* pFI_ ,int Num) :
|
||||
pDev_( pCurrDev ), boTerminated_( boTerminated ), requestPendingForDisplay_( INVALID_ID ), pFI_( pFI_ ),Local_Num(Num)
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
p_unit_queue = new ASyncQueue<cv::Mat>(Unit_Queue_Size);
|
||||
}
|
||||
CaptureThread::~CaptureThread()
|
||||
{
|
||||
delete p_unit_queue;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void CaptureThread::process( void )
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
try
|
||||
{
|
||||
//Line5回调
|
||||
mvIMPACT::acquire::GenICam::EventControl pEventCtrl_(pDev_);
|
||||
//pEventCtrl_.eventSelector.writeS("Line5FallingEdge");
|
||||
//pEventCtrl_.eventNotification.writeS("Off");
|
||||
//pEventCtrl_.eventSelector.writeS("Line5RisingEdge");
|
||||
//pEventCtrl_.eventNotification.writeS("Off");
|
||||
pEventCtrl_.eventSelector.writeS("Line5AnyEdge");
|
||||
#ifdef IMM_PROCESS
|
||||
pEventCtrl_.eventNotification.writeS("Off");
|
||||
#else
|
||||
pEventCtrl_.eventNotification.writeS("On");
|
||||
#endif
|
||||
|
||||
#ifndef IMM_PROCESS
|
||||
EventCallback eventCallback(&pEventCtrl_);
|
||||
eventCallback.p_unit_queue_ = p_unit_queue;
|
||||
eventCallback.p_image_queue_ = p_image_queue;
|
||||
eventCallback.p_result_wait_queue_ = p_result_wait_queue;
|
||||
eventCallback.p_shooted_queue_ = p_shooted_queue;
|
||||
eventCallback.p_double_queue_ = p_double_queue;
|
||||
eventCallback.m_pMVCamera = pDev_;
|
||||
eventCallback.pCaptureThread = this;
|
||||
eventCallback.registerComponent(pEventCtrl_.eventLine5AnyEdge);
|
||||
#endif
|
||||
|
||||
m_threadFunc.m_pMVCamera = pDev_;
|
||||
m_threadFunc.p_result_queue_ = p_result_queue;
|
||||
m_threadFunc.p_double_queue_ = p_double_queue;
|
||||
|
||||
//相机掉线回调
|
||||
CIwtCameraLostCallbackMV cam_lost_cb;
|
||||
cam_lost_cb.channel_ = Local_Num;
|
||||
if (cam_lost_cb.registerComponent(pDev_->state) != true)
|
||||
{
|
||||
std::cout << "ERROR: Unable to register the camera's lost CallBack function!\n";
|
||||
}
|
||||
//图像采集循环
|
||||
TDMR_ERROR result = DMR_NO_ERROR;
|
||||
while( ( result = static_cast< TDMR_ERROR >( pFI_->imageRequestSingle() ) ) == DMR_NO_ERROR ) {};
|
||||
if( result != DEV_NO_FREE_REQUEST_AVAILABLE )
|
||||
{
|
||||
qDebug() << "'FunctionInterface.imageRequestSingle' returned with an unexpected result: " << QString::fromStdString( mvIMPACT::acquire::ImpactAcquireException::getErrorCodeAsString( result ) );
|
||||
}
|
||||
manuallyStartAcquisitionIfNeeded( pDev_, *pFI_ );
|
||||
int cnt = 0;
|
||||
|
||||
// run thread loop
|
||||
mvIMPACT::acquire::Statistics statistics( pDev_ );
|
||||
mvIMPACT::acquire::Request* pRequest = 0;
|
||||
mvIMPACT::acquire::Request* pPreviousRequest = nullptr;
|
||||
const unsigned int timeout_ms = 200;
|
||||
Ready = true;
|
||||
while( !boTerminated_ )
|
||||
{
|
||||
const int requestNr = pFI_->imageRequestWaitFor( timeout_ms );
|
||||
pRequest = pFI_->isRequestNrValid( requestNr ) ? pFI_->getRequest( requestNr ) : 0;
|
||||
if( pRequest )
|
||||
{
|
||||
if (pRequest->isOK())
|
||||
{
|
||||
// do something with the image
|
||||
int openCVDataType = CV_8UC1;
|
||||
if ((pRequest->imagePixelFormat.read() == ibpfBGR888Packed) || (pRequest->imagePixelFormat.read() == ibpfRGB888Packed))
|
||||
openCVDataType = CV_8UC3;
|
||||
cv::Mat openCVImage(cv::Size(pRequest->imageWidth.read(), pRequest->imageHeight.read()), openCVDataType, pRequest->imageData.read(), pRequest->imageLinePitch.read());
|
||||
cv::Mat image_clone = openCVImage.clone();
|
||||
if (!g_debug_mode)
|
||||
{
|
||||
#ifdef IMM_PROCESS
|
||||
p_image_queue->put(std::make_pair(1,image_clone)); //放入临时队列
|
||||
#else
|
||||
p_unit_queue->put(image_clone); //放入临时队列
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
p_debug_queue->put(image_clone); //放入调试队列
|
||||
}
|
||||
cnt++;
|
||||
// display some statistics
|
||||
if (cnt % 100 == 0)
|
||||
{
|
||||
QString data = QString::fromStdString(statistics.framesPerSecond.readS());
|
||||
emit updateStatistics(data.left(4),Local_Num);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// some error: pRequest->requestResult.readS() will return a string representation
|
||||
}
|
||||
// this image has been used thus the buffer is no longer needed...
|
||||
if (pPreviousRequest)
|
||||
{
|
||||
// this image has been displayed thus the buffer is no longer needed...
|
||||
pPreviousRequest->unlock();
|
||||
}
|
||||
pPreviousRequest = pRequest;
|
||||
// send a new image request into the capture queue
|
||||
pFI_->imageRequestSingle();
|
||||
}
|
||||
#if defined (IMM_FEED_BACK) || defined (CAP_FEED_BACK)
|
||||
m_threadFunc.SendFeedBack(ImageCap);
|
||||
#endif
|
||||
}
|
||||
manuallyStopAcquisitionIfNeeded( pDev_, *pFI_ );
|
||||
if( pRequest )
|
||||
{
|
||||
pRequest->unlock();
|
||||
}
|
||||
pFI_->imageRequestReset( 0, 0 );
|
||||
}
|
||||
catch( const ImpactAcquireException& e )
|
||||
{
|
||||
emit error( QString::fromStdString( e.getErrorCodeAsString() ) );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int CaptureThread::getPendingRequestNr( void )
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
QMutexLocker lockedScope( &lock_ );
|
||||
int result = requestPendingForDisplay_;
|
||||
// Reset the ID of the request to tell the capture loop that this request has already been
|
||||
// picked up and someone else will take care of it from now on.
|
||||
requestPendingForDisplay_ = INVALID_ID;
|
||||
return result;
|
||||
}
|
@ -1,241 +0,0 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef CaptureThreadH
|
||||
#define CaptureThreadH CaptureThreadH
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "balluffcamera.h"
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
#include <QTimer>
|
||||
#include <qdebug.h>
|
||||
|
||||
#include "SyncQueue.h"
|
||||
#include "ASyncQueue.h"
|
||||
|
||||
#include "apps/Common/exampleHelper.h"
|
||||
#include <apps/Common/qtIncludePrologue.h>
|
||||
#include <apps/Common/qtIncludeEpilogue.h>
|
||||
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
#include <common.h>
|
||||
|
||||
extern SingleCamInfoStruct SingleCamInfo[NumberOfSupportedCameras];
|
||||
|
||||
class CaptureThread_Func
|
||||
{
|
||||
public:
|
||||
Device* m_pMVCamera;
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
send_ok=true;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
mvIMPACT::acquire::GenICam::DigitalIOControl mvDIOC(m_pMVCamera);
|
||||
if(send_ng){
|
||||
mvDIOC.userOutputSelector.writeS("UserOutput0");
|
||||
mvIMPACT::acquire::TBoolean tb = mvDIOC.userOutputValue.read();
|
||||
if (tb == bFalse)
|
||||
mvDIOC.userOutputValue.write(bTrue);
|
||||
else
|
||||
mvDIOC.userOutputValue.write(bFalse);
|
||||
}
|
||||
else if (send_ok)
|
||||
{
|
||||
mvDIOC.userOutputSelector.writeS("UserOutput1");
|
||||
mvIMPACT::acquire::TBoolean tb = mvDIOC.userOutputValue.read();
|
||||
if (tb == bFalse)
|
||||
mvDIOC.userOutputValue.write(bTrue);
|
||||
else
|
||||
mvDIOC.userOutputValue.write(bFalse);
|
||||
}
|
||||
}
|
||||
catch (const ImpactAcquireException& e)
|
||||
{
|
||||
std::cout<< "(error code: " << e.getErrorCodeAsString() << "). Press [ENTER] to end the application..." << std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class CaptureThread : public QObject
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CaptureThread( Device* pCurrDev, bool boTerminated, FunctionInterface* pFi ,int Num);
|
||||
CaptureThread::~CaptureThread(void);
|
||||
void terminate( void )
|
||||
{
|
||||
boTerminated_ = true;
|
||||
}
|
||||
int getPendingRequestNr();
|
||||
|
||||
signals:
|
||||
void error( QString err );
|
||||
void finished( void );
|
||||
void requestReady( void );
|
||||
void updateStatistics( const QString& data ,int Num);
|
||||
|
||||
private slots:
|
||||
void process( 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;
|
||||
bool Ready = false;
|
||||
CaptureThread_Func m_threadFunc;
|
||||
private:
|
||||
Device* pDev_;
|
||||
volatile bool boTerminated_;
|
||||
int requestPendingForDisplay_;
|
||||
FunctionInterface* pFI_;
|
||||
QMutex lock_;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
//================= Camera's property callback ================================
|
||||
//=============================================================================
|
||||
class EventCallback : public mvIMPACT::acquire::ComponentCallback
|
||||
{
|
||||
public:
|
||||
ASyncQueue<cv::Mat> *p_unit_queue_;
|
||||
SyncQueue<std::pair<int, cv::Mat> > *p_image_queue_;
|
||||
ASyncQueue<bool> *p_result_wait_queue_;
|
||||
ASyncQueue<bool> *p_shooted_queue_;
|
||||
ASyncQueue<bool> *p_double_queue_;
|
||||
explicit EventCallback(void* pUserData = 0) : ComponentCallback(pUserData) {}
|
||||
Device* m_pMVCamera;
|
||||
CaptureThread* pCaptureThread = NULL;
|
||||
int count = 0;
|
||||
|
||||
virtual void execute(Component& c, void* pUserData)
|
||||
{
|
||||
try
|
||||
{
|
||||
// re-generating the object/data previously attached to the callback object. This could now be used to call a certain member function e.g. to update a class instance about this event!
|
||||
mvIMPACT::acquire::GenICam::EventControl* ec = reinterpret_cast<mvIMPACT::acquire::GenICam::EventControl*>(pUserData);
|
||||
// Execute the followings if the component is a property.
|
||||
if (c.isProp())
|
||||
{
|
||||
mvIMPACT::acquire::GenICam::DigitalIOControl mvDIOC(m_pMVCamera);
|
||||
mvDIOC.lineSelector.writeS("Line5");
|
||||
if (mvDIOC.lineStatus.read())
|
||||
{
|
||||
#ifdef IMM_FEED_BACK
|
||||
if (p_shooted_queue_->count() > 0)
|
||||
{
|
||||
bool temp;
|
||||
p_shooted_queue_->take(temp);
|
||||
}
|
||||
#elif defined ONE_TIME_SHIFT
|
||||
if (
|
||||
p_shooted_queue_->count() > 0
|
||||
#if defined DOUBLE_FEED_BACK
|
||||
|| p_double_queue_->count() >0
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (p_shooted_queue_->count() > 0){
|
||||
bool temp;
|
||||
p_shooted_queue_->take(temp);
|
||||
}
|
||||
pCaptureThread->m_threadFunc.SendFeedBack(EdgeEvent);
|
||||
}
|
||||
#else
|
||||
if (p_result_wait_queue_->count() > 0)
|
||||
{
|
||||
bool temp;
|
||||
p_result_wait_queue_->take(temp);
|
||||
pCaptureThread->m_threadFunc.SendFeedBack(EdgeEvent);
|
||||
}
|
||||
if (p_shooted_queue_->count() > 0)
|
||||
{
|
||||
bool temp;
|
||||
p_shooted_queue_->take(temp);
|
||||
p_result_wait_queue_->put(true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
int unit_count = p_unit_queue_->count();
|
||||
if (unit_count > 0)
|
||||
{
|
||||
cv::Mat long_image;
|
||||
for (int i = 0; i < unit_count; i++)
|
||||
{
|
||||
cv::Mat image;
|
||||
p_unit_queue_->take(image);
|
||||
if (0 == i)
|
||||
{
|
||||
long_image = cv::Mat::zeros(image.rows * unit_count, image.cols, image.type());
|
||||
}
|
||||
cv::Rect r(0, i * image.rows, image.cols, image.rows);
|
||||
cv::Mat roi = long_image(r);
|
||||
image.copyTo(roi);
|
||||
}
|
||||
p_image_queue_->put(std::make_pair(unit_count, long_image));
|
||||
p_shooted_queue_->put(true);
|
||||
}
|
||||
p_unit_queue_->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const ImpactAcquireException& e)
|
||||
{
|
||||
qDebug() << "Error";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class CIwtCameraLostCallbackMV : public mvIMPACT::acquire::ComponentCallback
|
||||
{
|
||||
public:
|
||||
CIwtCameraLostCallbackMV() : ComponentCallback() {}
|
||||
int channel_;
|
||||
virtual void execute(mvIMPACT::acquire::Component& c, void* pDummy)
|
||||
{
|
||||
PropertyIDeviceState p(c);
|
||||
std::cout << p.name() << " = " << p.readS() << endl;
|
||||
SingleCamInfo[channel_].OffLine = true;
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
#endif // CaptureThreadH
|
@ -1,176 +0,0 @@
|
||||
#include "CaptureThreadBasler.h"
|
||||
#include <QtWidgets/QApplication>
|
||||
#include "PLCDevice.h"
|
||||
#include "common.h"
|
||||
#include <qdebug.h>
|
||||
extern PLCDevice * m_PLCDevice;
|
||||
//-----------------------------------------------------------------------------
|
||||
CaptureThreadBasler::CaptureThreadBasler(Pylon::CBaslerUniversalInstantCamera* pCurrDev, bool boTerminated,int Num,int shoot) :
|
||||
pDev_( pCurrDev ), boTerminated_( boTerminated ),Local_Num(Num)
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
p_unit_queue = new ASyncQueue<cv::Mat>(Unit_Queue_Size);
|
||||
Shoot_Num = shoot;
|
||||
}
|
||||
CaptureThreadBasler::~CaptureThreadBasler()
|
||||
{
|
||||
delete p_unit_queue;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
m_threadFunc.pDev__ = pDev_;
|
||||
m_threadFunc.p_result_queue_ = p_result_queue;
|
||||
m_threadFunc.p_double_queue_ = p_double_queue;
|
||||
m_threadFunc.m_IOTimer_ = m_IOTimer;
|
||||
#ifndef USB_BASLER_NEW_FW
|
||||
if (pDev_->TriggerSelector.TrySetValue(Basler_UniversalCameraParams::TriggerSelector_FrameBurstStart))
|
||||
{
|
||||
pDev_->TriggerMode.SetValue(Basler_UniversalCameraParams::TriggerMode_On);
|
||||
pDev_->TriggerSource.SetValue(Basler_UniversalCameraParams::TriggerSource_Line1);
|
||||
pDev_->TriggerActivation.SetValue(Basler_UniversalCameraParams::TriggerActivation_RisingEdge);
|
||||
pDev_->AcquisitionBurstFrameCount.SetValue(Shoot_Num);
|
||||
if (pDev_->EventSelector.TrySetValue(Basler_UniversalCameraParams::EventSelector_FrameBurstStart))
|
||||
{
|
||||
if (!pDev_->EventNotification.TrySetValue(Basler_UniversalCameraParams::EventNotification_On))
|
||||
{
|
||||
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_GenICamEvent);
|
||||
}
|
||||
|
||||
m_IOTimer = new QTimer();
|
||||
connect(m_IOTimer, SIGNAL(timeout()), this, SLOT(ioTimeout()));
|
||||
m_IOTimer->setSingleShot(true);
|
||||
BurstEvent.ioTimer = m_IOTimer;
|
||||
pDev_->RegisterCameraEventHandler(&BurstEvent, "EventFrameBurstStartData", eMyFrameBurstStartEvent, Pylon::RegistrationMode_Append, Pylon::Cleanup_None);
|
||||
}
|
||||
|
||||
if(pDev_->EventSelector.TrySetValue("Line1RisingEdge"))
|
||||
{
|
||||
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off);
|
||||
}
|
||||
if(pDev_->EventSelector.TrySetValue("Line1FallingEdge"))
|
||||
{
|
||||
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off);
|
||||
}
|
||||
}
|
||||
#else
|
||||
/*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);
|
||||
}
|
||||
}
|
||||
|
||||
pDev_->RegisterCameraEventHandler(&BurstEvent, "EventLine1RisingEdgeData", Line1RisingEdge, Pylon::RegistrationMode_Append, Pylon::Cleanup_None);
|
||||
pDev_->EventSelector.SetValue("Line1RisingEdge");
|
||||
#ifdef IMM_PROCESS
|
||||
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off);
|
||||
#else
|
||||
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_On);
|
||||
#endif
|
||||
pDev_->RegisterCameraEventHandler(&BurstEvent, "EventLine1FallingEdgeData", Line1FallingEdge, Pylon::RegistrationMode_Append, Pylon::Cleanup_None);
|
||||
pDev_->EventSelector.SetValue("Line1FallingEdge");
|
||||
#ifdef IMM_PROCESS
|
||||
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off);
|
||||
#else
|
||||
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_On);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
const unsigned int timeout_ms = 200;
|
||||
// This smart pointer will receive the grab result data.
|
||||
Pylon::CGrabResultPtr ptrGrabResult;
|
||||
|
||||
pDev_->StartGrabbing();
|
||||
|
||||
m_Timer = new QTimer();
|
||||
connect(m_Timer, SIGNAL(timeout()), this, SLOT(fpsTimeout()));
|
||||
m_Timer->start(1000);
|
||||
Ready = true;
|
||||
while (!boTerminated_)
|
||||
{
|
||||
// Retrieve grab results and notify the camera event and image event handlers.
|
||||
pDev_->RetrieveResult(timeout_ms, ptrGrabResult, Pylon::TimeoutHandling_Return);
|
||||
#if defined (IMM_FEED_BACK) || defined (CAP_FEED_BACK)
|
||||
m_threadFunc.SendFeedBack(ImageCap);
|
||||
#endif
|
||||
QCoreApplication::processEvents();//Make sure the timer is triggered
|
||||
}
|
||||
#ifndef USB_BASLER_NEW_FW
|
||||
// Disable sending Event Overrun events.
|
||||
if (pDev_->EventSelector.TrySetValue(Basler_UniversalCameraParams::EventSelector_FrameBurstStart))
|
||||
{
|
||||
pDev_->EventNotification.TrySetValue(Basler_UniversalCameraParams::EventNotification_Off);
|
||||
}
|
||||
if (m_IOTimer) delete m_IOTimer;
|
||||
#endif
|
||||
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");
|
||||
#endif
|
||||
}
|
||||
catch(const Pylon::GenericException& e)
|
||||
{
|
||||
emit error( QString::fromStdString( e.GetDescription()) );
|
||||
std::cout << e.GetSourceLine()<<e.GetDescription() << std::endl;
|
||||
pDev_->StopGrabbing();
|
||||
}
|
||||
}
|
||||
|
||||
void CaptureThreadBasler::fpsTimeout()
|
||||
{
|
||||
uint64_t delta = m_cntGrabbedImages - m_cntLastGrabbedImages;
|
||||
m_cntLastGrabbedImages = m_cntGrabbedImages;
|
||||
QString data = QString("%1").arg(delta);
|
||||
emit updateStatistics(data.left(4), Local_Num);
|
||||
}
|
||||
|
||||
void CaptureThreadBasler::ioTimeout()
|
||||
{
|
||||
pDev_->UserOutputSelector.SetValue(Basler_UniversalCameraParams::UserOutputSelector_UserOutput1);
|
||||
pDev_->UserOutputValue.SetValue(false);
|
||||
|
||||
pDev_->UserOutputSelector.SetValue(Basler_UniversalCameraParams::UserOutputSelector_UserOutput3);
|
||||
pDev_->UserOutputValue.SetValue(false);
|
||||
|
||||
}
|
@ -1,301 +0,0 @@
|
||||
#include "CaptureThreadHIK.h"
|
||||
#include <QtWidgets/QApplication>
|
||||
#include "PLCDevice.h"
|
||||
#include "common.h"
|
||||
#include <windows.h>
|
||||
extern bool g_debug_mode; //相机调试模式,调试模式必须暂停状态才能打开
|
||||
extern SingleCamInfoStruct SingleCamInfo[NumberOfSupportedCameras];
|
||||
extern PLCDevice * m_PLCDevice;
|
||||
|
||||
inline void LossCallBackfunction(unsigned int pData, void* pUser){
|
||||
try{
|
||||
CaptureThreadHIK* CaptureThreadHIKptr = (CaptureThreadHIK*)pUser;
|
||||
SingleCamInfo[CaptureThreadHIKptr->Local_Num].OffLine = true;
|
||||
CaptureThreadHIKptr->terminate();
|
||||
}
|
||||
catch(...){
|
||||
std::cout << "LossCallBackfunction error" << std::endl;
|
||||
}
|
||||
}
|
||||
inline void FallingGpioEventfunction(MV_EVENT_OUT_INFO* pEventInfo, void* pUser){
|
||||
try{
|
||||
CaptureThreadHIK* CaptureThreadHIKptr = (CaptureThreadHIK*)pUser;
|
||||
int unit_count = CaptureThreadHIKptr->p_unit_queue->count();
|
||||
if (unit_count > 0)
|
||||
{
|
||||
cv::Mat long_image;
|
||||
for (int i = 0; i < unit_count; i++)
|
||||
{
|
||||
cv::Mat image;
|
||||
CaptureThreadHIKptr->p_unit_queue->take(image);
|
||||
if (0 == i)
|
||||
{
|
||||
long_image = cv::Mat::zeros(image.rows * unit_count, image.cols, image.type());
|
||||
}
|
||||
cv::Rect r(0, i * image.rows, image.cols, image.rows);
|
||||
cv::Mat roi = long_image(r);
|
||||
image.copyTo(roi);
|
||||
}
|
||||
CaptureThreadHIKptr->p_image_queue->put(std::make_pair(unit_count, long_image));
|
||||
CaptureThreadHIKptr->p_shooted_queue->put(true);
|
||||
}
|
||||
CaptureThreadHIKptr->p_unit_queue->clear();
|
||||
}
|
||||
catch(...){
|
||||
std::cout << "FallingGpioEventfunction error" << std::endl;
|
||||
}
|
||||
}
|
||||
inline void RisingGpioEventfunction(MV_EVENT_OUT_INFO* pEventInfo, void* pUser){
|
||||
try{
|
||||
CaptureThreadHIK* CaptureThreadHIKptr = (CaptureThreadHIK*)pUser;
|
||||
#ifdef IMM_FEED_BACK
|
||||
if (CaptureThreadHIKptr->p_shooted_queue->count() > 0)
|
||||
{
|
||||
bool temp;
|
||||
CaptureThreadHIKptr->p_shooted_queue->take(temp);
|
||||
}
|
||||
|
||||
#elif defined ONE_TIME_SHIFT
|
||||
if(
|
||||
CaptureThreadHIKptr->p_shooted_queue->count() > 0
|
||||
#if defined DOUBLE_FEED_BACK
|
||||
|| CaptureThreadHIKptr->p_double_queue->count() > 0
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (CaptureThreadHIKptr->p_shooted_queue->count() > 0){
|
||||
bool temp;
|
||||
CaptureThreadHIKptr->p_shooted_queue->take(temp);
|
||||
}
|
||||
CaptureThreadHIKptr->m_threadFunc.SendFeedBack(EdgeEvent);
|
||||
}
|
||||
#else
|
||||
if(CaptureThreadHIKptr->p_result_wait_queue->count() > 0)
|
||||
{
|
||||
bool temp;
|
||||
CaptureThreadHIKptr->p_result_wait_queue->take(temp);
|
||||
CaptureThreadHIKptr->m_threadFunc.SendFeedBack(EdgeEvent);
|
||||
}
|
||||
if(CaptureThreadHIKptr->p_shooted_queue->count() > 0)
|
||||
{
|
||||
bool temp;
|
||||
CaptureThreadHIKptr->p_shooted_queue->take(temp);
|
||||
CaptureThreadHIKptr->p_result_wait_queue->put(true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
catch(...){
|
||||
std::cout << "RisingGpioEventfunction error" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
#define CaptureThreadHIK_init(a)\
|
||||
void __stdcall LossCallBack##a(unsigned int pData, void* pUser){LossCallBackfunction(pData,pUser);}\
|
||||
void __stdcall FallingGpioEvent##a(MV_EVENT_OUT_INFO* pEventInfo, void* pUser){FallingGpioEventfunction(pEventInfo,pUser);}\
|
||||
void __stdcall RisingGpioEvent##a(MV_EVENT_OUT_INFO* pEventInfo, void* pUser){RisingGpioEventfunction(pEventInfo,pUser);}
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
|
||||
CaptureThreadHIK_init(1)
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1)
|
||||
CaptureThreadHIK_init(2)
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2)
|
||||
CaptureThreadHIK_init(3)
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3)
|
||||
CaptureThreadHIK_init(4)
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4)
|
||||
CaptureThreadHIK_init(5)
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5)
|
||||
CaptureThreadHIK_init(6)
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6)
|
||||
CaptureThreadHIK_init(7)
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7)
|
||||
CaptureThreadHIK_init(8)
|
||||
#endif
|
||||
|
||||
void(*LossCallBack[NumberOfSupportedCameras])(unsigned int pData, void* pUser) = {
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
|
||||
LossCallBack1
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1)
|
||||
,LossCallBack2
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2)
|
||||
,LossCallBack3
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3)
|
||||
,LossCallBack4
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4)
|
||||
,LossCallBack5
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5)
|
||||
,LossCallBack6
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6)
|
||||
,LossCallBack7
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7)
|
||||
,LossCallBack8
|
||||
#endif
|
||||
};
|
||||
void(*FallingGpioEvent[NumberOfSupportedCameras])(MV_EVENT_OUT_INFO* pEventInfo, void* pUser) = {
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
|
||||
FallingGpioEvent1
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1)
|
||||
,FallingGpioEvent2
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2)
|
||||
,FallingGpioEvent3
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3)
|
||||
,FallingGpioEvent4
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4)
|
||||
,FallingGpioEvent5
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5)
|
||||
,FallingGpioEvent6
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6)
|
||||
,FallingGpioEvent7
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7)
|
||||
,FallingGpioEvent8
|
||||
#endif
|
||||
};
|
||||
void(*RisingGpioEvent[NumberOfSupportedCameras])(MV_EVENT_OUT_INFO* pEventInfo, void* pUser) = {
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
|
||||
RisingGpioEvent1
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1)
|
||||
,RisingGpioEvent2
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2)
|
||||
,RisingGpioEvent3
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3)
|
||||
,RisingGpioEvent4
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4)
|
||||
,RisingGpioEvent5
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5)
|
||||
,RisingGpioEvent6
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6)
|
||||
,RisingGpioEvent7
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7)
|
||||
,RisingGpioEvent8
|
||||
#endif
|
||||
};
|
||||
void CaptureThreadHIK::fpsTimeout(void)
|
||||
{
|
||||
uint64_t delta = m_cntGrabbedImages - m_cntLastGrabbedImages;
|
||||
m_cntLastGrabbedImages = m_cntGrabbedImages;
|
||||
QString data = QString("%1").arg(delta);
|
||||
emit updateStatistics(data.left(4), Local_Num);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
CaptureThreadHIK::CaptureThreadHIK(void *camhandle, bool boTerminated,int Num) :
|
||||
CamHandle( camhandle ), boTerminated_( boTerminated ),Local_Num(Num)
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
p_unit_queue = new ASyncQueue<cv::Mat>(Unit_Queue_Size);
|
||||
g_pImage_buf = (unsigned char*)malloc(3000 * 3000 * 3);
|
||||
}
|
||||
CaptureThreadHIK::~CaptureThreadHIK()
|
||||
{
|
||||
delete p_unit_queue;
|
||||
free(g_pImage_buf);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void CaptureThreadHIK::process( void )
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
try {
|
||||
int nRet = MV_OK, nnRet = MV_OK;
|
||||
|
||||
m_threadFunc.CamHandle_ = CamHandle;
|
||||
m_threadFunc.p_result_queue_ = p_result_queue;
|
||||
m_threadFunc.p_double_queue_ = p_double_queue;
|
||||
|
||||
nRet = MV_CC_RegisterExceptionCallBack(CamHandle, LossCallBack[Local_Num], this);
|
||||
if (nRet) { std::cout << "can not register loss callback" << std::endl; nnRet = nRet; }
|
||||
|
||||
#ifdef IMM_FEED_BACK ///不打开无反馈等
|
||||
nRet = MV_CC_SetEnumValueByString(CamHandle, "EventSelector", "Line0FallingEdge");
|
||||
if (nRet) { std::cout << "can not set EventSelector" << std::endl; nnRet = nRet; }
|
||||
|
||||
nRet = MV_CC_SetEnumValueByString(CamHandle, "EventNotification", "On");
|
||||
if (nRet) { std::cout << "can not set EventNotification" << std::endl; nnRet = nRet; }
|
||||
|
||||
nRet = MV_CC_SetEnumValueByString(CamHandle, "EventSelector", "Line0RisingEdge");
|
||||
if (nRet) { std::cout << "can not set EventSelector" << std::endl; nnRet = nRet; }
|
||||
|
||||
nRet = MV_CC_SetEnumValueByString(CamHandle, "EventNotification", "On");
|
||||
if (nRet) { std::cout << "can not set EventNotification" << std::endl; nnRet = nRet; }
|
||||
|
||||
nRet = MV_CC_RegisterEventCallBackEx(CamHandle, "Line0FallingEdge", FallingGpioEvent[Local_Num], this);
|
||||
if (nRet) { std::cout << "can not register GPIO callback" << std::endl; nnRet = nRet; }
|
||||
|
||||
nRet = MV_CC_RegisterEventCallBackEx(CamHandle, "Line0RisingEdge", RisingGpioEvent[Local_Num], this);
|
||||
if (nRet) { std::cout << "can not register GPIO callback" << std::endl; nnRet = nRet; }
|
||||
#endif
|
||||
|
||||
m_Timer = new QTimer();
|
||||
connect(m_Timer, SIGNAL(timeout()), this, SLOT(fpsTimeout()));
|
||||
m_Timer->start(1000);
|
||||
|
||||
unsigned int nDataSize;
|
||||
MVCC_INTVALUE_EX stIntValue = { 0 };
|
||||
nRet = MV_CC_GetIntValueEx(CamHandle, "PayloadSize", &stIntValue);
|
||||
if (nRet) { std::cout << "Get PayloadSize error" << std::endl; }
|
||||
nDataSize = stIntValue.nCurValue;
|
||||
MV_CC_StartGrabbing(CamHandle);
|
||||
Ready = true;
|
||||
while(!boTerminated_)
|
||||
{
|
||||
nRet = MV_CC_GetOneFrameTimeout(CamHandle, g_pImage_buf, nDataSize, &stFrameInfo, 200);
|
||||
if (MV_OK == nRet)
|
||||
{
|
||||
m_cntGrabbedImages++;
|
||||
|
||||
cv::Mat openCVImage(stFrameInfo.nHeight, stFrameInfo.nWidth, CV_8UC1, g_pImage_buf);
|
||||
cv::Mat image_clone = openCVImage.clone();
|
||||
if (!g_debug_mode)
|
||||
{
|
||||
#ifdef IMM_PROCESS
|
||||
p_image_queue->put(std::make_pair(1,image_clone));
|
||||
#else
|
||||
p_unit_queue->put(image_clone); //放入临时队列
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
p_debug_queue->put(image_clone); //放入调试队列
|
||||
}
|
||||
}
|
||||
#if defined (IMM_FEED_BACK) || defined (CAP_FEED_BACK)
|
||||
m_threadFunc.SendFeedBack(ImageCap);
|
||||
#endif
|
||||
QCoreApplication::processEvents();//Make sure the timer is triggered
|
||||
}
|
||||
MV_CC_StopGrabbing(CamHandle);
|
||||
MV_CC_CloseDevice(CamHandle);
|
||||
delete m_Timer;
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
const char* err_msg = e.what();
|
||||
std::cout << "exception caught: " << err_msg << std::endl;
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
class CleanWorkThread : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CleanWorkThread(QObject* parent = nullptr);
|
||||
~CleanWorkThread();
|
||||
public slots:
|
||||
void startWork();
|
||||
void startWorkAuto();
|
||||
void doWork();
|
||||
void setSelAuto();
|
||||
void setSel();
|
||||
signals:
|
||||
void workFinished();
|
||||
void workStart();
|
||||
void workStartAuto();
|
||||
public:
|
||||
qint64 DirFileSize(const QString& path);
|
||||
void CleanImageFile(const QString& path, const qint64& delDays);
|
||||
private:
|
||||
int delSelection;
|
||||
};
|
@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
#include "Windows.h"
|
||||
|
||||
typedef enum _EncMethod {
|
||||
none = 0,
|
||||
addtime = 1
|
||||
Device = 0,
|
||||
License = 1
|
||||
}EncMethod;
|
||||
|
||||
extern "C" bool GenerateDeviceID(void);
|
||||
extern "C" bool GenerateLicenseData(EncMethod Method, char* suffix);
|
||||
extern "C" bool VerifyLicense(EncMethod Method);
|
||||
extern "C" bool GenerateLicenseData(const char* flag, const char* suffix);
|
||||
extern "C" bool VerifyLicense(void);
|
||||
extern "C" bool AddParaForLicenseData(char* flag, char* suffix);
|
||||
extern "C" bool DeleteParaForLicenseData(char* flag);
|
||||
extern "C" bool AnalysisLicense(const char* flag);
|
Binary file not shown.
@ -1,164 +0,0 @@
|
||||
#include "Logthread.h"
|
||||
#include <QDir>
|
||||
#include <QMutex>
|
||||
#include <QDate>
|
||||
|
||||
const char PATH_LogPath[] = "D:/log/";
|
||||
const char Suffix[] = ".txt";
|
||||
bool CLog::isFileReady = false;
|
||||
bool CLog::isRecord2File = true;
|
||||
QFile localFile;
|
||||
QMutex mutexLog;
|
||||
|
||||
CLog::CLog()
|
||||
{
|
||||
}
|
||||
|
||||
void CLog::setLogType(const CLog::CLOG_TYPE& level)
|
||||
{
|
||||
}
|
||||
|
||||
bool CLog::init(LogConfig& logConfig)
|
||||
{
|
||||
isRecord2File = logConfig.isRecord2File;
|
||||
QString logDir = QString(PATH_LogPath);
|
||||
if (createDir(logDir))
|
||||
{
|
||||
QString fileName = logDir + QDir::separator() + QDate::currentDate().toString("yyyy-MM-dd") + QString(Suffix);
|
||||
QFileInfo fi(fileName);
|
||||
if (fi.exists())
|
||||
{
|
||||
if (!localFile.exists())
|
||||
{
|
||||
localFile.setFileName(fileName);
|
||||
if (localFile.open(QFile::WriteOnly | QFile::Append | QFile::Text))
|
||||
{
|
||||
isFileReady = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isFileReady = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
localFile.setFileName(fileName);
|
||||
if (localFile.open(QFile::WriteOnly | QFile::Append | QFile::Text))
|
||||
{
|
||||
isFileReady = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isFileReady;
|
||||
}
|
||||
|
||||
bool CLog::createDir(QString dirPath)
|
||||
{
|
||||
QFileInfo fileInfo(dirPath);
|
||||
if (!fileInfo.exists())
|
||||
{
|
||||
QDir tmpDir;
|
||||
return tmpDir.mkpath(dirPath);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CLog::log(CLOG_TYPE nType, const char* fileDesc, const char* functionDesc, int lineNum, const char* data, ...)
|
||||
{
|
||||
QMutexLocker locker(&mutexLog);
|
||||
if (isFileReady)
|
||||
{
|
||||
QString recordInfo = QString("[%1]").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss:zzz"));
|
||||
recordInfo.append(getTypeDesc(nType));
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
recordInfo.append(QString("[%1:%2:%3]").arg(fileDesc).arg(functionDesc).arg(lineNum));
|
||||
#endif
|
||||
va_list vlist;
|
||||
va_start(vlist, data);
|
||||
|
||||
QByteArray byteArray;
|
||||
#if defined(Q_OS_WIN)
|
||||
int recordLen = _vscprintf(data, vlist);
|
||||
byteArray.resize(recordLen);
|
||||
#else
|
||||
byteArray.resize(1024);
|
||||
#endif
|
||||
vsprintf(byteArray.data(), data, vlist);
|
||||
recordInfo.append(byteArray);
|
||||
va_end(vlist);
|
||||
|
||||
recordInfo.append("\n");
|
||||
|
||||
if (isRecord2File) {
|
||||
localFile.write(recordInfo.toLocal8Bit().data(), recordInfo.toLocal8Bit().length());
|
||||
localFile.flush();
|
||||
}
|
||||
else {
|
||||
// qDebug()<<recordInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CLog::log(CLOG_TYPE nType, const char* data, ...)
|
||||
{
|
||||
QMutexLocker locker(&mutexLog);
|
||||
if (isFileReady)
|
||||
{
|
||||
QString recordInfo = QString("[%1]").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss:zzz"));
|
||||
recordInfo.append(getTypeDesc(nType));
|
||||
recordInfo.append(" ");
|
||||
|
||||
va_list vlist;
|
||||
va_start(vlist, data);
|
||||
|
||||
QByteArray byteArray;
|
||||
#if defined(Q_OS_WIN)
|
||||
int recordLen = _vscprintf(data, vlist);
|
||||
byteArray.resize(recordLen);
|
||||
#else
|
||||
byteArray.resize(1024);
|
||||
#endif
|
||||
vsprintf(byteArray.data(), data, vlist);
|
||||
recordInfo.append(byteArray);
|
||||
va_end(vlist);
|
||||
|
||||
recordInfo.append("\n");
|
||||
|
||||
if (isRecord2File) {
|
||||
localFile.write(recordInfo.toLocal8Bit().data(), recordInfo.toLocal8Bit().length());
|
||||
localFile.flush();
|
||||
}
|
||||
else {
|
||||
// qDebug()<<recordInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString CLog::getTypeDesc(CLog::CLOG_TYPE type)
|
||||
{
|
||||
/*
|
||||
switch (type)
|
||||
{
|
||||
case CLOG_TYPE::STARTAPP:
|
||||
return "[INFO]";
|
||||
case CLOG_TYPE::STARTWORK:
|
||||
return "[WARNING]";
|
||||
case CLOG_TYPE::PAUSEWORK:
|
||||
return "[ERROR]";
|
||||
}
|
||||
*/
|
||||
return "[INFO]";
|
||||
}
|
||||
|
||||
void CLog::recMegFromCigarette(QString str)
|
||||
{
|
||||
CLog::LogConfig logConfig;
|
||||
logConfig.isRecord2File = true;
|
||||
logConfig.level = 0;
|
||||
CLog::init(logConfig);
|
||||
//qDebug() << GetCurrentThreadId() << "WinAPI";
|
||||
CLOG_INFO(str.toStdString().c_str());
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
#pragma once
|
||||
#include <QDialog>
|
||||
class CLog : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
enum CLOG_TYPE
|
||||
{
|
||||
|
||||
STARTAPP,
|
||||
STARTWORK,
|
||||
PAUSEWORK,
|
||||
UNLOCK,
|
||||
DEBUGMODE,
|
||||
UNKICKMODE,
|
||||
SETTING,
|
||||
CLEANPIC,
|
||||
DOUBLECLICK,
|
||||
ROTATEPIC,
|
||||
PLCSETTING,
|
||||
ALARM
|
||||
};
|
||||
//Q_DECLARE_FLAGS(CLOG_TYPE_Flags, CLOG_TYPE)
|
||||
Q_ENUM(CLOG_TYPE)
|
||||
|
||||
struct LogConfig
|
||||
{
|
||||
bool isRecord2File;
|
||||
int level;
|
||||
};
|
||||
|
||||
CLog();
|
||||
|
||||
void setLogType(const CLog::CLOG_TYPE& type);
|
||||
// CLog::CLOG_TYPE getLogType() { return logType; }
|
||||
|
||||
//void startClog();
|
||||
//void doWork();
|
||||
static bool init(CLog::LogConfig& logConfig);
|
||||
static bool createDir(QString dirPath);
|
||||
static void log(CLOG_TYPE nType, const char* fileDesc, const char* functionDesc, int lineNum, const char* data, ...);
|
||||
static void log(CLOG_TYPE nType, const char* data, ...);
|
||||
public slots:
|
||||
void recMegFromCigarette(QString);
|
||||
|
||||
private:
|
||||
static QString getTypeDesc(CLOG_TYPE type);
|
||||
|
||||
private:
|
||||
static bool isRecord2File;
|
||||
static bool isFileReady;
|
||||
};
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#define FILE_SEPARATOR '\\'
|
||||
#else
|
||||
#define FILE_SEPARATOR '/'
|
||||
#endif
|
||||
|
||||
#define FUNC_SEPARATOR '::'
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
#define __FILENAME__ (strrchr(__FILE__, FILE_SEPARATOR) ? (strrchr(__FILE__, FILE_SEPARATOR) + 1):__FILE__)
|
||||
#define __FUNNAME__ (strrchr(__FUNCTION__,FUNC_SEPARATOR)?(strrchr(__FUNCTION__, FUNC_SEPARATOR) + 1):__FUNCTION__)
|
||||
#else
|
||||
#define __FILENAME__ NULL
|
||||
#define __FUNNAME__ NULL
|
||||
#endif
|
||||
|
||||
#define CLOG_INFO(...) CLog::log(CLog::STARTAPP, __VA_ARGS__)
|
@ -1,3 +1,3 @@
|
||||
#include "SyncQueue.h"
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,166 @@
|
||||
#include "CaptureThread.h"
|
||||
#include "common.h"
|
||||
#include "exportData.h"
|
||||
|
||||
extern bool g_debug_mode; //相机调试模式,工作模式必须停止状态才能打开
|
||||
extern SyncQueue<_XMLExportDataInfo>* export_XMLData_Info_queue;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
CaptureThread::CaptureThread(Device* pCurrDev, bool boTerminated, FunctionInterface* pFI_, int Num) :
|
||||
pDev_(pCurrDev), boTerminated_(boTerminated), requestPendingForDisplay_(INVALID_ID), pFI_(pFI_), Local_Num(Num)
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
p_unit_queue = new ASyncQueue<cv::Mat>(Unit_Queue_Size);
|
||||
}
|
||||
|
||||
void CaptureThread::fpsTimeout(void)
|
||||
{
|
||||
uint64_t delta = m_cntGrabbedImages - m_cntLastGrabbedImages;
|
||||
m_cntLastGrabbedImages = m_cntGrabbedImages;
|
||||
QString data = QString("%1").arg(delta);
|
||||
emit updateStatistics(data.left(4), Local_Num);
|
||||
}
|
||||
|
||||
CaptureThread::~CaptureThread()
|
||||
{
|
||||
delete p_unit_queue;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void CaptureThread::process(void)
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
try
|
||||
{
|
||||
//Line5回调
|
||||
mvIMPACT::acquire::GenICam::EventControl pEventCtrl_(pDev_);
|
||||
//pEventCtrl_.eventSelector.writeS("Line5FallingEdge");
|
||||
//pEventCtrl_.eventNotification.writeS("Off");
|
||||
//pEventCtrl_.eventSelector.writeS("Line5RisingEdge");
|
||||
//pEventCtrl_.eventNotification.writeS("Off");
|
||||
pEventCtrl_.eventSelector.writeS("Line5AnyEdge");
|
||||
#ifdef IMM_PROCESS
|
||||
pEventCtrl_.eventNotification.writeS("Off");
|
||||
#else
|
||||
pEventCtrl_.eventNotification.writeS("On");
|
||||
#endif
|
||||
|
||||
#ifndef IMM_PROCESS
|
||||
EventCallback eventCallback(&pEventCtrl_);
|
||||
eventCallback.p_unit_queue_ = p_unit_queue;
|
||||
#ifdef SYNC_CAMERA
|
||||
eventCallback.p_image_sync_arr_ = p_image_sync_arr;
|
||||
eventCallback.p_image_sync_queue_ = p_image_sync_queue;
|
||||
#else
|
||||
eventCallback.p_image_queue_ = p_image_queue;
|
||||
#endif
|
||||
eventCallback.p_result_wait_queue_ = p_result_wait_queue;
|
||||
eventCallback.p_shooted_queue_ = p_shooted_queue;
|
||||
eventCallback.p_double_queue_ = p_double_queue;
|
||||
eventCallback.m_pMVCamera = pDev_;
|
||||
eventCallback.pCaptureThread = this;
|
||||
eventCallback.registerComponent(pEventCtrl_.eventLine5AnyEdge);
|
||||
#endif
|
||||
|
||||
m_threadFunc.m_pMVCamera = pDev_;
|
||||
m_threadFunc.p_result_queue_ = p_result_queue;
|
||||
m_threadFunc.p_double_queue_ = p_double_queue;
|
||||
|
||||
//相机掉线回调
|
||||
CIwtCameraLostCallbackMV cam_lost_cb;
|
||||
cam_lost_cb.channel_ = Local_Num;
|
||||
if (cam_lost_cb.registerComponent(pDev_->state) != true)
|
||||
{
|
||||
std::cout << "ERROR: Unable to register the camera's lost CallBack function!\n";
|
||||
}
|
||||
//图像采集循环
|
||||
TDMR_ERROR result = DMR_NO_ERROR;
|
||||
while ((result = static_cast<TDMR_ERROR>(pFI_->imageRequestSingle())) == DMR_NO_ERROR) {};
|
||||
if (result != DEV_NO_FREE_REQUEST_AVAILABLE)
|
||||
{
|
||||
qDebug() << "'FunctionInterface.imageRequestSingle' returned with an unexpected result: " << QString::fromStdString(mvIMPACT::acquire::ImpactAcquireException::getErrorCodeAsString(result));
|
||||
}
|
||||
manuallyStartAcquisitionIfNeeded(pDev_, *pFI_);
|
||||
int cnt = 0;
|
||||
|
||||
// run thread loop
|
||||
mvIMPACT::acquire::Statistics statistics(pDev_);
|
||||
mvIMPACT::acquire::Request* pRequest = 0;
|
||||
mvIMPACT::acquire::Request* pPreviousRequest = nullptr;
|
||||
const unsigned int timeout_ms = 100;
|
||||
Ready = true;
|
||||
while (!boTerminated_)
|
||||
{
|
||||
const int requestNr = pFI_->imageRequestWaitFor(timeout_ms);
|
||||
pRequest = pFI_->isRequestNrValid(requestNr) ? pFI_->getRequest(requestNr) : 0;
|
||||
if (pRequest)
|
||||
{
|
||||
if (pRequest->isOK())
|
||||
{
|
||||
// do something with the image
|
||||
int openCVDataType = CV_8UC1;
|
||||
if ((pRequest->imagePixelFormat.read() == ibpfBGR888Packed) || (pRequest->imagePixelFormat.read() == ibpfRGB888Packed))
|
||||
openCVDataType = CV_8UC3;
|
||||
cv::Mat openCVImage(cv::Size(pRequest->imageWidth.read(), pRequest->imageHeight.read()), openCVDataType, pRequest->imageData.read(), pRequest->imageLinePitch.read());
|
||||
cv::Mat image_clone = openCVImage.clone();
|
||||
if (!g_debug_mode)
|
||||
{
|
||||
#ifdef IMM_PROCESS
|
||||
p_image_queue->put(std::make_pair(1, image_clone)); //放入临时队列
|
||||
#else
|
||||
p_unit_queue->put(image_clone); //放入临时队列
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
p_debug_queue->put(image_clone); //放入调试队列
|
||||
}
|
||||
cnt++;
|
||||
// display some statistics
|
||||
if (cnt % 10 == 0)
|
||||
{
|
||||
QString data = QString::fromStdString(statistics.framesPerSecond.readS());
|
||||
emit updateStatistics(data.left(4), Local_Num);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// some error: pRequest->requestResult.readS() will return a string representation
|
||||
}
|
||||
// this image has been used thus the buffer is no longer needed...
|
||||
if (pPreviousRequest)
|
||||
{
|
||||
// this image has been displayed thus the buffer is no longer needed...
|
||||
pPreviousRequest->unlock();
|
||||
}
|
||||
pPreviousRequest = pRequest;
|
||||
// send a new image request into the capture queue
|
||||
pFI_->imageRequestSingle();
|
||||
}
|
||||
#if defined (IMM_FEED_BACK) || defined (CAP_FEED_BACK)
|
||||
m_threadFunc.SendFeedBack(ImageCap);
|
||||
#endif
|
||||
}
|
||||
manuallyStopAcquisitionIfNeeded(pDev_, *pFI_);
|
||||
if (pRequest)
|
||||
{
|
||||
pRequest->unlock();
|
||||
}
|
||||
pFI_->imageRequestReset(0, 0);
|
||||
}
|
||||
catch (const ImpactAcquireException& e)
|
||||
{
|
||||
emit error(QString::fromStdString(e.getErrorCodeAsString()));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int CaptureThread::getPendingRequestNr(void)
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
QMutexLocker lockedScope(&lock_);
|
||||
int result = requestPendingForDisplay_;
|
||||
// Reset the ID of the request to tell the capture loop that this request has already been
|
||||
// picked up and someone else will take care of it from now on.
|
||||
requestPendingForDisplay_ = INVALID_ID;
|
||||
return result;
|
||||
}
|
@ -0,0 +1,268 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef CaptureThreadH
|
||||
#define CaptureThreadH CaptureThreadH
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "balluffcamera.h"
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
#include <QTimer>
|
||||
#include <qdebug.h>
|
||||
|
||||
#include "SyncQueue.h"
|
||||
#include "ASyncQueue.h"
|
||||
|
||||
#include "apps/Common/exampleHelper.h"
|
||||
#include <apps/Common/qtIncludePrologue.h>
|
||||
#include <apps/Common/qtIncludeEpilogue.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
extern SingleCamInfoStruct SingleCamInfo[NumberOfSupportedCameras];
|
||||
extern int work_camera_nums;
|
||||
|
||||
class CaptureThread_Func
|
||||
{
|
||||
public:
|
||||
Device* m_pMVCamera;
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
send_ok = true;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
mvIMPACT::acquire::GenICam::DigitalIOControl mvDIOC(m_pMVCamera);
|
||||
if (send_ng) {
|
||||
mvDIOC.userOutputSelector.writeS("UserOutput0");
|
||||
mvIMPACT::acquire::TBoolean tb = mvDIOC.userOutputValue.read();
|
||||
if (tb == bFalse)
|
||||
mvDIOC.userOutputValue.write(bTrue);
|
||||
else
|
||||
mvDIOC.userOutputValue.write(bFalse);
|
||||
}
|
||||
else if (send_ok)
|
||||
{
|
||||
mvDIOC.userOutputSelector.writeS("UserOutput1");
|
||||
mvIMPACT::acquire::TBoolean tb = mvDIOC.userOutputValue.read();
|
||||
if (tb == bFalse)
|
||||
mvDIOC.userOutputValue.write(bTrue);
|
||||
else
|
||||
mvDIOC.userOutputValue.write(bFalse);
|
||||
}
|
||||
}
|
||||
catch (const ImpactAcquireException& e)
|
||||
{
|
||||
std::cout << "(error code: " << e.getErrorCodeAsString() << "). Press [ENTER] to end the application..." << std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class CaptureThread : public QObject
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CaptureThread(Device* pCurrDev, bool boTerminated, FunctionInterface* pFi, int Num);
|
||||
CaptureThread::~CaptureThread(void);
|
||||
void terminate(void)
|
||||
{
|
||||
boTerminated_ = true;
|
||||
}
|
||||
int getPendingRequestNr();
|
||||
|
||||
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;
|
||||
QTimer* m_Timer;
|
||||
uint64_t m_cntGrabbedImages = 0;
|
||||
uint64_t m_cntLastGrabbedImages = 0;
|
||||
#ifdef SYNC_CAMERA
|
||||
ImageSyncArr* p_image_sync_arr;
|
||||
SyncQueue<std::vector<std::pair<int, cv::Mat>>>* p_image_sync_queue;
|
||||
#else
|
||||
SyncQueue<std::pair<int, cv::Mat> >* p_image_queue;
|
||||
#endif
|
||||
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;
|
||||
bool Ready = false;
|
||||
CaptureThread_Func m_threadFunc;
|
||||
private:
|
||||
Device* pDev_;
|
||||
volatile bool boTerminated_;
|
||||
int requestPendingForDisplay_;
|
||||
FunctionInterface* pFI_;
|
||||
QMutex lock_;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
//================= Camera's property callback ================================
|
||||
//=============================================================================
|
||||
class EventCallback : public mvIMPACT::acquire::ComponentCallback
|
||||
{
|
||||
public:
|
||||
ASyncQueue<cv::Mat>* p_unit_queue_;
|
||||
#ifdef SYNC_CAMERA
|
||||
ImageSyncArr* p_image_sync_arr_;
|
||||
SyncQueue<std::vector<std::pair<int, cv::Mat>>>* p_image_sync_queue_;
|
||||
#else
|
||||
SyncQueue<std::pair<int, cv::Mat> >* p_image_queue_;
|
||||
#endif
|
||||
ASyncQueue<bool>* p_result_wait_queue_;
|
||||
ASyncQueue<bool>* p_shooted_queue_;
|
||||
ASyncQueue<bool>* p_double_queue_;
|
||||
explicit EventCallback(void* pUserData = 0) : ComponentCallback(pUserData) {}
|
||||
Device* m_pMVCamera;
|
||||
CaptureThread* pCaptureThread = NULL;
|
||||
int count = 0;
|
||||
|
||||
virtual void execute(Component& c, void* pUserData)
|
||||
{
|
||||
try
|
||||
{
|
||||
// re-generating the object/data previously attached to the callback object. This could now be used to call a certain member function e.g. to update a class instance about this event!
|
||||
mvIMPACT::acquire::GenICam::EventControl* ec = reinterpret_cast<mvIMPACT::acquire::GenICam::EventControl*>(pUserData);
|
||||
// Execute the followings if the component is a property.
|
||||
if (c.isProp())
|
||||
{
|
||||
mvIMPACT::acquire::GenICam::DigitalIOControl mvDIOC(m_pMVCamera);
|
||||
mvDIOC.lineSelector.writeS("Line5");
|
||||
if (mvDIOC.lineStatus.read())
|
||||
{
|
||||
#ifdef IMM_FEED_BACK
|
||||
if (p_shooted_queue_->count() > 0)
|
||||
{
|
||||
bool temp;
|
||||
p_shooted_queue_->take(temp);
|
||||
}
|
||||
#elif defined ONE_TIME_SHIFT
|
||||
if (
|
||||
p_shooted_queue_->count() > 0
|
||||
#if defined DOUBLE_FEED_BACK
|
||||
|| p_double_queue_->count() > 0
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (p_shooted_queue_->count() > 0) {
|
||||
bool temp;
|
||||
p_shooted_queue_->take(temp);
|
||||
}
|
||||
pCaptureThread->m_threadFunc.SendFeedBack(EdgeEvent);
|
||||
}
|
||||
#else
|
||||
if (p_result_wait_queue_->count() > 0)
|
||||
{
|
||||
bool temp;
|
||||
p_result_wait_queue_->take(temp);
|
||||
pCaptureThread->m_threadFunc.SendFeedBack(EdgeEvent);
|
||||
}
|
||||
if (p_shooted_queue_->count() > 0)
|
||||
{
|
||||
bool temp;
|
||||
p_shooted_queue_->take(temp);
|
||||
p_result_wait_queue_->put(true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
int unit_count = p_unit_queue_->count();
|
||||
if (unit_count > 0)
|
||||
{
|
||||
cv::Mat long_image;
|
||||
for (int i = 0; i < unit_count; i++)
|
||||
{
|
||||
cv::Mat image;
|
||||
p_unit_queue_->take(image);
|
||||
if (0 == i)
|
||||
{
|
||||
long_image = cv::Mat::zeros(image.rows * unit_count, image.cols, image.type());
|
||||
}
|
||||
cv::Rect r(0, i * image.rows, image.cols, image.rows);
|
||||
cv::Mat roi = long_image(r);
|
||||
image.copyTo(roi);
|
||||
}
|
||||
#ifdef SYNC_CAMERA
|
||||
{
|
||||
std::lock_guard<std::mutex> locker(p_image_sync_arr_->lock);
|
||||
p_image_sync_arr_->image_sync_arr.at(pCaptureThread->Local_Num) = std::make_pair(unit_count, long_image);
|
||||
p_image_sync_arr_->collect_cnt++;
|
||||
if (p_image_sync_arr_->collect_cnt == work_camera_nums)
|
||||
{
|
||||
p_image_sync_queue_->put(p_image_sync_arr_->image_sync_arr);
|
||||
p_image_sync_arr_->collect_cnt = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
p_image_queue_->put(std::make_pair(unit_count, long_image));
|
||||
#endif
|
||||
p_shooted_queue_->put(true);
|
||||
}
|
||||
p_unit_queue_->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const ImpactAcquireException& e)
|
||||
{
|
||||
qDebug() << "Error";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class CIwtCameraLostCallbackMV : public mvIMPACT::acquire::ComponentCallback
|
||||
{
|
||||
public:
|
||||
CIwtCameraLostCallbackMV() : ComponentCallback() {}
|
||||
int channel_;
|
||||
virtual void execute(mvIMPACT::acquire::Component& c, void* pDummy)
|
||||
{
|
||||
PropertyIDeviceState p(c);
|
||||
std::cout << p.name() << " = " << p.readS() << endl;
|
||||
SingleCamInfo[channel_].OffLine = true;
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
#endif // CaptureThreadH
|
@ -0,0 +1,207 @@
|
||||
#include "CaptureThreadBasler.h"
|
||||
#include <QtWidgets/QApplication>
|
||||
#include "PLCDevice.h"
|
||||
#include "common.h"
|
||||
#include <qdebug.h>
|
||||
#include <exportData.h>
|
||||
extern SyncQueue<_XMLExportDataInfo>* export_XMLData_Info_queue;
|
||||
extern PLCDevice* m_PLCDevice;
|
||||
//-----------------------------------------------------------------------------
|
||||
CaptureThreadBasler::CaptureThreadBasler(Pylon::CBaslerUniversalInstantCamera* pCurrDev, bool boTerminated, int Num, int shoot) :
|
||||
pDev_(pCurrDev), boTerminated_(boTerminated), Local_Num(Num)
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
p_unit_queue = new ASyncQueue<cv::Mat>(Unit_Queue_Size);
|
||||
Shoot_Num = shoot;
|
||||
}
|
||||
CaptureThreadBasler::~CaptureThreadBasler()
|
||||
{
|
||||
delete p_unit_queue;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void CaptureThreadBasler::process(void)
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
bool last_high = false;
|
||||
bool last_result = false;
|
||||
|
||||
CSampleConfigurationEventHandler* CfgEvent = NULL;
|
||||
CfgEvent = new CSampleConfigurationEventHandler;
|
||||
CfgEvent->channel_ = Local_Num;
|
||||
pDev_->RegisterConfiguration(CfgEvent, Pylon::RegistrationMode_Append, Pylon::Cleanup_None);
|
||||
|
||||
CSampleImageEventHandler ImageEvent;
|
||||
#ifdef SYNC_CAMERA
|
||||
ImageEvent.p_image_sync_arr_ = p_image_sync_arr;
|
||||
ImageEvent.p_image_sync_queue_ = p_image_sync_queue;
|
||||
#else
|
||||
ImageEvent.p_image_queue_ = p_image_queue;
|
||||
#endif
|
||||
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;
|
||||
#ifdef SYNC_CAMERA
|
||||
BurstEvent.p_image_sync_arr_ = p_image_sync_arr;
|
||||
BurstEvent.p_image_sync_queue_ = p_image_sync_queue;
|
||||
#else
|
||||
BurstEvent.p_image_queue_ = p_image_queue;
|
||||
#endif
|
||||
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.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;
|
||||
m_threadFunc.m_IOTimer_ = m_IOTimer;
|
||||
#ifndef USB_BASLER_NEW_FW
|
||||
if (pDev_->TriggerSelector.TrySetValue(Basler_UniversalCameraParams::TriggerSelector_FrameBurstStart))
|
||||
{
|
||||
pDev_->TriggerMode.SetValue(Basler_UniversalCameraParams::TriggerMode_On);
|
||||
pDev_->TriggerSource.SetValue(Basler_UniversalCameraParams::TriggerSource_Line1);
|
||||
pDev_->TriggerActivation.SetValue(Basler_UniversalCameraParams::TriggerActivation_RisingEdge);
|
||||
pDev_->AcquisitionBurstFrameCount.SetValue(Shoot_Num);
|
||||
if (pDev_->EventSelector.TrySetValue(Basler_UniversalCameraParams::EventSelector_FrameBurstStart))
|
||||
{
|
||||
if (!pDev_->EventNotification.TrySetValue(Basler_UniversalCameraParams::EventNotification_On))
|
||||
{
|
||||
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_GenICamEvent);
|
||||
}
|
||||
|
||||
m_IOTimer = new QTimer();
|
||||
connect(m_IOTimer, SIGNAL(timeout()), this, SLOT(ioTimeout()));
|
||||
m_IOTimer->setSingleShot(true);
|
||||
BurstEvent.ioTimer = m_IOTimer;
|
||||
pDev_->RegisterCameraEventHandler(&BurstEvent, "EventFrameBurstStartData", eMyFrameBurstStartEvent, Pylon::RegistrationMode_Append, Pylon::Cleanup_None);
|
||||
}
|
||||
|
||||
if (pDev_->EventSelector.TrySetValue("Line1RisingEdge"))
|
||||
{
|
||||
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off);
|
||||
}
|
||||
if (pDev_->EventSelector.TrySetValue("Line1FallingEdge"))
|
||||
{
|
||||
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off);
|
||||
}
|
||||
}
|
||||
#else
|
||||
/*Set here*/
|
||||
if (pDev_->TriggerSelector.TrySetValue(Basler_UniversalCameraParams::TriggerSelector_FrameBurstStart))
|
||||
{
|
||||
pDev_->TriggerMode.SetValue(Basler_UniversalCameraParams::TriggerMode_Off);
|
||||
if (pDev_->EventSelector.TrySetValue(Basler_UniversalCameraParams::EventSelector_FrameBurstStart))
|
||||
{
|
||||
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off);
|
||||
}
|
||||
}
|
||||
|
||||
pDev_->RegisterCameraEventHandler(&BurstEvent, "EventLine1RisingEdgeData", Line1RisingEdge, Pylon::RegistrationMode_Append, Pylon::Cleanup_None);
|
||||
pDev_->EventSelector.SetValue("Line1RisingEdge");
|
||||
#ifdef IMM_PROCESS
|
||||
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off);
|
||||
#else
|
||||
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_On);
|
||||
#endif
|
||||
pDev_->RegisterCameraEventHandler(&BurstEvent, "EventLine1FallingEdgeData", Line1FallingEdge, Pylon::RegistrationMode_Append, Pylon::Cleanup_None);
|
||||
pDev_->EventSelector.SetValue("Line1FallingEdge");
|
||||
#ifdef IMM_PROCESS
|
||||
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off);
|
||||
#else
|
||||
pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_On);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
const unsigned int timeout_ms = 100;
|
||||
// This smart pointer will receive the grab result data.
|
||||
Pylon::CGrabResultPtr ptrGrabResult;
|
||||
|
||||
pDev_->StartGrabbing();
|
||||
|
||||
m_Timer = new QTimer();
|
||||
connect(m_Timer, SIGNAL(timeout()), this, SLOT(fpsTimeout()));
|
||||
m_Timer->start(1000);
|
||||
Ready = true;
|
||||
while (!boTerminated_)
|
||||
{
|
||||
// Retrieve grab results and notify the camera event and image event handlers.
|
||||
pDev_->RetrieveResult(timeout_ms, ptrGrabResult, Pylon::TimeoutHandling_Return);
|
||||
#if defined (IMM_FEED_BACK) || defined (CAP_FEED_BACK)
|
||||
m_threadFunc.SendFeedBack(ImageCap);
|
||||
#endif
|
||||
QCoreApplication::processEvents();//Make sure the timer is triggered
|
||||
}
|
||||
#ifndef USB_BASLER_NEW_FW
|
||||
// Disable sending Event Overrun events.
|
||||
if (pDev_->EventSelector.TrySetValue(Basler_UniversalCameraParams::EventSelector_FrameBurstStart))
|
||||
{
|
||||
pDev_->EventNotification.TrySetValue(Basler_UniversalCameraParams::EventNotification_Off);
|
||||
}
|
||||
if (m_IOTimer) delete m_IOTimer;
|
||||
#endif
|
||||
if (m_Timer) delete m_Timer;
|
||||
pDev_->StopGrabbing();
|
||||
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
|
||||
}
|
||||
catch (const Pylon::GenericException& e)
|
||||
{
|
||||
emit error(QString::fromStdString(e.GetDescription()));
|
||||
std::cout << e.GetSourceLine() << e.GetDescription() << std::endl;
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CaptureThreadBasler::fpsTimeout()
|
||||
{
|
||||
uint64_t delta = m_cntGrabbedImages - m_cntLastGrabbedImages;
|
||||
m_cntLastGrabbedImages = m_cntGrabbedImages;
|
||||
QString data = QString("%1").arg(delta);
|
||||
emit updateStatistics(data.left(4), Local_Num);
|
||||
}
|
||||
|
||||
void CaptureThreadBasler::ioTimeout()
|
||||
{
|
||||
pDev_->UserOutputSelector.SetValue(Basler_UniversalCameraParams::UserOutputSelector_UserOutput1);
|
||||
pDev_->UserOutputValue.SetValue(false);
|
||||
|
||||
pDev_->UserOutputSelector.SetValue(Basler_UniversalCameraParams::UserOutputSelector_UserOutput3);
|
||||
pDev_->UserOutputValue.SetValue(false);
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
class CleanWorkThread : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CleanWorkThread(QObject* parent = nullptr);
|
||||
~CleanWorkThread();
|
||||
public slots:
|
||||
void startWork();
|
||||
void startWorkAuto();
|
||||
void doWork();
|
||||
void setSelAuto();
|
||||
void setSel();
|
||||
signals:
|
||||
void workFinished();
|
||||
void workStart();
|
||||
void workStartAuto();
|
||||
public:
|
||||
qint64 DirFileSize(const QString& path);
|
||||
void CleanImageFile(const QString& path, const qint64& delDays);
|
||||
private:
|
||||
int delSelection;
|
||||
};
|
@ -0,0 +1,164 @@
|
||||
#include "Logthread.h"
|
||||
#include <QDir>
|
||||
#include <QMutex>
|
||||
#include <QDate>
|
||||
|
||||
const char PATH_LogPath[] = "D:/log/";
|
||||
const char Suffix[] = ".txt";
|
||||
bool CLog::isFileReady = false;
|
||||
bool CLog::isRecord2File = true;
|
||||
QFile localFile;
|
||||
QMutex mutexLog;
|
||||
|
||||
CLog::CLog()
|
||||
{
|
||||
}
|
||||
|
||||
void CLog::setLogType(const CLog::CLOG_TYPE& level)
|
||||
{
|
||||
}
|
||||
|
||||
bool CLog::init(LogConfig& logConfig)
|
||||
{
|
||||
isRecord2File = logConfig.isRecord2File;
|
||||
QString logDir = QString(PATH_LogPath);
|
||||
if (createDir(logDir))
|
||||
{
|
||||
QString fileName = logDir + QDir::separator() + QDate::currentDate().toString("yyyy-MM-dd") + QString(Suffix);
|
||||
QFileInfo fi(fileName);
|
||||
if (fi.exists())
|
||||
{
|
||||
if (!localFile.exists())
|
||||
{
|
||||
localFile.setFileName(fileName);
|
||||
if (localFile.open(QFile::WriteOnly | QFile::Append | QFile::Text))
|
||||
{
|
||||
isFileReady = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isFileReady = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
localFile.setFileName(fileName);
|
||||
if (localFile.open(QFile::WriteOnly | QFile::Append | QFile::Text))
|
||||
{
|
||||
isFileReady = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isFileReady;
|
||||
}
|
||||
|
||||
bool CLog::createDir(QString dirPath)
|
||||
{
|
||||
QFileInfo fileInfo(dirPath);
|
||||
if (!fileInfo.exists())
|
||||
{
|
||||
QDir tmpDir;
|
||||
return tmpDir.mkpath(dirPath);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CLog::log(CLOG_TYPE nType, const char* fileDesc, const char* functionDesc, int lineNum, const char* data, ...)
|
||||
{
|
||||
QMutexLocker locker(&mutexLog);
|
||||
if (isFileReady)
|
||||
{
|
||||
QString recordInfo = QString("[%1]").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss:zzz"));
|
||||
recordInfo.append(getTypeDesc(nType));
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
recordInfo.append(QString("[%1:%2:%3]").arg(fileDesc).arg(functionDesc).arg(lineNum));
|
||||
#endif
|
||||
va_list vlist;
|
||||
va_start(vlist, data);
|
||||
|
||||
QByteArray byteArray;
|
||||
#if defined(Q_OS_WIN)
|
||||
int recordLen = _vscprintf(data, vlist);
|
||||
byteArray.resize(recordLen);
|
||||
#else
|
||||
byteArray.resize(1024);
|
||||
#endif
|
||||
vsprintf(byteArray.data(), data, vlist);
|
||||
recordInfo.append(byteArray);
|
||||
va_end(vlist);
|
||||
|
||||
recordInfo.append("\n");
|
||||
|
||||
if (isRecord2File) {
|
||||
localFile.write(recordInfo.toLocal8Bit().data(), recordInfo.toLocal8Bit().length());
|
||||
localFile.flush();
|
||||
}
|
||||
else {
|
||||
// qDebug()<<recordInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CLog::log(CLOG_TYPE nType, const char* data, ...)
|
||||
{
|
||||
QMutexLocker locker(&mutexLog);
|
||||
if (isFileReady)
|
||||
{
|
||||
QString recordInfo = QString("[%1]").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss:zzz"));
|
||||
recordInfo.append(getTypeDesc(nType));
|
||||
recordInfo.append(" ");
|
||||
|
||||
va_list vlist;
|
||||
va_start(vlist, data);
|
||||
|
||||
QByteArray byteArray;
|
||||
#if defined(Q_OS_WIN)
|
||||
int recordLen = _vscprintf(data, vlist);
|
||||
byteArray.resize(recordLen);
|
||||
#else
|
||||
byteArray.resize(1024);
|
||||
#endif
|
||||
vsprintf(byteArray.data(), data, vlist);
|
||||
recordInfo.append(byteArray);
|
||||
va_end(vlist);
|
||||
|
||||
recordInfo.append("\n");
|
||||
|
||||
if (isRecord2File) {
|
||||
localFile.write(recordInfo.toLocal8Bit().data(), recordInfo.toLocal8Bit().length());
|
||||
localFile.flush();
|
||||
}
|
||||
else {
|
||||
// qDebug()<<recordInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString CLog::getTypeDesc(CLog::CLOG_TYPE type)
|
||||
{
|
||||
/*
|
||||
switch (type)
|
||||
{
|
||||
case CLOG_TYPE::STARTAPP:
|
||||
return "[INFO]";
|
||||
case CLOG_TYPE::STARTWORK:
|
||||
return "[WARNING]";
|
||||
case CLOG_TYPE::PAUSEWORK:
|
||||
return "[ERROR]";
|
||||
}
|
||||
*/
|
||||
return "[INFO]";
|
||||
}
|
||||
|
||||
void CLog::recMegFromCigarette(QString str)
|
||||
{
|
||||
CLog::LogConfig logConfig;
|
||||
logConfig.isRecord2File = true;
|
||||
logConfig.level = 0;
|
||||
CLog::init(logConfig);
|
||||
//qDebug() << GetCurrentThreadId() << "WinAPI";
|
||||
CLOG_INFO(str.toStdString().c_str());
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
#pragma once
|
||||
#include <QDialog>
|
||||
class CLog : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
enum CLOG_TYPE
|
||||
{
|
||||
|
||||
STARTAPP,
|
||||
STARTWORK,
|
||||
PAUSEWORK,
|
||||
UNLOCK,
|
||||
DEBUGMODE,
|
||||
UNKICKMODE,
|
||||
SETTING,
|
||||
CLEANPIC,
|
||||
DOUBLECLICK,
|
||||
ROTATEPIC,
|
||||
PLCSETTING,
|
||||
ALARM
|
||||
};
|
||||
//Q_DECLARE_FLAGS(CLOG_TYPE_Flags, CLOG_TYPE)
|
||||
Q_ENUM(CLOG_TYPE)
|
||||
|
||||
struct LogConfig
|
||||
{
|
||||
bool isRecord2File;
|
||||
int level;
|
||||
};
|
||||
|
||||
CLog();
|
||||
|
||||
void setLogType(const CLog::CLOG_TYPE& type);
|
||||
// CLog::CLOG_TYPE getLogType() { return logType; }
|
||||
|
||||
//void startClog();
|
||||
//void doWork();
|
||||
static bool init(CLog::LogConfig& logConfig);
|
||||
static bool createDir(QString dirPath);
|
||||
static void log(CLOG_TYPE nType, const char* fileDesc, const char* functionDesc, int lineNum, const char* data, ...);
|
||||
static void log(CLOG_TYPE nType, const char* data, ...);
|
||||
public slots:
|
||||
void recMegFromCigarette(QString);
|
||||
|
||||
private:
|
||||
static QString getTypeDesc(CLOG_TYPE type);
|
||||
|
||||
private:
|
||||
static bool isRecord2File;
|
||||
static bool isFileReady;
|
||||
};
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#define FILE_SEPARATOR '\\'
|
||||
#else
|
||||
#define FILE_SEPARATOR '/'
|
||||
#endif
|
||||
|
||||
#define FUNC_SEPARATOR '::'
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
#define __FILENAME__ (strrchr(__FILE__, FILE_SEPARATOR) ? (strrchr(__FILE__, FILE_SEPARATOR) + 1):__FILE__)
|
||||
#define __FUNNAME__ (strrchr(__FUNCTION__,FUNC_SEPARATOR)?(strrchr(__FUNCTION__, FUNC_SEPARATOR) + 1):__FUNCTION__)
|
||||
#else
|
||||
#define __FILENAME__ NULL
|
||||
#define __FUNNAME__ NULL
|
||||
#endif
|
||||
|
||||
#define CLOG_INFO(...) CLog::log(CLog::STARTAPP, __VA_ARGS__)
|
@ -0,0 +1,95 @@
|
||||
#ifndef _DEBUGTHREAD_H
|
||||
#define _DEBUGTHREAD_H
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
#include "SyncQueue.h"
|
||||
#include "basecamera.h"
|
||||
#include "common.h"
|
||||
#include "balluffcamera.h"
|
||||
#include "hikcamera.h"
|
||||
|
||||
extern SyncQueue<cv::Mat>* g_debug_queue[NumberOfSupportedCameras]; //相机调试模式图像队列
|
||||
extern DisplayLabelConf g_display_label_conf[NumberOfSupportedCameras];
|
||||
extern SingleCamInfoStruct SingleCamInfo[NumberOfSupportedCameras];
|
||||
extern int rotationAngle[NumberOfSupportedCameras]; //图片旋转角度
|
||||
extern bool isNeedRotate[NumberOfSupportedCameras];
|
||||
class DebugThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void notify(int Num, int Cnt, cv::Mat);
|
||||
public:
|
||||
DebugThread(QObject* parent = 0) : QThread(parent)
|
||||
{
|
||||
|
||||
}
|
||||
~DebugThread()
|
||||
{
|
||||
stop();
|
||||
p_debug_queue->put(cv::Mat());
|
||||
quit();
|
||||
wait();
|
||||
}
|
||||
void init(SyncQueue<cv::Mat>* ptr, int Num)
|
||||
{
|
||||
local_camera_number = Num;
|
||||
b_quit = false;
|
||||
p_debug_queue = ptr;
|
||||
}
|
||||
void start_work()
|
||||
{
|
||||
start(HighestPriority);
|
||||
}
|
||||
void stop()
|
||||
{
|
||||
b_quit = true;
|
||||
}
|
||||
protected:
|
||||
void run()
|
||||
{
|
||||
while (!b_quit) {
|
||||
cv::Mat image;
|
||||
p_debug_queue->take(image);
|
||||
if (image.data)
|
||||
{
|
||||
//cv::cvtColor(image, image, CV_BGR2RGB); //灰度图像转为彩色图像
|
||||
// 解决进入调试模式海康彩色相机变色,关闭色彩调整巴鲁夫相机变黑的问题
|
||||
if (image.channels() == 1)
|
||||
{
|
||||
cv::cvtColor(image, image, CV_BGR2RGB); //灰度图像转为彩色图像
|
||||
}
|
||||
if (isNeedRotate[local_camera_number]) {
|
||||
if (rotationAngle[local_camera_number] != (cv::ROTATE_90_COUNTERCLOCKWISE + 1))
|
||||
{
|
||||
cv::rotate(image, image, rotationAngle[local_camera_number]);
|
||||
}
|
||||
}
|
||||
//sleep(100);
|
||||
emit notify(local_camera_number, 0, image);
|
||||
}
|
||||
#ifdef DRAW_RECT
|
||||
std::lock_guard<std::mutex> locker2(g_display_label_conf[local_camera_number].lock);
|
||||
local_DisplayLabelConf.leftButtonDownFlag = g_display_label_conf[local_camera_number].leftButtonDownFlag;
|
||||
local_DisplayLabelConf.Flag[0] = g_display_label_conf[local_camera_number].Flag[0];
|
||||
local_DisplayLabelConf.Flag[1] = g_display_label_conf[local_camera_number].Flag[1];
|
||||
local_DisplayLabelConf.originalPoint = g_display_label_conf[local_camera_number].originalPoint;
|
||||
local_DisplayLabelConf.processPoint = g_display_label_conf[local_camera_number].processPoint;
|
||||
local_DisplayLabelConf.RectVet[0] = g_display_label_conf[local_camera_number].RectVet[0];
|
||||
local_DisplayLabelConf.RectVet[1] = g_display_label_conf[local_camera_number].RectVet[1];
|
||||
|
||||
DrawSelectRects(image, local_DisplayLabelConf, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
public:
|
||||
int local_camera_number;
|
||||
int local_classid;
|
||||
bool b_quit;
|
||||
SyncQueue<cv::Mat>* p_debug_queue;
|
||||
DisplayLabelConf local_DisplayLabelConf;
|
||||
|
||||
};
|
||||
#endif //end of _DEBUGTHREAD_H
|
@ -0,0 +1,100 @@
|
||||
#ifndef SAVE_THREAD_H
|
||||
#define SAVE_THREAD_H
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include "SyncQueue.h"
|
||||
#include "common.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <qdir.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
|
||||
extern SyncQueue<std::pair<std::string, cv::Mat>>* g_save_queue; //图像保存队列
|
||||
|
||||
class SaveThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void sendDataToExport(QString filePath);
|
||||
|
||||
public:
|
||||
SaveThread(QObject* parent = 0) : QThread(parent)
|
||||
{
|
||||
|
||||
}
|
||||
~SaveThread()
|
||||
{
|
||||
stop();
|
||||
g_save_queue->put(std::make_pair("", cv::Mat()));
|
||||
quit();
|
||||
wait();
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
b_quit = false;
|
||||
}
|
||||
void start_work()
|
||||
{
|
||||
start(HighestPriority);
|
||||
}
|
||||
void stop()
|
||||
{
|
||||
b_quit = true;
|
||||
}
|
||||
|
||||
protected:
|
||||
void run()
|
||||
{
|
||||
while (!b_quit) {
|
||||
cv::Mat image;
|
||||
std::pair<std::string, cv::Mat> element;
|
||||
g_save_queue->take(element);
|
||||
std::string file_name = element.first;
|
||||
image = element.second;
|
||||
if (image.data)
|
||||
{
|
||||
std::size_t found = file_name.find_last_of("/\\");
|
||||
std::string dir_path = file_name.substr(0, found);
|
||||
check_save_dir(dir_path);
|
||||
bool b_save = cv::imwrite(file_name, image);
|
||||
if (b_save)
|
||||
{
|
||||
//sendDataToExport(QString::fromStdString(file_name));
|
||||
sendDataToExport(QString::fromLocal8Bit(QByteArray::fromRawData(file_name.c_str(), file_name.size())));
|
||||
//qDebug() << "Save pic successfully";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void check_save_dir(std::string dir_path)
|
||||
{
|
||||
bool b_find = false;
|
||||
for (int i = 0; i < vec_save_dirs.size(); i++)
|
||||
{
|
||||
if (dir_path == vec_save_dirs[i])
|
||||
{
|
||||
b_find = true;
|
||||
}
|
||||
}
|
||||
if (!b_find)
|
||||
{
|
||||
//QString dir_str = QString::fromStdString(dir_path);
|
||||
QString dir_str = QString::fromLocal8Bit(QByteArray::fromRawData(dir_path.c_str(), dir_path.size()));
|
||||
|
||||
QDir dir;
|
||||
if (!dir.exists(dir_str))
|
||||
{
|
||||
dir.mkpath(dir_str);
|
||||
}
|
||||
vec_save_dirs.push_back(dir_path);
|
||||
}
|
||||
}
|
||||
public:
|
||||
bool b_quit;
|
||||
std::vector<std::string> vec_save_dirs;
|
||||
};
|
||||
#endif
|
@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
#include "SyncQueue.h"
|
||||
#include "ASyncQueue.h"
|
||||
#include "common.h"
|
||||
class SyncWorkThread :
|
||||
public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
#ifdef SYNC_CAMERA
|
||||
signals:
|
||||
void notify(int Num, int Cnt, cv::Mat);
|
||||
void display_timecost(int Num, int ms);
|
||||
void display_check_total(int Num, long no);
|
||||
void display_jd_no(int Num, QString jd_no);
|
||||
|
||||
void event_ok(int Num);
|
||||
void event_ng(int Num);
|
||||
#endif
|
||||
|
||||
public:
|
||||
SyncWorkThread(QObject* parent = 0) : QThread(parent)
|
||||
{
|
||||
|
||||
}
|
||||
~SyncWorkThread();
|
||||
|
||||
void init(SyncQueue<std::vector<std::pair<int, cv::Mat>>>* image_ptr, ASyncQueue<bool>* result_ptr);
|
||||
void start_work();
|
||||
void stop();
|
||||
protected:
|
||||
void run();
|
||||
public:
|
||||
int local_camera_number;
|
||||
SyncQueue<std::vector<std::pair<int, cv::Mat>>>* local_g_image_sync_queue;
|
||||
ASyncQueue<bool>* local_g_result_queue;
|
||||
bool b_quit;
|
||||
long frame_total[NumberOfSupportedCameras];
|
||||
SysConf local_SysConf;
|
||||
DisplayLabelConf local_DisplayLabelConf;
|
||||
};
|
@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include "common.h"
|
||||
#include "SyncQueue.h"
|
||||
|
||||
#include <QUdpSocket>
|
||||
|
||||
class threadReceive : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QString ip;
|
||||
threadReceive(QObject* o = nullptr) :QThread(o)
|
||||
{
|
||||
isLoop = true;
|
||||
}
|
||||
|
||||
~threadReceive()
|
||||
{
|
||||
stop();
|
||||
quit();
|
||||
wait();
|
||||
}
|
||||
void stop();
|
||||
void init(std::string IP, int port);
|
||||
void start_work();
|
||||
|
||||
private slots:
|
||||
void processPendingDatagram();
|
||||
void fileprocessPendingDatagram();
|
||||
|
||||
signals:
|
||||
void sendMsgToCigratte(QString data);
|
||||
|
||||
public:
|
||||
std::atomic_bool isLoop = { 0 };
|
||||
QUdpSocket* mSocket;
|
||||
QUdpSocket* filemSocket;
|
||||
};
|
@ -0,0 +1,96 @@
|
||||
#pragma once
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include "common.h"
|
||||
#include "SyncQueue.h"
|
||||
|
||||
#include <QUdpSocket>
|
||||
|
||||
#define image_width 160
|
||||
#define image_heigh 120
|
||||
|
||||
#define info_frame 1
|
||||
#define speed_frame 2
|
||||
#define kick_frame 3
|
||||
#define ok_frame 4
|
||||
#define ng_frame 5
|
||||
#define image_frame 6
|
||||
#define total_frame 7
|
||||
|
||||
class _UDPSendInfo
|
||||
{
|
||||
public:
|
||||
int FrameID;
|
||||
int index;
|
||||
cv::Mat image;
|
||||
int cnt;
|
||||
long Total;
|
||||
QString JD;
|
||||
QString timecost;
|
||||
int ok[NumberOfSupportedCameras];
|
||||
int ng[NumberOfSupportedCameras];
|
||||
QString speed;
|
||||
int Kick[NumberOfSupportedCameras];
|
||||
|
||||
_UDPSendInfo()
|
||||
{
|
||||
FrameID = 0;
|
||||
index = 0;
|
||||
image = cv::Mat(image_width, image_heigh, CV_8UC3, cv::Scalar(0, 0, 0));
|
||||
Total = 0;
|
||||
JD = QString("0,0,0");
|
||||
timecost = QString("0ms");;
|
||||
for (int i = 0; i < NumberOfSupportedCameras; i++)ok[i] = 0;
|
||||
for (int i = 0; i < NumberOfSupportedCameras; i++)ng[i] = 0;
|
||||
speed = QString(" ");
|
||||
for (int i = 0; i < NumberOfSupportedCameras; i++)Kick[i] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
class threadSend : public QThread
|
||||
{
|
||||
public:
|
||||
QString ip;
|
||||
int dataport;
|
||||
int imageport;
|
||||
threadSend(QObject* o = nullptr) :QThread(o)
|
||||
{
|
||||
isLoop = true;
|
||||
}
|
||||
|
||||
~threadSend()
|
||||
{
|
||||
stop();
|
||||
_UDPSendInfo UDPSendInfo;
|
||||
Local_UDP_Info_queue->put(UDPSendInfo);
|
||||
quit();
|
||||
wait();
|
||||
}
|
||||
void stop();
|
||||
|
||||
protected:
|
||||
void run();
|
||||
|
||||
public:
|
||||
void init(SyncQueue<_UDPSendInfo>* p_UDP_Info_queue, std::string IP, int port);
|
||||
void start_work();
|
||||
|
||||
void sendData(_UDPSendInfo* UDPSendInfo, int port);
|
||||
void sendData(QString data, int port);
|
||||
void sendImage(_UDPSendInfo* UDPSendInfo, int port);
|
||||
void sendSpeed(_UDPSendInfo* UDPSendInfo, int port);
|
||||
void sendKick(_UDPSendInfo* UDPSendInfo, int port);
|
||||
void sendOK(_UDPSendInfo* UDPSendInfo, int port);
|
||||
void sendNG(_UDPSendInfo* UDPSendInfo, int port);
|
||||
void sendTotal(_UDPSendInfo* UDPSendInfo, int port);
|
||||
void sendFile(QString FilePath, int port);
|
||||
public:
|
||||
SyncQueue<_UDPSendInfo>* Local_UDP_Info_queue;
|
||||
std::atomic_bool isLoop = { 0 };
|
||||
QUdpSocket mSocket;
|
||||
};
|
@ -0,0 +1,97 @@
|
||||
#include "threadSendMqtt.h"
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#include <stdio.h>
|
||||
#include <qtcpsocket.h>
|
||||
|
||||
// 相关头文件
|
||||
#include <QFile> // 文件操作
|
||||
#include <QJsonObject> // JSON对象
|
||||
#include <QJsonArray> // JSON数组
|
||||
#include <QJsonDocument> // JSON文档
|
||||
#include <QJsonParseError> // JSON异常捕捉
|
||||
|
||||
void threadSendMqtt::init(SyncQueue<_MqttSendInfo>* p_MQTT_Info_queue, std::string ip_, int port_) {
|
||||
ip = QString::fromStdString(ip_);
|
||||
port = port_;
|
||||
qDebug() << "Mqtt ip:" << ip << "| Mqtt port:" << port;
|
||||
Local_MQTT_Info_queue = p_MQTT_Info_queue;
|
||||
}
|
||||
void threadSendMqtt::start_work()
|
||||
{
|
||||
//start(HighestPriority);
|
||||
start();
|
||||
}
|
||||
|
||||
void threadSendMqtt::stop()
|
||||
{
|
||||
isLoop = false;
|
||||
wait();
|
||||
delete m_client;
|
||||
}
|
||||
|
||||
bool threadSendMqtt::connectTCP() {
|
||||
|
||||
m_client = new QMqttClient(this);
|
||||
m_client->setHostname(ip);
|
||||
m_client->setPort(port);
|
||||
//m_client->setUsername(userName);
|
||||
//m_client->setPassword(userPassword);
|
||||
m_client->connectToHost();
|
||||
//connect(m_client, &QMqttClient::stateChanged, this, &MainWindow::updateLogStateChange);
|
||||
|
||||
connect(m_client, &QMqttClient::connected, this, [this](void) {qDebug() << "Mqtt connected";});
|
||||
connect(m_client, &QMqttClient::disconnected, this, [this](void) {qDebug() << "Mqtt disconnected"; });
|
||||
|
||||
connect(m_client, SIGNAL(messageSent(qint32)), this, SLOT(MQTT_DATASEND_SUCCESS(qint32)));//消息发送成功提示的槽函数绑定
|
||||
|
||||
connect(m_client, &QMqttClient::messageReceived, this, [this](const QByteArray &message, const QMqttTopicName &topic) {
|
||||
const QString content = QDateTime::currentDateTime().toString()
|
||||
+ QLatin1String(" Received Topic: ")
|
||||
+ topic.name()
|
||||
+ QLatin1String(" Message: ")
|
||||
+ message
|
||||
+ QLatin1Char('\n');
|
||||
//ui->editLog->insertPlainText(content);
|
||||
});
|
||||
|
||||
connect(m_client, &QMqttClient::pingResponseReceived, this, [this]() {
|
||||
const QString content = QDateTime::currentDateTime().toString()
|
||||
+ QLatin1String(" PingResponse")
|
||||
+ QLatin1Char('\n');
|
||||
//ui->editLog->insertPlainText(content);
|
||||
});
|
||||
|
||||
//connect(ui->lineEditHost, &QLineEdit::textChanged, m_client, &QMqttClient::setHostname);
|
||||
//connect(ui->spinBoxPort, QOverload<int>::of(&QSpinBox::valueChanged), this, &MainWindow::setClientPort);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void threadSendMqtt::run()
|
||||
{
|
||||
if (!connectTCP())
|
||||
qDebug() << "Mqtt connect error!";
|
||||
|
||||
while (isLoop) {
|
||||
_MqttSendInfo TCPSendInfo;
|
||||
Local_MQTT_Info_queue->take(TCPSendInfo);
|
||||
num++;
|
||||
sendData(&TCPSendInfo, num);
|
||||
}
|
||||
}
|
||||
|
||||
void threadSendMqtt::sendData(_MqttSendInfo* TCPSendInfo, int Num) {
|
||||
QJsonObject addressObject;
|
||||
// 方式二:赋值
|
||||
addressObject["street"] = "123 Main St.";
|
||||
addressObject["city"] = "Anytown";
|
||||
addressObject["country"] = "USA";
|
||||
|
||||
|
||||
if (m_client->state() == QMqttClient::Connected) {
|
||||
QJsonDocument jsonDoc(addressObject);
|
||||
QByteArray jsonBytes = jsonDoc.toJson();
|
||||
auto result = m_client->publish(QMqttTopicName("topic"), jsonBytes, 0, true);
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include <iostream>
|
||||
#include <QThread>
|
||||
#include <QtMqtt/qmqttclient.h>
|
||||
#include "common.h"
|
||||
#include "SyncQueue.h"
|
||||
|
||||
class _MqttSendInfo
|
||||
{
|
||||
public:
|
||||
int MsgID;
|
||||
QString timecost;
|
||||
|
||||
_MqttSendInfo()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class threadSendMqtt : public QThread {
|
||||
public:
|
||||
QString ip;
|
||||
int port;
|
||||
int num = 0;
|
||||
|
||||
threadSendMqtt(QObject* o = nullptr) :QThread(o)
|
||||
{
|
||||
isLoop = true;
|
||||
}
|
||||
|
||||
~threadSendMqtt()
|
||||
{
|
||||
stop();
|
||||
_MqttSendInfo TCPSendInfo;
|
||||
Local_MQTT_Info_queue->put(TCPSendInfo);
|
||||
quit();
|
||||
wait();
|
||||
}
|
||||
void stop();
|
||||
bool connectTCP();
|
||||
|
||||
protected:
|
||||
void run();
|
||||
|
||||
public:
|
||||
void init(SyncQueue<_MqttSendInfo>* p_MQTT_Info_queue, std::string ip_, int port_);
|
||||
void start_work();
|
||||
void sendData(_MqttSendInfo* TCPSendInfo, int Num);
|
||||
|
||||
public:
|
||||
SyncQueue<_MqttSendInfo>* Local_MQTT_Info_queue;
|
||||
std::atomic_bool isLoop = { 0 };
|
||||
QMqttClient* m_client = NULL;
|
||||
};
|
@ -0,0 +1,60 @@
|
||||
#include "threadSendTCP.h"
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#include <stdio.h>
|
||||
#include <qtcpsocket.h>
|
||||
#pragma comment(lib, "ws2_32.lib")
|
||||
|
||||
void threadSendTCP::init(SyncQueue<_TCPSendInfo>* p_TCP_Info_queue, std::string ip_, int port_) {
|
||||
ip = QString::fromStdString(ip_);
|
||||
port = port_;
|
||||
qDebug() << "tcp ip:" << ip << "| tcp port:" << port;
|
||||
Local_TCP_Info_queue = p_TCP_Info_queue;
|
||||
}
|
||||
void threadSendTCP::start_work()
|
||||
{
|
||||
//start(HighestPriority);
|
||||
start();
|
||||
}
|
||||
|
||||
void threadSendTCP::stop()
|
||||
{
|
||||
isLoop = false;
|
||||
// wait();
|
||||
delete mySocket;
|
||||
}
|
||||
|
||||
bool threadSendTCP::connectTCP() {
|
||||
mySocket = new QTcpSocket();
|
||||
// 取消已有的连接
|
||||
mySocket->abort();
|
||||
// 连接服务器
|
||||
mySocket->connectToHost(ip, port);
|
||||
if (!mySocket->waitForConnected(30000)) {
|
||||
qDebug() << "connect failed!";
|
||||
return false;
|
||||
}
|
||||
qDebug() << "connect successfully!";
|
||||
return true;
|
||||
}
|
||||
|
||||
void threadSendTCP::run()
|
||||
{
|
||||
if (!connectTCP())
|
||||
qDebug() << "TCP connect error!";
|
||||
while (isLoop) {
|
||||
_TCPSendInfo TCPSendInfo;
|
||||
Local_TCP_Info_queue->take(TCPSendInfo);
|
||||
num++;
|
||||
sendData(&TCPSendInfo, num);
|
||||
//mySocket->write("Hello! here is tcp client!\n");
|
||||
//mySocket->flush();
|
||||
}
|
||||
}
|
||||
|
||||
void threadSendTCP::sendData(_TCPSendInfo* TCPSendInfo, int Num) {
|
||||
std::string fileName = TCPSendInfo->pics_name + ", " + QString::number(Num).toStdString();
|
||||
mySocket->write(fileName.c_str());
|
||||
mySocket->write("\n");
|
||||
mySocket->flush();
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include <iostream>
|
||||
#include <QThread>
|
||||
#include <qtcpsocket.h>
|
||||
#include "common.h"
|
||||
#include "SyncQueue.h"
|
||||
|
||||
class _TCPSendInfo
|
||||
{
|
||||
public:
|
||||
std::string pics_name;
|
||||
|
||||
_TCPSendInfo()
|
||||
{
|
||||
pics_name = "";
|
||||
}
|
||||
};
|
||||
|
||||
class threadSendTCP : public QThread {
|
||||
public:
|
||||
QString ip;
|
||||
int port;
|
||||
int num = 0;
|
||||
|
||||
threadSendTCP(QObject* o = nullptr) :QThread(o)
|
||||
{
|
||||
isLoop = true;
|
||||
}
|
||||
|
||||
~threadSendTCP()
|
||||
{
|
||||
stop();
|
||||
_TCPSendInfo TCPSendInfo;
|
||||
Local_TCP_Info_queue->put(TCPSendInfo);
|
||||
quit();
|
||||
wait();
|
||||
}
|
||||
void stop();
|
||||
bool connectTCP();
|
||||
|
||||
protected:
|
||||
void run();
|
||||
|
||||
public:
|
||||
void init(SyncQueue<_TCPSendInfo>* p_TCP_Info_queue, std::string ip_, int port_);
|
||||
void start_work();
|
||||
void sendData(_TCPSendInfo* TCPSendInfo, int Num);
|
||||
|
||||
public:
|
||||
SyncQueue<_TCPSendInfo>* Local_TCP_Info_queue;
|
||||
std::atomic_bool isLoop = { 0 };
|
||||
QTcpSocket* mySocket;
|
||||
};
|
@ -0,0 +1,325 @@
|
||||
#include "workthread.h"
|
||||
#include "alg_jd.h"
|
||||
#include "common.h"
|
||||
#include "balluffcamera.h"
|
||||
#include "baslercamera.h"
|
||||
#include "threadSend.h"
|
||||
#include <PLCDevice.h>
|
||||
#include "exportData.h"
|
||||
#include <QMap>
|
||||
|
||||
extern AlgJd alg_jd[NumberOfSupportedCameras]; //检测胶点的AI算法
|
||||
extern ConfPath g_conf_path;
|
||||
extern SysConf g_sys_conf; //系统配置参数
|
||||
extern DisplayLabelConf g_display_label_conf[NumberOfSupportedCameras];
|
||||
|
||||
extern int rotationAngle[NumberOfSupportedCameras]; //图片旋转角度
|
||||
extern bool isNeedRotate[NumberOfSupportedCameras];
|
||||
|
||||
extern SyncQueue<std::pair<std::string, cv::Mat> >* g_save_queue; //图片保存队列
|
||||
extern SyncQueue<std::pair<int, cv::Mat>>* g_image_queue[NumberOfSupportedCameras]; //int表示一个目标拍了几张
|
||||
#ifdef __UDPSend
|
||||
extern SyncQueue<_UDPSendInfo>* UDP_Info_queue;
|
||||
#endif
|
||||
#ifdef __TCPSend
|
||||
extern SyncQueue<_TCPSendInfo>* TCP_Info_queue;
|
||||
#endif
|
||||
#ifdef __ExportData
|
||||
extern ExportDataThread exportDataThread;
|
||||
#endif
|
||||
extern PLCDevice* m_PLCDevice;
|
||||
extern bool g_debug_mode;
|
||||
|
||||
WorkThread::~WorkThread()
|
||||
{
|
||||
stop();
|
||||
local_g_image_queue->put(std::make_pair(0, cv::Mat()));
|
||||
quit();
|
||||
wait();
|
||||
}
|
||||
|
||||
void WorkThread::init(SyncQueue<std::pair<int, cv::Mat>>* image_ptr, ASyncQueue<bool>* result_ptr, int classid, int Num)
|
||||
{
|
||||
local_camera_number = Num;
|
||||
local_classid = classid;
|
||||
local_g_image_queue = image_ptr;
|
||||
local_g_result_queue = result_ptr;
|
||||
b_quit = false;
|
||||
frame_total = 0;
|
||||
}
|
||||
void WorkThread::start_work()
|
||||
{
|
||||
start(HighestPriority);
|
||||
}
|
||||
void WorkThread::stop()
|
||||
{
|
||||
b_quit = true;
|
||||
}
|
||||
|
||||
void WorkThread::run()
|
||||
{
|
||||
try {
|
||||
uint32_t result_index = 0;
|
||||
while (!b_quit) {
|
||||
{//不要删掉这个括号,用来定义锁的作用域
|
||||
std::lock_guard<std::mutex> locker(g_sys_conf.lock);
|
||||
local_SysConf.save = g_sys_conf.save;
|
||||
local_SysConf.shoot[local_camera_number] = g_sys_conf.shoot[local_camera_number];
|
||||
local_SysConf.MisMatchAct = g_sys_conf.MisMatchAct;
|
||||
local_SysConf.ConfThreshold = g_sys_conf.ConfThreshold;//
|
||||
for (int i = 0; i < 3; i++)local_SysConf.no[local_camera_number][i] = g_sys_conf.no[local_camera_number][i];
|
||||
|
||||
#ifdef DRAW_RECT
|
||||
std::lock_guard<std::mutex> locker2(g_display_label_conf[local_camera_number].lock);
|
||||
local_DisplayLabelConf.leftButtonDownFlag = g_display_label_conf[local_camera_number].leftButtonDownFlag;
|
||||
local_DisplayLabelConf.Flag[0] = g_display_label_conf[local_camera_number].Flag[0];
|
||||
local_DisplayLabelConf.Flag[1] = g_display_label_conf[local_camera_number].Flag[1];
|
||||
local_DisplayLabelConf.originalPoint = g_display_label_conf[local_camera_number].originalPoint;
|
||||
local_DisplayLabelConf.processPoint = g_display_label_conf[local_camera_number].processPoint;
|
||||
local_DisplayLabelConf.RectVet[0] = g_display_label_conf[local_camera_number].RectVet[0];
|
||||
local_DisplayLabelConf.RectVet[1] = g_display_label_conf[local_camera_number].RectVet[1];
|
||||
#endif
|
||||
}
|
||||
|
||||
QDateTime now_ts = QDateTime::currentDateTime();
|
||||
std::pair<int, cv::Mat> element;
|
||||
local_g_image_queue->take(element);
|
||||
int unit_count = element.first;
|
||||
cv::Mat image = element.second;
|
||||
|
||||
#ifdef __UDPSend
|
||||
_UDPSendInfo UDPSendInfo;
|
||||
UDPSendInfo.FrameID = info_frame;
|
||||
UDPSendInfo.index = local_camera_number;
|
||||
#endif
|
||||
|
||||
#ifdef __TCPSend
|
||||
_TCPSendInfo TCPSendInfo;
|
||||
#endif
|
||||
if (!image.data)
|
||||
{
|
||||
continue; //图像为空,跳过
|
||||
}
|
||||
if (image.channels() == 1)
|
||||
{
|
||||
cv::cvtColor(image, image, CV_BGR2RGB); //灰度图像转为彩色图像
|
||||
}
|
||||
if (local_SysConf.shoot[local_camera_number] == unit_count)
|
||||
{
|
||||
std::vector<cv::Mat> vec_in;
|
||||
int w = image.cols;
|
||||
int h = image.rows / unit_count;
|
||||
for (int index = 0; index < unit_count; index++) {
|
||||
cv::Rect temp_Rect(0, h * index, w, h);
|
||||
cv::Mat temp_image = image(temp_Rect).clone();
|
||||
if (isNeedRotate[local_camera_number]) {
|
||||
if (rotationAngle[local_camera_number] != (cv::ROTATE_90_COUNTERCLOCKWISE + 1))
|
||||
{
|
||||
cv::rotate(temp_image, temp_image, rotationAngle[local_camera_number]);
|
||||
}
|
||||
}
|
||||
vec_in.push_back(temp_image.clone());
|
||||
}
|
||||
|
||||
std::vector<cv::Mat> vec_out;
|
||||
std::vector<std::vector<std::pair<int, cv::Rect> > > vec_results;
|
||||
QDateTime ts_start = QDateTime::currentDateTime();
|
||||
if (unit_count == 1) {
|
||||
std::vector<std::pair<int, cv::Rect> > results;
|
||||
cv::Mat imagein, imageout;
|
||||
imagein = vec_in[0];
|
||||
alg_jd[local_camera_number].detect(imagein, imageout, results);
|
||||
vec_out.push_back(imageout.clone());
|
||||
vec_results.push_back(results);
|
||||
}
|
||||
else {
|
||||
alg_jd[local_camera_number].detect_batch(vec_in, vec_out, vec_results);
|
||||
}
|
||||
QDateTime ts_jd = QDateTime::currentDateTime();
|
||||
int time_process = ts_start.msecsTo(ts_jd);
|
||||
#ifndef SYNC_CAMERA
|
||||
emit display_timecost(local_camera_number, time_process);
|
||||
#endif
|
||||
|
||||
#ifdef __UDPSend
|
||||
UDPSendInfo.timecost = QString::number(time_process);
|
||||
#endif
|
||||
cv::Mat image1;
|
||||
cv::Mat image2;
|
||||
|
||||
QString jd_no;
|
||||
for (int index = 0; index < unit_count; index++) {
|
||||
jd_no += QString::number(vec_results[index].size()) + ",";
|
||||
}
|
||||
jd_no.chop(1);
|
||||
#ifndef SYNC_CAMERA
|
||||
emit display_jd_no(local_camera_number, jd_no);
|
||||
#endif
|
||||
#ifdef __UDPSend
|
||||
UDPSendInfo.JD = jd_no;
|
||||
#endif
|
||||
bool IsNG = false;
|
||||
int ngReason = 0;
|
||||
QMap<int, QString> ng_reason_maps;
|
||||
ng_reason_maps[0] = "unknow";
|
||||
ng_reason_maps[1] = "less_than_setting";
|
||||
ng_reason_maps[2] = "too_diff_from_model";
|
||||
ng_reason_maps[3] = "out_of_setting_range";
|
||||
for (int index = 0; index < unit_count; index++)
|
||||
{
|
||||
if (vec_results[index].size() < local_SysConf.no[local_camera_number][index])
|
||||
{
|
||||
IsNG |= true;
|
||||
ngReason = 1;
|
||||
}
|
||||
//if (vec_results[index].size() != 1)IsNG |= true;//反向训练
|
||||
if (local_SysConf.ConfThreshold == 0)
|
||||
{
|
||||
IsNG = false;
|
||||
ngReason = 0;
|
||||
}
|
||||
if (local_SysConf.save == 2)//三张照片分别存储
|
||||
{
|
||||
cv::Mat m = vec_in[index].clone();
|
||||
QString file_name = g_conf_path.save_pics_path + "/ALL/" +
|
||||
now_ts.toString("yyyy-MM-dd") + "/"
|
||||
+ QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" +
|
||||
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
|
||||
"#" + "_" + QString::number(index + 1) + ".jpg";
|
||||
std::string filename = file_name.toLocal8Bit().constData();
|
||||
g_save_queue->put(std::make_pair(filename, m));
|
||||
|
||||
QString sendName = now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
|
||||
"#" + "_" + QString::number(index + 1) + ".jpg";
|
||||
#ifdef __TCPSend
|
||||
TCPSendInfo.pics_name = sendName.toLocal8Bit().constData();
|
||||
TCP_Info_queue->put(TCPSendInfo);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (unit_count >= 2) {
|
||||
image1 = vec_out[(result_index) % 2].clone();
|
||||
#ifdef DRAW_RECT
|
||||
IsNG |= CheckSelectRects(image1, vec_results, (result_index) % 2, local_DisplayLabelConf, 0);
|
||||
if (IsNG) {
|
||||
ngReason = 2;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
image1 = vec_out[0].clone();
|
||||
#ifdef DRAW_RECT
|
||||
IsNG |= CheckSelectRects(image1, vec_results, 0, local_DisplayLabelConf, 0);
|
||||
if (IsNG) {
|
||||
ngReason = 2;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef DRAW_RECT
|
||||
DrawSelectRects(image1, local_DisplayLabelConf, 0);
|
||||
#endif
|
||||
|
||||
if (unit_count >= 3) {
|
||||
image2 = vec_out[2].clone();
|
||||
#ifdef DRAW_RECT
|
||||
DrawSelectRects(image2, local_DisplayLabelConf, 1);
|
||||
IsNG |= CheckSelectRects(image1, vec_results, 2, local_DisplayLabelConf, 1);
|
||||
if (IsNG) {
|
||||
ngReason = 3;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
result_index++;
|
||||
|
||||
if (!IsNG)
|
||||
{
|
||||
if (!g_debug_mode)
|
||||
{
|
||||
#ifndef SYNC_CAMERA
|
||||
emit event_ok(local_camera_number);
|
||||
#endif
|
||||
local_g_result_queue->put(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!g_debug_mode)
|
||||
{
|
||||
#ifndef SYNC_CAMERA
|
||||
emit event_ng(local_camera_number);
|
||||
#endif
|
||||
local_g_result_queue->put(false);
|
||||
}
|
||||
|
||||
if ((local_SysConf.save == 2) || (local_SysConf.save == 1))
|
||||
{
|
||||
for (int index = 0; index < unit_count; index++)
|
||||
{
|
||||
cv::Mat m = vec_in[index].clone();
|
||||
QString file_name = g_conf_path.save_pics_path + "/ng/" +
|
||||
now_ts.toString("yyyy-MM-dd") + "/"
|
||||
+ QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" +
|
||||
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
|
||||
"#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] +
|
||||
".jpg";
|
||||
QString remotePath = "/image/ng/" +
|
||||
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
|
||||
"#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] +
|
||||
".jpg";
|
||||
g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), m));
|
||||
|
||||
m = vec_out[index].clone();
|
||||
file_name = g_conf_path.save_pics_path + "/ng_result/" +
|
||||
now_ts.toString("yyyy-MM-dd") + "/"
|
||||
+ QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" +
|
||||
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
|
||||
"#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] +
|
||||
".jpg";
|
||||
remotePath = "/image/ng_result/" +
|
||||
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
|
||||
"#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] +
|
||||
".jpg";
|
||||
//g_save_queue->put(std::make_pair(file_name.toStdString(), m));
|
||||
g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), m));
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifndef SYNC_CAMERA
|
||||
if (!g_debug_mode)
|
||||
{
|
||||
emit display_check_total(local_camera_number, ++frame_total);
|
||||
//exportDataInfo.cameraTotal = frame_total;
|
||||
|
||||
emit notify(local_camera_number, 0, image1);
|
||||
if (unit_count >= 3)
|
||||
emit notify(local_camera_number, 1, image2);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifndef SYNC_CAMERA
|
||||
else
|
||||
{
|
||||
//保证不错位
|
||||
if (!g_debug_mode)
|
||||
{
|
||||
if (local_SysConf.MisMatchAct == 1)//as ng
|
||||
emit event_ng(local_camera_number);
|
||||
else if (local_SysConf.MisMatchAct == 0)//as ok
|
||||
emit event_ok(local_camera_number);
|
||||
emit display_check_total(local_camera_number, ++frame_total);
|
||||
qDebug() << local_camera_number << "#camera# " << now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx " << unit_count;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef __UDPSend
|
||||
UDP_Info_queue->put(UDPSendInfo);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (cv::Exception& e)
|
||||
{
|
||||
const char* err_msg = e.what();
|
||||
std::cout << "exception caught: " << err_msg << std::endl;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
#include "SyncQueue.h"
|
||||
#include "ASyncQueue.h"
|
||||
#include "common.h"
|
||||
|
||||
class WorkThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
#ifndef SYNC_CAMERA
|
||||
signals:
|
||||
void notify(int Num, int Cnt, cv::Mat);
|
||||
void display_timecost(int Num, int ms);
|
||||
void display_check_total(int Num, long no);
|
||||
void display_jd_no(int Num, QString jd_no);
|
||||
|
||||
void event_ok(int Num);
|
||||
void event_ng(int Num);
|
||||
#endif
|
||||
|
||||
public:
|
||||
WorkThread(QObject* parent = 0) : QThread(parent)
|
||||
{
|
||||
|
||||
}
|
||||
~WorkThread();
|
||||
|
||||
void init(SyncQueue<std::pair<int, cv::Mat>>* image_ptr, ASyncQueue<bool>* result_ptr, int classid, int Num);
|
||||
void start_work();
|
||||
void stop();
|
||||
protected:
|
||||
void run();
|
||||
public:
|
||||
int local_camera_number;
|
||||
int local_classid;
|
||||
SyncQueue<std::pair<int, cv::Mat>>* local_g_image_queue;
|
||||
ASyncQueue<bool>* local_g_result_queue;
|
||||
bool b_quit;
|
||||
long frame_total;
|
||||
SysConf local_SysConf;
|
||||
DisplayLabelConf local_DisplayLabelConf;
|
||||
};
|
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include <QDialog>
|
||||
#include "ui_alarmdialog.h"
|
||||
|
||||
class AlarmDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AlarmDialog(QWidget* parent = Q_NULLPTR);
|
||||
~AlarmDialog();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_close_released();
|
||||
void on_pushButton_clear_released();
|
||||
|
||||
private:
|
||||
Ui::AlarmDialog ui;
|
||||
};
|
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include "ui_camera_glue.h"
|
||||
#include "basecamera.h"
|
||||
#include "common.h"
|
||||
class camera_glue : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
camera_glue(QDialog* parent = Q_NULLPTR);
|
||||
~camera_glue();
|
||||
signals:
|
||||
void sendMsgToDialogSetup(int ptr[][3]);
|
||||
|
||||
public slots:
|
||||
void recMsgFromDialogSetup(int ptr[][3]);
|
||||
void on_pushButton_take_released(void);
|
||||
|
||||
private:
|
||||
Ui::camera_glue ui;
|
||||
QSpinBox* spinBox[NumberOfSupportedCameras][3];
|
||||
SysConf local_SysConf;
|
||||
};
|
@ -0,0 +1,90 @@
|
||||
#include "change_shift.h"
|
||||
#include <common.h>
|
||||
#include <dialogsetup.hpp>
|
||||
|
||||
extern SysConf g_sys_conf;
|
||||
change_shift::change_shift(QDialog* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
this->setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
if (g_sys_conf.auto_shift == 1) {
|
||||
ui.radioButton_auto->setChecked(true);
|
||||
}
|
||||
else {
|
||||
ui.radioButton_auto->setChecked(false);
|
||||
}
|
||||
if (g_sys_conf.shift_byhand == 1) {
|
||||
ui.radioButton_byhand->setChecked(true);
|
||||
}
|
||||
else {
|
||||
ui.radioButton_byhand->setChecked(false);
|
||||
}
|
||||
if (g_sys_conf.timing_shift == 1) {
|
||||
ui.radioButton_time->setChecked(true);
|
||||
}
|
||||
else {
|
||||
ui.radioButton_time->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
change_shift::~change_shift()
|
||||
{
|
||||
}
|
||||
|
||||
void change_shift::on_pushButton_apply_released()
|
||||
{
|
||||
QTime timeA;
|
||||
QTime timeB;
|
||||
QTime timeC;
|
||||
if (ui.radioButton_auto->isChecked()) { /// 已隐藏
|
||||
g_sys_conf.auto_shift = 1;
|
||||
g_sys_conf.timing_shift = 0;
|
||||
g_sys_conf.shift_byhand = 0;
|
||||
|
||||
timeA.setHMS(ui.A_hour->minimum(), ui.A_minute->minimum(), 0);
|
||||
timeB.setHMS(ui.B_hour->minimum(), ui.B_minute->minimum(), 0);
|
||||
timeC.setHMS(ui.C_hour->minimum(), ui.C_minute->minimum(), 0);
|
||||
//emit sendMsgToDialogSetup(timeA, timeB, timeC);
|
||||
//this->close();
|
||||
}
|
||||
else if (ui.radioButton_time->isChecked()) {
|
||||
g_sys_conf.auto_shift = 0;
|
||||
g_sys_conf.timing_shift = 1;
|
||||
g_sys_conf.shift_byhand = 0;
|
||||
|
||||
timeA.setHMS(ui.A_hour->text().toInt(), ui.A_minute->text().toInt(), 0);
|
||||
timeB.setHMS(ui.B_hour->text().toInt(), ui.B_minute->text().toInt(), 0);
|
||||
timeC.setHMS(ui.C_hour->text().toInt(), ui.C_minute->text().toInt(), 0);
|
||||
//emit sendMsgToDialogSetup(timeA, timeB, timeC);
|
||||
//this->close();
|
||||
}
|
||||
else if (ui.radioButton_byhand->isChecked()) {
|
||||
g_sys_conf.auto_shift = 0;
|
||||
g_sys_conf.timing_shift = 0;
|
||||
g_sys_conf.shift_byhand = 1;
|
||||
|
||||
timeA.setHMS(ui.A_hour->minimum(), ui.A_minute->minimum(), 0);
|
||||
timeB.setHMS(ui.B_hour->minimum(), ui.B_minute->minimum(), 0);
|
||||
timeC.setHMS(ui.C_hour->minimum(), ui.C_minute->minimum(), 0);
|
||||
|
||||
}
|
||||
emit sendMsgToDialogSetup(timeA, timeB, timeC);
|
||||
this->close();
|
||||
DialogSetup::write_config();
|
||||
}
|
||||
|
||||
void change_shift::recMsgFromDialogSetup(QTime timeA, QTime timeB, QTime timeC)
|
||||
{
|
||||
ui.A_hour->setValue(timeA.hour());
|
||||
ui.A_minute->setValue(timeA.minute());
|
||||
|
||||
ui.B_hour->setValue(timeB.hour());
|
||||
ui.B_minute->setValue(timeB.minute());
|
||||
|
||||
ui.C_hour->setValue(timeC.hour());
|
||||
ui.C_minute->setValue(timeC.minute());
|
||||
|
||||
this->show();
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include "ui_change_shift.h"
|
||||
#include "QtCore/qdatetime.h"
|
||||
|
||||
class change_shift : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
change_shift(QDialog* parent = Q_NULLPTR);
|
||||
~change_shift();
|
||||
|
||||
private:
|
||||
Ui::change_shift ui;
|
||||
|
||||
private slots:
|
||||
void on_pushButton_apply_released();
|
||||
|
||||
public slots:
|
||||
void recMsgFromDialogSetup(QTime timeA, QTime timeB, QTime timeC);
|
||||
|
||||
signals:
|
||||
void sendMsgToDialogSetup(QTime timeA, QTime timeB, QTime timeC);
|
||||
|
||||
};
|
@ -0,0 +1,96 @@
|
||||
#include "dialogin.hpp"
|
||||
#include <QCryptographicHash>
|
||||
#include <qdebug.h>
|
||||
#include <qmessagebox.h>
|
||||
|
||||
extern bool g_op_mode; //是否操作员模式
|
||||
|
||||
extern QString g_op_pswd; //操作员密码
|
||||
|
||||
Dialogin::Dialogin(QWidget* parent) : QDialog(parent) {
|
||||
ui.setupUi(this);
|
||||
m_pswd = "";
|
||||
this->setWindowFlags(Qt::FramelessWindowHint);
|
||||
}
|
||||
|
||||
Dialogin::~Dialogin() {
|
||||
|
||||
}
|
||||
|
||||
void Dialogin::on_pushButton_close_released()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
void Dialogin::on_pushButton_clr_released()
|
||||
{
|
||||
m_pswd = "";
|
||||
ui.lineEdit->setText("");
|
||||
}
|
||||
void Dialogin::on_pushButton_ok_released()
|
||||
{
|
||||
QString md5Str = QCryptographicHash::hash(m_pswd.toLatin1(), QCryptographicHash::Md5).toHex();
|
||||
qDebug() << "m_pswd_op:" << m_pswd;
|
||||
qDebug() << "m_pswd_op md5:" << md5Str;
|
||||
qDebug() << "g_admin_pswd_op md5:" << g_op_pswd;
|
||||
if (md5Str.compare(g_op_pswd, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
g_op_mode = true;
|
||||
//QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("验证通过,进入管理员模式"), QMessageBox::Ok);
|
||||
emit enter_op();
|
||||
this->close();
|
||||
}
|
||||
else {
|
||||
QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("密码错误,请重新输入"), QMessageBox::Ok);
|
||||
on_pushButton_clr_released();
|
||||
}
|
||||
}
|
||||
void Dialogin::on_pushButton_0_released()
|
||||
{
|
||||
m_pswd += "0";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void Dialogin::on_pushButton_1_released()
|
||||
{
|
||||
m_pswd += "1";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void Dialogin::on_pushButton_2_released()
|
||||
{
|
||||
m_pswd += "2";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void Dialogin::on_pushButton_3_released()
|
||||
{
|
||||
m_pswd += "3";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void Dialogin::on_pushButton_4_released()
|
||||
{
|
||||
m_pswd += "4";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void Dialogin::on_pushButton_5_released()
|
||||
{
|
||||
m_pswd += "5";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void Dialogin::on_pushButton_6_released()
|
||||
{
|
||||
m_pswd += "6";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void Dialogin::on_pushButton_7_released()
|
||||
{
|
||||
m_pswd += "7";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void Dialogin::on_pushButton_8_released()
|
||||
{
|
||||
m_pswd += "8";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void Dialogin::on_pushButton_9_released()
|
||||
{
|
||||
m_pswd += "9";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include <QDialog>
|
||||
#include "ui_dialogin.h"
|
||||
|
||||
class Dialogin : public QDialog {
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void enter_op();
|
||||
|
||||
public:
|
||||
Dialogin(QWidget* parent = Q_NULLPTR);
|
||||
~Dialogin();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_close_released();
|
||||
void on_pushButton_clr_released();
|
||||
void on_pushButton_ok_released();
|
||||
void on_pushButton_0_released();
|
||||
void on_pushButton_1_released();
|
||||
void on_pushButton_2_released();
|
||||
void on_pushButton_3_released();
|
||||
void on_pushButton_4_released();
|
||||
void on_pushButton_5_released();
|
||||
void on_pushButton_6_released();
|
||||
void on_pushButton_7_released();
|
||||
void on_pushButton_8_released();
|
||||
void on_pushButton_9_released();
|
||||
|
||||
public:
|
||||
QString m_pswd;
|
||||
|
||||
private:
|
||||
Ui::Dialogin ui;
|
||||
};
|
@ -0,0 +1,73 @@
|
||||
#pragma once
|
||||
#include <QDialog>
|
||||
#include "ui_dialogsetup.h"
|
||||
#include "basecamera.h"
|
||||
#include <qdebug.h>
|
||||
#include "common.h"
|
||||
#include "camera_glue.h"
|
||||
#include "output_statistic.h"
|
||||
#include "change_shift.h"
|
||||
|
||||
class DialogSetup : public QDialog {
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void system_exit();
|
||||
void sendMsgToShift(QTime timeA, QTime timeB, QTime timeC);
|
||||
void sendMsgToOutput();
|
||||
void sendMsgToConfig(int ptr[][3]);
|
||||
#ifdef __DEBUG
|
||||
void _testimg();
|
||||
void _testimgs();
|
||||
#endif
|
||||
private slots:
|
||||
void on_toolButton_keyboard_released();
|
||||
void on_pushButton_exit_released();
|
||||
void on_pushButton_save_released();
|
||||
void on_pushButton_close_released();
|
||||
void on_toolButton_choose_config_path_released();
|
||||
void on_toolButton_choose_model_path_released();
|
||||
void on_toolButton_choose_path_jpg_released();
|
||||
void on_toolButton_choose_save_pics_path_released();
|
||||
void on_pushButton_desktop_released();
|
||||
void on_pushButton_image_released();
|
||||
void on_pushButton_pswd_released();
|
||||
void on_pushButton_pswd_op_released();
|
||||
void on_pushButton_expo_released();
|
||||
void on_pushButton_filter_released();
|
||||
void on_pushButton_clear_pic_released();
|
||||
|
||||
void on_pushButton_config_released();
|
||||
void on_pushButton_change_released();
|
||||
void on_pushButton_statistic_released();
|
||||
|
||||
void on_checkBox_auto_open_clicked(bool checked);
|
||||
void on_checkBox_auto_work_clicked(bool checked);
|
||||
|
||||
void recMsgFromDialogConfig(int ptr[][3]);
|
||||
void recMsgFromChangeShift(QTime timeA, QTime timeB, QTime timeC);
|
||||
void onComboBoxSelect(int index);
|
||||
void onComboBoxConfSelect(int index);
|
||||
void onComboBoxPicsPathSelect(int index);
|
||||
#ifdef __DEBUG
|
||||
void on_pushButton_testimg_released();
|
||||
void on_pushButton_testimgs_released();
|
||||
#endif
|
||||
public:
|
||||
DialogSetup(QWidget* parent = Q_NULLPTR);
|
||||
~DialogSetup();
|
||||
QLineEdit* lineEdit_expo_mat[NumberOfSupportedCameras];
|
||||
QLineEdit* lineEdit_gain_mat[NumberOfSupportedCameras];
|
||||
QLineEdit* lineEdit_filter_mat[NumberOfSupportedCameras];
|
||||
void InitPtrMat();
|
||||
static void write_pswd();
|
||||
static void write_pswd_op();
|
||||
static void write_config();
|
||||
static void write_conf_path();
|
||||
|
||||
public:
|
||||
camera_glue* m_camera_glue = NULL;
|
||||
change_shift* m_change_shift = NULL;
|
||||
output_statistic* m_output_statistic = NULL;
|
||||
private:
|
||||
Ui::DialogSetup ui;
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,98 @@
|
||||
#include "dialogsetuppasswd.hpp"
|
||||
|
||||
#include <QCryptographicHash>
|
||||
|
||||
#include <qdebug.h>
|
||||
|
||||
#include <qmessagebox.h>
|
||||
|
||||
extern bool g_admin_mode; //是否管理员模式
|
||||
extern QString g_admin_pswd; //管理员密码
|
||||
|
||||
DialogSetupPasswd::DialogSetupPasswd(QWidget* parent) : QDialog(parent) {
|
||||
ui.setupUi(this);
|
||||
m_pswd = "";
|
||||
this->setWindowFlags(Qt::FramelessWindowHint);
|
||||
}
|
||||
|
||||
DialogSetupPasswd::~DialogSetupPasswd() {
|
||||
|
||||
}
|
||||
|
||||
void DialogSetupPasswd::on_pushButton_close_released()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
void DialogSetupPasswd::on_pushButton_clr_released()
|
||||
{
|
||||
m_pswd = "";
|
||||
ui.lineEdit->setText("");
|
||||
}
|
||||
void DialogSetupPasswd::on_pushButton_ok_released()
|
||||
{
|
||||
QString md5Str = QCryptographicHash::hash(m_pswd.toLatin1(), QCryptographicHash::Md5).toHex();
|
||||
qDebug() << "m_pswd:" << m_pswd;
|
||||
qDebug() << "m_pswd md5:" << md5Str;
|
||||
qDebug() << "g_admin_pswd md5:" << g_admin_pswd;
|
||||
if (md5Str.compare(g_admin_pswd, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
g_admin_mode = true;
|
||||
//QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("验证通过,进入管理员模式"), QMessageBox::Ok);
|
||||
emit enter_admin();
|
||||
this->close();
|
||||
}
|
||||
else {
|
||||
QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("密码错误,请重新输入"), QMessageBox::Ok);
|
||||
on_pushButton_clr_released();
|
||||
}
|
||||
}
|
||||
void DialogSetupPasswd::on_pushButton_0_released()
|
||||
{
|
||||
m_pswd += "0";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void DialogSetupPasswd::on_pushButton_1_released()
|
||||
{
|
||||
m_pswd += "1";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void DialogSetupPasswd::on_pushButton_2_released()
|
||||
{
|
||||
m_pswd += "2";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void DialogSetupPasswd::on_pushButton_3_released()
|
||||
{
|
||||
m_pswd += "3";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void DialogSetupPasswd::on_pushButton_4_released()
|
||||
{
|
||||
m_pswd += "4";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void DialogSetupPasswd::on_pushButton_5_released()
|
||||
{
|
||||
m_pswd += "5";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void DialogSetupPasswd::on_pushButton_6_released()
|
||||
{
|
||||
m_pswd += "6";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void DialogSetupPasswd::on_pushButton_7_released()
|
||||
{
|
||||
m_pswd += "7";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void DialogSetupPasswd::on_pushButton_8_released()
|
||||
{
|
||||
m_pswd += "8";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
||||
void DialogSetupPasswd::on_pushButton_9_released()
|
||||
{
|
||||
m_pswd += "9";
|
||||
ui.lineEdit->setText(ui.lineEdit->text() + "*");
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include <QDialog>
|
||||
#include "ui_dialogsetuppasswd.h"
|
||||
|
||||
class DialogSetupPasswd : public QDialog {
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void enter_admin();
|
||||
|
||||
public:
|
||||
DialogSetupPasswd(QWidget* parent = Q_NULLPTR);
|
||||
~DialogSetupPasswd();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_close_released();
|
||||
void on_pushButton_clr_released();
|
||||
void on_pushButton_ok_released();
|
||||
void on_pushButton_0_released();
|
||||
void on_pushButton_1_released();
|
||||
void on_pushButton_2_released();
|
||||
void on_pushButton_3_released();
|
||||
void on_pushButton_4_released();
|
||||
void on_pushButton_5_released();
|
||||
void on_pushButton_6_released();
|
||||
void on_pushButton_7_released();
|
||||
void on_pushButton_8_released();
|
||||
void on_pushButton_9_released();
|
||||
|
||||
|
||||
public:
|
||||
QString m_pswd;
|
||||
|
||||
private:
|
||||
Ui::DialogSetupPasswd ui;
|
||||
};
|
@ -0,0 +1,69 @@
|
||||
#include "output_statistic.h"
|
||||
#include "QtCore\qfile.h"
|
||||
#include "QtCore\qtextstream.h"
|
||||
#include "exportData.h"
|
||||
#include <map>
|
||||
|
||||
extern ConfPath g_conf_path;
|
||||
|
||||
#define output_init(a, b)\
|
||||
textBrowser_mat[a] = ui.textBrowser_##b;
|
||||
|
||||
output_statistic::output_statistic(QDialog* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
this->setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 0)
|
||||
output_init(0, 1);
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 1)
|
||||
output_init(1, 2);
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 2)
|
||||
output_init(2, 3);
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 3)
|
||||
output_init(3, 4);
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 4)
|
||||
output_init(4, 5);
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 5)
|
||||
output_init(5, 6);
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 6)
|
||||
output_init(6, 7);
|
||||
#endif
|
||||
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > 7)
|
||||
output_init(7, 8);
|
||||
#endif
|
||||
}
|
||||
|
||||
output_statistic::~output_statistic()
|
||||
{
|
||||
}
|
||||
|
||||
void output_statistic::recMsgFromDialogSetup()
|
||||
{
|
||||
QString file_path, file_name;
|
||||
QFile file;
|
||||
for (int i = 0; i < NumberOfSupportedCameras; i++) {
|
||||
file_name = QString(STATISTIC_FILE).arg(i);
|
||||
file_path = g_conf_path.config_path + "/" + file_name;
|
||||
file.setFileName(file_path);
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
QTextStream in(&file);
|
||||
//in.setCodec("UTF-8");
|
||||
textBrowser_mat[i]->setText(in.readAll());
|
||||
}
|
||||
else {
|
||||
std::cout << "can not open statistic file" << std::endl;
|
||||
}
|
||||
file.close();
|
||||
this->show();
|
||||
}
|
||||
//this->show();
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include "common.h"
|
||||
#include "ui_output_statistic.h"
|
||||
|
||||
class output_statistic : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
output_statistic(QDialog* parent = Q_NULLPTR);
|
||||
~output_statistic();
|
||||
|
||||
private:
|
||||
Ui::output_statistic ui;
|
||||
QTextBrowser* textBrowser_mat[NumberOfSupportedCameras];
|
||||
|
||||
public slots:
|
||||
void recMsgFromDialogSetup();
|
||||
};
|
@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
#include <QDialog>
|
||||
#include <QPushButton>
|
||||
#include "ui_plcsetup.h"
|
||||
#include "plc_item.h"
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <QTimer>
|
||||
#include "modbus.h"
|
||||
|
||||
class QTimer;
|
||||
|
||||
class PlcSetup : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PlcSetup(QWidget* parent = Q_NULLPTR);
|
||||
~PlcSetup();
|
||||
|
||||
QTimer* m_pTimer;
|
||||
|
||||
void read_plc_items();
|
||||
void save_plc_items();
|
||||
private slots:
|
||||
void click_read();
|
||||
void click_write();
|
||||
void click_save();
|
||||
|
||||
void on_toolButton_batch_read_released();
|
||||
void on_toolButton_keyboard_released();
|
||||
void on_toolButton_close_released();
|
||||
|
||||
void handleTimeout(); //窗口加载时执行一次,批处理读取所有地址
|
||||
|
||||
private:
|
||||
Ui::PlcSetup ui;
|
||||
|
||||
std::vector<PlcItem> m_plc_items;
|
||||
};
|
@ -0,0 +1,42 @@
|
||||
#ifndef _CIGARETTE_JD_ng
|
||||
#define _CIGARETTE_JD_ng
|
||||
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <opencv2/dnn.hpp>
|
||||
#include <opencv2/dnn/shape_utils.hpp>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
#include <opencv2/highgui.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "common.h"
|
||||
class AlgJd_ng
|
||||
{
|
||||
public:
|
||||
bool init_ng(QString model_path, QString model_name);
|
||||
bool test_detect_ng();
|
||||
bool test_detect_batcht_ng(int shoot);
|
||||
int detect_ng(cv::Mat& in, cv::Mat &draw_frame, cv::Mat &out, std::vector<std::pair<int, cv::Rect>> &results);
|
||||
int detect_ng(cv::Mat& in, cv::Mat &out, std::vector<std::pair<int, cv::Rect> > &results);
|
||||
// Remove the bounding boxes with low confidence using non-maxima suppression
|
||||
void post_process_ng(cv::Mat& frame, std::vector<cv::Mat>& outs, std::vector<std::pair<int, cv::Rect>> &results);
|
||||
void CircleImagePro_ng(cv::Mat src, cv::Mat dst, std::vector<float> radius);
|
||||
void detect_batch_ng(std::vector<cv::Mat>& vec_in, std::vector<cv::Mat> &vec_out, std::vector<std::vector<std::pair<int, cv::Rect> > > &vec_results);
|
||||
void detect_batch_ng(std::vector<cv::Mat>& vec_in, std::vector<cv::Mat> &transits, std::vector<cv::Mat> &vec_out, std::vector<std::vector<std::pair<int, cv::Rect>>> &vec_results);
|
||||
// Remove the bounding boxes with low confidence using non-maxima suppression
|
||||
void post_process_batch_ng(std::vector<cv::Mat>& vec_frame, std::vector<cv::Mat>& outs, std::vector<std::vector<std::pair<int, cv::Rect>>> &vec_results);
|
||||
void analyse_ng(cv::Mat vec_in, std::vector<std::pair<int, cv::Rect> > & vec_results);
|
||||
// Get the names of the output layers
|
||||
std::vector<cv::String> getOutputsNames_ng(const cv::dnn::Net& net);
|
||||
// Draw the predicted bounding box
|
||||
void drawPred_ng(int classId, float conf, int left, int top, int right, int bottom, cv::Mat& frame);
|
||||
private:
|
||||
cv::dnn::Net net_ng;
|
||||
std::vector<std::string> classes_ng;
|
||||
};
|
||||
//jinhuan+
|
||||
bool sort_rect_by_x_center_ng(cv::Rect r1, cv::Rect r2);
|
||||
bool sort_rect_by_y_center_ng(cv::Rect r1, cv::Rect r2);
|
||||
bool sort_rect_by_height_ng(cv::Rect r1, cv::Rect r2);
|
||||
bool sort_rect_by_width_ng(cv::Rect r1, cv::Rect r2);
|
||||
//jinhuan-
|
||||
#endif //end of _CIGARETTE_JD
|
@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include "ui_camera_glue.h"
|
||||
#include "basecamera.h"
|
||||
#include "common.h"
|
||||
class camera_glue : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
camera_glue(QDialog *parent = Q_NULLPTR);
|
||||
~camera_glue();
|
||||
signals:
|
||||
void sendMsgToDialogSetup(int ptr[][3]);
|
||||
|
||||
public slots:
|
||||
void recMsgFromDialogSetup(int ptr[][3]);
|
||||
void on_pushButton_take_released(void);
|
||||
|
||||
private:
|
||||
Ui::camera_glue ui;
|
||||
QSpinBox *spinBox[NumberOfSupportedCameras][3];
|
||||
SysConf local_SysConf;
|
||||
};
|
@ -1,88 +0,0 @@
|
||||
#include "change_shift.h"
|
||||
#include <common.h>
|
||||
#include <dialogsetup.hpp>
|
||||
|
||||
extern SysConf g_sys_conf;
|
||||
change_shift::change_shift(QDialog *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
this->setWindowFlags(windowFlags()&~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
if (g_sys_conf.auto_shift == 1) {
|
||||
ui.radioButton_auto->setChecked(true);
|
||||
}
|
||||
else {
|
||||
ui.radioButton_auto->setChecked(false);
|
||||
}
|
||||
if (g_sys_conf.shift_byhand == 1) {
|
||||
ui.radioButton_byhand->setChecked(true);
|
||||
}
|
||||
else {
|
||||
ui.radioButton_byhand->setChecked(false);
|
||||
}
|
||||
if (g_sys_conf.timing_shift == 1) {
|
||||
ui.radioButton_time->setChecked(true);
|
||||
}
|
||||
else {
|
||||
ui.radioButton_time->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
change_shift::~change_shift()
|
||||
{
|
||||
}
|
||||
|
||||
void change_shift::on_pushButton_apply_released()
|
||||
{
|
||||
QTime timeA;
|
||||
QTime timeB;
|
||||
QTime timeC;
|
||||
if (ui.radioButton_auto->isChecked()) { /// ÒÑÒþ²Ø
|
||||
g_sys_conf.auto_shift = 1;
|
||||
g_sys_conf.timing_shift = 0;
|
||||
|
||||
timeA.setHMS(ui.A_hour->minimum(), ui.A_minute->minimum(), 0);
|
||||
timeB.setHMS(ui.B_hour->minimum(), ui.B_minute->minimum(), 0);
|
||||
timeC.setHMS(ui.C_hour->minimum(), ui.C_minute->minimum(), 0);
|
||||
//emit sendMsgToDialogSetup(timeA, timeB, timeC);
|
||||
//this->close();
|
||||
}
|
||||
else if (ui.radioButton_time->isChecked()) {
|
||||
g_sys_conf.auto_shift = 0;
|
||||
g_sys_conf.timing_shift = 1;
|
||||
g_sys_conf.shift_byhand = 0;
|
||||
|
||||
timeA.setHMS(ui.A_hour->text().toInt(), ui.A_minute->text().toInt(), 0);
|
||||
timeB.setHMS(ui.B_hour->text().toInt(), ui.B_minute->text().toInt(), 0);
|
||||
timeC.setHMS(ui.C_hour->text().toInt(), ui.C_minute->text().toInt(), 0);
|
||||
//emit sendMsgToDialogSetup(timeA, timeB, timeC);
|
||||
//this->close();
|
||||
}
|
||||
else if (ui.radioButton_byhand->isChecked()) {
|
||||
g_sys_conf.timing_shift = 0;
|
||||
g_sys_conf.shift_byhand = 1;
|
||||
|
||||
timeA.setHMS(ui.A_hour->minimum(), ui.A_minute->minimum(), 0);
|
||||
timeB.setHMS(ui.B_hour->minimum(), ui.B_minute->minimum(), 0);
|
||||
timeC.setHMS(ui.C_hour->minimum(), ui.C_minute->minimum(), 0);
|
||||
|
||||
}
|
||||
emit sendMsgToDialogSetup(timeA, timeB, timeC);
|
||||
this->close();
|
||||
DialogSetup::write_config();
|
||||
}
|
||||
|
||||
void change_shift::recMsgFromDialogSetup(QTime timeA, QTime timeB, QTime timeC)
|
||||
{
|
||||
ui.A_hour->setValue(timeA.hour());
|
||||
ui.A_minute->setValue(timeA.minute());
|
||||
|
||||
ui.B_hour->setValue(timeB.hour());
|
||||
ui.B_minute->setValue(timeB.minute());
|
||||
|
||||
ui.C_hour->setValue(timeC.hour());
|
||||
ui.C_minute->setValue(timeC.minute());
|
||||
|
||||
this->show();
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include "ui_change_shift.h"
|
||||
#include "QtCore/qdatetime.h"
|
||||
|
||||
class change_shift : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
change_shift(QDialog *parent = Q_NULLPTR);
|
||||
~change_shift();
|
||||
|
||||
private:
|
||||
Ui::change_shift ui;
|
||||
|
||||
private slots:
|
||||
void on_pushButton_apply_released();
|
||||
|
||||
public slots:
|
||||
void recMsgFromDialogSetup(QTime timeA, QTime timeB, QTime timeC);
|
||||
|
||||
signals:
|
||||
void sendMsgToDialogSetup(QTime timeA, QTime timeB, QTime timeC);
|
||||
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,2 @@
|
||||
CONF_PATH=D:/conf-模型1
|
||||
SAVE_PICS_PATH=D:/image-中文测试
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue