ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkVideoFileReader.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkVideoFileReader_h
00019 #define __itkVideoFileReader_h
00020 
00021 #include "itkVideoSource.h"
00022 #include "itkVideoIOFactory.h"
00023 #include "itkDefaultConvertPixelTraits.h"
00024 
00025 namespace itk
00026 {
00027 
00040 template< class TOutputVideoStream >
00041 class ITK_EXPORT VideoFileReader : public VideoSource< TOutputVideoStream >
00042 {
00043 public:
00044 
00046   typedef VideoFileReader                          Self;
00047   typedef VideoSource< TOutputVideoStream >        Superclass;
00048   typedef SmartPointer<Self>                       Pointer;
00049   typedef TOutputVideoStream                       VideoStreamType;
00050   typedef typename VideoStreamType::Pointer        VideoStreamPointer;
00051 
00052   typedef typename VideoStreamType::FrameType      FrameType;
00053   typedef typename FrameType::PixelType            PixelType;
00054   typedef typename FrameType::RegionType           RegionType;
00055   typedef typename FrameType::SizeType             SizeType;
00056   typedef typename FrameType::IndexType            IndexType;
00057   typedef typename FrameType::PointType            PointType;
00058   typedef typename FrameType::SpacingType          SpacingType;
00059   typedef typename FrameType::DirectionType        DirectionType;
00060 
00061   typedef typename VideoIOBase::TemporalOffsetType TemporalOffsetType;
00062   typedef typename VideoIOBase::FrameOffsetType    FrameOffsetType;
00063   typedef typename VideoIOBase::TemporalRatioType  TemporalRatioType;
00064 
00065   itkStaticConstMacro(FrameDimension,unsigned int,FrameType::ImageDimension);
00066 
00068   typedef DefaultConvertPixelTraits<PixelType> ConvertPixelTraits;
00069 
00071   itkNewMacro(Self);
00072 
00074   itkTypeMacro(VideoFileReader, VideoSource);
00075 
00079   itkSetStringMacro(FileName);
00080   itkGetStringMacro(FileName);
00082 
00085   itkSetMacro(IFrameSafe, bool);
00086   itkGetMacro(IFrameSafe, bool);
00088 
00090   virtual void UpdateOutputInformation();
00091 
00094   void SetVideoIO(VideoIOBase* videoIO);
00095 
00097   FrameOffsetType GetCurrentPositionFrame();
00098 
00099   TemporalRatioType GetCurrentPositionRatio();
00100 
00101   TemporalOffsetType GetCurrentPositionMSec();
00102 
00104   FrameOffsetType GetNumberOfFrames();
00105 
00107   TemporalRatioType GetFramesPerSecond();
00108 
00109 protected:
00110 
00112   VideoFileReader();
00113   virtual ~VideoFileReader();
00114   void PrintSelf(std::ostream &os, Indent indent) const;
00116 
00120   virtual void TemporalStreamingGenerateData();
00121 
00123   void DoConvertBuffer(void* inputData, FrameOffsetType frameNumber);
00124 
00127   void InitializeVideoIO();
00128 
00132   std::string m_FileName;
00133 
00136   VideoIOBase::Pointer m_VideoIO;
00137 
00139   bool m_PixelConversionNeeded;
00140 
00143   bool m_IFrameSafe;
00144 private:
00145   VideoFileReader(const Self &); // purposely not implemented
00146   void operator=(const Self &);  // purposely not implemented
00148 
00149 };
00150 
00151 } // end namespace itk
00152 
00153 #if ITK_TEMPLATE_TXX
00154 #include "itkVideoFileReader.hxx"
00155 #endif
00156 
00157 #endif
00158