ITK  5.4.0
Insight Toolkit
itkVXLVideoIO.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 {
46 class VXLVideoIO : public VideoIOBase
47 {
48 public:
49  ITK_DISALLOW_COPY_AND_MOVE(VXLVideoIO);
50 
52  using Self = VXLVideoIO;
55 
61  itkNewMacro(Self);
62 
64  itkOverrideGetNameOfClassMacro(VXLVideoIO);
65 
67  void
68  FinishReadingOrWriting() override;
69 
70  /*-------- This part of the interface deals with reading data. ------ */
71 
73  void
74  SetReadFromFile() override;
75 
77  void
78  SetReadFromCamera() override;
79 
82  bool
83  CanReadFile(const char *) override;
84 
86  bool
87  CanReadCamera(CameraIDType cameraID) const override;
88 
90  void
91  ReadImageInformation() override;
92 
94  void
95  Read(void * buffer) override;
96 
97 
100  bool
101  SetNextFrameToRead(FrameOffsetType frameNumber) override;
102 
105  GetPositionInMSec() const override;
107  GetRatio() const override;
109  GetFrameTotal() const override;
111  GetFramesPerSecond() const override;
113  GetCurrentFrame() const override;
115  GetLastIFrame() const override;
116  virtual FrameOffsetType
117  GetIFrameInterval() const;
121  virtual void
122  SetCameraIndex(int idx);
123  virtual int
124  GetCameraIndex();
128  /*-------- This part of the interfaces deals with writing data. ----- */
129 
132  bool
133  CanWriteFile(const char *) override;
134 
137  void
138  WriteImageInformation() override;
139 
142  void
143  Write(const void * buffer) override;
144 
146  void
148  const std::vector<SizeValueType> & dim,
149  const char * fourCC,
150  unsigned int nChannels,
151  IOComponentEnum componentType) override;
152 
153 protected:
154  VXLVideoIO();
155  ~VXLVideoIO();
156 
157  void
158  PrintSelf(std::ostream & os, Indent indent) const override;
159 
161  void
163 
165  void
166  ResetMembers();
167 
169  void
170  OpenReader();
171 
173  void
174  OpenWriter();
175 
176 
178  vidl_ffmpeg_ostream_params::encoder_type
179  FourCCtoEncoderType(const char * fourCC);
180 
182  unsigned int
183  GetNChannelsFromPixelFormat(vidl_pixel_format fmt);
184 
186  unsigned int
187  GetSizeFromPixelFormat(vidl_pixel_format fmt);
188 
190  bool
191  PixelFormatSupported(vidl_pixel_format fmt);
192 
193 private:
195  vidl_pixel_format m_PixelFormat{};
196  vidl_frame_sptr m_VIDLFrame{};
197  vidl_ffmpeg_istream * m_Reader{};
198  vidl_ffmpeg_ostream * m_Writer{};
199  vidl_ffmpeg_ostream_params::encoder_type m_Encoder{};
200 
201 
204 };
205 } // end namespace itk
206 
207 #endif // itkVXLVideoIO_h
itk::VXLVideoIO::GetRatio
TemporalRatioType GetRatio() const override
itk::VXLVideoIO::SetCameraIndex
virtual void SetCameraIndex(int idx)
itk::VXLVideoIO::GetFramesPerSecond
TemporalRatioType GetFramesPerSecond() const override
itk::VXLVideoIO::Read
void Read(void *buffer) override
itk::VXLVideoIO::OpenReader
void OpenReader()
itk::VXLVideoIO::SetReadFromCamera
void SetReadFromCamera() override
itk::VXLVideoIO::Write
void Write(const void *buffer) override
itk::VXLVideoIO::GetLastIFrame
FrameOffsetType GetLastIFrame() const override
itk::VXLVideoIO::CanReadCamera
bool CanReadCamera(CameraIDType cameraID) const override
itk::VXLVideoIO::GetPositionInMSec
TemporalOffsetType GetPositionInMSec() const override
itk::VXLVideoIO::m_CameraIndex
int m_CameraIndex
Definition: itkVXLVideoIO.h:203
itk::VXLVideoIO::~VXLVideoIO
~VXLVideoIO()
itk::VXLVideoIO::GetFrameTotal
FrameOffsetType GetFrameTotal() const override
itk::SmartPointer< Self >
itk::CommonEnums::IOComponent
IOComponent
Definition: itkCommonEnums.h:76
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::VXLVideoIO::FinishReadingOrWriting
void FinishReadingOrWriting() override
itk::VXLVideoIO::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::VXLVideoIO::SetReadFromFile
void SetReadFromFile() override
itk::VXLVideoIO::CanReadFile
bool CanReadFile(const char *) override
itkVideoIOBase.h
itk::VXLVideoIO::m_Encoder
vidl_ffmpeg_ostream_params::encoder_type m_Encoder
Definition: itkVXLVideoIO.h:199
itk::VXLVideoIO::m_Reader
vidl_ffmpeg_istream * m_Reader
Definition: itkVXLVideoIO.h:197
itk::VXLVideoIO::GetSizeFromPixelFormat
unsigned int GetSizeFromPixelFormat(vidl_pixel_format fmt)
itk::VXLVideoIO::PixelFormatSupported
bool PixelFormatSupported(vidl_pixel_format fmt)
itk::VXLVideoIO::ResetMembers
void ResetMembers()
itk::VXLVideoIO::FourCCtoEncoderType
vidl_ffmpeg_ostream_params::encoder_type FourCCtoEncoderType(const char *fourCC)
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::VXLVideoIO::GetIFrameInterval
virtual FrameOffsetType GetIFrameInterval() const
itk::VXLVideoIO::WriteImageInformation
void WriteImageInformation() override
itk::VideoIOBase::TemporalRatioType
double TemporalRatioType
Definition: itkVideoIOBase.h:84
itk::VXLVideoIO::SetWriterParameters
void SetWriterParameters(TemporalRatioType fps, const std::vector< SizeValueType > &dim, const char *fourCC, unsigned int nChannels, IOComponentEnum componentType) override
itk::VXLVideoIO::GetCurrentFrame
FrameOffsetType GetCurrentFrame() const override
itk::VXLVideoIO::SetNextFrameToRead
bool SetNextFrameToRead(FrameOffsetType frameNumber) override
itk::VXLVideoIO::VXLVideoIO
VXLVideoIO()
itk::VideoIOBase::VideoIOBase
VideoIOBase()
itk::VideoIOBase::TemporalOffsetType
double TemporalOffsetType
Definition: itkVideoIOBase.h:82
itk::VXLVideoIO
VideoIO object for reading and writing videos using VXL.
Definition: itkVXLVideoIO.h:46
itk::VXLVideoIO::GetNChannelsFromPixelFormat
unsigned int GetNChannelsFromPixelFormat(vidl_pixel_format fmt)
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::VideoIOBase::CameraIDType
SizeValueType CameraIDType
Definition: itkVideoIOBase.h:87
itk::VXLVideoIO::UpdateReaderProperties
void UpdateReaderProperties()
itk::VXLVideoIO::m_PixelFormat
vidl_pixel_format m_PixelFormat
Definition: itkVXLVideoIO.h:195
itk::VideoIOBase::FrameOffsetType
SizeValueType FrameOffsetType
Definition: itkVideoIOBase.h:83
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::VXLVideoIO::m_Writer
vidl_ffmpeg_ostream * m_Writer
Definition: itkVXLVideoIO.h:198
itk::VideoIOBase
Abstract superclass defines video IO interface.
Definition: itkVideoIOBase.h:70
itk::VXLVideoIO::CanWriteFile
bool CanWriteFile(const char *) override
itk::VXLVideoIO::GetCameraIndex
virtual int GetCameraIndex()
itk::VXLVideoIO::ReadImageInformation
void ReadImageInformation() override
itk::VXLVideoIO::m_VIDLFrame
vidl_frame_sptr m_VIDLFrame
Definition: itkVXLVideoIO.h:196
itk::VXLVideoIO::OpenWriter
void OpenWriter()