ITK  4.10.0
Insight Segmentation and Registration Toolkit
itkOpenCVVideoIO.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkOpenCVVideoIO_h
19 #define itkOpenCVVideoIO_h
20 
21 #include "itkVideoIOBase.h"
22 #include "cv.h"
23 #include "highgui.h"
24 #include "ITKVideoBridgeOpenCVExport.h"
25 
26 
27 namespace itk
28 {
35 class ITKVideoBridgeOpenCV_EXPORT OpenCVVideoIO : public VideoIOBase
36 {
37 public:
42 
43  typedef Superclass::TemporalOffsetType TemporalOffsetType;
44  typedef Superclass::FrameOffsetType FrameOffsetType;
45  typedef Superclass::TemporalRatioType TemporalRatioType;
46  typedef Superclass::CameraIDType CameraIDType;
47 
49  itkNewMacro(Self);
50 
52  itkTypeMacro(OpenCVVideoIO, Superclass);
53 
55  virtual void FinishReadingOrWriting();
56 
57  //
58  // Data reading-related methods
59  //
60 
62  virtual void SetReadFromFile();
63 
65  virtual void SetReadFromCamera();
66 
69  virtual bool CanReadFile(const char *);
70 
72  virtual bool CanReadCamera( CameraIDType cameraID ) const;
73 
75  virtual void ReadImageInformation();
76 
78  virtual void Read(void *buffer);
79 
82  virtual bool SetNextFrameToRead( FrameOffsetType frameNumber );
83 
85  virtual TemporalOffsetType GetPositionInMSec() const;
86  virtual TemporalRatioType GetRatio() const;
87  virtual FrameOffsetType GetFrameTotal() const;
88  virtual TemporalRatioType GetFramesPerSecond() const;
89  virtual FrameOffsetType GetCurrentFrame() const;
90  virtual FrameOffsetType GetIFrameInterval() const;
91  virtual FrameOffsetType GetLastIFrame() const;
93 
94  //
95  // Data writing-related methods
96  //
97 
99  virtual void SetCameraIndex(CameraIDType idx);
100  virtual CameraIDType GetCameraIndex() const;
102 
105  virtual double GetSpacing(unsigned int itkNotUsed(i)) const
106  { return 1.0; }
107  virtual double GetOrigin(unsigned int itkNotUsed(i)) const
108  { return 0.0; }
109  virtual std::vector< double > GetDirection(unsigned int i) const
110  { return this->GetDefaultDirection(i); }
112 
115  virtual bool CanWriteFile(const char *);
116 
119  virtual void WriteImageInformation();
120 
123  virtual void Write(const void *buffer);
124 
126  virtual void SetWriterParameters( TemporalRatioType fps,
127  const std::vector<SizeValueType>& dim,
128  const char* fourCC,
129  unsigned int nChannels,
130  IOComponentType componentType );
131 
132 protected:
133  OpenCVVideoIO();
134  ~OpenCVVideoIO();
135 
136  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
137 
139  void UpdateReaderProperties();
140 
142  void ResetMembers();
143 
145  void OpenReader();
146 
148  void OpenWriter();
149 
150 private:
151  OpenCVVideoIO(const Self &) ITK_DELETE_FUNCTION;
152  void operator=(const Self &) ITK_DELETE_FUNCTION;
153 
154 private:
155  IplImage* m_CVImage;
156  IplImage* m_TempImage;
157  CvCapture* m_Capture;
158  CvVideoWriter* m_Writer;
159  int m_FourCC;
160 
162 
163 };
164 } // end namespace itk
165 
166 #endif // itkOpenCVVideoIO_h
Abstract superclass defines video IO interface.
virtual double GetSpacing(unsigned int) const
OpenCVVideoIO Self
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes...
Definition: itkArray.h:30
virtual double GetOrigin(unsigned int) const
CvVideoWriter * m_Writer
Superclass::TemporalOffsetType TemporalOffsetType
Superclass::CameraIDType CameraIDType
Superclass::TemporalRatioType TemporalRatioType
SmartPointer< Self > Pointer
VideoIOBase Superclass
VideoIO object for reading and writing videos using OpenCV.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual std::vector< double > GetDirection(unsigned int i) const
Superclass::FrameOffsetType FrameOffsetType