Browse Source

Mekorot Step634

AGP
Evgeny Gagua at Mercury 6 years ago
parent
commit
6b46e90877
  1. 14
      Projects/MEKOROT/MEKOROT.cpp
  2. 51
      Projects/MEKOROT/MEKOROT_Kernel.cpp
  3. 5
      Projects/MEKOROT/MEKOROT_Kernel.h
  4. 2
      Projects/MEKOROT/mekorot.conf
  5. 3
      lib/data/media/video/videoAVLIBDestination.cpp

14
Projects/MEKOROT/MEKOROT.cpp

@ -2,7 +2,6 @@
//
#include "MEKOROT.h"
#define LOG( X ) m_pLog->Log( "main", NULL, X )
#define LOG_ERROR( X ) m_pLog->Log( "main", NULL, _LOG_ERROR, X )
@ -14,6 +13,8 @@ int main(){
config_setting_t * pSetting = NULL;
mekorotKernel * m_pKRNL;
fclose(stderr);
m_pCL = new objectConsoleLoggingService();
if ( m_pCL ) m_pLog->addHandler( m_pCL );
pSetting = config_setting_get_member( m_pSP, "USE_LOG_FILE" );
@ -64,14 +65,3 @@ int main(){
#undef LOG
#undef LOG_ERROR
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file

51
Projects/MEKOROT/MEKOROT_Kernel.cpp

@ -54,7 +54,7 @@ mekorotKernel::mekorotKernel(config_setting_t* ptr) : basicEngine(), basicThread
m_fCamTargetPan = m_fCamTargetTilt = m_fCamTargetZoom =
m_fHomePan = m_fHomeTilt = m_fHomeZoom =
m_fLeftZeroPan = m_fRightZeroPan = m_fHorizontalZeroPan = 0.f;
m_pZoomTable[0] = 0;
m_nLeftZeroShift = m_nCenterZeroShift = m_nRightZeroShift = 0;
m_bBringToHome = m_bUsePTZ = m_bRecordIsSaving = m_bRecordIsActive = false;
m_nCLoopMask = 0xFFFFFFFF;
@ -137,7 +137,19 @@ bool mekorotKernel::init(void){
config_setting_set_string(pSetting, m_pStorageBase);
basicSettingsProvider::getInstance()->compromise();
};
int tFrameCnt = MAX_RECORD_FRAMES;
pSetting = config_setting_get_member(m_pSettings, MEKOROT_KRNL_LAPSE_FRAMES);
if (pSetting != NULL) {
tFrameCnt = config_setting_get_int(pSetting);
} else {
pSetting = config_setting_add(m_pSettings, MEKOROT_KRNL_LAPSE_FRAMES, CONFIG_TYPE_INT);
basicSettingsProvider::getInstance()->compromise();
if (pSetting == NULL) {
LOG_ERROR("Failure while adding setting!");
return false;
};
config_setting_set_int(pSetting, tFrameCnt);
};
m_nInitialFSID = (uint32_t)time(NULL);
/* Storage Init */
m_pStorageProvider = storageProvider::getInstance( m_pStorageBase );
@ -148,7 +160,7 @@ bool mekorotKernel::init(void){
// m_bAssembleMP4 = false;
return false;
} else {
m_pVideoOutput->setFrameLapse( MAX_RECORD_FRAMES );
m_pVideoOutput->setFrameLapse(tFrameCnt);
};
pSetting = basicSettingsProvider::getInstance()->getSubNode(m_pSettings, (CSTR)KNL_SETTINGS_VIDEO_SECTION);
@ -213,6 +225,24 @@ bool mekorotKernel::init(void){
};
};
};
pSetting = basicSettingsProvider::getInstance()->getSubNode(m_pSettings, (CSTR)KNL_SETTINGS_ZOOM_TABLE_SECTION);
if (pSetting != NULL) {
m_nZoomTableCount = config_setting_length(pSetting);
if( m_nZoomTableCount ){
config_setting_t* tRec;
config_setting_t* ttRec;
for (int index = 0; index < m_nZoomTableCount; index++) {
tRec = config_setting_get_elem(pSetting, index);
if (tRec != NULL) {
double tVal;
if (!config_setting_lookup_float(tRec, KNL_SETTINGS_VIDEO_INPUT_FPS, &tVal)) tVal = 0;
m_pZoomTable[index] = tVal;
};
};
};
};
if (m_bHorizontal) {
m_nWidth = m_nWidth * m_nVideoInputs;
} else {
@ -504,6 +534,8 @@ void mekorotKernel::m_fThreadProc(void){
cTS = getMilliseconds();
if ((cTS - m_bOperationTO) > 1000) {
LOG_ERROR("FAILED TO COMMUNICATE WITH SENSOR");
m_bOperationTO = cTS;
if( m_nOperation > 1 ) m_nOperation = m_nOperation >> 1;
};
};
break;
@ -650,7 +682,7 @@ bool mekorotKernel::packetHandler(protocolPackage* Package) {
return true;// to erase data
};
void mekorotKernel::treat_alarm(uint8_t devID, uint16_t az, uint16_t ra, uint32_t wd) {
float rAz, rEl, rRange;
float rAz, rEl, rZoom;
uint16_t tAz, tRa;
switch (devID) {
case MEKOROT_DEV_LEFT: {
@ -671,7 +703,18 @@ void mekorotKernel::treat_alarm(uint8_t devID, uint16_t az, uint16_t ra, uint32_
rAz = m_fRightZeroPan;
break;
};
default: {
rEl = 0.f;
rAz = 0.f;
};
};
if (m_nZoomTableCount > 1) {
int idx = (ra * m_nZoomTableCount) / 4000;
rZoom = m_pZoomTable[idx];
} else {
rZoom = m_pZoomTable[0];
};
move_cam(rAz, rEl, rZoom);
};
void mekorotKernel::move_cam(float az, float el, float zoom){

5
Projects/MEKOROT/MEKOROT_Kernel.h

@ -16,6 +16,7 @@
#define MEKOROT_KRNL_SERIAL_LINE_TAG ((CSTR)"SERIAL_LINE")
#define MEKOROT_KRNL_SERIAL_SPEED_TAG ((CSTR)"SERIAL_SPEED")
#define MEKOROT_KRNL_LAPSE_FRAMES ((CSTR)"RECORD_FRAMES")
#define MEKOROT_KRNL_DEVICE_0_ID_TAG ((CSTR)"DEVICE_LEFT_ID")
#define MEKOROT_KRNL_DEVICE_1_ID_TAG ((CSTR)"DEVICE_CENTER_ID")
#define MEKOROT_KRNL_DEVICE_2_ID_TAG ((CSTR)"DEVICE_RIGHT_ID")
@ -38,6 +39,7 @@
#define KNL_SETTINGS_VIDEO_SCALE_WIDTH ((CSTR)"SCALE_WIDTH") // int
#define KNL_SETTINGS_VIDEO_SCALE_HEIGHT ((CSTR)"SCALE_HEIGHT") // int
#define KNL_SETTINGS_VIDEO_INPUT_FPS ((CSTR)"FPS") // float
#define KNL_SETTINGS_ZOOM_TABLE_SECTION ((CSTR)"ZOOM_TABLE")
#define MEKOROT_KRNL_STG_INIT 0
#define MEKOROT_KRNL_STG_CONNECT 1
@ -69,6 +71,7 @@
#define KERNEL_SLOW_SLEEP_TIME 1000 // msec
#define KERNEL_QUICK_SLEEP_TIME 50 // msec
#define MAX_ZOOM_TABLE_COUNT 32
class mekorotKernel: public basicEngine, public basicThread, public basicMediaDestination, public protocolLGS_CLIENT {
private:
@ -111,6 +114,8 @@ class mekorotKernel: public basicEngine, public basicThread, public basicMediaDe
bool m_bUsePTZ;
uint32_t m_nPtzMoveMatrix;
protocolPTZ_ONVIF * m_pPTZCTRL;
uint8_t m_nZoomTableCount;
float m_pZoomTable[MAX_ZOOM_TABLE_COUNT];
bool m_bBringToHome;
float m_fHomePan;
float m_fHomeTilt;

2
Projects/MEKOROT/mekorot.conf

@ -14,7 +14,7 @@ KERNEL :
{
INPUT_0 :
{
SOURCE = "rtsp://admin:4GetMyID@192.168.200.102:554/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif";
SOURCE = "artsp://admin:4GetMyID@192.168.200.102:554/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif";
PROFILE = "MediaProfile001";
WIDTH = 704;
HEIGHT = 576;

3
lib/data/media/video/videoAVLIBDestination.cpp

@ -525,6 +525,9 @@ void videoAVLIBDestination::pushFrame(cv::Mat *m_mFrame, void *src ){
m_pVideoState->m_bStatus = MS_STOPED;
return;
};
m_pFrame->width = m_nWidth;
m_pFrame->height = m_nHeight;
m_pFrame->format = VIDEO_OUTPUT_PIX_FMT;
avpicture_fill((AVPicture *)m_pFrame, m_pIn_buffer, VIDEO_OUTPUT_PIX_FMT, m_nWidth, m_nHeight);
};
int linesize[2];

Loading…
Cancel
Save