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.
287 lines
8.5 KiB
287 lines
8.5 KiB
#include "objectStaticCamera.h"
|
|
|
|
#define LOG(X) m_pLog->Log("objectStatic", this, X)
|
|
#define LOG_ERROR(X) m_pLog->Log("objectStatic", this, _LOG_ERROR, X)
|
|
|
|
objectStaticCamera::objectStaticCamera(config_setting_t * Settings) :
|
|
basicCamera(Settings)
|
|
{
|
|
m_pLog = basicLogCollection::getInstance();
|
|
}
|
|
|
|
objectStaticCamera::~objectStaticCamera()
|
|
{
|
|
if (m_pVideoSource != NULL)
|
|
{
|
|
delete((videoAVLIBSource *) m_pVideoSource);
|
|
}
|
|
}
|
|
|
|
bool objectStaticCamera::create(void)
|
|
{
|
|
if (m_pSettings == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
if (! basicCamera::create())
|
|
{
|
|
return false;
|
|
}
|
|
// init video
|
|
switch (m_sSourceInfo.type)
|
|
{
|
|
case 0:
|
|
{
|
|
videoAVLIBSource * tSource;
|
|
videoAVLIBDestination * tRecorder;
|
|
tRecorder = new videoAVLIBDestination();
|
|
tSource = new videoAVLIBSource();
|
|
if (tSource == NULL)
|
|
{
|
|
return false;
|
|
};
|
|
if (tSource->_open((CSTR) m_sSourceInfo.devicePath, false, -1.f, m_sSourceInfo.capturePin, m_sSourceInfo.width, m_sSourceInfo.height))
|
|
{
|
|
#ifndef NO_VIDEO_FILTERS
|
|
// Filter
|
|
switch (0)
|
|
{
|
|
case 1:
|
|
m_pVideoAnalyzer = new blobDetector();
|
|
if (m_pVideoAnalyzer != NULL)
|
|
{
|
|
//((blobDetector*)m_pVideoAnalyzer)->attachPTZ(this);
|
|
};
|
|
break;
|
|
case 2 : m_pVideoAnalyzer = new motionDetector(); break;
|
|
case 3 : m_pVideoAnalyzer = new opticalFlowDetector(); break;
|
|
case 4 : m_pVideoAnalyzer = new surfDetector(); break;
|
|
case 5 : m_pVideoAnalyzer = new vlfeatDetector(); break;
|
|
default: m_pVideoAnalyzer = NULL; break;
|
|
};
|
|
if (m_pVideoAnalyzer != NULL)
|
|
{
|
|
m_pVideoAnalyzer->attachDestination(m_pVideoNode);
|
|
m_pVideoAnalyzer->setStreaming(true);
|
|
m_pVideoAnalyzer->setPIP(false);
|
|
m_pVideoAnalyzer->init();
|
|
tSource->attachDestination(m_pVideoAnalyzer);
|
|
tSource->setStreaming(true);
|
|
}
|
|
else
|
|
#endif
|
|
{
|
|
// tNode->setTimeLapse(3000);
|
|
tSource->attachDestination(m_pVideoNode);
|
|
tSource->setStreaming(true);
|
|
};
|
|
m_pVideoSource = (basicMediaSource *) tSource;
|
|
m_pVideoNode->connect(tRecorder);
|
|
}
|
|
else
|
|
{
|
|
delete tRecorder;
|
|
delete tSource;
|
|
return false;
|
|
};
|
|
break;
|
|
};
|
|
case 1:
|
|
{
|
|
videoAVLIBSource * tSource;
|
|
videoAVLIBDestination * tRecorder;
|
|
tRecorder = new videoAVLIBDestination();
|
|
tSource = new videoAVLIBSource();
|
|
if (tSource == NULL)
|
|
{
|
|
return false;
|
|
};
|
|
if (tSource->_open((CSTR) m_sSourceInfo.devicePath, false))
|
|
{
|
|
#ifndef NO_VIDEO_FILTERS
|
|
// Filter
|
|
switch (0)
|
|
{
|
|
case 1:
|
|
m_pVideoAnalyzer = new blobDetector();
|
|
if (m_pVideoAnalyzer != NULL)
|
|
{
|
|
//((blobDetector*)m_pVideoAnalyzer)->attachPTZ(this);
|
|
};
|
|
break;
|
|
case 2 : m_pVideoAnalyzer = new motionDetector(); break;
|
|
case 3 : m_pVideoAnalyzer = new opticalFlowDetector(); break;
|
|
case 4 : m_pVideoAnalyzer = new surfDetector(); break;
|
|
case 5 : m_pVideoAnalyzer = new vlfeatDetector(); break;
|
|
default: m_pVideoAnalyzer = NULL; break;
|
|
};
|
|
if (m_pVideoAnalyzer != NULL)
|
|
{
|
|
m_pVideoAnalyzer->attachDestination(m_pVideoNode);
|
|
m_pVideoAnalyzer->setStreaming(true);
|
|
m_pVideoAnalyzer->setPIP(false);
|
|
m_pVideoAnalyzer->init();
|
|
tSource->attachDestination(m_pVideoAnalyzer);
|
|
tSource->setStreaming(true);
|
|
}
|
|
else
|
|
#endif
|
|
{
|
|
// tNode->setTimeLapse(3000);
|
|
tSource->attachDestination(m_pVideoNode);
|
|
tSource->setStreaming(true);
|
|
};
|
|
m_pVideoSource = (basicMediaSource *) tSource;
|
|
m_pVideoNode->connect(tRecorder);
|
|
}
|
|
else
|
|
{
|
|
delete tRecorder;
|
|
delete tSource;
|
|
return false;
|
|
};
|
|
break;
|
|
};
|
|
default: return false;
|
|
};
|
|
return true;
|
|
}
|
|
|
|
bool objectStaticCamera::create(SOURCE_INFO * SI)
|
|
{
|
|
/* This Method Only to Create New Instances */
|
|
if (m_pSettings == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
if (SI == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
if (basicCamera::create(SI))
|
|
{
|
|
config_setting_t * pSetting;
|
|
float tfVal;
|
|
int tiVal;
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_OPTIC_DATA_ENA, CONFIG_TYPE_BOOL);
|
|
if (pSetting == NULL)
|
|
{
|
|
LOG_ERROR("Some Trouble to create Camera Settings!");
|
|
return false;
|
|
};
|
|
if (SI->FLMin > 0 && SI->FLMax > 0)
|
|
{
|
|
config_setting_set_bool(pSetting, true);
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_OPTIC_FOCUS_LENGTH_MIN, CONFIG_TYPE_FLOAT);
|
|
config_setting_set_float(pSetting, SI->FLMin);
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_OPTIC_FOCUS_LENGTH_MAX, CONFIG_TYPE_FLOAT);
|
|
config_setting_set_float(pSetting, SI->FLMax);
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_OPTIC_FOCUS_LENGTH_CUR, CONFIG_TYPE_FLOAT);
|
|
config_setting_set_float(pSetting, SI->FLMin);
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_OPTIC_SENSOR_SIZE, CONFIG_TYPE_FLOAT);
|
|
config_setting_set_float(pSetting, SI->fSensorSize);
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_OPTIC_FOV, CONFIG_TYPE_FLOAT);
|
|
tfVal = calcFOV(SI->fSensorSize, SI->FLMin);
|
|
config_setting_set_float(pSetting, tfVal);
|
|
if (SI->FLMin != SI->FLMax)
|
|
{
|
|
// Zoom Ctrl is Enabled
|
|
m_sSourceInfo.bZoomEna = true;
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ENA_ZOOM_CTRL, CONFIG_TYPE_BOOL);
|
|
config_setting_set_bool(pSetting, true);
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ZOOM_MAX, CONFIG_TYPE_FLOAT);
|
|
tfVal = SI->FLMax / SI->FLMin;
|
|
config_setting_set_float(pSetting, tfVal);
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ZOOM_ENA_DIGITAL, CONFIG_TYPE_BOOL);
|
|
if (SI->fDigitalZoomMax > 0)
|
|
{
|
|
config_setting_set_bool(pSetting, true);
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ZOOM_DIGITAL_MAX, CONFIG_TYPE_FLOAT);
|
|
config_setting_set_float(pSetting, SI->fDigitalZoomMax);
|
|
}
|
|
else
|
|
{
|
|
config_setting_set_bool(pSetting, false);
|
|
};
|
|
};
|
|
}
|
|
else
|
|
{
|
|
config_setting_set_bool(pSetting, false);
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ENA_ZOOM_CTRL, CONFIG_TYPE_BOOL);
|
|
if (SI->fDigitalZoomMax > 0)
|
|
{
|
|
config_setting_set_bool(pSetting, true);
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ZOOM_MAX, CONFIG_TYPE_FLOAT);
|
|
tfVal = 1.f;
|
|
config_setting_set_float(pSetting, tfVal);
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ZOOM_DIGITAL_MAX, CONFIG_TYPE_FLOAT);
|
|
config_setting_set_float(pSetting, SI->fDigitalZoomMax);
|
|
}
|
|
else
|
|
{
|
|
config_setting_set_bool(pSetting, false);
|
|
};
|
|
};
|
|
if (SI->bAutoExposure || SI->fManualExposure > 0)
|
|
{
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ENA_EXPOSURE_CTRL, CONFIG_TYPE_BOOL);
|
|
config_setting_set_bool(pSetting, true);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_EXPOSURE_ENA_AUTO, CONFIG_TYPE_BOOL);
|
|
config_setting_set_bool(pSetting, SI->bAutoExposure);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_MANUAL_EXPOSURE_VAL, CONFIG_TYPE_FLOAT);
|
|
config_setting_set_float(pSetting, SI->fManualExposure);
|
|
};
|
|
if (SI->bAutoFocus || SI->fManualFocus > 0)
|
|
{
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ENA_FOCUS_CTRL, CONFIG_TYPE_BOOL);
|
|
config_setting_set_bool(pSetting, true);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_FOCUS_ENA_AUTO, CONFIG_TYPE_BOOL);
|
|
config_setting_set_bool(pSetting, SI->bAutoFocus);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_FOCUS_MANUAL_VAL, CONFIG_TYPE_FLOAT);
|
|
config_setting_set_float(pSetting, SI->fManualFocus);
|
|
};
|
|
if (SI->bAutoIris || SI->fManualIris > 0)
|
|
{
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ENA_IRIS_CTRL, CONFIG_TYPE_BOOL);
|
|
config_setting_set_bool(pSetting, true);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_IRIS_ENA_AUTO, CONFIG_TYPE_BOOL);
|
|
config_setting_set_bool(pSetting, SI->bAutoIris);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_MANUAL_IRIS_VAL, CONFIG_TYPE_FLOAT);
|
|
config_setting_set_float(pSetting, SI->fManualIris);
|
|
};
|
|
if (SI->bAutoWB || SI->fManualWB)
|
|
{
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ENA_WB_CTRL, CONFIG_TYPE_BOOL);
|
|
config_setting_set_bool(pSetting, true);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_WB_ENA_AUTO, CONFIG_TYPE_BOOL);
|
|
config_setting_set_bool(pSetting, SI->bAutoWB);
|
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_WB_WB_VAL, CONFIG_TYPE_FLOAT);
|
|
config_setting_set_float(pSetting, SI->fManualWB);
|
|
};
|
|
return create();
|
|
};
|
|
return false;
|
|
}
|
|
|
|
void objectStaticCamera::updateSettings(void)
|
|
{
|
|
if (! m_pSettings)
|
|
{
|
|
return;
|
|
}
|
|
basicCamera::updateSettings();
|
|
}
|
|
|
|
void objectStaticCamera::dispatchEvent(basicEvent * Evt) {}
|
|
|
|
#undef LOG
|
|
#undef ERROR_LOG
|