ITK  4.13.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 
46  typedef VideoStream Self;
51 
52  typedef TFrameType FrameType;
53  typedef typename FrameType::Pointer FramePointer;
54  typedef typename FrameType::ConstPointer FrameConstPointer;
55  typedef typename Superclass::BufferType BufferType;
56 
57  typedef typename FrameType::RegionType SpatialRegionType;
58  typedef typename FrameType::IndexType IndexType;
59  typedef typename FrameType::PixelType PixelType;
60  typedef typename FrameType::PointType PointType;
61  typedef typename FrameType::SpacingType SpacingType;
62  typedef typename FrameType::SizeType SizeType;
64 
66  typedef typename std::map<SizeValueType, SpatialRegionType> SpatialRegionMapType;
67  typedef typename std::map<SizeValueType, PointType> PointMapType;
68  typedef typename std::map<SizeValueType, DirectionType> DirectionMapType;
69  typedef typename std::map<SizeValueType, SpacingType> SpacingMapType;
70 
72  itkStaticConstMacro(FrameDimension, unsigned int, FrameType::ImageDimension);
73  static unsigned int GetFrameDimension()
74  {
75  return FrameType::ImageDimension;
76  }
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 
274  void Allocate();
276 
281  virtual void Graft(const DataObject* data) ITK_OVERRIDE;
282 
283 protected:
285  virtual ~VideoStream() ITK_OVERRIDE {}
286 
287  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE
288  {
289  Superclass::Print(os, indent);
290  }
291 
298 
304 
305 private:
306  ITK_DISALLOW_COPY_AND_ASSIGN(VideoStream);
307 
308 }; // end class VideoStream
309 
310 } // end namespace itk
311 
312 #ifndef ITK_MANUAL_INSTANTIATION
313 #include "itkVideoStream.hxx"
314 #endif
315 
316 #endif
const SpacingMapType & GetSpacingCache() const
std::map< SizeValueType, PointType > PointMapType
SpacingMapType m_SpacingCache
const SpatialRegionMapType & GetBufferedSpatialRegionCache() const
virtual ~VideoStream() override
WeakPointer< const Self > ConstWeakPointer
Superclass::BufferType BufferType
void SetBufferedSpatialRegionCache(SpatialRegionMapType map)
FrameType::PixelType PixelType
FrameType::RegionType SpatialRegionType
void SetOriginCache(PointMapType map)
std::map< SizeValueType, SpacingType > SpacingMapType
Implements a weak reference to an object.
FrameType::PointType PointType
DirectionMapType m_DirectionCache
unsigned long SizeValueType
Definition: itkIntTypes.h:143
void SetLargestPossibleSpatialRegionCache(SpatialRegionMapType map)
SmartPointer< const Self > ConstPointer
void SetDirectionCache(DirectionMapType map)
PointMapType m_OriginCache
const DirectionMapType & GetDirectionCache() const
const BufferType * GetFrameBuffer() const
FrameType::ConstPointer FrameConstPointer
SpatialRegionMapType m_RequestedSpatialRegionCache
SpatialRegionMapType m_LargestPossibleSpatialRegionCache
FrameType::Pointer FramePointer
void SetSpacingCache(SpacingMapType map)
const SpatialRegionMapType & GetRequestedSpatialRegionCache() const
FrameType::DirectionType DirectionType
A DataObject that holds a buffered portion of a video.
const SpatialRegionMapType & GetLargestPossibleSpatialRegionCache() const
FrameType::SizeType SizeType
TFrameType FrameType
virtual void PrintSelf(std::ostream &os, Indent indent) const override
VideoStream Self
const PointMapType & GetOriginCache() const
FrameType::IndexType IndexType
void SetRequestedSpatialRegionCache(SpatialRegionMapType map)
std::map< SizeValueType, SpatialRegionType > SpatialRegionMapType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
DataObject subclass with knowledge of temporal region.
SpatialRegionMapType m_BufferedSpatialRegionCache
TemporalDataObject Superclass
BufferType * GetFrameBuffer()
SmartPointer< Self > Pointer
Templated ring buffer for holding anything.
Definition: itkRingBuffer.h:39
static unsigned int GetFrameDimension()
Base class for all data objects in ITK.
FrameType::SpacingType SpacingType
std::map< SizeValueType, DirectionType > DirectionMapType