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.
299 lines
7.6 KiB
299 lines
7.6 KiB
//----------------------------------------------------------------------------
|
|
// Dr.Frucht Systems Ltd.
|
|
// Copyright © 2000-2017. All Rights Reserved.
|
|
// Version 2.0 6/11/2019
|
|
// Last modification: 6/11/2019
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: rgooseIPCamera.h
|
|
// AUTHOR: gagua
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Header file of rgooseIPCamera.h
|
|
//----------------------------------------------------------------------------
|
|
//
|
|
#ifndef __DEVICE_NODE_CAMERA_HEADER__
|
|
#define __DEVICE_NODE_CAMERA_HEADER__
|
|
|
|
#include "../../components/base/basicEventHeap.h"
|
|
#include "../../components/base/basicMutex.h"
|
|
#include "../../components/base/basicThread.h"
|
|
#include "../../data/protocol/protocolPTZ.h"
|
|
|
|
#include <queue>
|
|
#include <vector>
|
|
// #include "rgooseDBConnector.h"
|
|
#include "deviceNode.h"
|
|
|
|
// https://www.ebay.com/itm/Professional-Rolling-Makeup-Case-Bulb-Mirror-Cosmetic-Artist-Dressing-Train-Case/233264525474
|
|
|
|
// ffmpeg -i input.mp4 -af loudnorm=I=-23:LRA=7:tp=-2:print_format=json -f null -
|
|
// ffmpeg -i input.mp4 -af loudnorm=I=-23:LRA=7:tp=-2:measured_I=-30:measured_LRA=1.1:measured_tp=-11 04:measured_thresh=-40.21:offset=-0.47 -ar 48k -y output.mp4
|
|
|
|
#define CAM_POST_INIT
|
|
|
|
|
|
//#define NO_CAMERA_FUSION_ENGINE
|
|
|
|
#define CAM_CTRL_PROTO_VISCA 1
|
|
#define CAM_CTRL_PROTO_PELCO 2
|
|
#define CAM_CTRL_PROTO_ONVIF 3
|
|
#define CAM_CTRL_PROTO_PSIA 4
|
|
#define CAM_CTRL_PROTO_T28181 5
|
|
#define CAM_CTRL_PROTO_BRCP 6
|
|
|
|
#define UART_TYPE_HARDWARE 1
|
|
#define UART_TYPE_SOL 2
|
|
|
|
#define ARGUS_CAM_PCMD_MOVE_MASK 0x7F
|
|
#define ARGUS_CAM_PCMD_CMD_MASK 0x80
|
|
#define ARGUS_CAM_PCMD_STOP 1
|
|
|
|
#define ARGUS_PRESET_TYPE_POSITION 1
|
|
#define ARGUS_PRESET_TYPE_HOME 2
|
|
#define ARGUS_PRESET_TYPE_IR_AUTO 3
|
|
#define ARGUS_PRESET_TYPE_IR_ON 4
|
|
#define ARGUS_PRESET_TYPE_IR_OFF 5
|
|
#define ARGUS_PRESET_TYPE_IR_WISHER 6
|
|
|
|
#define DEFAULT_SHINE_ON_TARGET_TO 60 // seconds
|
|
|
|
typedef struct S_CAM_PTZ_CMD
|
|
{
|
|
uint8_t CMD;
|
|
float PAN;
|
|
float TILT;
|
|
float ZOOM;
|
|
} CAM_PTZ_CMD;
|
|
|
|
typedef enum E_CAM_PTZ_CMD
|
|
{
|
|
PTZ_STOP = 0,
|
|
PTZ_MOVE = 1,
|
|
PTZ_ABSOLUTE = 2,
|
|
PTZ_RELOAD_CAMERA = 3,
|
|
PTZ_CAPTURE_ONLY = 4,
|
|
PTZ_SET_PRESET = 5,
|
|
PTZ_CALL_PRESET = 6
|
|
} PTZ_CMD;
|
|
|
|
typedef std::queue<CAM_PTZ_CMD *> CAM_PTZ_CMD_QUEUE;
|
|
|
|
typedef enum E_CAM_WORKING_STATE
|
|
{
|
|
CAM_WS_INIT = 0,
|
|
CAM_WS_POWER_INIT = 1,
|
|
CAM_WS_WHITE_BALLANCE = 2,
|
|
CAM_WS_BACKLIGHT = 3,
|
|
CAM_WS_AUTO_FOCUS = 4,
|
|
CAM_WS_INIT_GO_HOME = 5,
|
|
CAM_WS_AUTOMATED_MOVE = 10,
|
|
CAM_WS_STOP_MOVE = 11,
|
|
CAM_WS_GO_ABS_POSITION = 12,
|
|
CAM_WS_GO_HOMING_PRESET = 13,
|
|
CAM_WS_GO_PRESET = 14,
|
|
CAM_WS_GO_ABS_ROI = 15,
|
|
CAM_WS_SET_PRESET = 16,
|
|
CAM_WS_READY = 64,
|
|
CAM_WS_BUSY = 128,
|
|
CAM_WS_WAIT_ONPOS = 129,
|
|
CAM_WS_END = 255
|
|
} CAM_WORK_STATE;
|
|
|
|
typedef struct S_CAM_TASK
|
|
{
|
|
bool isDone;
|
|
uint32_t source_evt_id;
|
|
bool movemet_needed;
|
|
CAM_PTZ_CMD * CMD;
|
|
} CAM_TASK;
|
|
|
|
typedef std::queue<CAM_TASK *> CAM_TASK_QUEUE;
|
|
|
|
#define LOSE_INTERES_TIME_MS 2000
|
|
|
|
inline CAM_ROI * createCAM_ROI(void)
|
|
{
|
|
//CAM_ROI * tROI = (CAM_ROI *) malloc(sizeof(CAM_ROI));
|
|
CAM_ROI * tROI = new CAM_ROI();
|
|
if (tROI)
|
|
{
|
|
//memset(tROI, 0, sizeof(CAM_ROI));
|
|
tROI->targets.clear();
|
|
};
|
|
return tROI;
|
|
}
|
|
|
|
inline void utilizeROI(CAM_ROI *& ptr)
|
|
{
|
|
if (ptr)
|
|
{
|
|
if (ptr->targets.size())
|
|
{
|
|
for (vCAM_TRACK_RECORDS::iterator idx = ptr->targets.begin(); idx != ptr->targets.end(); idx++)
|
|
{
|
|
free(*idx);
|
|
}
|
|
ptr->targets.clear();
|
|
};
|
|
//free(ptr);
|
|
delete( ptr );
|
|
ptr = NULL;
|
|
};
|
|
}
|
|
|
|
class deviceNodeCamera : public deviceNode, public basicThread
|
|
{
|
|
private:
|
|
|
|
basicPosition m_oPosition;
|
|
time_t m_tTimeTSeconds;
|
|
CAM_ROI * m_pCurrentROI;
|
|
|
|
float m_fMaxRange;
|
|
float m_fMinRange;
|
|
float m_fMaxFL;
|
|
float m_fMinFL;
|
|
float m_fR2FL; // Range to Focal Length
|
|
|
|
float m_fZoomCorrection;
|
|
|
|
uint16_t m_nRealFrameWidth;
|
|
uint16_t m_nRealFrameHeight;
|
|
float m_fMinHFov;
|
|
float m_fMaxHFov;
|
|
float m_fMinVFov;
|
|
float m_fMaxVFov;
|
|
|
|
protocolPTZ * m_pProtocol;
|
|
// basicTransport * m_pTransport;
|
|
|
|
CAM_TASK_QUEUE m_qCAM_TASK;
|
|
basicMutex m_mQPROTECTOR;
|
|
|
|
uint32_t m_nRelativeMoveCounter;
|
|
uint32_t m_nHomingCounter;
|
|
uint8_t m_bRelativeMoveMatrix;
|
|
uint8_t m_bCurrentPresetCol;
|
|
uint8_t m_bCurrentPresetRow;
|
|
float m_fSpeedRise;
|
|
float m_fRM_Pan;
|
|
float m_fRM_Tilt;
|
|
float m_fRM_Zoom;
|
|
|
|
float m_fCP_Pan;
|
|
float m_fCP_Tilt;
|
|
float m_fCP_Zoom;
|
|
|
|
bool m_bSkeepPositioningWait;
|
|
bool m_bNoAbsPositionning;
|
|
bool m_bCameraIsStatic;
|
|
// IR functionality
|
|
basicMutex m_mIRProtector;
|
|
bool m_bShineOnTarget;
|
|
bool m_bIRIsOn;
|
|
uint8_t m_bIRTO; // Default 60 seconds (1 video slice)
|
|
//
|
|
bool m_bCameraOnHomePosition;
|
|
|
|
/* Methotds Sutable to Control Camera */
|
|
bool relativeMove(float PanSPD, float TiltSPD, float ZoomSPD);
|
|
bool relativeStop();
|
|
bool absoluteMove(uint32_t RefID, float PanPOS, float TiltPOS, float ZoomPOS);
|
|
bool absoluteMove(uint32_t RefID, C3D_ORIENT_ONVIF O);
|
|
|
|
void updateOpticalParameters(uint16_t frame_width, uint16_t frame_heigth);
|
|
void translateROI2PRESET(float P, float T, float Z, uint8_t & col, uint8_t & row);
|
|
|
|
protected:
|
|
|
|
DBC_CAM_DATA m_sCamData;
|
|
MEDIA_SOURCE_DESC m_sMediaSource;
|
|
basicEventHeap * m_pBEH;
|
|
// bool m_bSourceConnected;
|
|
// uint32_t m_nActiveStreamID;
|
|
// bool inTheFOV( float lat, float lon, float alt );
|
|
#ifndef NO_CAMERA_FUSION_ENGINE
|
|
/* tracking Fusion methods */
|
|
vCAM_ROIS m_vROIS;
|
|
basicMutex m_mROIsProtector;
|
|
bool fusion_consumeData(uint32_t db_id, C3D_SPH_DEGREES tOR);
|
|
bool fusion_validateROI(uint64_t cts, CAM_ROI * ptr);
|
|
bool fusion_compare(CAM_ROI * ptr, C3D_SPH_DEGREES tp);
|
|
void fusion_validate(void);
|
|
CAM_ROI * fusion_fetchROI(void);
|
|
DBC_SNAPSHOT_DATA * fusion_translate_ROI(CAM_ROI *(&ptr));
|
|
#else
|
|
|
|
#endif
|
|
/* presets Fusion methods */
|
|
|
|
CAM_PRESETS_SET m_sCamPresets;
|
|
virtual bool load_presets(void);
|
|
|
|
CSTR getPresetToken(uint8_t CCOL, uint8_t CROW);
|
|
CSTR getPresetToken(uint8_t specialRole);
|
|
|
|
bool testFOV(C3D_WGS84_LOC); // Global Coords
|
|
bool testFOV(C3D_DECART); // System Coords
|
|
bool testFOV(C3D_SPH_RADIANS); // Local Coords
|
|
bool testFOV(C3D_SPH_DEGREES); // Local Coords
|
|
|
|
// bool lookAtWGS84( uint32_t TargetRefID, float lat, float lon, float alt );
|
|
bool lookAt(uint32_t TargetRefID, C3D_WGS84_LOC L); // GLobal
|
|
bool lookAt(uint32_t TargetRefID, C3D_DECART L); // System
|
|
bool lookAt(uint32_t TargetRefID, C3D_SPH_RADIANS L); // Local
|
|
bool lookAt(uint32_t TargetRefID, C3D_SPH_DEGREES L); // Local
|
|
|
|
bool makeSnap(uint32_t TargetRefID);
|
|
// void setBusy( bool Status );
|
|
bool connectToStream(uint32_t id);
|
|
bool disconnectFromStream(void);
|
|
CAM_TASK * fetchCamTask(void);
|
|
bool pushCamTask(CAM_TASK *);
|
|
virtual void m_fThreadProc(void);
|
|
|
|
public:
|
|
|
|
explicit deviceNodeCamera(uint32_t NodeID);
|
|
explicit deviceNodeCamera(DBC_NODE_DATA * Data);
|
|
virtual ~deviceNodeCamera();
|
|
bool create();
|
|
virtual bool validate();
|
|
virtual bool validateStream(void);
|
|
bool setNoPositionWait(bool FL = true);
|
|
|
|
virtual uint8_t getCamStatus()
|
|
{
|
|
return (uint8_t) m_sCamData.online;
|
|
}
|
|
|
|
uint32_t getCamStream()
|
|
{
|
|
return m_sCamData.stream_id;
|
|
}
|
|
|
|
virtual uint8_t getFlipMode()
|
|
{
|
|
return m_sCamData.flip_mode;
|
|
}
|
|
|
|
virtual uint8_t getPtzStatus();
|
|
virtual uint8_t getStreamStatus();
|
|
virtual float getSystemLocationX(){
|
|
return m_sCamData.x;
|
|
};
|
|
virtual float getSystemLocationY(){
|
|
return m_sCamData.y;
|
|
};
|
|
virtual float getSystemLocationZ(){
|
|
return m_sCamData.z;
|
|
};
|
|
virtual float getMaxRange(){
|
|
return m_fMaxRange;
|
|
};
|
|
};
|
|
|
|
typedef std::vector<deviceNodeCamera *> vectorNodeCameras;
|
|
|
|
#endif
|