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
187 lines
6.5 KiB
#include "VideoSourceChooser.h"
|
|
#include "VideoWidget.h"
|
|
#include "OpenGLWidget.h"
|
|
|
|
|
|
VideoSourceChooser::VideoSourceChooser( QWidget *parent ): QWidget(parent){
|
|
m_pSourceManager = mediaVideoSourceManager::getInstance();
|
|
m_pAddSourceDialog = NULL;
|
|
m_pParentWidget = parent;
|
|
m_pHorizontalLayout = new QHBoxLayout();
|
|
m_pHorizontalLayout->setSpacing(6);
|
|
m_pHorizontalLayout->setContentsMargins(11, 11, 11, 11);
|
|
m_pMainPreview = NULL;
|
|
|
|
|
|
m_pButtonCmdAdd = new QPushButton(this);
|
|
m_pButtonCmdAdd->setFixedSize(60, 180);
|
|
QIcon icon1;
|
|
icon1.addFile(QStringLiteral(":pictures/appbar.add.png"), QSize(), QIcon::Normal, QIcon::Off);
|
|
m_pButtonCmdAdd->setIcon(icon1);
|
|
m_pButtonCmdAdd->setIconSize(QSize(32, 32));
|
|
m_pButtonCmdAdd->setFlat(false);
|
|
|
|
|
|
|
|
connect(m_pButtonCmdAdd, &QPushButton::clicked, this, &VideoSourceChooser::showAddSourceDialog);
|
|
|
|
setLayout( m_pHorizontalLayout );
|
|
m_pHorizontalLayout->addWidget( m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop );
|
|
m_pSideSpacer = new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
|
m_pHorizontalLayout->addItem(m_pSideSpacer);
|
|
//setFixedSize( 1400, 200 );
|
|
m_pCurrentVideoNode = NULL;
|
|
m_pCurrentCamera = NULL;
|
|
for (vectorCamerasInterator index = m_pSourceManager->getCameraCollectionBegin(); index < m_pSourceManager->getCameraCollectionEnd(); index++){
|
|
VideoThumbWidget *t_VG;
|
|
t_VG = new VideoThumbWidget(NULL);
|
|
if (m_pCurrentVideoNode == NULL) m_pCurrentVideoNode = (*index)->m_pVideoNode;
|
|
if (m_pCurrentCamera == NULL) m_pCurrentCamera = (*index);
|
|
t_VG->setError(true, "Waiting for Stream");
|
|
m_pHorizontalLayout->removeWidget(m_pButtonCmdAdd);
|
|
m_pHorizontalLayout->removeItem(m_pSideSpacer);
|
|
m_pHorizontalLayout->addWidget(t_VG, 0, Qt::AlignLeft | Qt::AlignTop);
|
|
m_pHorizontalLayout->addWidget(m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop);
|
|
m_pHorizontalLayout->addItem(m_pSideSpacer);
|
|
(*index)->setViewer((basicMediaDestination*)t_VG);
|
|
//if (m_pCurrentVideoNode == NULL)(*index)->setViewer((basicMediaViewer*)t_VG);
|
|
t_VG->init();
|
|
//t_VG->setSignalParameter(this,(void *)(*index)->m_pVideoNode);
|
|
t_VG->setSignalParameter( this, (*index));
|
|
t_VG->setError(false);
|
|
};
|
|
};
|
|
|
|
VideoSourceChooser::~VideoSourceChooser(){
|
|
setMainMediaViewer(NULL);
|
|
m_pSourceManager->shutdownAllVideoSources();
|
|
if (m_pHorizontalLayout->children().size()){
|
|
QObjectList tQL = m_pHorizontalLayout->children();
|
|
for (QObjectList::Iterator index = tQL.begin(); index < tQL.end(); index++){
|
|
delete(*index);
|
|
};
|
|
tQL.clear();
|
|
};
|
|
};
|
|
|
|
void VideoSourceChooser::selectForMainPreview(void *P){
|
|
if (P != NULL){
|
|
m_pCurrentCamera = ((basicCamera *)P);
|
|
if (m_pMainPreview != NULL){
|
|
if (m_pCurrentVideoNode != NULL) m_pCurrentVideoNode->disconnect(m_pMainPreview);
|
|
m_pCurrentVideoNode = m_pCurrentCamera->m_pVideoNode;
|
|
m_pCurrentVideoNode->connect(m_pMainPreview);
|
|
((VideoWidget*)m_pMainPreview)->setCameraControl(m_pCurrentCamera, m_pCurrentCamera->getCaps() );
|
|
};
|
|
};
|
|
};
|
|
|
|
void VideoSourceChooser::removeCamera(basicCamera * ptr){
|
|
if (m_pSourceManager->removeSource(ptr)){
|
|
|
|
};
|
|
};
|
|
|
|
void VideoSourceChooser::setMainMediaViewer(basicMediaDestination *V){
|
|
m_pMainPreview = V;
|
|
if (m_pMainPreview != NULL){
|
|
if (m_pCurrentVideoNode != NULL) m_pCurrentVideoNode->connect(m_pMainPreview);
|
|
};
|
|
};
|
|
|
|
void VideoSourceChooser::showAddSourceDialog( ){
|
|
if( m_pAddSourceDialog == NULL ){
|
|
m_pAddSourceDialog = new guiAddSourceDialog(this);
|
|
};
|
|
if (m_pAddSourceDialog != NULL){
|
|
m_pAddSourceDialog->setDialogStage(0);// m_nAddSourceDialogStage);
|
|
m_pAddSourceDialog->setModal(true);
|
|
m_pAddSourceDialog->show();
|
|
};
|
|
};
|
|
|
|
void VideoSourceChooser::createNew(SOURCE_INFO *SI){
|
|
basicCamera *tCamera = NULL;
|
|
VideoThumbWidget *t_VG = NULL;
|
|
VideoThumbWidget *t_PVG = NULL;
|
|
tCamera = m_pSourceManager->addSource(SI);
|
|
if (tCamera){
|
|
t_VG = new VideoThumbWidget(NULL);
|
|
//t_VG->init();
|
|
t_VG->setError(true, "Waiting for Stream");
|
|
m_pHorizontalLayout->removeWidget(m_pButtonCmdAdd);
|
|
m_pHorizontalLayout->removeItem(m_pSideSpacer);
|
|
m_pHorizontalLayout->addWidget(t_VG, 0, Qt::AlignLeft | Qt::AlignTop);
|
|
m_pHorizontalLayout->addWidget(m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop);
|
|
m_pHorizontalLayout->addItem(m_pSideSpacer);
|
|
tCamera->setViewer((basicMediaDestination*)t_VG);
|
|
t_VG->init();
|
|
//t_VG->setSignalParameter(this, (void *)tCamera->m_pVideoNode);
|
|
t_VG->setSignalParameter(this, tCamera);
|
|
t_VG->setError(false);
|
|
/* Video Processor */
|
|
|
|
/*
|
|
t_PVG = new VideoThumbWidget(NULL);
|
|
t_PVG->setError(true, "Waiting for Stream");
|
|
m_pHorizontalLayout->removeWidget(m_pButtonCmdAdd);
|
|
m_pHorizontalLayout->removeItem(m_pSideSpacer);
|
|
m_pHorizontalLayout->addWidget(t_PVG, 0, Qt::AlignLeft | Qt::AlignTop);
|
|
m_pHorizontalLayout->addWidget(m_pButtonCmdAdd, 0, Qt::AlignLeft | Qt::AlignTop);
|
|
m_pHorizontalLayout->addItem(m_pSideSpacer);
|
|
t_PVG->init();
|
|
t_PVG->setSignalParameter(this, (void *)tCamera->m_pVideoNode);
|
|
|
|
//*
|
|
vlfeatDetector *bDet;
|
|
bDet = new vlfeatDetector();
|
|
bDet->attachDestination((basicMediaDestination*)m_pMainPreview); //t_PVG);
|
|
tCamera->m_pVideoNode->connect((basicMediaDestination*)bDet);
|
|
bDet->init();
|
|
//*/
|
|
|
|
/*
|
|
surfDetector *bDet;
|
|
bDet = new surfDetector();
|
|
bDet->attachDestination((basicMediaDestination*)m_pMainPreview); //t_PVG);
|
|
tCamera->m_pVideoNode->connect((basicMediaDestination*)bDet);
|
|
bDet->init();
|
|
//*/
|
|
|
|
/*
|
|
opticalFlowDetector *bDet;
|
|
bDet = new opticalFlowDetector();
|
|
bDet->attachDestination((basicMediaDestination*)m_pMainPreview); //t_PVG);
|
|
tCamera->m_pVideoNode->connect((basicMediaDestination*)bDet);
|
|
bDet->init();
|
|
//*/
|
|
|
|
/*
|
|
blobDetector *bDet;
|
|
bDet = new blobDetector();
|
|
bDet->attachDestination((basicMediaDestination*)m_pMainPreview); //t_PVG);
|
|
tCamera->m_pVideoNode->connect((basicMediaDestination*)bDet);
|
|
bDet->init();
|
|
//*/
|
|
/*
|
|
motionDetector *vMD;
|
|
vMD = new motionDetector();
|
|
vMD->attachDestination((basicMediaDestination*)m_pMainPreview); //t_PVG);
|
|
tCamera->m_pVideoNode->connect((basicMediaDestination*)vMD);
|
|
vMD->setParametersEx(3, 10);
|
|
vMD->init();
|
|
//*/
|
|
/*
|
|
darknetDetector *dDet;
|
|
dDet = new darknetDetector();
|
|
dDet->attachDestination((basicMediaDestination*)m_pMainPreview);//t_PVG);
|
|
tCamera->m_pVideoNode->connect((basicMediaDestination*)dDet);
|
|
dDet->init();
|
|
//*/
|
|
|
|
//t_PVG->init();
|
|
//t_PVG->setSignalParameter(this, (void *)tCamera->m_pVideoNode);
|
|
// t_PVG->setError(false);
|
|
};
|
|
};
|
|
|