Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _mitk_OpenCVVideo_Source_h_
00019 #define _mitk_OpenCVVideo_Source_h_
00020
00021 #include "mitkConfig.h"
00022
00023 #include "mitkVideoSource.h"
00024 #include "mitkUndistortCameraImage.h"
00025
00026
00027 #include "highgui.h"
00028
00029
00030 #include "itkRGBPixel.h"
00031 #include "itkImage.h"
00032 #include "itkImageRegionIterator.h"
00033 #include "mitkOpenCVImageSource.h"
00034
00035 namespace mitk
00036 {
00044 class MITK_OPENCVVIDEOSUPPORT_EXPORT OpenCVVideoSource :
00045 public VideoSource, public OpenCVImageSource
00046 {
00047 typedef itk::RGBPixel< unsigned char > CharPixelType;
00048 typedef itk::FixedArray <float,3> HSVPixelType;
00049 typedef itk::Image< CharPixelType , 2 > RGBPixelImageType;
00050 typedef itk::Image<HSVPixelType,2> HSVPixelImageType;
00051 typedef itk::ImageRegionIterator< RGBPixelImageType > RGBConstIteratorType;
00052 typedef itk::ImageRegionIterator< HSVPixelImageType > HSVConstIteratorType;
00053
00054 public:
00055 mitkClassMacro( OpenCVVideoSource, itk::Object );
00056 itkNewMacro( Self );
00057
00062 virtual void SetVideoFileInput(const char * filename, bool repeatVideo, bool useCVCAMLib = false);
00067 virtual void SetVideoCameraInput(int cameraindex, bool useCVCAMLib = false);
00081 virtual double GetVideoCaptureProperty(int property_id);
00086 virtual int SetVideoCaptureProperty(int property_id, double value);
00087
00088 virtual void GetCurrentFrameAsOpenCVImage(IplImage * image);
00092 const IplImage * GetImage();
00093 const IplImage * GetCurrentFrame();
00096 virtual void GetCurrentFrameAsItkHSVPixelImage(HSVPixelImageType::Pointer &Image);
00099 virtual void FetchFrame();
00102 virtual unsigned char * GetVideoTexture();
00105 virtual void StartCapturing();
00108 virtual void StopCapturing();
00111 virtual IplImage* RotateImage(IplImage* input);
00116 virtual void EnableOnlineImageUndistortion(mitk::Point3D focal, mitk::Point3D principal, mitk::Point4D distortion);
00119 virtual void DisableOnlineImageUndistortion();
00123 virtual bool OnlineImageUndistortionEnabled() const;
00124
00125 virtual void PauseCapturing();
00126
00127 itkGetConstMacro( CapturePaused, bool );
00128
00132 itkGetConstMacro( VideoFileName, std::string );
00133
00137 itkGetConstMacro( GrabbingDeviceNumber, short );
00138
00139 itkGetMacro( RepeatVideo, bool );
00140 itkSetMacro( RepeatVideo, bool );
00141
00142 protected:
00143 OpenCVVideoSource();
00144 virtual ~OpenCVVideoSource();
00145
00149 void Reset();
00150
00154 void UpdateVideoTexture();
00155
00156
00157 void sleep(unsigned int ms);
00158 void RGBtoHSV(float r, float g, float b, float &h, float &s, float &v);
00159
00160
00161 CvCapture * m_VideoCapture;
00162
00163
00164 IplImage * m_CurrentImage;
00165 unsigned char* m_CurrentVideoTexture;
00166
00167 IplImage * m_PauseImage;
00168 bool m_CapturePaused;
00169
00172 std::string m_VideoFileName;
00173
00176 short m_GrabbingDeviceNumber;
00177
00178
00179 bool m_RepeatVideo;
00180
00181
00182 bool m_UseCVCAMLib;
00183
00184
00185 bool m_UndistortImage;
00186 mitk::UndistortCameraImage::Pointer m_UndistortCameraImage;
00187 };
00188 }
00189 #endif // Header
00190
00191