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.

205 lines
7.7 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
4 years ago
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Dr.Frucht Systems Ltd.
  3. // Copyright � 2000-2017. All Rights Reserved.
  4. // Version 2.0 6/11/2019
  5. // Last modification: 6/11/2019
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: rgooseIPCamera.h
  9. // AUTHOR: gagua
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file of rgooseIPCamera.h
  13. //----------------------------------------------------------------------------
  14. //
  15. #ifndef __DEVICE_NODE_CAMERA_HEADER__
  16. #define __DEVICE_NODE_CAMERA_HEADER__
  17. #include <vector>
  18. #include <queue>
  19. #include "../../components/base/basicThread.h"
  20. #include "../../components/base/basicMutex.h"
  21. #include "../../data/protocol/protocolPTZ.h"
  22. #include "../../components/base/basicEventHeap.h"
  23. //#include "rgooseDBConnector.h"
  24. #include "deviceNode.h"
  25. //https://www.ebay.com/itm/Professional-Rolling-Makeup-Case-Bulb-Mirror-Cosmetic-Artist-Dressing-Train-Case/233264525474
  26. //ffmpeg -i input.mp4 -af loudnorm=I=-23:LRA=7:tp=-2:print_format=json -f null -
  27. //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
  28. #define CAM_CTRL_PROTO_VISCA 1
  29. #define CAM_CTRL_PROTO_PELCO 2
  30. #define CAM_CTRL_PROTO_ONVIF 3
  31. #define CAM_CTRL_PROTO_PSIA 4
  32. #define CAM_CTRL_PROTO_T28181 5
  33. #define UART_TYPE_HARDWARE 1
  34. #define UART_TYPE_SOL 2
  35. #define ARGUS_CAM_PCMD_MOVE_MASK 0x7F
  36. #define ARGUS_CAM_PCMD_CMD_MASK 0x80
  37. #define ARGUS_CAM_PCMD_STOP 1
  38. typedef struct S_CAM_PTZ_CMD{
  39. uint8_t CMD;
  40. float PAN;
  41. float TILT;
  42. float ZOOM;
  43. }CAM_PTZ_CMD;
  44. typedef enum E_CAM_PTZ_CMD{
  45. PTZ_STOP = 0,
  46. PTZ_MOVE = 1,
  47. PTZ_ABSOLUTE = 2,
  48. PTZ_RELOAD_CAMERA = 3,
  49. PTZ_CAPTURE_ONLY = 4
  50. }PTZ_CMD;
  51. typedef std::queue<CAM_PTZ_CMD *> CAM_PTZ_CMD_QUEUE;
  52. typedef enum E_CAM_WORKING_STATE{
  53. CAM_WS_INIT = 0,
  54. CAM_WS_WHITE_BALLANCE = 1,
  55. CAM_WS_BACKLIGHT = 2,
  56. CAM_WS_AUTO_FOCUS = 3,
  57. CAM_WS_INIT_GO_HOME = 4,
  58. CAM_WS_AUTOMATED_MOVE = 10,
  59. CAM_WS_STOP_MOVE = 11,
  60. CAM_WS_GO_ABS_POSITION = 12,
  61. CAM_WS_GO_HOMING_PRESET = 13,
  62. CAM_WS_GO_PRESET = 14,
  63. CAM_WS_GO_ABS_ROI = 15,
  64. CAM_WS_READY = 64,
  65. CAM_WS_BUSY = 128,
  66. CAM_WS_END = 255
  67. }CAM_WORK_STATE;
  68. typedef struct S_CAM_TASK{
  69. bool isDone;
  70. uint32_t source_evt_id;
  71. bool movemet_needed;
  72. CAM_PTZ_CMD * CMD;
  73. } CAM_TASK;
  74. typedef std::queue<CAM_TASK *> CAM_TASK_QUEUE;
  75. #define LOSE_INTERES_TIME_MS 2000
  76. inline CAM_ROI *createCAM_ROI( void ){
  77. CAM_ROI * tROI = (CAM_ROI*)malloc(sizeof(CAM_ROI));
  78. if( tROI ){
  79. memset( tROI,0,sizeof(CAM_ROI));
  80. tROI->targets.clear();
  81. };
  82. return tROI;
  83. };
  84. inline void utilizeROI( CAM_ROI *&ptr ){
  85. if( ptr ) {
  86. if ( ptr->targets.size() ) {
  87. for( vCAM_TRACK_RECORDS::iterator idx = ptr->targets.begin(); idx != ptr->targets.end(); idx++ ) free( *idx );
  88. ptr->targets.clear();
  89. };
  90. free( ptr );
  91. ptr = NULL;
  92. };
  93. };
  94. class deviceNodeCamera: public deviceNode, public basicThread {
  95. private:
  96. basicPosition m_oPosition;
  97. time_t m_tTimeTSeconds;
  98. CAM_ROI * m_pCurrentROI;
  99. float m_fMaxRange;
  100. float m_fMinRange;
  101. float m_fMaxFL;
  102. float m_fMinFL;
  103. float m_fR2FL; // Range to Focal Length
  104. uint16_t m_nRealFrameWidth;
  105. uint16_t m_nRealFrameHeight;
  106. float m_fMinHFov;
  107. float m_fMaxHFov;
  108. float m_fMinVFov;
  109. float m_fMaxVFov;
  110. protocolPTZ * m_pProtocol;
  111. basicTransport * m_pTransport;
  112. CAM_TASK_QUEUE m_qCAM_TASK;
  113. basicMutex m_mQPROTECTOR;
  114. uint32_t m_nRelativeMoveCounter;
  115. uint32_t m_nHomingCounter;
  116. uint8_t m_bRelativeMoveMatrix;
  117. float m_fSpeedRise;
  118. float m_fRM_Pan;
  119. float m_fRM_Tilt;
  120. float m_fRM_Zoom;
  121. float m_fCP_Pan;
  122. float m_fCP_Tilt;
  123. float m_fCP_Zoom;
  124. /* Methotds Sutable to Control Camera */
  125. bool relativeMove( float PanSPD, float TiltSPD, float ZoomSPD );
  126. bool relativeStop();
  127. bool absoluteMove( uint32_t RefID, float PanPOS, float TiltPOS, float ZoomPOS );
  128. bool absoluteMove( uint32_t RefID, C3D_ORIENT_ONVIF O );
  129. /* tracking Fusion methods */
  130. vCAM_ROIS m_vROIS;
  131. basicMutex m_mROIsProtector;
  132. bool fusion_consumeData( uint32_t db_id, C3D_SPH_DEGREES tOR );
  133. bool fusion_validateROI( uint64_t cts, CAM_ROI *ptr );
  134. bool fusion_compare( CAM_ROI *ptr, C3D_SPH_DEGREES tp );
  135. void fusion_validate( void );
  136. CAM_ROI * fusion_fetchROI( void );
  137. DBC_SNAPSHOT_DATA * fusion_translate_ROI( CAM_ROI *(&ptr) );
  138. void updateOpticalParameters( uint16_t frame_width, uint16_t frame_heigth );
  139. protected:
  140. DBC_CAM_DATA m_sCamData;
  141. MEDIA_SOURCE_DESC m_sMediaSource;
  142. basicEventHeap * m_pBEH;
  143. //bool m_bSourceConnected;
  144. //uint32_t m_nActiveStreamID;
  145. //bool inTheFOV( float lat, float lon, float alt );
  146. bool testFOV( C3D_WGS84_LOC ); //Global Coords
  147. bool testFOV( C3D_DECART ); //System Coords
  148. bool testFOV( C3D_SPH_RADIANS ); //Local Coords
  149. bool testFOV( C3D_SPH_DEGREES ); //Local Coords
  150. //bool lookAtWGS84( uint32_t TargetRefID, float lat, float lon, float alt );
  151. bool lookAt( uint32_t TargetRefID, C3D_WGS84_LOC L ); // GLobal
  152. bool lookAt( uint32_t TargetRefID, C3D_DECART L ); // System
  153. bool lookAt( uint32_t TargetRefID, C3D_SPH_RADIANS L ); // Local
  154. bool lookAt( uint32_t TargetRefID, C3D_SPH_DEGREES L ); // Local
  155. bool makeSnap( uint32_t TargetRefID );
  156. //void setBusy( bool Status );
  157. bool connectToStream( uint32_t id );
  158. bool disconnectFromStream( void );
  159. bool validateStream( void );
  160. CAM_TASK * fetchCamTask( void );
  161. bool pushCamTask( CAM_TASK * );
  162. virtual void m_fThreadProc( void );
  163. public:
  164. explicit deviceNodeCamera( uint32_t NodeID );
  165. explicit deviceNodeCamera( DBC_NODE_DATA *Data );
  166. virtual ~deviceNodeCamera();
  167. bool create();
  168. virtual bool validate();
  169. };
  170. typedef std::vector<deviceNodeCamera *> vectorNodeCameras;
  171. #endif