24 class QmitkOpenCVVideoControlsPrivate
44 void ToPropertyList();
45 void FromPropertyList();
50 , QWidget * parent, Qt::WindowFlags f)
52 , m_VideoBackground(nullptr)
53 , m_RenderWindow(nullptr)
54 , m_VideoSource(nullptr)
56 , m_SliderCurrentlyMoved(false)
57 , d(new QmitkOpenCVVideoControlsPrivate(this,
"QmitkOpenCVVideoControls"))
60 m_Controls->FileChooser->SetFileMustExist(
true);
65 d->FromPropertyList();
69 if (persistenceService !=
nullptr)
75 MITK_WARN <<
"No Persistence Service available in constructor";
87 if (persistenceService !=
nullptr)
93 MITK_WARN <<
"No Persistence Service available in destructor";
101 m_Controls->GrabbingDevicePanel->setEnabled(
true);
102 m_Controls->VideoFilePanel->setEnabled(
false);
107 m_Controls->GrabbingDevicePanel->setEnabled(
false);
131 double progressRatio =
static_cast<double>(
m_Controls->VideoProgressSlider->value())
132 / static_cast<double>(
m_Controls->VideoProgressSlider->maximum());
135 MITK_DEBUG <<
"resuming video with new pos ratio: " << progressRatio;
177 if (
m_Controls->UseGrabbingDeviceButton->isChecked())
180 m_Controls->VideoFileControls->setEnabled(
false);
193 MITK_ERROR <<
"Video could not be initialized!";
198 int hertz =
m_Controls->UpdateRate->text().toInt();
199 int updateTime = itk::Math::Round<int, double>(1000.0 / hertz);
210 this->
m_Controls->StopButton->setEnabled(
true);
212 if (
m_Controls->UseVideoFileButton->isChecked())
214 m_Controls->VideoFileControls->setEnabled(
true);
215 m_Controls->RepeatVideoButton->setEnabled(
true);
216 m_Controls->VideoProgressSlider->setEnabled(
true);
221 m_Controls->GrabbingDevicePanel->setEnabled(
false);
222 m_Controls->VideoFilePanel->setEnabled(
false);
223 m_Controls->UseGrabbingDeviceButton->setEnabled(
false);
224 m_Controls->UseVideoFileButton->setEnabled(
false);
225 m_Controls->UpdateRatePanel->setEnabled(
false);
233 m_Controls->UseGrabbingDeviceButton->setEnabled(
true);
234 m_Controls->UseVideoFileButton->setEnabled(
true);
235 if (
m_Controls->UseGrabbingDeviceButton->isChecked())
240 m_Controls->UpdateRatePanel->setEnabled(
true);
241 m_Controls->VideoFileControls->setEnabled(
false);
242 this->
m_Controls->StopButton->setEnabled(
false);
269 m_Controls->PlayButton->setIcon(QIcon(
":/OpenCVVideoSupportUI/media-playback-start.png"));
275 m_Controls->PlayButton->setIcon(QIcon(
":/OpenCVVideoSupportUI/media-playback-pause.png"));
285 *
m_Controls->VideoProgressSlider->maximum()));
290 if (
m_Controls->RepeatVideoButton->isChecked())
307 if (_RenderWindow == 0)
315 this->setEnabled(
false);
319 this->setEnabled(
true);
345 this->setEnabled(
false);
349 this->setEnabled(
true);
370 this->setEnabled(
false);
389 void QmitkOpenCVVideoControlsPrivate::ToPropertyList()
393 if (persistenceService !=
nullptr)
396 propList->Set(
"deviceType", q->m_Controls->UseGrabbingDeviceButton->isChecked() ? 0 : 1);
397 propList->Set(
"grabbingDeviceNumber", q->m_Controls->GrabbingDeviceNumber->value());
398 propList->Set(
"updateRate", q->m_Controls->UpdateRate->value());
399 propList->Set(
"repeatVideo", q->m_Controls->RepeatVideoButton->isChecked());
403 MITK_WARN <<
"Persistence Service not available.";
407 void QmitkOpenCVVideoControlsPrivate::FromPropertyList()
411 if (persistenceService !=
nullptr)
415 bool repeatVideo =
false;
416 propList->Get(
"repeatVideo", repeatVideo);
417 q->m_Controls->RepeatVideoButton->setChecked(repeatVideo);
420 propList->Get(
"updateRate", updateRate);
421 q->m_Controls->UpdateRate->setValue(updateRate);
423 int grabbingDeviceNumber = 0;
424 propList->Get(
"grabbingDeviceNumber", grabbingDeviceNumber);
425 q->m_Controls->GrabbingDeviceNumber->setValue(grabbingDeviceNumber);
428 propList->Get(
"deviceType", deviceType);
431 q->m_Controls->UseGrabbingDeviceButton->setChecked(
true);
435 q->m_Controls->UseVideoFileButton->setChecked(
true);
440 MITK_WARN <<
"Persistence Service not available.";
447 d->FromPropertyList();
void on_VideoProgressSlider_sliderReleased()
virtual int SetVideoCaptureProperty(int property_id, double value)
virtual void StopCapturing() override
virtual void AddPropertyListReplacedObserver(PropertyListReplacedObserver *observer)=0
void RemoveRenderWindow(vtkRenderWindow *renderWindow)
removes a renderwindow = disables video background there
void on_UseGrabbingDeviceButton_clicked(bool checked=false)
virtual std::string GetVideoFileName() const
void Disable()
disables visualization of the video.
void NewFrameAvailable(mitk::VideoSource *videoSource)
virtual double GetVideoCaptureProperty(int property_id)
void on_StopButton_clicked(bool checked=false)
virtual bool IsCapturingEnabled() const
void AddRenderWindow(vtkRenderWindow *renderWindow)
add a RenderWindow in which the video is displayed. -> must be initialized before enabling the backgr...
void EndOfVideoSourceReached(mitk::VideoSource *videoSource)
Key-value list holding instances of BaseProperty.
virtual vtkRenderWindow * GetVtkRenderWindow() override
QmitkVideoBackground * GetVideoBackground() const
Ui::QmitkOpenCVVideoControls * m_Controls
void NewOpenCVFrameAvailable(const IplImage *)
virtual void StartCapturing() override
void on_VideoProgressSlider_sliderPressed()
void SwitchPlayButton(bool paused)
QmitkOpenCVVideoControls(QmitkVideoBackground *_VideoBackground, QmitkRenderWindow *_RenderWindow, QWidget *parent=0, Qt::WindowFlags f=0)
virtual void SetRepeatVideo(bool _arg)
QmitkRenderWindow * m_RenderWindow
Offers widgets to play/pause/stop a video on a certain render window with the use of an !initialized!...
virtual void SetVideoFileInput(const char *filename, bool repeatVideo, bool useCVCAMLib=false)
bool m_SliderCurrentlyMoved
QmitkRenderWindow * GetRenderWindow() const
virtual void SetVideoCameraInput(int cameraindex, bool useCVCAMLib=false)
virtual void PauseCapturing() override
void SetVideoBackground(QmitkVideoBackground *_VideoBackground)
virtual ~QmitkOpenCVVideoControls()
MITK implementation of the QVTKWidget.
void QObjectDestroyed(QObject *obj=0)
void on_PlayButton_clicked(bool checked=false)
mitk::VideoSource * GetVideoSource()
virtual const IplImage * GetCurrentFrame()
#define PERSISTENCE_GET_SERVICE_METHOD_MACRO
virtual mitk::PropertyList::Pointer GetPropertyList(std::string &id, bool *existed=0)=0
void on_UseVideoFileButton_clicked(bool checked=false)
virtual short GetGrabbingDeviceNumber() const
void SetTimerDelay(int ms)
sets the update rate of the video in milli seconds, by default 25.
void AfterPropertyListReplaced(const std::string &id, mitk::PropertyList *propertyList) override
void SetRenderWindow(QmitkRenderWindow *_RenderWindow)
virtual void RemovePropertyListReplacedObserver(PropertyListReplacedObserver *observer)=0
virtual bool GetCapturePaused() const
void on_RepeatVideoButton_clicked(bool checked=false)
mitk::OpenCVVideoSource * m_VideoSource
QmitkVideoBackground * m_VideoBackground