|
|
|
@ -38,6 +38,14 @@ mekorotKernel::mekorotKernel(config_setting_t* ptr) : basicEngine(), basicThread |
|
|
|
m_bDeviceFlags[0] = m_bDeviceFlags[1] = m_bDeviceFlags[2] = false; |
|
|
|
m_bDeviceTO[0] = m_bDeviceTO[1] = m_bDeviceTO[2] = 0; |
|
|
|
m_bDeviceAlarms[0] = m_bDeviceAlarms[1] = m_bDeviceAlarms[2] = false; |
|
|
|
m_pVideoOutput = NULL; |
|
|
|
m_pStorageBase = NULL; |
|
|
|
m_nVideoInputs = 0; |
|
|
|
m_nWidth = 320; |
|
|
|
m_nHeight = 240; |
|
|
|
m_bHorizontal = true; |
|
|
|
m_nCLoopMask = 0xFFFFFFFF; |
|
|
|
m_nCLoopCheck = 0; |
|
|
|
}; |
|
|
|
|
|
|
|
mekorotKernel::~mekorotKernel() { |
|
|
|
@ -109,6 +117,60 @@ bool mekorotKernel::init(void){ |
|
|
|
}; |
|
|
|
|
|
|
|
basicSettingsProvider::getInstance()->validate(); |
|
|
|
|
|
|
|
m_nInitialFSID = (uint32_t)time(NULL); |
|
|
|
/* Storage Init */ |
|
|
|
m_pStorageProvider = storageProvider::getInstance( m_pStorageBase ); |
|
|
|
|
|
|
|
m_pVideoOutput = new lapsedVideoRecorder(); |
|
|
|
if (m_pVideoOutput == NULL) { |
|
|
|
LOG_ERROR("TimeLapse Recorder on create Failure!"); |
|
|
|
// m_bAssembleMP4 = false;
|
|
|
|
return false; |
|
|
|
} else { |
|
|
|
m_pVideoOutput->setFrameLapse( MAX_RECORD_FRAMES ); |
|
|
|
}; |
|
|
|
|
|
|
|
pSetting = basicSettingsProvider::getInstance()->getSubNode(m_pSettings, KNL_SETTINGS_VIDEO_SECTION); |
|
|
|
int mCount = config_setting_length(pSetting); |
|
|
|
if (mCount) { |
|
|
|
char tBuffer[256]; |
|
|
|
sprintf(tBuffer, "Defined %d Video Input", mCount); |
|
|
|
LOG(tBuffer); |
|
|
|
m_pVideoNames = (CSTR*)calloc(mCount, sizeof(CSTR*)); |
|
|
|
for( int i=0; i < mCount; i++ ){ m_pVideoNames[i]= (CSTR) malloc(256); }; |
|
|
|
m_pVideoInputs = (basicMediaSource**)calloc(mCount, sizeof(basicMediaSource*)); |
|
|
|
m_pVideoFrame = (cv::Mat**) calloc(mCount, sizeof(cv::Mat*)); |
|
|
|
memset(m_pVideoInputs, 0, sizeof(m_pVideoInputs)); |
|
|
|
memset(m_pVideoFrame, 0, sizeof(m_pVideoFrame)); |
|
|
|
if (m_pVideoInputs != NULL) { |
|
|
|
config_setting_t* tRec; |
|
|
|
config_setting_t* ttRec; |
|
|
|
int tIID, tWIDTH, tHEIGHT, tSCALEW, tSCALEH; |
|
|
|
bool tSCALED; |
|
|
|
double tFPS; |
|
|
|
m_nVideoInputs = mCount; |
|
|
|
for (int index = 0; index < m_nVideoInputs; index++) { |
|
|
|
m_pVideoInputs[index] = (basicMediaSource*)new videoAVLIBSource(); |
|
|
|
if (!((videoAVLIBSource*)m_pVideoInputs[index])->_open(tBuffer, false, (float)tFPS, -1, tWIDTH, tHEIGHT, tSCALED, tSCALEW, tSCALEH)) { |
|
|
|
delete((videoAVLIBSource*)m_pVideoInputs[index]); |
|
|
|
m_pVideoInputs[index] = NULL; |
|
|
|
LOG_ERROR("Source Open Failure."); |
|
|
|
} else { |
|
|
|
if (tSCALED) { |
|
|
|
if (m_nWidth < tSCALEW) m_nWidth = tSCALEW; |
|
|
|
if (m_nHeight < tSCALEH) m_nHeight = tSCALEH; |
|
|
|
} else { |
|
|
|
if (m_nWidth < tWIDTH) m_nWidth = tWIDTH; |
|
|
|
if (m_nHeight < tHEIGHT) m_nHeight = tHEIGHT; |
|
|
|
}; |
|
|
|
m_pVideoFrame[index] = new cv::Mat(tHEIGHT, tWIDTH, CV_8UC3); |
|
|
|
m_pVideoInputs[index]->attachDestination(this); |
|
|
|
LOG("Source Opened OK."); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
m_bStage = MEKOROT_KRNL_STG_CONNECT; |
|
|
|
return basicThread::init(); |
|
|
|
}; |
|
|
|
@ -119,13 +181,26 @@ void mekorotKernel::m_fThreadProc(void){ |
|
|
|
KEY_EVENT_RECORD krec; |
|
|
|
if( getconchar(krec) ){ |
|
|
|
//Parse KeyBoard Input
|
|
|
|
char tBuffer[128]; |
|
|
|
sprintf(tBuffer, "Key Stroke Code: %d", krec.wVirtualKeyCode); |
|
|
|
LOG(tBuffer); |
|
|
|
if (krec.wVirtualKeyCode == 81 || krec.wVirtualKeyCode == 75) { // q Or k
|
|
|
|
LOG("Exit by Operator Request!"); |
|
|
|
m_bThreadStatus = TH_ENDED; |
|
|
|
continue; |
|
|
|
switch (krec.wVirtualKeyCode) { |
|
|
|
case 13: |
|
|
|
case 32: |
|
|
|
case 82:{ |
|
|
|
// 'r' Or 'spc' or 'etr' = Start/Stop video record
|
|
|
|
break; |
|
|
|
}; |
|
|
|
case 81: |
|
|
|
case 75: { |
|
|
|
// 'q' Or 'k' - Exit Application
|
|
|
|
LOG("Exit by Operator Request!"); |
|
|
|
m_bThreadStatus = TH_ENDED; |
|
|
|
continue; |
|
|
|
}; |
|
|
|
default: { |
|
|
|
char tBuffer[128]; |
|
|
|
sprintf(tBuffer, "Key Stroke Code: %d", krec.wVirtualKeyCode); |
|
|
|
LOG(tBuffer); |
|
|
|
break; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
switch( m_bStage ) { |
|
|
|
|