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.

221 lines
8.9 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "objectStaticCamera.h"
  2. objectStaticCamera::objectStaticCamera(config_setting_t *Settings) : basicCamera( Settings ){
  3. m_pLog = basicLogCollection::getInstance();
  4. };
  5. objectStaticCamera::~objectStaticCamera(){
  6. if (m_pVideoSource != NULL) delete ((videoAVLIBSource *)m_pVideoSource );
  7. };
  8. bool objectStaticCamera::create(void){
  9. if (m_pSettings == NULL) return false;
  10. if (!basicCamera::create()) return false;
  11. //init video
  12. switch (m_sCameraInfo.m_iSourceType){
  13. case 0:{
  14. videoAVLIBSource *tSource;
  15. videoAVLIBDestination *tRecorder;
  16. tRecorder = new videoAVLIBDestination();
  17. tSource = new videoAVLIBSource();
  18. if (tSource == NULL){
  19. return false;
  20. };
  21. if (tSource->open((CSTR)m_sCameraInfo.m_pSourcePath, false, 25, m_sCameraInfo.m_iSourcePort, m_sCameraInfo.m_iWidth, m_sCameraInfo.m_iHeight)){
  22. //Filter
  23. switch (0){
  24. case 1:
  25. m_pVideoAnalyzer = new blobDetector();
  26. if (m_pVideoAnalyzer != NULL){
  27. //((blobDetector*)m_pVideoAnalyzer)->attachPTZ(this);
  28. };
  29. break;
  30. case 2: m_pVideoAnalyzer = new motionDetector(); break;
  31. case 3: m_pVideoAnalyzer = new opticalFlowDetector(); break;
  32. case 4: m_pVideoAnalyzer = new surfDetector(); break;
  33. case 5: m_pVideoAnalyzer = new vlfeatDetector(); break;
  34. default: m_pVideoAnalyzer = NULL; break;
  35. };
  36. if (m_pVideoAnalyzer != NULL){
  37. m_pVideoAnalyzer->attachDestination(m_pVideoNode);
  38. m_pVideoAnalyzer->setStreaming(true);
  39. m_pVideoAnalyzer->setPIP(false);
  40. m_pVideoAnalyzer->init();
  41. tSource->attachDestination(m_pVideoAnalyzer);
  42. tSource->setStreaming(true);
  43. }
  44. else {
  45. //tNode->setTimeLapse(3000);
  46. tSource->attachDestination(m_pVideoNode);
  47. tSource->setStreaming(true);
  48. };
  49. m_pVideoSource = (basicMediaSource *)tSource;
  50. m_pVideoNode->connect(tRecorder);
  51. } else {
  52. delete tRecorder;
  53. delete tSource;
  54. return false;
  55. };
  56. break;
  57. };
  58. case 1:{
  59. videoAVLIBSource *tSource;
  60. videoAVLIBDestination *tRecorder;
  61. tRecorder = new videoAVLIBDestination();
  62. tSource = new videoAVLIBSource();
  63. if (tSource == NULL){
  64. return false;
  65. };
  66. if (tSource->open((CSTR)m_sCameraInfo.m_pSourcePath, false)){
  67. //Filter
  68. switch (0){
  69. case 1:
  70. m_pVideoAnalyzer = new blobDetector();
  71. if (m_pVideoAnalyzer != NULL){
  72. //((blobDetector*)m_pVideoAnalyzer)->attachPTZ(this);
  73. };
  74. break;
  75. case 2: m_pVideoAnalyzer = new motionDetector(); break;
  76. case 3: m_pVideoAnalyzer = new opticalFlowDetector(); break;
  77. case 4: m_pVideoAnalyzer = new surfDetector(); break;
  78. case 5: m_pVideoAnalyzer = new vlfeatDetector(); break;
  79. default: m_pVideoAnalyzer = NULL; break;
  80. };
  81. if (m_pVideoAnalyzer != NULL){
  82. m_pVideoAnalyzer->attachDestination(m_pVideoNode);
  83. m_pVideoAnalyzer->setStreaming(true);
  84. m_pVideoAnalyzer->setPIP(false);
  85. m_pVideoAnalyzer->init();
  86. tSource->attachDestination(m_pVideoAnalyzer);
  87. tSource->setStreaming(true);
  88. }
  89. else {
  90. //tNode->setTimeLapse(3000);
  91. tSource->attachDestination(m_pVideoNode);
  92. tSource->setStreaming(true);
  93. };
  94. m_pVideoSource = (basicMediaSource *)tSource;
  95. m_pVideoNode->connect(tRecorder);
  96. } else {
  97. delete tRecorder;
  98. delete tSource;
  99. return false;
  100. };
  101. break;
  102. };
  103. default: return false;
  104. };
  105. return true;
  106. };
  107. bool objectStaticCamera::create(mediaSourceInfo *SI){
  108. /* This Method Only to Create New Instances */
  109. if ( m_pSettings == NULL) return false;
  110. if ( SI == NULL) return false;
  111. if (basicCamera::create(SI)){
  112. config_setting_t *pSetting;
  113. float tfVal;
  114. int tiVal;
  115. pSetting = config_setting_add(m_pSettings, BCI_TAG_OPTIC_DATA_ENA, CONFIG_TYPE_BOOL);
  116. if (SI->FLMin > 0 && SI->FLMax > 0){
  117. config_setting_set_bool(pSetting, true);
  118. m_sCameraInfo.m_bOpticEna = true;
  119. m_sCameraInfo.m_fFLMin = SI->FLMin;
  120. m_sCameraInfo.m_fFLMax = SI->FLMax;
  121. m_sCameraInfo.m_fFLCurrent = SI->FLMin;
  122. pSetting = config_setting_add(m_pSettings, BCI_TAG_OPTIC_FOCUS_LENGTH_MIN, CONFIG_TYPE_FLOAT);
  123. config_setting_set_float(pSetting, SI->FLMin);
  124. pSetting = config_setting_add(m_pSettings, BCI_TAG_OPTIC_FOCUS_LENGTH_MAX, CONFIG_TYPE_FLOAT);
  125. config_setting_set_float(pSetting, SI->FLMax);
  126. pSetting = config_setting_add(m_pSettings, BCI_TAG_OPTIC_FOCUS_LENGTH_CUR, CONFIG_TYPE_FLOAT);
  127. config_setting_set_float(pSetting, SI->FLMin);
  128. pSetting = config_setting_add(m_pSettings, BCI_TAG_OPTIC_SENSOR_SIZE, CONFIG_TYPE_FLOAT);
  129. config_setting_set_float(pSetting, SI->fSensorSize);
  130. pSetting = config_setting_add(m_pSettings, BCI_TAG_OPTIC_FOV, CONFIG_TYPE_FLOAT);
  131. tfVal = calcFOV(SI->fSensorSize, SI->FLMin);
  132. config_setting_set_float(pSetting, tfVal);
  133. if (SI->FLMin != SI->FLMax){
  134. // Zoom Ctrl is Enabled
  135. m_sCameraInfo.m_bZoomEna = true;
  136. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ENA_ZOOM_CTRL, CONFIG_TYPE_BOOL);
  137. config_setting_set_bool(pSetting, true);
  138. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ZOOM_MAX, CONFIG_TYPE_FLOAT);
  139. tfVal = SI->FLMax / SI->FLMin;
  140. config_setting_set_float(pSetting, tfVal);
  141. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ZOOM_ENA_DIGITAL, CONFIG_TYPE_BOOL);
  142. if (SI->fDigitalZoomMax > 0){
  143. config_setting_set_bool(pSetting, true);
  144. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ZOOM_DIGITAL_MAX, CONFIG_TYPE_FLOAT);
  145. config_setting_set_float(pSetting, SI->fDigitalZoomMax);
  146. } else {
  147. config_setting_set_bool(pSetting, false);
  148. };
  149. };
  150. } else {
  151. config_setting_set_bool(pSetting, false);
  152. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ENA_ZOOM_CTRL, CONFIG_TYPE_BOOL);
  153. if (SI->fDigitalZoomMax > 0){
  154. config_setting_set_bool(pSetting, true);
  155. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ZOOM_MAX, CONFIG_TYPE_FLOAT);
  156. tfVal = 1.f;
  157. config_setting_set_float(pSetting, tfVal);
  158. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ZOOM_DIGITAL_MAX, CONFIG_TYPE_FLOAT);
  159. config_setting_set_float(pSetting, SI->fDigitalZoomMax);
  160. } else {
  161. config_setting_set_bool(pSetting, false);
  162. };
  163. };
  164. if( SI->bAutoExposure || SI->fManualExposure > 0 ){
  165. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ENA_EXPOSURE_CTRL, CONFIG_TYPE_BOOL);
  166. config_setting_set_bool(pSetting, true );
  167. m_sCameraInfo.m_bExpoEna = true;
  168. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_EXPOSURE_ENA_AUTO, CONFIG_TYPE_BOOL);
  169. config_setting_set_bool(pSetting, SI->bAutoExposure );
  170. m_sCameraInfo.m_bAutoExposure = SI->bAutoExposure;
  171. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_MANUAL_EXPOSURE_VAL, CONFIG_TYPE_FLOAT);
  172. config_setting_set_float(pSetting, SI->fManualExposure);
  173. m_sCameraInfo.m_fManualExposure = SI->fManualExposure;
  174. };
  175. if( SI->bAutoFocus || SI->fManualFocus > 0 ){
  176. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ENA_FOCUS_CTRL, CONFIG_TYPE_BOOL);
  177. config_setting_set_bool(pSetting, true);
  178. m_sCameraInfo.m_bFocusEna = true;
  179. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_FOCUS_ENA_AUTO, CONFIG_TYPE_BOOL);
  180. config_setting_set_bool(pSetting, SI->bAutoFocus);
  181. m_sCameraInfo.m_bAutoFocus = SI->bAutoFocus;
  182. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_FOCUS_MANUAL_VAL, CONFIG_TYPE_FLOAT);
  183. config_setting_set_float(pSetting, SI->fManualFocus);
  184. m_sCameraInfo.m_fManualFocus = SI->fManualFocus;
  185. };
  186. if( SI->bAutoIris || SI->fManualIris > 0 ){
  187. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ENA_IRIS_CTRL, CONFIG_TYPE_BOOL);
  188. config_setting_set_bool(pSetting, true);
  189. m_sCameraInfo.m_bIrisEna = true;
  190. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_IRIS_ENA_AUTO, CONFIG_TYPE_BOOL);
  191. config_setting_set_bool(pSetting, SI->bAutoIris);
  192. m_sCameraInfo.m_bAutoIris = SI->bAutoIris;
  193. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_MANUAL_IRIS_VAL, CONFIG_TYPE_FLOAT);
  194. config_setting_set_float(pSetting, SI->fManualIris);
  195. m_sCameraInfo.m_fManualIris = SI->fManualIris;
  196. };
  197. if (SI->bAutoWB || SI->fManualWB){
  198. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_ENA_WB_CTRL, CONFIG_TYPE_BOOL);
  199. config_setting_set_bool(pSetting, true);
  200. m_sCameraInfo.m_bWBEna = true;
  201. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_WB_ENA_AUTO, CONFIG_TYPE_BOOL);
  202. config_setting_set_bool(pSetting, SI->bAutoWB);
  203. m_sCameraInfo.m_bAutoWB = SI->bAutoWB;
  204. pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_WB_WB_VAL, CONFIG_TYPE_FLOAT);
  205. config_setting_set_float(pSetting, SI->fManualWB);
  206. m_sCameraInfo.m_fManualWB = SI->fManualWB;
  207. };
  208. return create();
  209. };
  210. return false;
  211. };
  212. void objectStaticCamera::updateSettings(void){
  213. if (!m_pSettings) return;
  214. basicCamera::updateSettings();
  215. };
  216. void objectStaticCamera::dispatchEvent(basicEvent *Evt){
  217. };