Offers widgets to play/pause/stop a video on a certain render window with the use of an !initialized! QmitkVideoBackground. The QmitkVideoBackground should contain an OpenCVVideoSource is then owned by this widget (and deleted) More...
#include <QmitkOpenCVVideoControls.h>
Offers widgets to play/pause/stop a video on a certain render window with the use of an !initialized! QmitkVideoBackground. The QmitkVideoBackground should contain an OpenCVVideoSource is then owned by this widget (and deleted)
Definition at line 38 of file QmitkOpenCVVideoControls.h.
QmitkOpenCVVideoControls::QmitkOpenCVVideoControls | ( | QmitkVideoBackground * | _VideoBackground, |
QmitkStdMultiWidget * | _MultiWidget, | ||
QWidget * | parent = 0 , |
||
Qt::WindowFlags | f = 0 |
||
) |
Construct the widget with the given render window and the given preset values
Definition at line 23 of file QmitkOpenCVVideoControls.cpp.
References m_Controls, SetStdMultiWidget(), and SetVideoBackground().
: QWidget(parent, f) , m_VideoBackground(0) , m_MultiWidget(0) , m_VideoSource(0) , m_Controls(new Ui::QmitkOpenCVVideoControls) , m_SliderCurrentlyMoved(false) { m_Controls->setupUi(this); m_Controls->FileChooser->SetFileMustExist(true); m_Controls->FileChooser->SetSelectDir(false); this->SetStdMultiWidget(_MultiWidget); this->SetVideoBackground(_VideoBackground); }
QmitkOpenCVVideoControls::~QmitkOpenCVVideoControls | ( | ) | [virtual] |
call reset if video playback is enabled here
Definition at line 41 of file QmitkOpenCVVideoControls.cpp.
References mitk::VideoSource::IsCapturingEnabled(), m_VideoSource, and Stop().
{ if(m_VideoSource != 0 && m_VideoSource->IsCapturingEnabled()) this->Stop(); // emulate stop }
QmitkStdMultiWidget * QmitkOpenCVVideoControls::GetStdMultiWidget | ( | ) | const |
returns the current multiwidget
Definition at line 263 of file QmitkOpenCVVideoControls.cpp.
References m_MultiWidget.
{ return m_MultiWidget; }
QmitkVideoBackground * QmitkOpenCVVideoControls::GetVideoBackground | ( | ) | const |
returns the current QmitkVideoBackground
Definition at line 316 of file QmitkOpenCVVideoControls.cpp.
References m_VideoBackground.
{ return m_VideoBackground; }
void QmitkOpenCVVideoControls::NewFrameAvailable | ( | mitk::VideoSource * | videoSource ) | [protected, slot] |
Definition at line 225 of file QmitkOpenCVVideoControls.cpp.
References mitk::OpenCVVideoSource::GetCurrentFrame(), mitk::OpenCVVideoSource::GetVideoCaptureProperty(), m_Controls, m_SliderCurrentlyMoved, m_VideoSource, and NewOpenCVFrameAvailable().
Referenced by on_PlayButton_clicked(), and Stop().
{ emit NewOpenCVFrameAvailable( m_VideoSource->GetCurrentFrame() ); if(!m_SliderCurrentlyMoved) m_Controls->VideoProgressSlider->setValue( itk::Math::Round( m_VideoSource->GetVideoCaptureProperty(CV_CAP_PROP_POS_AVI_RATIO) *m_Controls->VideoProgressSlider->maximum() ) ); }
void QmitkOpenCVVideoControls::NewOpenCVFrameAvailable | ( | const IplImage * | ) | [signal] |
When playback is started this informs when a new frame was grabbed
Referenced by NewFrameAvailable().
void QmitkOpenCVVideoControls::on_PlayButton_clicked | ( | bool | checked = false ) |
[protected, slot] |
Definition at line 96 of file QmitkOpenCVVideoControls.cpp.
References QmitkVideoBackground::AddRenderWindow(), QmitkStdMultiWidget::DisableGradientBackground(), QmitkVideoBackground::Enable(), mitk::OpenCVVideoSource::GetCapturePaused(), QmitkStdMultiWidget::GetRenderWindow4(), mitk::VideoSource::IsCapturingEnabled(), m_Controls, m_MultiWidget, m_VideoBackground, m_VideoSource, MITK_ERROR, MITK_INFO, NewFrameAvailable(), mitk::OpenCVVideoSource::PauseCapturing(), mitk::OpenCVVideoSource::SetRepeatVideo(), QmitkVideoBackground::SetTimerDelay(), mitk::OpenCVVideoSource::SetVideoCameraInput(), mitk::OpenCVVideoSource::SetVideoFileInput(), mitk::OpenCVVideoSource::StartCapturing(), and SwitchPlayButton().
{ MITK_INFO << "play button clicked"; if(checked) { if( m_VideoSource->GetCapturePaused() ) { this->SwitchPlayButton(false); m_VideoSource->PauseCapturing(); } else { if(m_Controls->UseGrabbingDeviceButton->isChecked()) { m_VideoSource->SetVideoCameraInput(m_Controls->GrabbingDeviceNumber->text().toInt(),false); m_Controls->VideoFileControls->setEnabled(false); } else { m_VideoSource->SetVideoFileInput(m_Controls->FileChooser->GetFile().c_str(), m_Controls->RepeatVideoButton->isChecked(), false); m_VideoSource->SetRepeatVideo(m_Controls->RepeatVideoButton->isChecked()); m_Controls->VideoProgressSlider->setValue(0); } m_VideoSource->StartCapturing(); if(!m_VideoSource->IsCapturingEnabled()) { MITK_ERROR << "Video could not be initialized!"; m_Controls->PlayButton->setChecked(false); } else { int hertz = m_Controls->UpdateRate->text().toInt(); int updateTime = itk::Math::Round( static_cast<double>(1000.0/hertz) ); // resets the whole background m_VideoBackground->SetTimerDelay( updateTime ); m_VideoBackground->AddRenderWindow( m_MultiWidget->GetRenderWindow4()->GetRenderWindow() ); this->connect( m_VideoBackground, SIGNAL(NewFrameAvailable(mitk::VideoSource*)) , this, SLOT(NewFrameAvailable(mitk::VideoSource*))); m_MultiWidget->DisableGradientBackground(); m_VideoBackground->Enable(); this->m_Controls->StopButton->setEnabled(true); // show video file controls if(m_Controls->UseVideoFileButton->isChecked()) { m_Controls->VideoFileControls->setEnabled(true); m_Controls->RepeatVideoButton->setEnabled(true); m_Controls->VideoProgressSlider->setEnabled(true); } // show pause button this->SwitchPlayButton(false); // disable other controls m_Controls->GrabbingDevicePanel->setEnabled(false); m_Controls->VideoFilePanel->setEnabled(false); m_Controls->UseGrabbingDeviceButton->setEnabled(false); m_Controls->UseVideoFileButton->setEnabled(false); m_Controls->UpdateRatePanel->setEnabled(false); } } } else { // show pause button this->SwitchPlayButton(true); m_VideoSource->PauseCapturing(); } }
void QmitkOpenCVVideoControls::on_RepeatVideoButton_clicked | ( | bool | checked = false ) |
[protected, slot] |
Definition at line 90 of file QmitkOpenCVVideoControls.cpp.
References m_VideoSource, MITK_INFO, and mitk::OpenCVVideoSource::SetRepeatVideo().
{ MITK_INFO << "repeat video clicked"; m_VideoSource->SetRepeatVideo(checked); }
void QmitkOpenCVVideoControls::on_StopButton_clicked | ( | bool | checked = false ) |
[protected, slot] |
void QmitkOpenCVVideoControls::on_UseGrabbingDeviceButton_clicked | ( | bool | checked = false ) |
[protected, slot] |
Definition at line 47 of file QmitkOpenCVVideoControls.cpp.
References m_Controls.
Referenced by SetVideoBackground(), and Stop().
{ m_Controls->GrabbingDevicePanel->setEnabled(true); m_Controls->VideoFilePanel->setEnabled(false); }
void QmitkOpenCVVideoControls::on_UseVideoFileButton_clicked | ( | bool | checked = false ) |
[protected, slot] |
Definition at line 53 of file QmitkOpenCVVideoControls.cpp.
References m_Controls.
Referenced by Stop().
{ m_Controls->GrabbingDevicePanel->setEnabled(false); m_Controls->VideoFilePanel->setEnabled(true); m_Controls->FileChooser->setEnabled(true); }
void QmitkOpenCVVideoControls::on_VideoProgressSlider_sliderPressed | ( | ) | [protected, slot] |
Definition at line 68 of file QmitkOpenCVVideoControls.cpp.
References mitk::OpenCVVideoSource::GetCapturePaused(), mitk::OpenCVVideoSource::GetVideoCaptureProperty(), m_SliderCurrentlyMoved, m_VideoSource, MITK_DEBUG, and mitk::OpenCVVideoSource::PauseCapturing().
{ m_SliderCurrentlyMoved = true; // temporary pause the video while sliding if( !m_VideoSource->GetCapturePaused() ) m_VideoSource->PauseCapturing(); MITK_DEBUG << "freezing video with old pos ratio: "<< m_VideoSource->GetVideoCaptureProperty(CV_CAP_PROP_POS_AVI_RATIO); }
void QmitkOpenCVVideoControls::on_VideoProgressSlider_sliderReleased | ( | ) | [protected, slot] |
Definition at line 77 of file QmitkOpenCVVideoControls.cpp.
References mitk::OpenCVVideoSource::GetCapturePaused(), m_Controls, m_SliderCurrentlyMoved, m_VideoSource, MITK_DEBUG, mitk::OpenCVVideoSource::PauseCapturing(), and mitk::OpenCVVideoSource::SetVideoCaptureProperty().
{ double progressRatio = static_cast<double>(m_Controls->VideoProgressSlider->value()) /static_cast<double>(m_Controls->VideoProgressSlider->maximum()); m_VideoSource->SetVideoCaptureProperty(CV_CAP_PROP_POS_AVI_RATIO, progressRatio); MITK_DEBUG << "resuming video with new pos ratio: "<< progressRatio; // resume the video ( if it was not paused by the user) if( m_VideoSource->GetCapturePaused() && m_Controls->PlayButton->isChecked() ) m_VideoSource->PauseCapturing(); m_SliderCurrentlyMoved = false; }
void QmitkOpenCVVideoControls::QObjectDestroyed | ( | QObject * | obj = 0 ) |
[protected, slot] |
Definition at line 321 of file QmitkOpenCVVideoControls.cpp.
References m_MultiWidget, m_VideoBackground, m_VideoSource, SetStdMultiWidget(), and SetVideoBackground().
Referenced by SetStdMultiWidget(), and SetVideoBackground().
{ if(m_MultiWidget == obj) this->SetStdMultiWidget(0); else if(m_VideoBackground == obj) { m_VideoSource = 0; this->SetVideoBackground(0); } }
void QmitkOpenCVVideoControls::Reset | ( | ) | [protected, slot] |
Definition at line 204 of file QmitkOpenCVVideoControls.cpp.
References Stop().
Referenced by SetStdMultiWidget(), and SetVideoBackground().
{ this->Stop(); }
void QmitkOpenCVVideoControls::SetStdMultiWidget | ( | QmitkStdMultiWidget * | _MultiWidget ) |
sets the multiwidget for this video player
Definition at line 233 of file QmitkOpenCVVideoControls.cpp.
References m_MultiWidget, MITK_WARN, QObjectDestroyed(), and Reset().
Referenced by QmitkOpenCVVideoControls(), QObjectDestroyed(), and QmitkVideoPlayer::StdMultiWidgetAvailable().
{ if(m_MultiWidget == _MultiWidget) return; if(m_MultiWidget != 0) this->disconnect( m_MultiWidget, SIGNAL(destroyed(QObject*)) , this, SLOT(QObjectDestroyed(QObject*))); // In Reset() m_MultiWidget is used, set it to 0 now for avoiding errors if(_MultiWidget == 0) m_MultiWidget = 0; this->Reset(); m_MultiWidget = _MultiWidget; if(m_MultiWidget == 0) { MITK_WARN << "m_MultiWidget is 0"; this->setEnabled(false); } else { this->setEnabled(true); this->connect( m_MultiWidget, SIGNAL(destroyed(QObject*)) , this, SLOT(QObjectDestroyed(QObject*))); } }
void QmitkOpenCVVideoControls::SetVideoBackground | ( | QmitkVideoBackground * | _VideoBackground ) |
sets the qmitkvideobackground for this
Definition at line 268 of file QmitkOpenCVVideoControls.cpp.
References mitk::OpenCVVideoSource::GetGrabbingDeviceNumber(), QmitkVideoBackground::GetTimerDelay(), mitk::OpenCVVideoSource::GetVideoFileName(), QmitkVideoBackground::GetVideoSource(), m_Controls, m_VideoBackground, m_VideoSource, MITK_WARN, on_UseGrabbingDeviceButton_clicked(), QObjectDestroyed(), and Reset().
Referenced by QmitkOpenCVVideoControls(), and QObjectDestroyed().
{ if(m_VideoBackground == _VideoBackground) return; if(m_VideoBackground != 0) this->disconnect( m_VideoBackground, SIGNAL(destroyed(QObject*)) , this, SLOT(QObjectDestroyed(QObject*))); this->Reset(); m_VideoBackground = _VideoBackground; if(m_VideoBackground == 0) { m_VideoSource = 0; MITK_WARN << "m_MultiWidget is 0"; this->setEnabled(false); } else { this->setEnabled(true); m_VideoSource = dynamic_cast<mitk::OpenCVVideoSource*>(m_VideoBackground->GetVideoSource()); // preset form entries if(m_VideoSource != 0) { if(!m_VideoSource->GetVideoFileName().empty()) { m_Controls->FileChooser->SetFile( m_VideoSource->GetVideoFileName() ); on_UseGrabbingDeviceButton_clicked( false ); } else if( m_VideoSource->GetGrabbingDeviceNumber() >= 0) m_Controls->GrabbingDeviceNumber->setValue( m_VideoSource->GetGrabbingDeviceNumber() ); m_Controls->UpdateRate->setValue( m_VideoBackground->GetTimerDelay() ); this->connect( m_VideoBackground, SIGNAL(destroyed(QObject*)) , this, SLOT(QObjectDestroyed(QObject*))); } else { MITK_WARN << "m_VideoSource is 0"; this->setEnabled(false); } } }
void QmitkOpenCVVideoControls::Stop | ( | ) | [protected, slot] |
Definition at line 173 of file QmitkOpenCVVideoControls.cpp.
References QmitkVideoBackground::Disable(), QmitkStdMultiWidget::EnableGradientBackground(), QmitkStdMultiWidget::GetRenderWindow4(), m_Controls, m_MultiWidget, m_VideoBackground, m_VideoSource, NewFrameAvailable(), on_UseGrabbingDeviceButton_clicked(), on_UseVideoFileButton_clicked(), QmitkVideoBackground::RemoveRenderWindow(), mitk::OpenCVVideoSource::StopCapturing(), and SwitchPlayButton().
Referenced by on_StopButton_clicked(), Reset(), and ~QmitkOpenCVVideoControls().
{ // disable video file controls, stop button and show play button again m_Controls->UseGrabbingDeviceButton->setEnabled(true); m_Controls->UseVideoFileButton->setEnabled(true); if(m_Controls->UseGrabbingDeviceButton->isChecked()) on_UseGrabbingDeviceButton_clicked(true); else on_UseVideoFileButton_clicked(true); m_Controls->UpdateRatePanel->setEnabled(true); m_Controls->VideoFileControls->setEnabled(false); this->m_Controls->StopButton->setEnabled(false); this->SwitchPlayButton(true); if(m_MultiWidget) m_MultiWidget->EnableGradientBackground(); if(m_VideoBackground) { m_VideoBackground->Disable(); if(m_MultiWidget) m_VideoBackground->RemoveRenderWindow( m_MultiWidget->GetRenderWindow4()->GetRenderWindow() ); this->disconnect( m_VideoBackground, SIGNAL(NewFrameAvailable(mitk::VideoSource*)) , this, SLOT(NewFrameAvailable(mitk::VideoSource*))); } if(m_VideoSource != 0) m_VideoSource->StopCapturing(); }
void QmitkOpenCVVideoControls::SwitchPlayButton | ( | bool | paused ) | [protected, slot] |
Definition at line 209 of file QmitkOpenCVVideoControls.cpp.
References m_Controls.
Referenced by on_PlayButton_clicked(), and Stop().
{ if(paused) { m_Controls->PlayButton->setText("Play"); m_Controls->PlayButton->setIcon( QIcon(":/OpenCVVideoSupportUI/media-playback-start.png") ); m_Controls->PlayButton->setChecked(false); } else { m_Controls->PlayButton->setText("Pause"); m_Controls->PlayButton->setIcon( QIcon(":/OpenCVVideoSupportUI/media-playback-pause.png") ); m_Controls->PlayButton->setChecked(true); } }
Ui::QmitkOpenCVVideoControls* QmitkOpenCVVideoControls::m_Controls [protected] |
Definition at line 97 of file QmitkOpenCVVideoControls.h.
Referenced by NewFrameAvailable(), on_PlayButton_clicked(), on_UseGrabbingDeviceButton_clicked(), on_UseVideoFileButton_clicked(), on_VideoProgressSlider_sliderReleased(), QmitkOpenCVVideoControls(), SetVideoBackground(), Stop(), and SwitchPlayButton().
Definition at line 95 of file QmitkOpenCVVideoControls.h.
Referenced by GetStdMultiWidget(), on_PlayButton_clicked(), QObjectDestroyed(), SetStdMultiWidget(), and Stop().
bool QmitkOpenCVVideoControls::m_SliderCurrentlyMoved [protected] |
Definition at line 98 of file QmitkOpenCVVideoControls.h.
Referenced by NewFrameAvailable(), on_VideoProgressSlider_sliderPressed(), and on_VideoProgressSlider_sliderReleased().
Definition at line 94 of file QmitkOpenCVVideoControls.h.
Referenced by GetVideoBackground(), on_PlayButton_clicked(), QObjectDestroyed(), SetVideoBackground(), and Stop().
Definition at line 96 of file QmitkOpenCVVideoControls.h.
Referenced by NewFrameAvailable(), on_PlayButton_clicked(), on_RepeatVideoButton_clicked(), on_VideoProgressSlider_sliderPressed(), on_VideoProgressSlider_sliderReleased(), QObjectDestroyed(), SetVideoBackground(), Stop(), and ~QmitkOpenCVVideoControls().