ITK  5.4.0
Insight Toolkit
itkVideoFileReader.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 itkVideoFileReader_h
19 #define itkVideoFileReader_h
20 
21 #include "itkVideoSource.h"
22 #include "itkVideoIOFactory.h"
24 
25 namespace itk
26 {
27 
41 template <typename TOutputVideoStream>
42 class ITK_TEMPLATE_EXPORT VideoFileReader : public VideoSource<TOutputVideoStream>
43 {
44 public:
45  ITK_DISALLOW_COPY_AND_MOVE(VideoFileReader);
46 
51  using VideoStreamType = TOutputVideoStream;
53 
54  using FrameType = typename VideoStreamType::FrameType;
55  using PixelType = typename FrameType::PixelType;
57  using SizeType = typename FrameType::SizeType;
58  using IndexType = typename FrameType::IndexType;
59  using PointType = typename FrameType::PointType;
60  using SpacingType = typename FrameType::SpacingType;
62 
66 
67  static constexpr unsigned int FrameDimension = FrameType::ImageDimension;
68 
71 
73  itkNewMacro(Self);
74 
76  itkOverrideGetNameOfClassMacro(VideoFileReader);
77 
78 
80  itkSetStringMacro(FileName);
81  itkGetStringMacro(FileName);
86  itkSetMacro(IFrameSafe, bool);
87  itkGetMacro(IFrameSafe, bool);
88  itkBooleanMacro(IFrameSafe);
92  void
93  UpdateOutputInformation() override;
94 
97  void
98  SetVideoIO(VideoIOBase * videoIO);
99 
102  GetCurrentPositionFrame();
103 
105  GetCurrentPositionRatio();
106 
108  GetCurrentPositionMSec();
109 
112  GetNumberOfFrames();
113 
116  GetFramesPerSecond();
117 
118 protected:
119  VideoFileReader();
120  ~VideoFileReader() override = default;
121  void
122  PrintSelf(std::ostream & os, Indent indent) const override;
123 
127  void
128  TemporalStreamingGenerateData() override;
129 
131  void
132  DoConvertBuffer(const void * inputData, FrameOffsetType frameNumber);
133 
136  void
137  InitializeVideoIO();
138 
139 private:
141  std::string m_FileName{};
142 
145  VideoIOBase::Pointer m_VideoIO{};
146 
148  bool m_PixelConversionNeeded{};
149 
152  bool m_IFrameSafe{};
153 };
154 
155 } // end namespace itk
156 
157 #ifndef ITK_MANUAL_INSTANTIATION
158 # include "itkVideoFileReader.hxx"
159 #endif
160 
161 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
itk::VideoFileReader::FrameOffsetType
typename VideoIOBase::FrameOffsetType FrameOffsetType
Definition: itkVideoFileReader.h:64
itk::VideoFileReader::PixelType
typename FrameType::PixelType PixelType
Definition: itkVideoFileReader.h:55
itkVideoIOFactory.h
itk::VideoFileReader::SpacingType
typename FrameType::SpacingType SpacingType
Definition: itkVideoFileReader.h:60
itk::VideoFileReader::FrameType
typename VideoStreamType::FrameType FrameType
Definition: itkVideoFileReader.h:54
itk::VideoFileReader::RegionType
typename FrameType::RegionType RegionType
Definition: itkVideoFileReader.h:56
itk::VideoFileReader
Reader that creates a VideoStream.
Definition: itkVideoFileReader.h:42
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::VideoFileReader::TemporalOffsetType
typename VideoIOBase::TemporalOffsetType TemporalOffsetType
Definition: itkVideoFileReader.h:63
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itkDefaultConvertPixelTraits.h
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::DefaultConvertPixelTraits
Traits class used to by ConvertPixels to convert blocks of pixels.
Definition: itkDefaultConvertPixelTraits.h:41
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::VideoIOBase::TemporalRatioType
double TemporalRatioType
Definition: itkVideoIOBase.h:84
itk::VideoFileReader::DirectionType
typename FrameType::DirectionType DirectionType
Definition: itkVideoFileReader.h:61
itk::VideoIOBase::TemporalOffsetType
double TemporalOffsetType
Definition: itkVideoIOBase.h:82
itk::VideoFileReader::PointType
typename FrameType::PointType PointType
Definition: itkVideoFileReader.h:59
itk::VideoFileReader::IndexType
typename FrameType::IndexType IndexType
Definition: itkVideoFileReader.h:58
itk::VideoFileReader::TemporalRatioType
typename VideoIOBase::TemporalRatioType TemporalRatioType
Definition: itkVideoFileReader.h:65
itk::VideoFileReader::SizeType
typename FrameType::SizeType SizeType
Definition: itkVideoFileReader.h:57
itk::VideoFileReader::VideoStreamType
TOutputVideoStream VideoStreamType
Definition: itkVideoFileReader.h:51
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::VideoIOBase::FrameOffsetType
SizeValueType FrameOffsetType
Definition: itkVideoIOBase.h:83
itk::VideoIOBase
Abstract superclass defines video IO interface.
Definition: itkVideoIOBase.h:70
itk::VideoFileReader::VideoStreamPointer
typename VideoStreamType::Pointer VideoStreamPointer
Definition: itkVideoFileReader.h:52
itkVideoSource.h
itk::VideoSource
A TemporalProcessObject that produces a VideoStream.
Definition: itkVideoSource.h:44