ITK  4.6.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 
25 
26 namespace itk
27 {
35 {
36 public:
41 
46 
48  itkNewMacro(Self);
49 
51  itkTypeMacro(OpenCVVideoIO, Superclass);
52 
54  virtual void FinishReadingOrWriting();
55 
56  /*-------- This part of the interface deals with reading data. ------ */
57 
59  virtual void SetReadFromFile();
60 
62  virtual void SetReadFromCamera();
63 
66  virtual bool CanReadFile(const char *);
67 
69  virtual bool CanReadCamera( CameraIDType cameraID ) const;
70 
72  virtual void ReadImageInformation();
73 
75  virtual void Read(void *buffer);
76 
79  virtual bool SetNextFrameToRead( FrameOffsetType frameNumber );
80 
82  virtual TemporalOffsetType GetPositionInMSec() const;
83  virtual TemporalRatioType GetRatio() const;
84  virtual FrameOffsetType GetFrameTotal() const;
85  virtual TemporalRatioType GetFramesPerSecond() const;
86  virtual FrameOffsetType GetCurrentFrame() const;
87  virtual FrameOffsetType GetIFrameInterval() const;
88  virtual FrameOffsetType GetLastIFrame() const;
90 
91  /*-------- This part of the interfaces deals with writing data. ----- */
92 
94  virtual void SetCameraIndex(CameraIDType idx);
95  virtual CameraIDType GetCameraIndex() const;
97 
100  virtual double GetSpacing(unsigned int itkNotUsed(i)) const
101  { return 1.0; }
102  virtual double GetOrigin(unsigned int itkNotUsed(i)) const
103  { return 0.0; }
104  virtual std::vector< double > GetDirection(unsigned int i) const
105  { return this->GetDefaultDirection(i); }
107 
110  virtual bool CanWriteFile(const char *);
111 
114  virtual void WriteImageInformation();
115 
118  virtual void Write(const void *buffer);
119 
121  virtual void SetWriterParameters( TemporalRatioType fps,
122  const std::vector<SizeValueType>& dim,
123  const char* fourCC,
124  unsigned int nChannels,
125  IOComponentType componentType );
126 
127 protected:
128  OpenCVVideoIO();
129  ~OpenCVVideoIO();
130 
131  void PrintSelf(std::ostream & os, Indent indent) const;
132 
134  void UpdateReaderProperties();
135 
137  void ResetMembers();
138 
140  void OpenReader();
141 
143  void OpenWriter();
144 
145 private:
146  OpenCVVideoIO(const Self &); //purposely not implemented
147  void operator=(const Self &); //purposely not implemented
148 
150  IplImage* m_CVImage;
151  IplImage* m_TempImage;
152  CvCapture* m_Capture;
153  CvVideoWriter* m_Writer;
154  int m_FourCC;
155 
158 
159 
160 };
161 } // end namespace itk
162 
163 #endif // __itkOpenCVVideoIO_h
Light weight base class for most itk classes.
virtual void SetReadFromCamera()
virtual FrameOffsetType GetLastIFrame() const
Abstract superclass defines video IO interface.
virtual double GetSpacing(unsigned int) const
OpenCVVideoIO Self
void PrintSelf(std::ostream &os, Indent indent) const
virtual bool SetNextFrameToRead(FrameOffsetType frameNumber)
virtual void WriteImageInformation()
virtual double GetOrigin(unsigned int) const
virtual void Write(const void *buffer)
virtual CameraIDType GetCameraIndex() const
void operator=(const Self &)
SizeValueType FrameOffsetType
virtual void SetWriterParameters(TemporalRatioType fps, const std::vector< SizeValueType > &dim, const char *fourCC, unsigned int nChannels, IOComponentType componentType)
virtual TemporalOffsetType GetPositionInMSec() const
CvVideoWriter * m_Writer
virtual bool CanReadFile(const char *)
Superclass::TemporalOffsetType TemporalOffsetType
virtual void ReadImageInformation()
void UpdateReaderProperties()
Superclass::CameraIDType CameraIDType
virtual void SetCameraIndex(CameraIDType idx)
Superclass::TemporalRatioType TemporalRatioType
SizeValueType CameraIDType
SmartPointer< Self > Pointer
VideoIOBase Superclass
virtual FrameOffsetType GetIFrameInterval() const
VideoIO object for reading and writing videos using OpenCV.
virtual TemporalRatioType GetFramesPerSecond() const
virtual void FinishReadingOrWriting()
virtual bool CanWriteFile(const char *)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual TemporalRatioType GetRatio() const
virtual FrameOffsetType GetFrameTotal() const
virtual std::vector< double > GetDirection(unsigned int i) const
Base class for most ITK classes.
Definition: itkObject.h:57
virtual void Read(void *buffer)
virtual void SetReadFromFile()
double TemporalRatioType
double TemporalOffsetType
Superclass::FrameOffsetType FrameOffsetType
virtual std::vector< double > GetDefaultDirection(unsigned int i) const
virtual bool CanReadCamera(CameraIDType cameraID) const
virtual FrameOffsetType GetCurrentFrame() const