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.
 
 
 
 
 
 

238 lines
9.3 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_sCameraInfo.m_iSourceType){
case 0:{
videoAVLIBSource *tSource;
videoAVLIBDestination *tRecorder;
tRecorder = new videoAVLIBDestination();
tSource = new videoAVLIBSource();
if (tSource == NULL){
return false;
};
if (tSource->_open((CSTR)m_sCameraInfo.m_pSourcePath, false, -1.f, m_sCameraInfo.m_iSourcePort, m_sCameraInfo.m_iWidth, m_sCameraInfo.m_iHeight)){
#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_sCameraInfo.m_pSourcePath, 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(mediaSourceInfo *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);
m_sCameraInfo.m_bOpticEna = true;
m_sCameraInfo.m_fFLMin = SI->FLMin;
m_sCameraInfo.m_fFLMax = SI->FLMax;
m_sCameraInfo.m_fFLCurrent = SI->FLMin;
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_sCameraInfo.m_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 );
m_sCameraInfo.m_bExpoEna = true;
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_EXPOSURE_ENA_AUTO, CONFIG_TYPE_BOOL);
config_setting_set_bool(pSetting, SI->bAutoExposure );
m_sCameraInfo.m_bAutoExposure = SI->bAutoExposure;
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_MANUAL_EXPOSURE_VAL, CONFIG_TYPE_FLOAT);
config_setting_set_float(pSetting, SI->fManualExposure);
m_sCameraInfo.m_fManualExposure = 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);
m_sCameraInfo.m_bFocusEna = true;
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_FOCUS_ENA_AUTO, CONFIG_TYPE_BOOL);
config_setting_set_bool(pSetting, SI->bAutoFocus);
m_sCameraInfo.m_bAutoFocus = SI->bAutoFocus;
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_FOCUS_MANUAL_VAL, CONFIG_TYPE_FLOAT);
config_setting_set_float(pSetting, SI->fManualFocus);
m_sCameraInfo.m_fManualFocus = 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);
m_sCameraInfo.m_bIrisEna = true;
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_IRIS_ENA_AUTO, CONFIG_TYPE_BOOL);
config_setting_set_bool(pSetting, SI->bAutoIris);
m_sCameraInfo.m_bAutoIris = SI->bAutoIris;
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_MANUAL_IRIS_VAL, CONFIG_TYPE_FLOAT);
config_setting_set_float(pSetting, SI->fManualIris);
m_sCameraInfo.m_fManualIris = 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);
m_sCameraInfo.m_bWBEna = true;
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_WB_ENA_AUTO, CONFIG_TYPE_BOOL);
config_setting_set_bool(pSetting, SI->bAutoWB);
m_sCameraInfo.m_bAutoWB = SI->bAutoWB;
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_WB_WB_VAL, CONFIG_TYPE_FLOAT);
config_setting_set_float(pSetting, SI->fManualWB);
m_sCameraInfo.m_fManualWB = 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