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.

181 lines
6.4 KiB

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::setMainMediaViewer(basicMediaDestination *V){
  69. m_pMainPreview = V;
  70. if (m_pMainPreview != NULL){
  71. if (m_pCurrentVideoNode != NULL) m_pCurrentVideoNode->connect(m_pMainPreview);
  72. };
  73. };
  74. void VideoSourceChooser::showAddSourceDialog( ){
  75. if( m_pAddSourceDialog == NULL ){
  76. m_pAddSourceDialog = new guiAddSourceDialog(this);
  77. };
  78. if (m_pAddSourceDialog != NULL){
  79. m_pAddSourceDialog->setDialogStage(0);// m_nAddSourceDialogStage);
  80. m_pAddSourceDialog->setModal(true);
  81. m_pAddSourceDialog->show();
  82. };
  83. };
  84. void VideoSourceChooser::createNew(SOURCE_INFO *SI){
  85. basicCamera *tCamera = NULL;
  86. VideoThumbWidget *t_VG = NULL;
  87. VideoThumbWidget *t_PVG = NULL;
  88. tCamera = m_pSourceManager->addSource(SI);
  89. if (tCamera){
  90. t_VG = new VideoThumbWidget(NULL);
  91. //t_VG->init();
  92. t_VG->setError(true, "Waiting for Stream");
  93. m_pHorizontalLayout->removeWidget(m_pButtonCmdAdd);
  94. m_pHorizontalLayout->removeItem(m_pSideSpacer);
  95. m_pHorizontalLayout->addWidget(t_VG, 0, Qt::AlignLeft | Qt::AlignTop);
  96. m_pHorizontalLayout->addWidget(m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop);
  97. m_pHorizontalLayout->addItem(m_pSideSpacer);
  98. tCamera->setViewer((basicMediaDestination*)t_VG);
  99. t_VG->init();
  100. //t_VG->setSignalParameter(this, (void *)tCamera->m_pVideoNode);
  101. t_VG->setSignalParameter(this, tCamera);
  102. t_VG->setError(false);
  103. /* Video Processor */
  104. /*
  105. t_PVG = new VideoThumbWidget(NULL);
  106. t_PVG->setError(true, "Waiting for Stream");
  107. m_pHorizontalLayout->removeWidget(m_pButtonCmdAdd);
  108. m_pHorizontalLayout->removeItem(m_pSideSpacer);
  109. m_pHorizontalLayout->addWidget(t_PVG, 0, Qt::AlignLeft | Qt::AlignTop);
  110. m_pHorizontalLayout->addWidget(m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop);
  111. m_pHorizontalLayout->addItem(m_pSideSpacer);
  112. t_PVG->init();
  113. t_PVG->setSignalParameter(this, (void *)tCamera->m_pVideoNode);
  114. //*
  115. vlfeatDetector *bDet;
  116. bDet = new vlfeatDetector();
  117. bDet->attachDestination((basicMediaDestination*)m_pMainPreview); //t_PVG);
  118. tCamera->m_pVideoNode->connect((basicMediaDestination*)bDet);
  119. bDet->init();
  120. //*/
  121. /*
  122. surfDetector *bDet;
  123. bDet = new surfDetector();
  124. bDet->attachDestination((basicMediaDestination*)m_pMainPreview); //t_PVG);
  125. tCamera->m_pVideoNode->connect((basicMediaDestination*)bDet);
  126. bDet->init();
  127. //*/
  128. /*
  129. opticalFlowDetector *bDet;
  130. bDet = new opticalFlowDetector();
  131. bDet->attachDestination((basicMediaDestination*)m_pMainPreview); //t_PVG);
  132. tCamera->m_pVideoNode->connect((basicMediaDestination*)bDet);
  133. bDet->init();
  134. //*/
  135. /*
  136. blobDetector *bDet;
  137. bDet = new blobDetector();
  138. bDet->attachDestination((basicMediaDestination*)m_pMainPreview); //t_PVG);
  139. tCamera->m_pVideoNode->connect((basicMediaDestination*)bDet);
  140. bDet->init();
  141. //*/
  142. /*
  143. motionDetector *vMD;
  144. vMD = new motionDetector();
  145. vMD->attachDestination((basicMediaDestination*)m_pMainPreview); //t_PVG);
  146. tCamera->m_pVideoNode->connect((basicMediaDestination*)vMD);
  147. vMD->setParametersEx(3, 10);
  148. vMD->init();
  149. //*/
  150. /*
  151. darknetDetector *dDet;
  152. dDet = new darknetDetector();
  153. dDet->attachDestination((basicMediaDestination*)m_pMainPreview);//t_PVG);
  154. tCamera->m_pVideoNode->connect((basicMediaDestination*)dDet);
  155. dDet->init();
  156. //*/
  157. //t_PVG->init();
  158. //t_PVG->setSignalParameter(this, (void *)tCamera->m_pVideoNode);
  159. // t_PVG->setError(false);
  160. };
  161. };