ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkVideoStream.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 itkVideoStream_h
19 #define itkVideoStream_h
20 
21 #include "itkTemporalDataObject.h"
22 #include "itkImage.h"
23 
24 namespace itk
25 {
26 
40 template<typename TFrameType>
41 class ITK_TEMPLATE_EXPORT VideoStream : public TemporalDataObject
42 {
43 public:
44  ITK_DISALLOW_COPY_AND_ASSIGN(VideoStream);
45 
47  using Self = VideoStream;
52 
53  using FrameType = TFrameType;
54  using FramePointer = typename FrameType::Pointer;
55  using FrameConstPointer = typename FrameType::ConstPointer;
56  using BufferType = typename Superclass::BufferType;
57 
59  using IndexType = typename FrameType::IndexType;
60  using PixelType = typename FrameType::PixelType;
61  using PointType = typename FrameType::PointType;
62  using SpacingType = typename FrameType::SpacingType;
63  using SizeType = typename FrameType::SizeType;
65 
67  using SpatialRegionMapType = typename std::map<SizeValueType, SpatialRegionType>;
68  using PointMapType = typename std::map<SizeValueType, PointType>;
69  using DirectionMapType = typename std::map<SizeValueType, DirectionType>;
70  using SpacingMapType = typename std::map<SizeValueType, SpacingType>;
71 
73  static constexpr unsigned int FrameDimension = FrameType::ImageDimension;
74  static unsigned int GetFrameDimension()
75  {
76  return FrameType::ImageDimension;
77  }
78 
79  itkNewMacro(Self);
80 
82  itkTypeMacro(VideoStream, TemporalDataObject);
83 
85  void SetMinimumBufferSize(SizeValueType minimumNumberOfFrames);
86 
93  void InitializeEmptyFrames();
94 
97  {
98  return reinterpret_cast<BufferType*>(m_DataObjectBuffer.GetPointer() );
99  }
100  const BufferType* GetFrameBuffer() const
101  {
102  return reinterpret_cast<BufferType*>(m_DataObjectBuffer.GetPointer() );
103  }
105 
107  void SetFrameBuffer(BufferType* buffer);
108 
111  {
112  return m_LargestPossibleSpatialRegionCache;
113  }
115  {
116  m_LargestPossibleSpatialRegionCache = map;
117  }
119 
121  {
122  return m_RequestedSpatialRegionCache;
123  }
125  {
126  m_RequestedSpatialRegionCache = map;
127  }
128 
130  {
131  return m_BufferedSpatialRegionCache;
132  }
134  {
135  m_BufferedSpatialRegionCache = map;
136  }
137 
139  {
140  return m_SpacingCache;
141  }
143  {
144  m_SpacingCache = map;
145  }
146 
147  const PointMapType & GetOriginCache() const
148  {
149  return m_OriginCache;
150  }
152  {
153  m_OriginCache = map;
154  }
155 
157  {
158  return m_DirectionCache;
159  }
161  {
162  m_DirectionCache = map;
163  }
164 
166  void SetFrame(SizeValueType frameNumber, FramePointer frame);
167 
172  FramePointer GetFrame(SizeValueType frameNumber);
173  FrameConstPointer GetFrame(SizeValueType frameNumber) const;
175 
177  void SetFrameLargestPossibleSpatialRegion(SizeValueType frameNumber,
178  SpatialRegionType region);
179 
180  const SpatialRegionType &
181  GetFrameLargestPossibleSpatialRegion(SizeValueType frameNumber) const;
182 
184  void SetFrameRequestedSpatialRegion(SizeValueType frameNumber,
185  SpatialRegionType region);
186 
187  const SpatialRegionType &
188  GetFrameRequestedSpatialRegion(SizeValueType frameNumber) const;
189 
191  void SetFrameBufferedSpatialRegion(SizeValueType frameNumber,
192  SpatialRegionType region);
193 
194  const SpatialRegionType &
195  GetFrameBufferedSpatialRegion(SizeValueType frameNumber) const;
196 
198  void SetFrameSpacing(SizeValueType frameNumber, SpacingType spacing);
199 
200  const SpacingType & GetFrameSpacing(SizeValueType frameNumber) const;
201 
203  void SetFrameOrigin(SizeValueType frameNumber, PointType origin);
204 
205  const PointType & GetFrameOrigin(SizeValueType frameNumber) const;
206 
208  void SetFrameDirection(SizeValueType frameNumber, DirectionType direction);
209 
210  const DirectionType & GetFrameDirection(SizeValueType frameNumber) const;
211 
215  void SetAllLargestPossibleSpatialRegions(SpatialRegionType region);
216 
220  void SetAllRequestedSpatialRegions(SpatialRegionType region);
221 
225  void SetAllBufferedSpatialRegions(SpatialRegionType region);
226 
230  void SetAllFramesSpacing(SpacingType spacing);
231 
235  void SetAllFramesOrigin(PointType origin);
236 
240  void SetAllFramesDirection(DirectionType direction);
241 
256 
275  void Allocate();
276 
281  void Graft(const DataObject* data) override;
282 
283 protected:
284  VideoStream() = default;
285  ~VideoStream() override = default;
286 
287  void PrintSelf(std::ostream & os, Indent indent) const override
288  {
289  Superclass::Print(os, indent);
290  }
291 
298 
304 }; // end class VideoStream
305 
306 } // end namespace itk
307 
308 #ifndef ITK_MANUAL_INSTANTIATION
309 #include "itkVideoStream.hxx"
310 #endif
311 
312 #endif
typename FrameType::SpacingType SpacingType
const SpacingMapType & GetSpacingCache() const
typename FrameType::PixelType PixelType
SpacingMapType m_SpacingCache
const SpatialRegionMapType & GetBufferedSpatialRegionCache() const
typename std::map< SizeValueType, SpatialRegionType > SpatialRegionMapType
void SetBufferedSpatialRegionCache(SpatialRegionMapType map)
void SetOriginCache(PointMapType map)
unsigned long SizeValueType
Definition: itkIntTypes.h:83
void PrintSelf(std::ostream &os, Indent indent) const override
typename FrameType::SizeType SizeType
TFrameType FrameType
Implements a weak reference to an object.
DirectionMapType m_DirectionCache
void SetLargestPossibleSpatialRegionCache(SpatialRegionMapType map)
void SetDirectionCache(DirectionMapType map)
PointMapType m_OriginCache
const DirectionMapType & GetDirectionCache() const
const BufferType * GetFrameBuffer() const
SpatialRegionMapType m_RequestedSpatialRegionCache
SpatialRegionMapType m_LargestPossibleSpatialRegionCache
void SetSpacingCache(SpacingMapType map)
const SpatialRegionMapType & GetRequestedSpatialRegionCache() const
typename FrameType::ConstPointer FrameConstPointer
A DataObject that holds a buffered portion of a video.
const SpatialRegionMapType & GetLargestPossibleSpatialRegionCache() const
typename FrameType::DirectionType DirectionType
typename std::map< SizeValueType, PointType > PointMapType
const PointMapType & GetOriginCache() const
void SetRequestedSpatialRegionCache(SpatialRegionMapType map)
class ITK_FORWARD_EXPORT TemporalDataObject
Control indentation during Print() invocation.
Definition: itkIndent.h:49
DataObject subclass with knowledge of temporal region.
typename FrameType::IndexType IndexType
typename FrameType::PointType PointType
typename std::map< SizeValueType, SpacingType > SpacingMapType
typename FrameType::RegionType SpatialRegionType
SpatialRegionMapType m_BufferedSpatialRegionCache
typename std::map< SizeValueType, DirectionType > DirectionMapType
Base class for most ITK classes.
Definition: itkObject.h:60
BufferType * GetFrameBuffer()
Templated ring buffer for holding anything.
Definition: itkRingBuffer.h:39
static unsigned int GetFrameDimension()
Base class for all data objects in ITK.
typename FrameType::Pointer FramePointer