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.

187 lines
6.5 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "VideoSourceChooser.h"
  2. #include "VideoWidget.h"
  3. #include "OpenGLWidget.h"
  4. VideoSourceChooser::VideoSourceChooser( QWidget *parent ): QWidget(parent){
  5. m_pSourceManager = mediaVideoSourceManager::getInstance();
  6. m_pAddSourceDialog = NULL;
  7. m_pParentWidget = parent;
  8. m_pHorizontalLayout = new QHBoxLayout();
  9. m_pHorizontalLayout->setSpacing(6);
  10. m_pHorizontalLayout->setContentsMargins(11, 11, 11, 11);
  11. m_pMainPreview = NULL;
  12. m_pButtonCmdAdd = new QPushButton(this);
  13. m_pButtonCmdAdd->setFixedSize(60, 180);
  14. QIcon icon1;
  15. icon1.addFile(QStringLiteral(":pictures/appbar.add.png"), QSize(), QIcon::Normal, QIcon::Off);
  16. m_pButtonCmdAdd->setIcon(icon1);
  17. m_pButtonCmdAdd->setIconSize(QSize(32, 32));
  18. m_pButtonCmdAdd->setFlat(false);
  19. connect(m_pButtonCmdAdd, &QPushButton::clicked, this, &VideoSourceChooser::showAddSourceDialog);
  20. setLayout( m_pHorizontalLayout );
  21. m_pHorizontalLayout->addWidget( m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop );
  22. m_pSideSpacer = new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Minimum);
  23. m_pHorizontalLayout->addItem(m_pSideSpacer);
  24. //setFixedSize( 1400, 200 );
  25. m_pCurrentVideoNode = NULL;
  26. m_pCurrentCamera = NULL;
  27. for (vectorCamerasInterator index = m_pSourceManager->getCameraCollectionBegin(); index < m_pSourceManager->getCameraCollectionEnd(); index++){
  28. VideoThumbWidget *t_VG;
  29. t_VG = new VideoThumbWidget(NULL);
  30. if (m_pCurrentVideoNode == NULL) m_pCurrentVideoNode = (*index)->m_pVideoNode;
  31. if (m_pCurrentCamera == NULL) m_pCurrentCamera = (*index);
  32. t_VG->setError(true, "Waiting for Stream");
  33. m_pHorizontalLayout->removeWidget(m_pButtonCmdAdd);
  34. m_pHorizontalLayout->removeItem(m_pSideSpacer);
  35. m_pHorizontalLayout->addWidget(t_VG, 0, Qt::AlignLeft | Qt::AlignTop);
  36. m_pHorizontalLayout->addWidget(m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop);
  37. m_pHorizontalLayout->addItem(m_pSideSpacer);
  38. (*index)->setViewer((basicMediaDestination*)t_VG);
  39. //if (m_pCurrentVideoNode == NULL)(*index)->setViewer((basicMediaViewer*)t_VG);
  40. t_VG->init();
  41. //t_VG->setSignalParameter(this,(void *)(*index)->m_pVideoNode);
  42. t_VG->setSignalParameter( this, (*index));
  43. t_VG->setError(false);
  44. };
  45. };
  46. VideoSourceChooser::~VideoSourceChooser(){
  47. setMainMediaViewer(NULL);
  48. m_pSourceManager->shutdownAllVideoSources();
  49. if (m_pHorizontalLayout->children().size()){
  50. QObjectList tQL = m_pHorizontalLayout->children();
  51. for (QObjectList::Iterator index = tQL.begin(); index < tQL.end(); index++){
  52. delete(*index);
  53. };
  54. tQL.clear();
  55. };
  56. };
  57. void VideoSourceChooser::selectForMainPreview(void *P){
  58. if (P != NULL){
  59. m_pCurrentCamera = ((basicCamera *)P);
  60. if (m_pMainPreview != NULL){
  61. if (m_pCurrentVideoNode != NULL) m_pCurrentVideoNode->disconnect(m_pMainPreview);
  62. m_pCurrentVideoNode = m_pCurrentCamera->m_pVideoNode;
  63. m_pCurrentVideoNode->connect(m_pMainPreview);
  64. ((VideoWidget*)m_pMainPreview)->setCameraControl(m_pCurrentCamera, m_pCurrentCamera->getCaps() );
  65. };
  66. };
  67. };
  68. void VideoSourceChooser::removeCamera(basicCamera * ptr){
  69. if (m_pSourceManager->removeSource(ptr)){
  70. };
  71. };
  72. void VideoSourceChooser::setMainMediaViewer(basicMediaDestination *V){
  73. m_pMainPreview = V;
  74. if (m_pMainPreview != NULL){
  75. if (m_pCurrentVideoNode != NULL) m_pCurrentVideoNode->connect(m_pMainPreview);
  76. };
  77. };
  78. void VideoSourceChooser::showAddSourceDialog( ){
  79. if( m_pAddSourceDialog == NULL ){
  80. m_pAddSourceDialog = new guiAddSourceDialog(this);
  81. };
  82. if (m_pAddSourceDialog != NULL){
  83. m_pAddSourceDialog->setDialogStage(0);// m_nAddSourceDialogStage);
  84. m_pAddSourceDialog->setModal(true);
  85. m_pAddSourceDialog->show();
  86. };
  87. };
  88. void VideoSourceChooser::createNew(SOURCE_INFO *SI){
  89. basicCamera *tCamera = NULL;
  90. VideoThumbWidget *t_VG = NULL;
  91. VideoThumbWidget *t_PVG = NULL;
  92. tCamera = m_pSourceManager->addSource(SI);
  93. if (tCamera){
  94. t_VG = new VideoThumbWidget(NULL);
  95. //t_VG->init();
  96. t_VG->setError(true, "Waiting for Stream");
  97. m_pHorizontalLayout->removeWidget(m_pButtonCmdAdd);
  98. m_pHorizontalLayout->removeItem(m_pSideSpacer);
  99. m_pHorizontalLayout->addWidget(t_VG, 0, Qt::AlignLeft | Qt::AlignTop);
  100. m_pHorizontalLayout->addWidget(m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop);
  101. m_pHorizontalLayout->addItem(m_pSideSpacer);
  102. tCamera->setViewer((basicMediaDestination*)t_VG);
  103. t_VG->init();
  104. //t_VG->setSignalParameter(this, (void *)tCamera->m_pVideoNode);
  105. t_VG->setSignalParameter(this, tCamera);
  106. t_VG->setError(false);
  107. /* Video Processor */
  108. /*
  109. t_PVG = new VideoThumbWidget(NULL);
  110. t_PVG->setError(true, "Waiting for Stream");
  111. m_pHorizontalLayout->removeWidget(m_pButtonCmdAdd);
  112. m_pHorizontalLayout->removeItem(m_pSideSpacer);
  113. m_pHorizontalLayout->addWidget(t_PVG, 0, Qt::AlignLeft | Qt::AlignTop);
  114. m_pHorizontalLayout->addWidget(m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop);
  115. m_pHorizontalLayout->addItem(m_pSideSpacer);
  116. t_PVG->init();
  117. t_PVG->setSignalParameter(this, (void *)tCamera->m_pVideoNode);
  118. //*
  119. vlfeatDetector *bDet;
  120. bDet = new vlfeatDetector();
  121. bDet->attachDestination((basicMediaDestination*)m_pMainPreview); //t_PVG);
  122. tCamera->m_pVideoNode->connect((basicMediaDestination*)bDet);
  123. bDet->init();
  124. //*/
  125. /*
  126. surfDetector *bDet;
  127. bDet = new surfDetector();
  128. bDet->attachDestination((basicMediaDestination*)m_pMainPreview); //t_PVG);
  129. tCamera->m_pVideoNode->connect((basicMediaDestination*)bDet);
  130. bDet->init();
  131. //*/
  132. /*
  133. opticalFlowDetector *bDet;
  134. bDet = new opticalFlowDetector();
  135. bDet->attachDestination((basicMediaDestination*)m_pMainPreview); //t_PVG);
  136. tCamera->m_pVideoNode->connect((basicMediaDestination*)bDet);
  137. bDet->init();
  138. //*/
  139. /*
  140. blobDetector *bDet;
  141. bDet = new blobDetector();
  142. bDet->attachDestination((basicMediaDestination*)m_pMainPreview); //t_PVG);
  143. tCamera->m_pVideoNode->connect((basicMediaDestination*)bDet);
  144. bDet->init();
  145. //*/
  146. /*
  147. motionDetector *vMD;
  148. vMD = new motionDetector();
  149. vMD->attachDestination((basicMediaDestination*)m_pMainPreview); //t_PVG);
  150. tCamera->m_pVideoNode->connect((basicMediaDestination*)vMD);
  151. vMD->setParametersEx(3, 10);
  152. vMD->init();
  153. //*/
  154. /*
  155. darknetDetector *dDet;
  156. dDet = new darknetDetector();
  157. dDet->attachDestination((basicMediaDestination*)m_pMainPreview);//t_PVG);
  158. tCamera->m_pVideoNode->connect((basicMediaDestination*)dDet);
  159. dDet->init();
  160. //*/
  161. //t_PVG->init();
  162. //t_PVG->setSignalParameter(this, (void *)tCamera->m_pVideoNode);
  163. // t_PVG->setError(false);
  164. };
  165. };