ITK  4.9.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>
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;
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;
63  typedef typename FrameType::DirectionType DirectionType;
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  {
113  }
115  {
117  }
119 
121  {
123  }
125  {
127  }
128 
130  {
132  }
134  {
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 
178  SpatialRegionType region);
179 
180  const SpatialRegionType &
182 
185  SpatialRegionType region);
186 
187  const SpatialRegionType &
189 
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 
216 
221 
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() {}
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  VideoStream(const Self &) ITK_DELETE_FUNCTION;
307  void operator=(const Self &) ITK_DELETE_FUNCTION;
308 
309 }; // end class VideoStream
310 
311 } // end namespace itk
312 
313 #ifndef ITK_MANUAL_INSTANTIATION
314 #include "itkVideoStream.hxx"
315 #endif
316 
317 #endif
const PointType & GetFrameOrigin(SizeValueType frameNumber) const
const SpacingMapType & GetSpacingCache() const
std::map< SizeValueType, PointType > PointMapType
void Print(std::ostream &os, Indent indent=0) const
SpacingMapType m_SpacingCache
const SpatialRegionType & GetFrameRequestedSpatialRegion(SizeValueType frameNumber) const
const SpatialRegionMapType & GetBufferedSpatialRegionCache() const
WeakPointer< const Self > ConstWeakPointer
void InitializeEmptyFrames()
Superclass::BufferType BufferType
void SetBufferedSpatialRegionCache(SpatialRegionMapType map)
FrameType::PixelType PixelType
FrameType::RegionType SpatialRegionType
void SetMinimumBufferSize(SizeValueType minimumNumberOfFrames)
void SetOriginCache(PointMapType map)
std::map< SizeValueType, SpacingType > SpacingMapType
void SetAllRequestedSpatialRegions(SpatialRegionType region)
virtual ~VideoStream()
ObjectType * GetPointer() const
void SetFrameSpacing(SizeValueType frameNumber, SpacingType spacing)
Implements a weak reference to an object.
FrameType::PointType PointType
DirectionMapType m_DirectionCache
unsigned long SizeValueType
Definition: itkIntTypes.h:143
const DirectionType & GetFrameDirection(SizeValueType frameNumber) const
static const unsigned int FrameDimension
void SetLargestPossibleSpatialRegionCache(SpatialRegionMapType map)
SmartPointer< const Self > ConstPointer
void SetDirectionCache(DirectionMapType map)
void SetFrameOrigin(SizeValueType frameNumber, PointType origin)
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)
void SetFrameBuffer(BufferType *buffer)
const SpatialRegionMapType & GetRequestedSpatialRegionCache() const
void SetFrame(SizeValueType frameNumber, FramePointer frame)
FrameType::DirectionType DirectionType
A DataObject that holds a buffered portion of a video.
void SetFrameRequestedSpatialRegion(SizeValueType frameNumber, SpatialRegionType region)
const SpatialRegionMapType & GetLargestPossibleSpatialRegionCache() const
FrameType::SizeType SizeType
const SpatialRegionType & GetFrameLargestPossibleSpatialRegion(SizeValueType frameNumber) const
TFrameType FrameType
RingBuffer< DataObject > BufferType
virtual void PrintSelf(std::ostream &os, Indent indent) const override
VideoStream Self
void SetAllFramesSpacing(SpacingType spacing)
virtual void Graft(const DataObject *data) override
const PointMapType & GetOriginCache() const
void SetFrameBufferedSpatialRegion(SizeValueType frameNumber, SpatialRegionType region)
FrameType::IndexType IndexType
void SetRequestedSpatialRegionCache(SpatialRegionMapType map)
void SetFrameDirection(SizeValueType frameNumber, DirectionType direction)
std::map< SizeValueType, SpatialRegionType > SpatialRegionMapType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
DataObject subclass with knowledge of temporal region.
FramePointer GetFrame(SizeValueType frameNumber)
void SetAllFramesDirection(DirectionType direction)
SpatialRegionMapType m_BufferedSpatialRegionCache
BufferType::Pointer m_DataObjectBuffer
TemporalDataObject Superclass
const SpatialRegionType & GetFrameBufferedSpatialRegion(SizeValueType frameNumber) const
BufferType * GetFrameBuffer()
void SetFrameLargestPossibleSpatialRegion(SizeValueType frameNumber, SpatialRegionType region)
SmartPointer< Self > Pointer
Templated ring buffer for holding anything.
Definition: itkRingBuffer.h:39
void SetAllLargestPossibleSpatialRegions(SpatialRegionType region)
void SetAllFramesOrigin(PointType origin)
void SetAllBufferedSpatialRegions(SpatialRegionType region)
static unsigned int GetFrameDimension()
Base class for all data objects in ITK.
const SpacingType & GetFrameSpacing(SizeValueType frameNumber) const
FrameType::SpacingType SpacingType
std::map< SizeValueType, DirectionType > DirectionMapType