ITK  5.0.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:
48  ITK_DISALLOW_COPY_AND_ASSIGN(VXLVideoIO);
49 
51  using Self = VXLVideoIO;
54 
60  itkNewMacro(Self);
61 
63  itkTypeMacro(VXLVideoIO, Superclass);
64 
66  void FinishReadingOrWriting() override;
67 
68  /*-------- This part of the interface deals with reading data. ------ */
69 
71  void SetReadFromFile() override;
72 
74  void SetReadFromCamera() override;
75 
78  bool CanReadFile(const char *) override;
79 
81  bool CanReadCamera( CameraIDType cameraID ) const override;
82 
84  void ReadImageInformation() override;
85 
87  void Read(void *buffer) override;
88 
89 
92  bool SetNextFrameToRead( FrameOffsetType frameNumber) override;
93 
95  TemporalOffsetType GetPositionInMSec() const override;
96  TemporalRatioType GetRatio() const override;
97  FrameOffsetType GetFrameTotal() const override;
98  TemporalRatioType GetFramesPerSecond() const override;
99  FrameOffsetType GetCurrentFrame() const override;
100  FrameOffsetType GetLastIFrame() const override;
101  virtual FrameOffsetType GetIFrameInterval() const;
103 
105  virtual void SetCameraIndex(int idx);
106  virtual int GetCameraIndex();
108 
109 
110  /*-------- This part of the interfaces deals with writing data. ----- */
111 
114  bool CanWriteFile(const char *) override;
115 
118  void WriteImageInformation() override;
119 
122  void Write(const void *buffer) override;
123 
125  void SetWriterParameters(TemporalRatioType fps, const std::vector<SizeValueType>& dim, const char* fourCC,
126  unsigned int nChannels, IOComponentType componentType) override;
127 
128 protected:
129  VXLVideoIO();
130  ~VXLVideoIO();
131 
132  void PrintSelf(std::ostream & os, Indent indent) const override;
133 
135  void UpdateReaderProperties();
136 
138  void ResetMembers();
139 
141  void OpenReader();
142 
144  void OpenWriter();
145 
146 
148  vidl_ffmpeg_ostream_params::encoder_type FourCCtoEncoderType(const char* fourCC);
149 
151  unsigned int GetNChannelsFromPixelFormat(vidl_pixel_format fmt);
152 
154  unsigned int GetSizeFromPixelFormat(vidl_pixel_format fmt);
155 
157  bool PixelFormatSupported(vidl_pixel_format fmt);
158 
159 private:
161  vidl_pixel_format m_PixelFormat;
162  vidl_frame_sptr m_VIDLFrame;
163  vidl_ffmpeg_istream* m_Reader;
164  vidl_ffmpeg_ostream* m_Writer;
165  vidl_ffmpeg_ostream_params::encoder_type m_Encoder;
166 
167 
170 };
171 } // end namespace itk
172 
173 #endif // itkVXLVideoIO_h
void UpdateReaderProperties()
double TemporalOffsetType
Light weight base class for most itk classes.
void ReadImageInformation() override
Abstract superclass defines video IO interface.
SizeValueType FrameOffsetType
vidl_ffmpeg_istream * m_Reader
unsigned int GetSizeFromPixelFormat(vidl_pixel_format fmt)
virtual int GetCameraIndex()
vidl_frame_sptr m_VIDLFrame
bool CanWriteFile(const char *) override
double TemporalRatioType
vidl_pixel_format m_PixelFormat
TemporalRatioType GetRatio() const override
TemporalRatioType GetFramesPerSecond() const override
unsigned int GetNChannelsFromPixelFormat(vidl_pixel_format fmt)
bool SetNextFrameToRead(FrameOffsetType frameNumber) override
void SetWriterParameters(TemporalRatioType fps, const std::vector< SizeValueType > &dim, const char *fourCC, unsigned int nChannels, IOComponentType componentType) override
bool CanReadFile(const char *) override
FrameOffsetType GetFrameTotal() const override
virtual FrameOffsetType GetIFrameInterval() const
void PrintSelf(std::ostream &os, Indent indent) const override
void FinishReadingOrWriting() override
void SetReadFromFile() override
TemporalOffsetType GetPositionInMSec() const override
bool PixelFormatSupported(vidl_pixel_format fmt)
virtual void SetCameraIndex(int idx)
void SetReadFromCamera() override
void Read(void *buffer) override
vidl_ffmpeg_ostream_params::encoder_type FourCCtoEncoderType(const char *fourCC)
bool CanReadCamera(CameraIDType cameraID) const override
SizeValueType CameraIDType
void WriteImageInformation() override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
FrameOffsetType GetLastIFrame() const override
Base class for most ITK classes.
Definition: itkObject.h:60
void Write(const void *buffer) override
FrameOffsetType GetCurrentFrame() const override
vidl_ffmpeg_ostream_params::encoder_type m_Encoder
vidl_ffmpeg_ostream * m_Writer
VideoIO object for reading and writing videos using VXL.
Definition: itkVXLVideoIO.h:45