Browse Source

Mekorot step

AGP
Evgeny Gagua at Mercury 6 years ago
parent
commit
d16b0e14ee
  1. 2
      Projects/MEKOROT/MEKOROT.vcxproj
  2. 79
      Projects/MEKOROT/MEKOROT_Kernel.cpp
  3. 31
      Projects/MEKOROT/MEKOROT_Kernel.h
  4. 2
      Projects/MEKOROT/mekorot.conf

2
Projects/MEKOROT/MEKOROT.vcxproj

@ -113,7 +113,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>opencv_core440d.lib;libcurl_a_debug.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>opencv_core440d.lib;opencv_imgproc440d.lib;libcurl_a_debug.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

79
Projects/MEKOROT/MEKOROT_Kernel.cpp

@ -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

31
Projects/MEKOROT/MEKOROT_Kernel.h

@ -1,11 +1,17 @@
#ifndef __MEKOROT_KERNEL_HEADER__
#define __MEKOROT_KERNEL_HEADER__
#include "../../lib/components/base/basicEngine.h"
#include "../../lib/components/base/basicLogCollection.h"
#include "../../lib/components/base/basicMediaDestination.h"
#include "../../lib/components/base/basicSettingsProvider.h"
#include "../../lib/components/base/basicEngine.h"
#include "../../lib/components/base/basicThread.h"
#include "../../lib/data/media/lapsedVideoRecorder.h"
#include "../../lib/data/media/videoNode.h"
#include "../../lib/data/media/video/videoAVLIBSource.h"
//#include "../../lib/data/media/video/videoV4L2Source.h"
#include "../../lib/data/protocol/protocolLGS.h"
#include "../../lib/data/storage/storageProvider.h"
#include "../../lib/hardware/uart/serialPort.h"
#define MEKOROT_KRNL_SERIAL_LINE_TAG "SERIAL_LINE"
@ -22,7 +28,7 @@
#define KERNEL_SLOW_SLEEP_TIME 1000 // msec
#define KERNEL_QUICK_SLEEP_TIME 50 // msec
class mekorotKernel: public protocolLGS_CLIENT, public basicThread, basicEngine {
class mekorotKernel: public basicEngine, public basicThread, public basicMediaDestination, public protocolLGS_CLIENT {
private:
basicLogCollection *m_pLog;
config_setting_t *m_pSettings;
@ -34,6 +40,24 @@ class mekorotKernel: public protocolLGS_CLIENT, public basicThread, basicEngine
unsigned long long m_bDeviceTO[3];
bool m_bDeviceFlags[3];
bool m_bDeviceAlarms[3];
int m_nVideoInputs;
basicMediaSource ** m_pVideoInputs;
lapsedVideoRecorder * m_pVideoOutput;
uint32_t m_nInitialFSID;
uint32_t m_nRecordCounter;
uint32_t m_nFrameCounter;
basicMutex * m_pMatProtector;
cv::Mat * m_pFinalFrame;
cv::Mat ** m_pVideoFrame;
bool m_bHorizontal;
bool m_bRecordIsActive;
bool m_bRecordIsSaving;
long long m_lStartTS;
uint32_t m_nCLoopMask;
uint32_t m_nCLoopCheck;
protected:
void m_fThreadProc(void);
virtual bool packetHandler(protocolPackage* Package);
@ -41,7 +65,8 @@ class mekorotKernel: public protocolLGS_CLIENT, public basicThread, basicEngine
explicit mekorotKernel( config_setting_t *ptr=NULL );
virtual ~mekorotKernel();
virtual bool init(void);
virtual void pushFrame(cv::Mat* Frame, void* src = NULL);
bool copyFrame(cv::Mat& Frame);
};
#endif

2
Projects/MEKOROT/mekorot.conf

@ -5,7 +5,7 @@ GENERAL :
};
KERNEL :
{
SERIAL_LINE = "\\\\.\\COM2";
SERIAL_LINE = "\\\\.\\COM1";
SERIAL_SPEED = 19200;
DEVICE_LEFT_ID = 0;
DEVICE_CENTER_ID = -1;

Loading…
Cancel
Save