|
|
|
@ -27,7 +27,7 @@ bool getconchar(KEY_EVENT_RECORD& krec) { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
mekorotKernel::mekorotKernel(config_setting_t* ptr) : protocolLGS_CLIENT(), basicThread(), basicEngine() { |
|
|
|
mekorotKernel::mekorotKernel(config_setting_t* ptr) : basicEngine(), basicThread(), basicMediaDestination(), protocolLGS_CLIENT() { |
|
|
|
m_pLog = basicLogCollection::getInstance(); |
|
|
|
m_pSettings = basicSettingsProvider::getInstance()->getSubNode(ptr, (CSTR)"KERNEL"); |
|
|
|
m_bStage = MEKOROT_KRNL_STG_INIT; |
|
|
|
@ -237,5 +237,82 @@ bool mekorotKernel::packetHandler(protocolPackage* Package) { |
|
|
|
return true;// to erase data
|
|
|
|
}; |
|
|
|
|
|
|
|
void mekorotKernel::pushFrame(cv::Mat* Frame, void* src) { |
|
|
|
if (src == NULL) { |
|
|
|
return; |
|
|
|
}; |
|
|
|
if (m_nFrameCounter == 0) m_lStartTS = getMilliseconds(); |
|
|
|
m_nFrameCounter++; |
|
|
|
for (int index = 0; index < m_nVideoInputs; index++) { |
|
|
|
if (src == m_pVideoInputs[index]) { |
|
|
|
Frame->copyTo((*m_pVideoFrame[index])); |
|
|
|
m_nCLoopMask &= ~(1 << index); |
|
|
|
break; |
|
|
|
}; |
|
|
|
}; |
|
|
|
//If we get all frames;
|
|
|
|
if (m_pFinalFrame != NULL) { |
|
|
|
if ((m_nCLoopMask & m_nCLoopCheck) == 0) { |
|
|
|
int cx, cy; |
|
|
|
cx = 0; cy = 15; |
|
|
|
m_pMatProtector->lock(); |
|
|
|
//rectangle( (*m_pFinalFrame), Point(0,0), Point(m_nWidth, m_nHeight), Scalar(0,0,0), CV_FILLED );
|
|
|
|
for (int index = 0; index < m_nVideoInputs; index++) { |
|
|
|
if (m_bHorizontal) { |
|
|
|
m_pVideoFrame[index]->copyTo((*m_pFinalFrame)(cv::Rect(cx, cy, m_pVideoFrame[index]->cols, m_pVideoFrame[index]->rows))); |
|
|
|
cx += m_pVideoFrame[index]->cols; |
|
|
|
} |
|
|
|
else { |
|
|
|
m_pVideoFrame[index]->copyTo((*m_pFinalFrame)(cv::Rect(cx, cy, m_pVideoFrame[index]->cols, m_pVideoFrame[index]->rows))); |
|
|
|
cy += m_pVideoFrame[index]->rows; |
|
|
|
}; |
|
|
|
}; |
|
|
|
int X, W = 260; |
|
|
|
X = (m_pFinalFrame->cols - W) >> 1; |
|
|
|
//rectangle( (*m_pFinalFrame), Point( X, 10 ), Point( X+W, 25 ), Scalar( 0, 0, 0 ), CV_FILLED );
|
|
|
|
rectangle((*m_pFinalFrame), Point(0, 0), Point(m_pFinalFrame->cols, 15), Scalar(0, 0, 0), cv::FILLED); |
|
|
|
long long aMilliseconds = getMilliseconds(); |
|
|
|
long long tMilliseconds; |
|
|
|
float fps = 0.f; |
|
|
|
|
|
|
|
tMilliseconds = aMilliseconds - m_lStartTS; |
|
|
|
if (tMilliseconds > 0 && m_nVideoInputs > 0) { |
|
|
|
fps = ((float)(m_nFrameCounter / m_nVideoInputs) * 1000.f) / (float)tMilliseconds; |
|
|
|
}; |
|
|
|
|
|
|
|
char DateStr[200]; |
|
|
|
sprintf(DateStr, "TS:%010lu", tMilliseconds); |
|
|
|
putText((*m_pFinalFrame), DateStr, Point(X, 12), FONT_HERSHEY_SIMPLEX, .4, Scalar(0, 255, 255), 1); |
|
|
|
sprintf(DateStr, "FID:%06lu", m_nFrameCounter); |
|
|
|
putText((*m_pFinalFrame), DateStr, Point(X + 110, 12), FONT_HERSHEY_SIMPLEX, .4, Scalar(0, 255, 0), 1); |
|
|
|
sprintf(DateStr, "FPS:%03.2f", fps); |
|
|
|
putText((*m_pFinalFrame), DateStr, Point(X + 190, 12), FONT_HERSHEY_SIMPLEX, .4, Scalar(255, 0, 255), 1); |
|
|
|
|
|
|
|
if (m_bRecordIsActive) { |
|
|
|
rectangle((*m_pFinalFrame), Point(X + 260, 3), Point(X + 275, 12), Scalar(0, 0, 255), cv::FILLED); |
|
|
|
} |
|
|
|
else { |
|
|
|
rectangle((*m_pFinalFrame), Point(X + 260, 3), Point(X + 275, 12), Scalar(0, 255, 0), cv::FILLED); |
|
|
|
}; |
|
|
|
//if( m_bAssembleMP4 ) {
|
|
|
|
m_pVideoOutput->pushFrame(m_pFinalFrame); |
|
|
|
//};
|
|
|
|
m_pMatProtector->unlock(); |
|
|
|
// Assemble Final Frame;
|
|
|
|
m_nCLoopMask = 0xFFFFFFFF; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
bool mekorotKernel::copyFrame(cv::Mat& Frame) { |
|
|
|
if (m_pFinalFrame == NULL) return false; |
|
|
|
m_pMatProtector->lock(); |
|
|
|
if (m_pFinalFrame == NULL) return false; |
|
|
|
m_pFinalFrame->copyTo(Frame); |
|
|
|
m_pMatProtector->unlock(); |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
#undef LOG
|
|
|
|
#undef LOG_ERROR
|