52 changed files with 2545 additions and 1047 deletions
-
10Projects/argus/argus.vpj
-
1Projects/argus/debug
-
136Projects/argus/makefile
-
2lib/App/argus/ArgusBackend.cpp
-
64lib/alg/generic/Transform.cpp
-
4lib/alg/generic/Transform.h
-
28lib/components/base/basicCameraInfo.cpp
-
6lib/components/base/basicCameraInfo.h
-
10lib/components/base/basicEvent.cpp
-
11lib/components/base/basicEvent.h
-
8lib/components/base/basicEventHandler.cpp
-
5lib/components/base/basicEventHandler.h
-
28lib/components/base/basicEventHeap.cpp
-
46lib/components/base/basicEventHeap.h
-
6lib/components/base/basicFunctionality.cpp
-
23lib/components/base/basicPosition.cpp
-
74lib/components/object/objectSystemAnchor.cpp
-
2lib/data/net/netClientHandler.h
-
62lib/data/ponvif/ponvif.cpp
-
11lib/data/ponvif/ponvif.h
-
17lib/data/protocol/protocolPTZ.h
-
33lib/data/protocol/protocolPTZ_ONVIF.cpp
-
2lib/data/protocol/protocolPTZ_ONVIF.h
-
2lib/data/protocol/protocolPTZ_PELCO.cpp
-
2lib/data/protocol/protocolPTZ_PELCO.h
-
2lib/data/protocol/protocolPTZ_VISCA.cpp
-
2lib/data/protocol/protocolPTZ_VISCA.h
-
28lib/hardware/sensors/lrf/lrf_3d.cpp
-
657lib/rgoose/rgooseCamera.cpp
-
92lib/rgoose/rgooseCamera.h
-
273lib/rgoose/rgooseDBConnector.cpp
-
62lib/rgoose/rgooseDBConnector.h
-
176lib/rgoose/rgooseFilterAPF.cpp
-
39lib/rgoose/rgooseFilterAPF.h
-
2lib/rgoose/rgooseHardwareManager.cpp
-
2lib/rgoose/rgooseKafkaModule.cpp
-
142lib/rgoose/rgooseKernel.cpp
-
21lib/rgoose/rgooseKernel.h
-
2lib/rgoose/rgooseModule.cpp
-
26lib/rgoose/rgooseModuleFlyHunter.cpp
-
21lib/rgoose/rgooseNode.cpp
-
13lib/rgoose/rgooseNode.h
-
88lib/rgoose/rgooseNode2D.cpp
-
2lib/rgoose/rgooseNode3D.cpp
-
10lib/rgoose/rgooseNodeFactory.cpp
-
394lib/rgoose/rgooseNodePTZCamControl.cpp
-
57lib/rgoose/rgooseNodePTZCamControl.h
-
26lib/rgoose/rgooseTargetFilter.cpp
-
32lib/rgoose/rgooseTargetFilter.h
-
345lib/rgoose/rgooseTypes.h
-
424lib/rgoose/rgooseZLMediaModule.cpp
-
61lib/rgoose/rgooseZLMediaModule.h
@ -0,0 +1 @@ |
|||||
|
(gdb) set follow-fork-mode child |
||||
@ -1,18 +1,34 @@ |
|||||
#include "basicCameraInfo.h"
|
#include "basicCameraInfo.h"
|
||||
|
|
||||
float calcFOV(float SensorSize, float FN){ |
|
||||
|
float calcFOV_inch(float SensorSize, float FN){ |
||||
/*
|
/*
|
||||
The calculator below converts between the focal length f and the field of view (FOV) of a rectilinear lens. |
The calculator below converts between the focal length f and the field of view (FOV) of a rectilinear lens. |
||||
The formula that it implements is FOV = 2 arctan (x / (2 f)), where x is the diagonal of the film. |
The formula that it implements is FOV = 2 arctan (x / (2 f)), where x is the diagonal of the film. |
||||
The FOV is measured across the frame's diagonal, and is therefore smaller across the horizontal dimension, |
The FOV is measured across the frame's diagonal, and is therefore smaller across the horizontal dimension, |
||||
and even smaller across the vertical dimension. |
and even smaller across the vertical dimension. |
||||
*/ |
*/ |
||||
return 2.f * atanf((SensorSize * 25.4f) / (2.f * FN)); |
|
||||
|
return 2.0f * atanf((SensorSize * 25.4f) / (2.0f * FN)); |
||||
|
}; |
||||
|
float calcFOV_mm(float SensorSize, float FN){ |
||||
|
/*
|
||||
|
The calculator below converts between the focal length f and the field of view (FOV) of a rectilinear lens. |
||||
|
The formula that it implements is FOV = 2 arctan (x / (2 f)), where x is the diagonal of the film. |
||||
|
The FOV is measured across the frame's diagonal, and is therefore smaller across the horizontal dimension, |
||||
|
and even smaller across the vertical dimension. |
||||
|
*/ |
||||
|
return 2.0f * atanf( SensorSize / (2.0f * FN)); |
||||
|
}; |
||||
|
|
||||
|
float calcMaxDistance_inch( float SensorSize, float MaxFL, int ImageWidth ){ |
||||
|
float tFOV, tt; |
||||
|
tFOV = calcFOV_inch( SensorSize, MaxFL); |
||||
|
tt = tFOV / ((float)ImageWidth); // 1 pixel
|
||||
|
return .1 / tanf( tt / 2.0f ); // return Distance in meters to see 1 cm as 1 pixel
|
||||
}; |
}; |
||||
|
|
||||
float calcMaxDistance(float SensorSize, float MaxFL, int ImageWidth ){ |
|
||||
double tFOV, tt; |
|
||||
tFOV = calcFOV(SensorSize, MaxFL); |
|
||||
|
float calcMaxDistance_mm( float SensorSize, float MaxFL, int ImageWidth ){ |
||||
|
float tFOV, tt; |
||||
|
tFOV = calcFOV_mm( SensorSize, MaxFL); |
||||
tt = tFOV / ((float)ImageWidth); // 1 pixel
|
tt = tFOV / ((float)ImageWidth); // 1 pixel
|
||||
return .01 / tan(tt / 2.0); // return Distance in meters to see 1 cm as 1 pixel
|
|
||||
|
return .1 / tanf( tt / 2.0f ); // return Distance in meters to see 1 cm as 1 pixel
|
||||
}; |
}; |
||||
@ -1,10 +1,12 @@ |
|||||
#include "basicEventHandler.h"
|
#include "basicEventHandler.h"
|
||||
#include "basicEventHeap.h"
|
#include "basicEventHeap.h"
|
||||
|
|
||||
// Constructor implementation
|
// Constructor implementation
|
||||
basicEventHandler::basicEventHandler( bool atBottom ){ |
|
||||
basicEventHeap::getInstance()->addHandler(this, atBottom); |
|
||||
|
basicEventHandler::basicEventHandler(){ |
||||
|
basicEventHeap::getInstance()->addHandler( this, false ); |
||||
}; |
}; |
||||
// Destructor implementation
|
// Destructor implementation
|
||||
basicEventHandler::~basicEventHandler(){ |
basicEventHandler::~basicEventHandler(){ |
||||
basicEventHeap::getInstance()->removeHandler(this); |
|
||||
|
basicEventHeap::getInstance()->removeHandler( this ); |
||||
}; |
}; |
||||
|
|
||||
@ -0,0 +1,176 @@ |
|||||
|
#include "rgooseFilterAPF.h"
|
||||
|
|
||||
|
#define LOG( X ) m_pLog->Log( "APF", this, X )
|
||||
|
#ifdef DEBUG
|
||||
|
#define LOG_ERROR( X ) {\
|
||||
|
char _tBfrErrMSG2w34[256];\ |
||||
|
sprintf( _tBfrErrMSG2w34, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\ |
||||
|
m_pLog->Log( "APF", this, _LOG_ERROR, _tBfrErrMSG2w34 );\ |
||||
|
} |
||||
|
#else
|
||||
|
#define LOG_ERROR( X ) m_pLog->Log( "APF", this, _LOG_ERROR, X );
|
||||
|
#endif
|
||||
|
|
||||
|
ARGUS_APF::ARGUS_APF( uint32_t id ):ARGUS_TARGET_FILTER( id ), basicThread() { |
||||
|
m_iSocketFD = -1; |
||||
|
m_pLog = basicLogCollection::getInstance(); |
||||
|
m_pPosition = new basicPosition(); |
||||
|
m_fDeltaX = 0.5f; |
||||
|
m_fDeltaY = 0.5f; |
||||
|
m_fDeltaZ = 1.0f; |
||||
|
|
||||
|
memset( &m_Settings, 0, sizeof(DBC_APF_DATA)); |
||||
|
DBC_APF_DATA *tData = m_pDBC->getAPFData( m_nDBID ); |
||||
|
if( tData != NULL ) { |
||||
|
memcpy( &m_Settings, tData, sizeof(DBC_APF_DATA)); |
||||
|
free( tData ); |
||||
|
}; |
||||
|
}; |
||||
|
|
||||
|
ARGUS_APF::~ARGUS_APF(){ |
||||
|
stopFilter(); |
||||
|
}; |
||||
|
|
||||
|
bool ARGUS_APF::initFilter(){ |
||||
|
#ifdef DEBUG
|
||||
|
LOG("Init Started"); |
||||
|
#endif
|
||||
|
struct sockaddr_in servaddr; |
||||
|
|
||||
|
// Creating socket file descriptor
|
||||
|
if(( m_iSocketFD = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ){ |
||||
|
LOG_ERROR("socket creation failed"); |
||||
|
return false; |
||||
|
}; |
||||
|
memset(&servaddr, 0, sizeof(servaddr)); |
||||
|
|
||||
|
// Filling server information
|
||||
|
servaddr.sin_family = AF_INET; // IPv4
|
||||
|
servaddr.sin_addr.s_addr = INADDR_ANY; |
||||
|
servaddr.sin_port = htons( m_Settings.port ); |
||||
|
|
||||
|
// Bind the socket with the server address
|
||||
|
if( bind(m_iSocketFD, (const struct sockaddr *)&servaddr, sizeof(servaddr)) < 0 ){ |
||||
|
LOG_ERROR( "bind failed" ); |
||||
|
return false; |
||||
|
}; |
||||
|
|
||||
|
#ifdef DEBUG
|
||||
|
LOG("UDP PORT LISTEN"); |
||||
|
#endif
|
||||
|
if( m_pPosition ) { |
||||
|
m_pPosition->setPositionDeg( m_Settings.lat, m_Settings.lon, m_Settings.alt, m_Settings.roll, m_Settings.pitch, m_Settings.yaw, 0.f ); |
||||
|
return init(); |
||||
|
}; |
||||
|
LOG_ERROR( "POSITION ERROR!" ); |
||||
|
stopFilter(); |
||||
|
return false; |
||||
|
}; |
||||
|
|
||||
|
bool ARGUS_APF::stopFilter(){ |
||||
|
m_bActive = false; |
||||
|
waitThreadEnd( true ); |
||||
|
if( m_iSocketFD > -1 ){ |
||||
|
shutdown( m_iSocketFD, 2 ); |
||||
|
}; |
||||
|
if( m_vBounds.size() ) { |
||||
|
for( V_BOUNDS::iterator idx = m_vBounds.begin(); idx < m_vBounds.end(); idx++ ) { |
||||
|
free( *idx ); |
||||
|
}; |
||||
|
m_vBounds.clear(); |
||||
|
}; |
||||
|
return true; |
||||
|
}; |
||||
|
|
||||
|
bool ARGUS_APF::validateTarget( uint32_t DevID, TARGET_DATA *ptr ){ |
||||
|
if( m_bActive ) { |
||||
|
if( m_vBounds.size() > 0 ) { |
||||
|
for( V_BOUNDS::iterator idx = m_vBounds.begin(); idx < m_vBounds.end(); idx++ ) { |
||||
|
bool X,Y,Z; |
||||
|
#ifdef DEBUG
|
||||
|
char tBuf[100]; |
||||
|
// COMP: -41.34x-9.50x-6.18 <> -41.78x-8.50x-15.87
|
||||
|
sprintf( tBuf,"COMP: %0.2fx%0.2fx%0.2f <> %0.2fx%0.2fx%0.2f", ptr->system_target.x, ptr->system_target.y, ptr->system_target.z, (*idx)->position.x, (*idx)->position.y, (*idx)->position.z ); |
||||
|
LOG( tBuf ); |
||||
|
#endif
|
||||
|
X = ( ptr->system_target.x < (*idx)->position.x+m_fDeltaX ) && ( ptr->system_target.x > (*idx)->position.x-m_fDeltaX ); |
||||
|
Y = ( ptr->system_target.y < (*idx)->position.y+m_fDeltaY ) && ( ptr->system_target.y > (*idx)->position.y-m_fDeltaY ); |
||||
|
Z = ( ptr->system_target.z < (*idx)->position.z+m_fDeltaZ ) && ( ptr->system_target.z > (*idx)->position.z-m_fDeltaZ ); |
||||
|
if( X && Y && Z ) return false; |
||||
|
}; |
||||
|
}; |
||||
|
}; |
||||
|
return true; |
||||
|
}; |
||||
|
|
||||
|
APF_BOUNDARY *ARGUS_APF::getBoxByID( CSTR id ){ |
||||
|
if( m_vBounds.size() ) { |
||||
|
for( V_BOUNDS::iterator idx = m_vBounds.begin(); idx < m_vBounds.end(); idx++ ) { |
||||
|
if( strstr( (*idx)->idc, id )!= NULL ){ |
||||
|
return (*idx); |
||||
|
}; |
||||
|
}; |
||||
|
}; |
||||
|
return NULL; |
||||
|
}; |
||||
|
void ARGUS_APF::m_fThreadProc( void ){ |
||||
|
struct sockaddr_in CA; |
||||
|
socklen_t caLen; |
||||
|
int dLen; |
||||
|
char inBuff[1024]; |
||||
|
|
||||
|
caLen = sizeof(CA); |
||||
|
memset(&CA, 0, caLen); |
||||
|
m_bActive = true; |
||||
|
m_bThreadStatus = TH_WORKING; |
||||
|
while (m_bThreadStatus < TH_ENDED) { |
||||
|
memset( inBuff, 0, 1024 ); |
||||
|
dLen = recvfrom( m_iSocketFD, (char *)inBuff, 1024, MSG_WAITALL, ( struct sockaddr *) &CA, &caLen ); |
||||
|
if( dLen < 0 ) { |
||||
|
m_bThreadStatus = TH_ENDED; |
||||
|
LOG_ERROR( "RECV error!"); |
||||
|
continue; |
||||
|
}; |
||||
|
//char tB[128];
|
||||
|
//LOG( inBuff );
|
||||
|
//sprintf( tB, "Received %d Bytes", dLen );
|
||||
|
//LOG( tB );
|
||||
|
if( strstr( inBuff, "display:" ) != NULL ) { |
||||
|
CSTR PACK = inBuff+8; |
||||
|
CArray *Parts; |
||||
|
if( m_pPosition == NULL ) continue; |
||||
|
Parts = explode( ',', PACK ); |
||||
|
if( Parts != NULL ) { |
||||
|
APF_BOUNDARY * tBOX; |
||||
|
tBOX = getBoxByID( (*Parts)[1] ); |
||||
|
if( tBOX == NULL ) { |
||||
|
tBOX = (APF_BOUNDARY *) malloc( sizeof(APF_BOUNDARY)); |
||||
|
memset( tBOX, 0, sizeof(APF_BOUNDARY) ); |
||||
|
strncpy( tBOX->idc, (*Parts)[1], 16 ); |
||||
|
m_vBounds.push_back( tBOX ); |
||||
|
}; |
||||
|
systemAnchor* tSystem = systemAnchor::getInstance(); |
||||
|
if( tSystem != NULL ) { |
||||
|
C3D_DECART tDecart; |
||||
|
//C3D_SPH_DEGREES
|
||||
|
C3D_SPH_RADIANS tSpherical; |
||||
|
tDecart.x = atof( (*Parts)[6] );//Y
|
||||
|
tDecart.y = atof( (*Parts)[5] );//X
|
||||
|
tDecart.z = atof( (*Parts)[7] );//Z
|
||||
|
decart2spherical( tDecart, tSpherical ); |
||||
|
tSystem->convertToSystem( m_pPosition, tSpherical, tBOX->position ); |
||||
|
m_pDBC->updateAFPBox( m_nDBID, (*Parts)[1], tDecart.x, tDecart.y, tDecart.z ); |
||||
|
} else { |
||||
|
LOG_ERROR("No SYSTEM ANCHOR!"); |
||||
|
} |
||||
|
delete( Parts ); |
||||
|
}; |
||||
|
}; |
||||
|
SLEEP( 2 ); |
||||
|
}; |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
#undef LOG
|
||||
|
#undef LOG_ERROR
|
||||
|
|
||||
@ -0,0 +1,39 @@ |
|||||
|
#ifndef __ARGUS_TARGET_FILTER_APF_HEADER__ |
||||
|
#define __ARGUS_TARGET_FILTER_APF_HEADER__ |
||||
|
|
||||
|
#include "rgooseTargetFilter.h" |
||||
|
#include "../components/object/objectSystemAnchor.h" |
||||
|
#include "../components/base/basicThread.h" |
||||
|
|
||||
|
typedef struct S_APF_BOUNDARY{ |
||||
|
char idc[16]; |
||||
|
C3D_DECART position; |
||||
|
}APF_BOUNDARY; |
||||
|
|
||||
|
typedef vector<APF_BOUNDARY *> V_BOUNDS; |
||||
|
|
||||
|
class ARGUS_APF: public ARGUS_TARGET_FILTER, public basicThread{ |
||||
|
private: |
||||
|
basicLogCollection * m_pLog; |
||||
|
basicPosition * m_pPosition; |
||||
|
int m_iSocketFD; |
||||
|
V_BOUNDS m_vBounds; |
||||
|
DBC_APF_DATA m_Settings; |
||||
|
|
||||
|
/* CUBE DEFENITION IN METERS */ |
||||
|
float m_fDeltaX; |
||||
|
float m_fDeltaY; |
||||
|
float m_fDeltaZ; |
||||
|
|
||||
|
APF_BOUNDARY * getBoxByID( CSTR id ); |
||||
|
protected: |
||||
|
virtual void m_fThreadProc( void ); |
||||
|
public: |
||||
|
explicit ARGUS_APF( uint32_t id ); |
||||
|
virtual ~ARGUS_APF(); |
||||
|
virtual bool initFilter(); |
||||
|
virtual bool stopFilter(); |
||||
|
virtual bool validateTarget( uint32_t DevID, TARGET_DATA *ptr ); |
||||
|
}; |
||||
|
|
||||
|
#endif |
||||
@ -1,319 +1,147 @@ |
|||||
#include "rgooseNodePTZCamControl.h"
|
#include "rgooseNodePTZCamControl.h"
|
||||
|
|
||||
#include "../hardware/uart/serialPort.h"
|
|
||||
#include "../hardware/uart/serialSOL.h"
|
|
||||
|
|
||||
#include "../data/protocol/protocolPTZ_VISCA.h"
|
|
||||
#include "../data/protocol/protocolPTZ_ONVIF.h"
|
|
||||
#include "../data/protocol/protocolPTZ_PELCO.h"
|
|
||||
|
|
||||
#define LOG( X ) m_pLog->Log( "PTZ_CAM", this, X )
|
#define LOG( X ) m_pLog->Log( "PTZ_CAM", this, X )
|
||||
#define LOG_ERROR( X ) m_pLog->Log( "PTZ_CAM", this, _LOG_ERROR, X )
|
#define LOG_ERROR( X ) m_pLog->Log( "PTZ_CAM", this, _LOG_ERROR, X )
|
||||
|
|
||||
ARGUS_PTZCAM::ARGUS_PTZCAM( uint32_t id ): ARGUS_Camera( id ), basicThread(){ |
|
||||
|
ARGUS_PTZCAM::ARGUS_PTZCAM( DBC_NODE_DATA *Data ): basicEventHandler(), argusNetNode( Data ), ARGUS_Camera(){ |
||||
m_pLog = basicLogCollection::getInstance(); |
m_pLog = basicLogCollection::getInstance(); |
||||
m_pProtocol = NULL; |
|
||||
m_pTransport = NULL; |
|
||||
m_bState = 0; |
|
||||
}; |
|
||||
|
/*
|
||||
|
DBC_CAM_DATA * tData = m_pDBC->getCamData( m_sNodeData.aux_id ); |
||||
|
|
||||
ARGUS_PTZCAM::~ARGUS_PTZCAM(){ |
|
||||
if( m_pTransport!= NULL ) { |
|
||||
DBC_UART_DATA *tData = NULL; |
|
||||
tData = m_pDBC->getUartData( m_sCamData.uart_id ); |
|
||||
switch( tData->type ) { |
|
||||
case UART_TYPE_HARDWARE:{ |
|
||||
delete((serialPort*)m_pTransport); |
|
||||
break; |
|
||||
}; |
|
||||
case UART_TYPE_SOL:{ |
|
||||
delete((serialSOL*)m_pTransport); |
|
||||
break; |
|
||||
}; |
|
||||
}; |
|
||||
|
m_fMaxRange = m_fMinHFov = m_fMaxHFov = m_fMinVFov = m_fMaxVFov = .0f; |
||||
|
|
||||
|
if( tData != NULL ) { |
||||
|
memcpy( &m_sCamData, tData, sizeof(DBC_CAM_DATA) ); |
||||
|
free( tData ); |
||||
}; |
}; |
||||
if( m_pProtocol != NULL ) { |
|
||||
switch( m_sCamData.protocol ) { |
|
||||
case CAM_CTRL_PROTO_VISCA: |
|
||||
delete( (protocolPTZ_VISCA *) m_pProtocol ); |
|
||||
break; |
|
||||
case CAM_CTRL_PROTO_PELCO: |
|
||||
delete( (protocolPTZ_PELCO *) m_pProtocol ); |
|
||||
break; |
|
||||
case CAM_CTRL_PROTO_ONVIF: |
|
||||
delete( (protocolPTZ_ONVIF *) m_pProtocol ); |
|
||||
break; |
|
||||
default: |
|
||||
delete( m_pProtocol ); |
|
||||
}; |
|
||||
|
memset( &m_sCtrlData, 0, sizeof(CAMERA_CTRL_DATA) ); |
||||
|
if( m_sCamData.max_range == .0f ){ |
||||
|
m_fMaxRange = calcMaxDistance_mm( AC_imager_diag[m_sCamData.imager_type], m_sCamData.max_f, 1280 ); |
||||
|
} else { |
||||
|
m_fMaxRange = m_sCamData.max_range; |
||||
}; |
}; |
||||
|
m_fMinHFov = calcFOV_mm( AC_imager_width[m_sCamData.imager_type], m_sCamData.min_f ); |
||||
|
m_fMaxHFov = calcFOV_mm( AC_imager_width[m_sCamData.imager_type], m_sCamData.max_f ); |
||||
|
m_fMinVFov = calcFOV_mm( AC_imager_height[m_sCamData.imager_type], m_sCamData.min_f ); |
||||
|
m_fMaxVFov = calcFOV_mm( AC_imager_height[m_sCamData.imager_type], m_sCamData.max_f ); |
||||
|
#ifdef DEBUG
|
||||
|
char tB[128]; |
||||
|
LOG("Camera Info:"); |
||||
|
sprintf( tB, "Maximal Range: %0.2f m. ", m_fMaxRange); |
||||
|
LOG(tB); |
||||
|
sprintf( tB, "Maximal FOVs, Horizontal: %0.2f Vertical: %0.2f", m_fMinHFov, m_fMinVFov ); |
||||
|
LOG(tB); |
||||
|
sprintf( tB, "Minimal FOVs, Horizontal: %0.2f Vertical: %0.2f", m_fMaxHFov, m_fMaxVFov ); |
||||
|
LOG(tB); |
||||
|
#endif
|
||||
|
m_pPosition = new basicPosition( m_sCamData.lat, m_sCamData.lon, m_sCamData.alt, m_sCamData.roll, m_sCamData.pitch, m_sCamData.yaw ); |
||||
|
*/ |
||||
|
}; |
||||
|
|
||||
|
ARGUS_PTZCAM::ARGUS_PTZCAM( uint32_t id ): basicEventHandler(), argusNetNode( id ), ARGUS_Camera(){ |
||||
|
m_pLog = basicLogCollection::getInstance(); |
||||
|
memset( &m_sCtrlData, 0, sizeof(CAMERA_CTRL_DATA) ); |
||||
|
}; |
||||
|
|
||||
|
ARGUS_PTZCAM::~ARGUS_PTZCAM(){ |
||||
|
|
||||
}; |
}; |
||||
|
|
||||
bool ARGUS_PTZCAM::startService(){ |
bool ARGUS_PTZCAM::startService(){ |
||||
if( m_pProtocol != NULL ){ |
|
||||
LOG_ERROR("Cannot Start: Service Already Running!"); |
|
||||
return false; |
|
||||
}; |
|
||||
switch( m_sCamData.protocol ){ |
|
||||
case CAM_CTRL_PROTO_VISCA: { |
|
||||
|
return create( m_sNodeData.aux_id ); |
||||
|
}; |
||||
|
|
||||
|
bool ARGUS_PTZCAM::stopService(){ |
||||
|
return true; |
||||
|
}; |
||||
|
|
||||
|
void ARGUS_PTZCAM::dispatchEvent( EVENT_CONTAINER *E ){ |
||||
|
if( E == NULL ) return; |
||||
|
//if( !m_sCamData.online ) return;
|
||||
|
//if( m_bBusy ) return;
|
||||
|
switch( E->m_eClass ) { |
||||
|
case EVT_CLASS_SENSOR_CLD: |
||||
|
case EVT_CLASS_SENSOR_LGS: |
||||
|
case EVT_CLASS_SENSOR_LFS: |
||||
|
case EVT_CLASS_SENSOR_MND: |
||||
|
case EVT_CLASS_SENSOR_PLS_210: |
||||
|
case EVT_CLASS_SENSOR_PLS_360: |
||||
|
case EVT_CLASS_SENSOR_ALS: |
||||
|
case EVT_CLASS_SENSOR_3D: |
||||
|
case EVT_CLASS_SENSOR_ACC:{ |
||||
|
switch( E->m_eType ) { |
||||
|
case EVT_TARGET_1D: |
||||
|
case EVT_TARGET_2D_BLACK: |
||||
|
case EVT_TARGET_2D_WHITE: |
||||
|
case EVT_TARGET_3D_BLACK: |
||||
|
case EVT_TARGET_3D_WHITE:{ |
||||
|
TARGET_DATA *tDATA; |
||||
|
tDATA = (TARGET_DATA *)E->m_pEvtData; |
||||
|
if( tDATA ) { |
||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||
LOG("VISCA"); |
|
||||
|
LOG( "CHECK CAMERA FOV" ); |
||||
#endif
|
#endif
|
||||
m_pProtocol = (protocolPTZ *) new protocolPTZ_VISCA(); |
|
||||
if( m_pProtocol!= NULL ) { |
|
||||
DBC_UART_DATA *tData = NULL; |
|
||||
tData = m_pDBC->getUartData( m_sCamData.uart_id ); |
|
||||
if( tData!= NULL ) { |
|
||||
basicTransport *tTransport = NULL; |
|
||||
switch( tData->type ) { |
|
||||
case UART_TYPE_HARDWARE:{ // Hardware
|
|
||||
serialPort *tT = NULL; |
|
||||
tT = new serialPort(); |
|
||||
if( tT!= NULL ){ |
|
||||
if( tT->create( tData->path, tData->speed ) ){ |
|
||||
tTransport = (basicTransport *) tT; |
|
||||
} else { |
|
||||
delete( tT ); |
|
||||
}; |
|
||||
}; |
|
||||
break; |
|
||||
}; |
|
||||
case UART_TYPE_SOL:{ // E2S
|
|
||||
serialSOL *tT = NULL; |
|
||||
tT = new serialSOL( (SOL_TYPE) tData->mode ); |
|
||||
if( tT!= NULL ){ |
|
||||
if( tT->create( tData->path, tData->port, tData->speed ) ){ |
|
||||
tTransport = (basicTransport *) tT; |
|
||||
} else { |
|
||||
delete( tT ); |
|
||||
}; |
|
||||
|
if( inTheFOV( tDATA->global_target.lat, tDATA->global_target.lon, tDATA->global_target.alt ) ){ |
||||
|
#ifdef DEBUG
|
||||
|
LOG("TARGET IN CAMERA FOV"); |
||||
|
#endif
|
||||
|
if( lookAtWGS84( E->m_db_id, tDATA->global_target.lat, tDATA->global_target.lon, tDATA->global_target.alt ) ){ |
||||
|
/*
|
||||
|
#ifdef DEBUG
|
||||
|
LOG("CHECK CAMERA STREAMS"); |
||||
|
#endif
|
||||
|
EVENT_CONTAINER *tEVT; |
||||
|
DBC_INT_LIST *tStreams; |
||||
|
tStreams = m_pDBC->listCamMediaStreams( m_sNodeData.aux_id ); |
||||
|
if( tStreams!= NULL ) { |
||||
|
for( uint32_t idx = 0; idx < tStreams->size(); idx++ ) { |
||||
|
tEVT = createBasicTargetedEvent( m_nDBID, tStreams->at(idx), EVT_CLASS_VIDEO, EVT_CAPTURE_START, E->m_UUID ); |
||||
|
if( tEVT != NULL ) { |
||||
|
tEVT->m_ref_id = E->m_db_id; |
||||
|
m_pEvtHeap->broadcast( tEVT ); |
||||
|
}; |
||||
|
}; |
||||
|
delete( tStreams ); |
||||
|
}; |
||||
|
*/ |
||||
}; |
}; |
||||
break; |
|
||||
}; |
}; |
||||
}; |
}; |
||||
if( tTransport!= NULL ) { |
|
||||
m_pProtocol->setTransport( tTransport ); |
|
||||
}; |
|
||||
free( tData ); |
|
||||
|
break; |
||||
}; |
}; |
||||
}; |
}; |
||||
break; |
break; |
||||
}; |
}; |
||||
case CAM_CTRL_PROTO_PELCO:{ |
|
||||
#ifdef DEBUG
|
|
||||
LOG("PELCO"); |
|
||||
#endif
|
|
||||
m_pProtocol = (protocolPTZ *) new protocolPTZ_PELCO(); |
|
||||
if( m_pProtocol!= NULL ) { |
|
||||
DBC_UART_DATA *tData = NULL; |
|
||||
tData = m_pDBC->getUartData( m_sCamData.uart_id ); |
|
||||
if( tData!= NULL ) { |
|
||||
basicTransport *tTransport = NULL; |
|
||||
switch( tData->type ) { |
|
||||
case UART_TYPE_HARDWARE:{ |
|
||||
#ifdef DEBUG
|
|
||||
LOG("HW Port"); |
|
||||
#endif
|
|
||||
serialPort *tT = NULL; |
|
||||
tT = new serialPort(); |
|
||||
if( tT!= NULL ){ |
|
||||
if( tT->create( tData->path, tData->speed ) ){ |
|
||||
tTransport = (basicTransport *) tT; |
|
||||
|
case EVT_CLASS_CAMERA_CTRL:{ |
||||
|
/*
|
||||
|
if( E->m_nDestinationUID == m_sCamData.node_id ) { |
||||
|
switch( E->m_eType ) { |
||||
|
case EVT_CAMERA_DM:{ |
||||
|
CAMERA_CTRL_DATA *tDATA = (CAMERA_CTRL_DATA *)E->m_pEvtData; |
||||
|
if( tDATA != NULL ) { |
||||
|
if( tDATA->moveMask & 0x08 == 0x08 ){ |
||||
|
//Relative Move cmd
|
||||
|
if( tDATA->moveMask & 0x07 == 0 ){ |
||||
|
relativeStop(); |
||||
} else { |
} else { |
||||
delete( tT ); |
|
||||
|
relativeMove( tDATA->spdPAN, tDATA->spdTILT, tDATA->spdZOOM ); |
||||
}; |
}; |
||||
}; |
|
||||
break; |
|
||||
}; |
|
||||
case UART_TYPE_SOL:{ |
|
||||
#ifdef DEBUG
|
|
||||
LOG("SOL Port"); |
|
||||
#endif
|
|
||||
serialSOL *tT = NULL; |
|
||||
tT = new serialSOL( (SOL_TYPE)tData->mode ); |
|
||||
if( tT!= NULL ){ |
|
||||
|
|
||||
if( tT->create( tData->path, tData->port, tData->speed ) ){ |
|
||||
tTransport = (basicTransport *) tT; |
|
||||
} else { |
|
||||
delete( tT ); |
|
||||
|
} else { |
||||
|
if( tDATA->moveMask & 0xF0 != 0x00 ) { |
||||
|
absoluteMove( tDATA->absPAN, tDATA->absTILT, tDATA->absZOOM ); |
||||
}; |
}; |
||||
}; |
}; |
||||
break; |
|
||||
}; |
}; |
||||
#ifdef DEBUG
|
|
||||
default: LOG_ERROR("Unknown Port Type!"); |
|
||||
#endif
|
|
||||
|
break; |
||||
}; |
}; |
||||
if( tTransport!= NULL ) { |
|
||||
LOG( "Bind Transport Port!" ); |
|
||||
if( m_pProtocol->setTransport( tTransport )){ |
|
||||
if( !m_pProtocol->create() ){ |
|
||||
LOG_ERROR("Protocol <<< Create >>> Failure!"); |
|
||||
}; |
|
||||
} else { |
|
||||
LOG_ERROR("Binding Port Failure!"); |
|
||||
}; |
|
||||
} else LOG_ERROR("Transport Creation Failure!"); |
|
||||
free( tData ); |
|
||||
} |
|
||||
#ifdef DEBUG
|
|
||||
else LOG_ERROR("No Uart DATA loaddesd!"); |
|
||||
#endif
|
|
||||
} |
|
||||
#ifdef DEBUG
|
|
||||
else LOG_ERROR("Protocol NEW failure!"); |
|
||||
#endif
|
|
||||
break; |
|
||||
}; |
|
||||
case CAM_CTRL_PROTO_ONVIF:{ |
|
||||
#ifdef DEBUG
|
|
||||
LOG("ONVIF"); |
|
||||
#endif
|
|
||||
m_pProtocol = (protocolPTZ *) new protocolPTZ_ONVIF( m_sCamData.ip, m_sCamData.username, m_sCamData.password ); |
|
||||
if( m_pProtocol!=NULL ) { |
|
||||
if( !m_pProtocol->create() ) { |
|
||||
LOG_ERROR("Error Creating Proto!"); |
|
||||
delete( (protocolPTZ_ONVIF*) m_pProtocol ); |
|
||||
m_pProtocol = NULL; |
|
||||
}; |
}; |
||||
}; |
|
||||
|
} |
||||
|
;*/ |
||||
break; |
break; |
||||
}; |
}; |
||||
}; |
}; |
||||
if( m_pProtocol == NULL ) { |
|
||||
LOG_ERROR("No Proto Created!!"); |
|
||||
m_sCamData.online = false; |
|
||||
} else { |
|
||||
#ifdef DEBUG
|
|
||||
LOG("Proto is OK"); |
|
||||
#endif
|
|
||||
m_sCamData.online = init(); |
|
||||
}; |
|
||||
return m_sCamData.online; |
|
||||
}; |
}; |
||||
|
|
||||
bool ARGUS_PTZCAM::relativeMove( float PanSPD, float TiltSPD, float ZoomSPD ){ |
|
||||
if( m_sCamData.online ) { |
|
||||
uint32_t MoveMatrix = 0; |
|
||||
if( PanSPD != .0f ){ |
|
||||
if( PanSPD > 0 ) { |
|
||||
MoveMatrix |= PTZ_DRIVE_PAN_RIGHT; |
|
||||
} else { |
|
||||
MoveMatrix |= PTZ_DRIVE_PAN_LEFT; |
|
||||
}; |
|
||||
}; |
|
||||
if( TiltSPD != .0f ){ |
|
||||
if( TiltSPD > 0 ) { |
|
||||
MoveMatrix |= PTZ_DRIVE_TILT_UP; |
|
||||
} else { |
|
||||
MoveMatrix |= PTZ_DRIVE_TILT_DOWN; |
|
||||
}; |
|
||||
}; |
|
||||
if( ZoomSPD != .0f ){ |
|
||||
if( ZoomSPD > 0 ) { |
|
||||
MoveMatrix |= PTZ_DRIVE_ZOOM_WIDE; |
|
||||
} else { |
|
||||
MoveMatrix |= PTZ_DRIVE_ZOOM_TELE; |
|
||||
}; |
|
||||
}; |
|
||||
if( MoveMatrix!= 0 ) { |
|
||||
m_pProtocol->setPTZSpeed( PanSPD, TiltSPD, ZoomSPD ); |
|
||||
}; |
|
||||
return m_pProtocol->move( MoveMatrix ); |
|
||||
}; |
|
||||
return false; |
|
||||
}; |
|
||||
|
|
||||
bool ARGUS_PTZCAM::relativeStop(){ |
|
||||
if( m_sCamData.online ) { |
|
||||
return m_pProtocol->move( 0 ); |
|
||||
}; |
|
||||
return false; |
|
||||
}; |
|
||||
|
|
||||
bool ARGUS_PTZCAM::absoluteMove( float PanPOS, float TiltPOS, float ZoomPOS ){ |
|
||||
if( m_sCamData.online ) { |
|
||||
CAM_PTZ_CMD *tCMD = (CAM_PTZ_CMD*) malloc( sizeof(CAM_PTZ_CMD)); |
|
||||
if( tCMD ) { |
|
||||
memset( tCMD, 0 , sizeof(CAM_PTZ_CMD)); |
|
||||
tCMD->CMD = PTZ_ABSOLUTE; |
|
||||
tCMD->PAN = PanPOS; |
|
||||
tCMD->TILT = TiltPOS; |
|
||||
tCMD->ZOOM = ZoomPOS; |
|
||||
m_mQPROTECTOR.lock(); |
|
||||
m_qCAM_CMD.push( tCMD ); |
|
||||
m_mQPROTECTOR.unlock(); |
|
||||
return true; |
|
||||
}; |
|
||||
}; |
|
||||
return false; |
|
||||
}; |
|
||||
|
|
||||
void ARGUS_PTZCAM::m_fThreadProc( void ){ |
|
||||
m_bThreadStatus = TH_WORKING; |
|
||||
while (m_bThreadStatus < TH_ENDED) { |
|
||||
switch( m_bState ) { |
|
||||
case CAM_WS_INIT:{ |
|
||||
// Init Camera - PowerMode
|
|
||||
if( m_pProtocol->initCamera() ) m_bState = CAM_WS_WHITE_BALLANCE; |
|
||||
break; |
|
||||
}; |
|
||||
case CAM_WS_WHITE_BALLANCE:{ |
|
||||
// Set Speed
|
|
||||
if( m_pProtocol->setWhiteBalanceMode( WB_AUTO ) ) m_bState = CAM_WS_BACKLIGHT; |
|
||||
break; |
|
||||
}; |
|
||||
case CAM_WS_BACKLIGHT:{ |
|
||||
// Go 0
|
|
||||
if( m_pProtocol->setBackLightMode( true ) ) m_bState = CAM_WS_AUTO_FOCUS; |
|
||||
//if( m_pProtocol->goHomePosition() ) m_bState++;
|
|
||||
break; |
|
||||
}; |
|
||||
case CAM_WS_AUTO_FOCUS:{ |
|
||||
if( m_pProtocol->setAutoFocus( true ) ) m_bState = CAM_WS_INIT_GO_HOME; |
|
||||
break; |
|
||||
}; |
|
||||
case CAM_WS_INIT_GO_HOME:{ |
|
||||
if( m_pProtocol->goAbsolute( -1, -1, 0 ) ) m_bState = CAM_WS_READY; |
|
||||
break; |
|
||||
}; |
|
||||
case CAM_WS_READY:{ |
|
||||
m_mQPROTECTOR.lock(); |
|
||||
if( m_qCAM_CMD.size() > 0 ) { |
|
||||
CAM_PTZ_CMD *tCMD = m_qCAM_CMD.front(); |
|
||||
if( tCMD ) { |
|
||||
m_qCAM_CMD.pop(); |
|
||||
m_mQPROTECTOR.unlock(); |
|
||||
switch( tCMD->CMD ) { |
|
||||
case PTZ_STOP:{ |
|
||||
m_pProtocol->goStop(); |
|
||||
break; |
|
||||
}; |
|
||||
case PTZ_MOVE:{ |
|
||||
uint32_t MoveMatrix = 0; |
|
||||
if( m_pProtocol->setPTZSpeed( tCMD->PAN, tCMD->TILT, tCMD->ZOOM ) ){ |
|
||||
SLEEP( 10 ); |
|
||||
m_pProtocol->move( MoveMatrix ); |
|
||||
}; |
|
||||
break; |
|
||||
}; |
|
||||
case PTZ_ABSOLUTE:{ |
|
||||
if( m_pProtocol->goAbsolute( tCMD->PAN, tCMD->TILT, tCMD->ZOOM ) ) SLEEP( 1000 ); |
|
||||
break; |
|
||||
}; |
|
||||
}; |
|
||||
} else m_mQPROTECTOR.unlock(); |
|
||||
} else { |
|
||||
m_mQPROTECTOR.unlock(); |
|
||||
SLEEP( 100 ); |
|
||||
}; |
|
||||
break; |
|
||||
}; |
|
||||
case CAM_WS_END: m_bThreadStatus = TH_ENDED; break; |
|
||||
}; |
|
||||
}; |
|
||||
}; |
|
||||
|
|
||||
#undef LOG
|
#undef LOG
|
||||
#undef LOG_ERROR
|
#undef LOG_ERROR
|
||||
@ -0,0 +1,26 @@ |
|||||
|
#include "rgooseTargetFilter.h"
|
||||
|
|
||||
|
ARGUS_TARGET_FILTER::ARGUS_TARGET_FILTER( uint32_t id ){ |
||||
|
m_nDBID = id; |
||||
|
m_pDBC = argusDBC::getInstance(); |
||||
|
m_bActive = false; |
||||
|
if( m_pDBC != NULL ) { |
||||
|
//DBC_NODE_DATA *tData = NULL;
|
||||
|
//tData = m_pDBC->getNodeData( m_nDBID );
|
||||
|
//if( tData != NULL ) {
|
||||
|
// memcpy( &m_sNodeData , tData, sizeof(DBC_NODE_DATA));
|
||||
|
// free( tData );
|
||||
|
//} else {
|
||||
|
// memset( &m_sNodeData , 0, sizeof(DBC_NODE_DATA));
|
||||
|
// m_sNodeData.type = ARGUS_UNKNOWN;
|
||||
|
// m_sNodeData.node_id = id;
|
||||
|
//};
|
||||
|
} else { |
||||
|
//memset( &m_sNodeData , 0, sizeof(DBC_NODE_DATA));
|
||||
|
//m_sNodeData.type = ARGUS_UNKNOWN;
|
||||
|
//m_sNodeData.node_id = id;
|
||||
|
}; |
||||
|
}; |
||||
|
|
||||
|
ARGUS_TARGET_FILTER::~ARGUS_TARGET_FILTER(){ |
||||
|
}; |
||||
@ -0,0 +1,32 @@ |
|||||
|
#ifndef __ARGUS_TARGET_FILTER_HEADER__ |
||||
|
#define __ARGUS_TARGET_FILTER_HEADER__ |
||||
|
|
||||
|
#include "../components/base/basicEvent.h" |
||||
|
#include "../components/base/basicPosition.h" |
||||
|
#include "rgooseDBConnector.h" |
||||
|
|
||||
|
typedef enum E_TARGET_FILTER_TYPE{ |
||||
|
TR_UDEFINED_FILTER = 0, |
||||
|
TF_AUTHORISED_PEOPLE_FILTER = 1, |
||||
|
TF_LA_METRO_TRAIN_FILTER = 2 |
||||
|
}TARGET_FILTER_TYPE; |
||||
|
|
||||
|
class ARGUS_TARGET_FILTER{ |
||||
|
protected: |
||||
|
argusDBC * m_pDBC; |
||||
|
uint32_t m_nDBID; |
||||
|
uint8_t m_bFilterType; |
||||
|
bool m_bActive; |
||||
|
public: |
||||
|
explicit ARGUS_TARGET_FILTER( uint32_t id ); |
||||
|
virtual ~ARGUS_TARGET_FILTER(); |
||||
|
virtual bool validateTarget( uint32_t DevID, TARGET_DATA *ptr ){ return true; }; |
||||
|
virtual bool initFilter(){ return true; }; |
||||
|
virtual bool stopFilter(){ return true; }; |
||||
|
uint32_t getID(){ return m_nDBID; }; |
||||
|
uint8_t getType(){ return m_bFilterType; }; |
||||
|
}; |
||||
|
|
||||
|
typedef vector<ARGUS_TARGET_FILTER *> V_TARGET_FILTERS; |
||||
|
|
||||
|
#endif |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue