|
|
|
|
|
/******************************************************************************
|
|
|
|
|
|
Copyright(C):2015~2018 hzleaper
|
|
|
|
|
|
FileName:qtpthreadimage.cpp
|
|
|
|
|
|
Author:zhikun wu
|
|
|
|
|
|
Email:zk.wu@hzleaper.com
|
|
|
|
|
|
Tools:vs2010 pc on company
|
|
|
|
|
|
Created:2015/03/26
|
|
|
|
|
|
History:26:3:2015 17:10
|
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
#include "qtpthreadimage.h"
|
|
|
|
|
|
#include "globalCoreCtrl.h"
|
|
|
|
|
|
#include "CoreCtrl.h"
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
|
|
|
|
QTpThreadImage::QTpThreadImage(class CCoreCtrl* pCtrl, class IDetectorEngine* pDE /*= NULL*/,QObject *parent /* = NULL */)
|
|
|
|
|
|
: QTpThreadBase(parent)
|
|
|
|
|
|
, m_pCoreCtrl(pCtrl)
|
|
|
|
|
|
, m_objImage(pCtrl)
|
|
|
|
|
|
, m_pDE(pDE)
|
|
|
|
|
|
{
|
|
|
|
|
|
// LOG_SPIDER::InitLog("", "log.txt");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QTpThreadImage::~QTpThreadImage()
|
|
|
|
|
|
{
|
|
|
|
|
|
LOG_SPIDER::FreeLog();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool QTpThreadImage::loop()
|
|
|
|
|
|
{
|
|
|
|
|
|
QTime timespan;
|
|
|
|
|
|
|
|
|
|
|
|
timespan.start();
|
|
|
|
|
|
CZkCameraImage* pCamImage = glpCameralPool->IPopCameraImage();
|
|
|
|
|
|
int span = timespan.elapsed();
|
|
|
|
|
|
if (span > 100)
|
|
|
|
|
|
{
|
|
|
|
|
|
qWarning() << "Pop image from poll cost " << span << " MSecs"
|
|
|
|
|
|
<< " - " __FUNCTION__;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( NULL != pCamImage )
|
|
|
|
|
|
{
|
|
|
|
|
|
{
|
|
|
|
|
|
// send image to UI
|
|
|
|
|
|
timespan.restart();
|
|
|
|
|
|
m_pCoreCtrl->ShowCameraImage(pCamImage->Serial()
|
|
|
|
|
|
, pCamImage->FrameNumber()
|
|
|
|
|
|
, pCamImage->ToQImage()
|
|
|
|
|
|
, pCamImage->Stamp()
|
|
|
|
|
|
, 0
|
|
|
|
|
|
, QString::fromUtf8(pCamImage->FileName()));//(pCamImage);
|
|
|
|
|
|
|
|
|
|
|
|
qDebug() << "Show camera image to UI cost " << timespan.elapsed() << " MSecs"
|
|
|
|
|
|
<< " - " __FUNCTION__;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
// Algorithm process image
|
|
|
|
|
|
timespan.restart();
|
|
|
|
|
|
m_objImage.SetCameraImage(pCamImage);
|
|
|
|
|
|
glpImgProc->IImageProcess(&m_objImage, m_pDE);
|
|
|
|
|
|
qDebug() << "Process Image(ID:" << pCamImage->FrameNumber()
|
|
|
|
|
|
<< ") cost " << timespan.elapsed() << " MSecs"
|
|
|
|
|
|
<< " - " __FUNCTION__;
|
|
|
|
|
|
}
|
|
|
|
|
|
//release CameraImage
|
|
|
|
|
|
m_objImage.SetCameraImage(NULL);
|
|
|
|
|
|
glpCameralPool->IFreeCameraImage(pCamImage);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
QTpThreadBase::loop();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|