ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkVXLVideoIO.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 __itkVXLVideoIO_h
19 #define __itkVXLVideoIO_h
20 
21 // Define support for VXLVideo
22 #ifndef ITK_VIDEO_USE_VXL
23 #define ITK_VIDEO_USE_VXL
24 #endif
25 
26 #ifdef _MSC_VER
27 #pragma warning ( disable : 4786 )
28 #endif
29 
30 #include "itkVideoIOBase.h"
31 #include "vidl/vidl_ffmpeg_istream.h"
32 #include "vidl/vidl_ffmpeg_ostream.h"
33 #include "vidl/vidl_convert.h"
34 #include "vul/vul_reg_exp.h"
35 
36 namespace itk
37 {
45 class VXLVideoIO:public VideoIOBase
46 {
47 public:
49  typedef VXLVideoIO Self;
52 
58  itkNewMacro(Self);
59 
61  itkTypeMacro(VXLVideoIO, Superclass);
62 
64  virtual void FinishReadingOrWriting();
65 
66  /*-------- This part of the interface deals with reading data. ------ */
67 
69  virtual void SetReadFromFile();
70 
72  virtual void SetReadFromCamera();
73 
76  virtual bool CanReadFile(const char *);
77 
79  virtual bool CanReadCamera( CameraIDType cameraID ) const;
80 
82  virtual void ReadImageInformation();
83 
85  virtual void Read(void *buffer);
86 
87 
90  virtual bool SetNextFrameToRead( FrameOffsetType frameNumber);
91 
93  virtual TemporalOffsetType GetPositionInMSec() const;
94  virtual TemporalRatioType GetRatio() const;
95  virtual FrameOffsetType GetFrameTotal() const;
96  virtual TemporalRatioType GetFramesPerSecond() const;
97  virtual FrameOffsetType GetCurrentFrame() const;
98  virtual FrameOffsetType GetIFrameInterval() const;
99  virtual FrameOffsetType GetLastIFrame() const;
101 
103  virtual void SetCameraIndex(int idx);
104  virtual int GetCameraIndex();
106 
107 
108  /*-------- This part of the interfaces deals with writing data. ----- */
109 
112  virtual bool CanWriteFile(const char *);
113 
116  virtual void WriteImageInformation();
117 
120  virtual void Write(const void *buffer);
121 
123  virtual void SetWriterParameters(TemporalRatioType fps, const std::vector<SizeValueType>& dim, const char* fourCC,
124  unsigned int nChannels, IOComponentType componentType);
125 
126 protected:
127  VXLVideoIO();
128  ~VXLVideoIO();
129 
130  void PrintSelf(std::ostream & os, Indent indent) const;
131 
133  void UpdateReaderProperties();
134 
136  void ResetMembers();
137 
139  void OpenReader();
140 
142  void OpenWriter();
143 
144 
146  vidl_ffmpeg_ostream_params::encoder_type FourCCtoEncoderType(const char* fourCC);
147 
149  unsigned int GetNChannelsFromPixelFormat(vidl_pixel_format fmt);
150 
152  unsigned int GetSizeFromPixelFormat(vidl_pixel_format fmt);
153 
155  bool PixelFormatSupported(vidl_pixel_format fmt);
156 
157 private:
158  VXLVideoIO(const Self &); //purposely not implemented
159  void operator=(const Self &); //purposely not implemented
160 
162  vidl_pixel_format m_PixelFormat;
163  vidl_frame_sptr m_VIDLFrame;
164  vidl_ffmpeg_istream* m_Reader;
165  vidl_ffmpeg_ostream* m_Writer;
166  vidl_ffmpeg_ostream_params::encoder_type m_Encoder;
167 
168 
171 };
172 } // end namespace itk
173 
174 #endif // __itkVXLVideoIO_h
virtual void SetReadFromFile()
void UpdateReaderProperties()
virtual void SetWriterParameters(TemporalRatioType fps, const std::vector< SizeValueType > &dim, const char *fourCC, unsigned int nChannels, IOComponentType componentType)
SmartPointer< Self > Pointer
Definition: itkVXLVideoIO.h:51
Light weight base class for most itk classes.
Abstract superclass defines video IO interface.
void operator=(const Self &)
vidl_ffmpeg_istream * m_Reader
unsigned int GetSizeFromPixelFormat(vidl_pixel_format fmt)
virtual bool CanWriteFile(const char *)
virtual void Write(const void *buffer)
virtual int GetCameraIndex()
vidl_frame_sptr m_VIDLFrame
virtual void FinishReadingOrWriting()
Superclass::FrameOffsetType FrameOffsetType
Definition: itkVXLVideoIO.h:54
void PrintSelf(std::ostream &os, Indent indent) const
vidl_pixel_format m_PixelFormat
Superclass::TemporalRatioType TemporalRatioType
Definition: itkVXLVideoIO.h:55
Superclass::TemporalOffsetType TemporalOffsetType
Definition: itkVXLVideoIO.h:53
SizeValueType FrameOffsetType
VideoIOBase Superclass
Definition: itkVXLVideoIO.h:50
unsigned int GetNChannelsFromPixelFormat(vidl_pixel_format fmt)
virtual bool CanReadCamera(CameraIDType cameraID) const
virtual void Read(void *buffer)
virtual TemporalRatioType GetRatio() const
virtual FrameOffsetType GetIFrameInterval() const
VXLVideoIO Self
Definition: itkVXLVideoIO.h:49
SizeValueType CameraIDType
bool PixelFormatSupported(vidl_pixel_format fmt)
virtual FrameOffsetType GetLastIFrame() const
virtual bool SetNextFrameToRead(FrameOffsetType frameNumber)
virtual void SetCameraIndex(int idx)
Superclass::CameraIDType CameraIDType
Definition: itkVXLVideoIO.h:56
virtual TemporalOffsetType GetPositionInMSec() const
virtual void SetReadFromCamera()
vidl_ffmpeg_ostream_params::encoder_type FourCCtoEncoderType(const char *fourCC)
virtual TemporalRatioType GetFramesPerSecond() const
virtual void ReadImageInformation()
virtual void WriteImageInformation()
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual FrameOffsetType GetCurrentFrame() const
virtual FrameOffsetType GetFrameTotal() const
Base class for most ITK classes.
Definition: itkObject.h:57
vidl_ffmpeg_ostream_params::encoder_type m_Encoder
double TemporalRatioType
virtual bool CanReadFile(const char *)
double TemporalOffsetType
vidl_ffmpeg_ostream * m_Writer
VideoIO object for reading and writing videos using VXL.
Definition: itkVXLVideoIO.h:45