ITK  5.2.0
Insight Toolkit
itkVideoStream.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  * 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 itkVideoStream_h
19 #define itkVideoStream_h
20 
21 #include "itkTemporalDataObject.h"
22 #include "itkImage.h"
23 
24 namespace itk
25 {
26 
41 template <typename TFrameType>
42 class ITK_TEMPLATE_EXPORT VideoStream : public TemporalDataObject
43 {
44 public:
45  ITK_DISALLOW_COPY_AND_ASSIGN(VideoStream);
46 
48  using Self = VideoStream;
53 
54  using FrameType = TFrameType;
55  using FramePointer = typename FrameType::Pointer;
56  using FrameConstPointer = typename FrameType::ConstPointer;
57  using BufferType = typename Superclass::BufferType;
58 
60  using IndexType = typename FrameType::IndexType;
61  using PixelType = typename FrameType::PixelType;
62  using PointType = typename FrameType::PointType;
63  using SpacingType = typename FrameType::SpacingType;
64  using SizeType = typename FrameType::SizeType;
66 
68  using SpatialRegionMapType = typename std::map<SizeValueType, SpatialRegionType>;
69  using PointMapType = typename std::map<SizeValueType, PointType>;
70  using DirectionMapType = typename std::map<SizeValueType, DirectionType>;
71  using SpacingMapType = typename std::map<SizeValueType, SpacingType>;
72 
74  static constexpr unsigned int FrameDimension = FrameType::ImageDimension;
75  static unsigned int
77  {
78  return FrameType::ImageDimension;
79  }
80 
81  itkNewMacro(Self);
82 
84  itkTypeMacro(VideoStream, TemporalDataObject);
85 
87  void
88  SetMinimumBufferSize(SizeValueType minimumNumberOfFrames);
89 
96  void
97  InitializeEmptyFrames();
98 
100  BufferType *
102  {
103  return reinterpret_cast<BufferType *>(m_DataObjectBuffer.GetPointer());
104  }
105  const BufferType *
107  {
108  return reinterpret_cast<BufferType *>(m_DataObjectBuffer.GetPointer());
109  }
111 
113  void
114  SetFrameBuffer(BufferType * buffer);
115 
117  const SpatialRegionMapType &
119  {
120  return m_LargestPossibleSpatialRegionCache;
121  }
122  void
124  {
125  m_LargestPossibleSpatialRegionCache = map;
126  }
128 
129  const SpatialRegionMapType &
131  {
132  return m_RequestedSpatialRegionCache;
133  }
134  void
136  {
137  m_RequestedSpatialRegionCache = map;
138  }
139 
140  const SpatialRegionMapType &
142  {
143  return m_BufferedSpatialRegionCache;
144  }
145  void
147  {
148  m_BufferedSpatialRegionCache = map;
149  }
150 
151  const SpacingMapType &
153  {
154  return m_SpacingCache;
155  }
156  void
158  {
159  m_SpacingCache = map;
160  }
161 
162  const PointMapType &
164  {
165  return m_OriginCache;
166  }
167  void
169  {
170  m_OriginCache = map;
171  }
172 
173  const DirectionMapType &
175  {
176  return m_DirectionCache;
177  }
178  void
180  {
181  m_DirectionCache = map;
182  }
183 
185  void
186  SetFrame(SizeValueType frameNumber, FramePointer frame);
187 
192  FramePointer
193  GetFrame(SizeValueType frameNumber);
194  FrameConstPointer
195  GetFrame(SizeValueType frameNumber) const;
197 
199  void
200  SetFrameLargestPossibleSpatialRegion(SizeValueType frameNumber, SpatialRegionType region);
201 
202  const SpatialRegionType &
203  GetFrameLargestPossibleSpatialRegion(SizeValueType frameNumber) const;
204 
206  void
207  SetFrameRequestedSpatialRegion(SizeValueType frameNumber, SpatialRegionType region);
208 
209  const SpatialRegionType &
210  GetFrameRequestedSpatialRegion(SizeValueType frameNumber) const;
211 
213  void
214  SetFrameBufferedSpatialRegion(SizeValueType frameNumber, SpatialRegionType region);
215 
216  const SpatialRegionType &
217  GetFrameBufferedSpatialRegion(SizeValueType frameNumber) const;
218 
220  void
221  SetFrameSpacing(SizeValueType frameNumber, SpacingType spacing);
222 
223  const SpacingType &
224  GetFrameSpacing(SizeValueType frameNumber) const;
225 
227  void
228  SetFrameOrigin(SizeValueType frameNumber, PointType origin);
229 
230  const PointType &
231  GetFrameOrigin(SizeValueType frameNumber) const;
232 
234  void
235  SetFrameDirection(SizeValueType frameNumber, DirectionType direction);
236 
237  const DirectionType &
238  GetFrameDirection(SizeValueType frameNumber) const;
239 
243  void
244  SetAllLargestPossibleSpatialRegions(SpatialRegionType region);
245 
249  void
250  SetAllRequestedSpatialRegions(SpatialRegionType region);
251 
255  void
256  SetAllBufferedSpatialRegions(SpatialRegionType region);
257 
261  void
262  SetAllFramesSpacing(SpacingType spacing);
263 
267  void
268  SetAllFramesOrigin(PointType origin);
269 
273  void
274  SetAllFramesDirection(DirectionType direction);
275 
290 
309  void
310  Allocate();
311 
316  void
317  Graft(const DataObject * data) override;
318 
319 protected:
320  VideoStream() = default;
321  ~VideoStream() override = default;
322 
323  void
324  PrintSelf(std::ostream & os, Indent indent) const override
325  {
326  Superclass::Print(os, indent);
327  }
328 
335 
341 }; // end class VideoStream
342 
343 } // end namespace itk
344 
345 #ifndef ITK_MANUAL_INSTANTIATION
346 # include "itkVideoStream.hxx"
347 #endif
348 
349 #endif
itk::TemporalDataObject
class ITK_FORWARD_EXPORT TemporalDataObject
Definition: itkTemporalProcessObject.h:29
itk::VideoStream::PointType
typename FrameType::PointType PointType
Definition: itkVideoStream.h:62
itk::VideoStream::m_RequestedSpatialRegionCache
SpatialRegionMapType m_RequestedSpatialRegionCache
Definition: itkVideoStream.h:333
itk::VideoStream::FrameType
TFrameType FrameType
Definition: itkVideoStream.h:54
itk::VideoStream::m_BufferedSpatialRegionCache
SpatialRegionMapType m_BufferedSpatialRegionCache
Definition: itkVideoStream.h:334
itk::VideoStream::SpacingMapType
typename std::map< SizeValueType, SpacingType > SpacingMapType
Definition: itkVideoStream.h:71
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
itk::VideoStream::GetFrameBuffer
BufferType * GetFrameBuffer()
Definition: itkVideoStream.h:101
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::VideoStream::SpatialRegionType
typename FrameType::RegionType SpatialRegionType
Definition: itkVideoStream.h:59
itk::VideoStream::GetRequestedSpatialRegionCache
const SpatialRegionMapType & GetRequestedSpatialRegionCache() const
Definition: itkVideoStream.h:130
itk::VideoStream::PixelType
typename FrameType::PixelType PixelType
Definition: itkVideoStream.h:61
itk::VideoStream::GetSpacingCache
const SpacingMapType & GetSpacingCache() const
Definition: itkVideoStream.h:152
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::VideoStream::m_DirectionCache
DirectionMapType m_DirectionCache
Definition: itkVideoStream.h:339
itkImage.h
itk::VideoStream::SpatialRegionMapType
typename std::map< SizeValueType, SpatialRegionType > SpatialRegionMapType
Definition: itkVideoStream.h:68
itk::VideoStream::m_OriginCache
PointMapType m_OriginCache
Definition: itkVideoStream.h:340
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::VideoStream::GetLargestPossibleSpatialRegionCache
const SpatialRegionMapType & GetLargestPossibleSpatialRegionCache() const
Definition: itkVideoStream.h:118
itk::VideoStream::m_LargestPossibleSpatialRegionCache
SpatialRegionMapType m_LargestPossibleSpatialRegionCache
Definition: itkVideoStream.h:332
itk::VideoStream::IndexType
typename FrameType::IndexType IndexType
Definition: itkVideoStream.h:60
itk::VideoStream::SizeType
typename FrameType::SizeType SizeType
Definition: itkVideoStream.h:64
itk::VideoStream::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkVideoStream.h:324
itk::VideoStream::GetFrameDimension
static unsigned int GetFrameDimension()
Definition: itkVideoStream.h:76
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::VideoStream::DirectionMapType
typename std::map< SizeValueType, DirectionType > DirectionMapType
Definition: itkVideoStream.h:70
itk::VideoStream::PointMapType
typename std::map< SizeValueType, PointType > PointMapType
Definition: itkVideoStream.h:69
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::VideoStream::GetBufferedSpatialRegionCache
const SpatialRegionMapType & GetBufferedSpatialRegionCache() const
Definition: itkVideoStream.h:141
itk::RingBuffer
Templated ring buffer for holding anything.
Definition: itkRingBuffer.h:40
itk::VideoStream::GetOriginCache
const PointMapType & GetOriginCache() const
Definition: itkVideoStream.h:163
itk::VideoStream::SetLargestPossibleSpatialRegionCache
void SetLargestPossibleSpatialRegionCache(SpatialRegionMapType map)
Definition: itkVideoStream.h:123
itk::VideoStream::m_SpacingCache
SpacingMapType m_SpacingCache
Definition: itkVideoStream.h:338
itk::VideoStream::GetDirectionCache
const DirectionMapType & GetDirectionCache() const
Definition: itkVideoStream.h:174
itk::VideoStream::GetFrameBuffer
const BufferType * GetFrameBuffer() const
Definition: itkVideoStream.h:106
itk::VideoStream::SetDirectionCache
void SetDirectionCache(DirectionMapType map)
Definition: itkVideoStream.h:179
itk::WeakPointer
Implements a weak reference to an object.
Definition: itkWeakPointer.h:44
itk::VideoStream::FramePointer
typename FrameType::Pointer FramePointer
Definition: itkVideoStream.h:55
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::VideoStream
A DataObject that holds a buffered portion of a video.
Definition: itkVideoStream.h:42
itkTemporalDataObject.h
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::VideoStream::SpacingType
typename FrameType::SpacingType SpacingType
Definition: itkVideoStream.h:63
itk::VideoStream::SetOriginCache
void SetOriginCache(PointMapType map)
Definition: itkVideoStream.h:168
itk::VideoStream::SetSpacingCache
void SetSpacingCache(SpacingMapType map)
Definition: itkVideoStream.h:157
itk::VideoStream::FrameConstPointer
typename FrameType::ConstPointer FrameConstPointer
Definition: itkVideoStream.h:56
itk::VideoStream::SetRequestedSpatialRegionCache
void SetRequestedSpatialRegionCache(SpatialRegionMapType map)
Definition: itkVideoStream.h:135
itk::VideoStream::DirectionType
typename FrameType::DirectionType DirectionType
Definition: itkVideoStream.h:65
itk::VideoStream::SetBufferedSpatialRegionCache
void SetBufferedSpatialRegionCache(SpatialRegionMapType map)
Definition: itkVideoStream.h:146
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::TemporalDataObject
DataObject subclass with knowledge of temporal region.
Definition: itkTemporalDataObject.h:65
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293