NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
niftkOpenCVVideoDataSourceService.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 #ifndef niftkOpenCVVideoDataSourceService_h
15 #define niftkOpenCVVideoDataSourceService_h
16 
17 #include <niftkIGIDataSource.h>
25 
26 #include <mitkOpenCVVideoSource.h>
27 
28 #include <QObject>
29 #include <QSet>
30 #include <QMutex>
31 #include <QString>
32 
33 namespace niftk
34 {
35 
43  : public QObject
44  , public IGIDataSource
45  , public IGILocalDataSourceI
48 {
49 
50 public:
51 
53  mitkNewMacro3Param(OpenCVVideoDataSourceService, QString, const IGIDataSourceProperties&, mitk::DataStorage::Pointer)
54 
58  virtual void StartPlayback(niftk::IGIDataType::IGITimeType firstTimeStamp,
59  niftk::IGIDataType::IGITimeType lastTimeStamp) override;
60 
64  void PlaybackData(niftk::IGIDataType::IGITimeType requestedTimeStamp) override;
65 
69  virtual void StopPlayback() override;
70 
74  virtual std::vector<IGIDataItemInfo> Update(const niftk::IGIDataType::IGITimeType& time) override;
75 
79  virtual void CleanBuffer() override;
80 
84  virtual void GrabData() override;
85 
89  bool ProbeRecordedData(niftk::IGIDataType::IGITimeType* firstTimeStampInStore,
90  niftk::IGIDataType::IGITimeType* lastTimeStampInStore) override;
91 
95  virtual void SetProperties(const IGIDataSourceProperties& properties) override;
96 
100  virtual IGIDataSourceProperties GetProperties() const override;
101 
102 protected:
103 
104  OpenCVVideoDataSourceService(QString factoryName,
105  const IGIDataSourceProperties& properties,
106  mitk::DataStorage::Pointer dataStorage
107  );
108  virtual ~OpenCVVideoDataSourceService();
109 
110 private:
111 
112  OpenCVVideoDataSourceService(const OpenCVVideoDataSourceService&); // deliberately not implemented
113  OpenCVVideoDataSourceService& operator=(const OpenCVVideoDataSourceService&); // deliberately not implemented
114 
115  void SaveItem(niftk::IGIDataType::Pointer item) override;
116 
117  static niftk::IGIDataSourceLocker s_Lock;
118  QMutex m_Lock;
119  mitk::OpenCVVideoSource::Pointer m_VideoSource;
120  int m_ChannelNumber;
121  niftk::IGIDataType::IGIIndexType m_FrameId;
122  niftk::IGIDataSourceBuffer::Pointer m_Buffer;
123  niftk::IGIDataSourceBackgroundDeleteThread* m_BackgroundDeleteThread;
124  niftk::IGIDataSourceGrabbingThread* m_DataGrabbingThread;
125  std::set<niftk::IGIDataType::IGITimeType> m_PlaybackIndex;
126 
127 }; // end class
128 
129 } // end namespace
130 
131 #endif
QString
Definition: niftkOpenCVVideoDataSourceService.h:53
Abstract base class for local data sources.
Definition: niftkIGILocalDataSourceI.h:29
const IGIDataSourceProperties virtual mitk::DataStorage::Pointer void StartPlayback(niftk::IGIDataType::IGITimeType firstTimeStamp, niftk::IGIDataType::IGITimeType lastTimeStamp) override
Definition: niftkOpenCVVideoDataSourceService.cxx:158
Thread class, based on IGITimerBasedThread to simply call "CleanBuffer".
Definition: niftkIGIDataSourceBackgroundDeleteThread.h:29
Abstract base class for data sources that can clean their own buffer.
Definition: niftkIGICleanableDataSourceI.h:27
Definition: niftkMeshSmoother.cxx:19
Definition: ReceptorMemberCommandTest.cxx:25
bool ProbeRecordedData(niftk::IGIDataType::IGITimeType *firstTimeStampInStore, niftk::IGIDataType::IGITimeType *lastTimeStampInStore) override
Definition: niftkOpenCVVideoDataSourceService.cxx:234
void PlaybackData(niftk::IGIDataType::IGITimeType requestedTimeStamp) override
Definition: niftkOpenCVVideoDataSourceService.cxx:194
virtual void StopPlayback() override
Definition: niftkOpenCVVideoDataSourceService.cxx:182
Abstract base class for IGI Data, such as objects containing tracking data, video frames or ultrasoun...
Definition: niftkIGIDataType.h:35
virtual void CleanBuffer() override
Definition: niftkOpenCVVideoDataSourceService.cxx:150
Manages a buffer of niftk::IGIDataType.
Definition: niftkIGIDataSourceBuffer.h:42
QMap< QString, QVariant > IGIDataSourceProperties
Definition: niftkIGIDataSourceI.h:33
Provides an OpenCV video feed, as an IGIDataSourceServiceI.
Definition: niftkOpenCVVideoDataSourceService.h:42
Info class to describe current state, so that GUI can display status.
Definition: niftkIGIDataSourceI.h:47
Abstract base class for IGI DataSources, such as objects that produce tracking data, video frames or ultrasound frames.
Definition: niftkIGIDataSource.h:47
virtual std::vector< IGIDataItemInfo > Update(const niftk::IGIDataType::IGITimeType &time) override
Definition: niftkOpenCVVideoDataSourceService.cxx:355
virtual void SetProperties(const IGIDataSourceProperties &properties) override
IGIDataSourceI::SetProperties()
Definition: niftkOpenCVVideoDataSourceService.cxx:123
Helper class to provide a class-level counter.
Definition: niftkIGIDataSourceLocker.h:29
virtual IGIDataSourceProperties GetProperties() const override
IGIDataSourceI::GetProperties()
Definition: niftkOpenCVVideoDataSourceService.cxx:137
Definition: niftkIGIDataSourceGrabbingThread.h:29
virtual void GrabData() override
Definition: niftkOpenCVVideoDataSourceService.cxx:267
Definition: niftkExceptionObject.h:21
Abstract base class for data sources that can clean their own buffer.
Definition: niftkIGIBufferedSaveableDataSourceI.h:28
mitkClassMacroItkParent(OpenCVVideoDataSourceService, IGIDataSource) mitkNewMacro3Param(OpenCVVideoDataSourceService