You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.7 KiB
77 lines
1.7 KiB
#include "basicVideoAnalyzer.h"
|
|
|
|
basicVideoAnalyzer::basicVideoAnalyzer() :
|
|
basicThread(),
|
|
basicMediaDestination(),
|
|
basicMediaSource(),
|
|
m_mBufferProtectorMutex()
|
|
{
|
|
m_bDetectionStatus = false;
|
|
m_bDataIsActive = false;
|
|
m_pLog = basicLogCollection::getInstance();
|
|
m_pEventHeap = basicEventHeap::getInstance();
|
|
}
|
|
|
|
basicVideoAnalyzer::~basicVideoAnalyzer()
|
|
{
|
|
m_mBufferProtectorMutex.lock();
|
|
m_bDataIsActive = false;
|
|
waitThreadEnd(true);
|
|
m_mBufferProtectorMutex.unlock();
|
|
}
|
|
|
|
void basicVideoAnalyzer::m_fThreadProc(void)
|
|
{
|
|
int RetVal;
|
|
m_bThreadStatus = TH_WORKING;
|
|
pthread_setname_np(pthread_self(), "basicVideoAnalizer");
|
|
while (m_bThreadStatus < TH_ENDED)
|
|
{
|
|
while (! m_bDataIsActive && m_bThreadStatus < TH_ENDED)
|
|
{
|
|
SLEEP(1);
|
|
}
|
|
if (m_bThreadStatus < TH_ENDED)
|
|
{
|
|
m_mBufferProtectorMutex.lock();
|
|
m_bDetectionStatus = m_fImageAnalyzer(m_oWorkingMat);
|
|
m_bDataIsActive = false;
|
|
m_mBufferProtectorMutex.unlock();
|
|
};
|
|
};
|
|
}
|
|
|
|
void basicVideoAnalyzer::pushFrame(cv::Mat * Frame)
|
|
{
|
|
Mat mOutputMap;
|
|
if (m_mBufferProtectorMutex.try_lock())
|
|
{
|
|
m_oWorkingMat.copyTo(mOutputMap);
|
|
Frame->copyTo(m_oWorkingMat);
|
|
// cvtColor(*Frame, *Frame, CV_BGR2RGB);
|
|
if (! mOutputMap.empty())
|
|
{
|
|
markup(mOutputMap);
|
|
}
|
|
m_bDataIsActive = true;
|
|
m_mBufferProtectorMutex.unlock();
|
|
if (m_bDetectionStatus)
|
|
{
|
|
// markup(*Frame);
|
|
/* Generate Event */
|
|
basicEvent * tEvt;
|
|
tEvt = createVAEvent(true); // EVT_CLASS_VIDEO, EVT_ALARM, "Motion Detected");
|
|
if (tEvt != NULL)
|
|
{
|
|
m_pEventHeap->broadcast(tEvt);
|
|
}
|
|
};
|
|
};
|
|
if (! mOutputMap.empty())
|
|
{
|
|
if (m_pMediaDestination != NULL)
|
|
{
|
|
m_pMediaDestination->pushFrame(&mOutputMap);
|
|
}
|
|
}
|
|
}
|