MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkOpenCVVideoSource.h
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
13#ifndef mitkOpenCVVideoSource_h
14#define mitkOpenCVVideoSource_h
15
16#include "mitkConfig.h"
17
18#include "mitkVideoSource.h"
20
21// HighGui camera interface: a convenient way for grabbing from a video capture (on windows VfW is used)
22#include <opencv2/highgui.hpp>
23
24// For Providing ITK Image Interface
25#include "itkRGBPixel.h"
26#include "itkImage.h"
27#include "itkImageRegionIterator.h"
29
30namespace mitk
31{
39 class MITKOPENCVVIDEOSUPPORT_EXPORT OpenCVVideoSource :
40 virtual public VideoSource, virtual public OpenCVImageSource
41 {
42 public:
43 typedef itk::RGBPixel< unsigned char > CharPixelType;
44 typedef itk::FixedArray <float,3> HSVPixelType;
45 typedef itk::Image< CharPixelType , 2 > RGBPixelImageType;
46 typedef itk::Image<HSVPixelType,2> HSVPixelImageType;
47 typedef itk::ImageRegionIterator< RGBPixelImageType > RGBConstIteratorType;
48 typedef itk::ImageRegionIterator< HSVPixelImageType > HSVConstIteratorType;
49
53
58 virtual void SetVideoFileInput(const char * filename, bool repeatVideo, bool useCVCAMLib = false);
63 virtual void SetVideoCameraInput(int cameraindex, bool useCVCAMLib = false);
76 virtual double GetVideoCaptureProperty(int property_id);
80 virtual int SetVideoCaptureProperty(int property_id, double value);
81
82 virtual void GetCurrentFrameAsOpenCVImage(IplImage * image);
86 cv::Mat GetImage() override;
87 virtual const IplImage * GetCurrentFrame();
90 virtual void GetCurrentFrameAsItkHSVPixelImage(HSVPixelImageType::Pointer &Image);
93 void FetchFrame() override;
96 unsigned char * GetVideoTexture() override;
99 void StartCapturing() override;
102 void StopCapturing() override;
105 virtual IplImage* FlipImage(IplImage* input);
110 virtual void EnableOnlineImageUndistortion(mitk::Point3D focal, mitk::Point3D principal, mitk::Point4D distortion);
113 virtual void DisableOnlineImageUndistortion();
117 virtual bool OnlineImageUndistortionEnabled() const;
118
119 void PauseCapturing() override;
123 itkGetConstMacro( VideoFileName, std::string );
124
125 virtual void SetEnableXAxisFlip(bool enable);
126 virtual void SetEnableYAxisFlip(bool enable);
127
131 itkGetConstMacro( GrabbingDeviceNumber, short );
132
133 itkGetMacro( RepeatVideo, bool );
134 itkSetMacro( RepeatVideo, bool );
135
136
137 protected:
139 ~OpenCVVideoSource() override;
140
144 void Reset();
145
149 void UpdateVideoTexture();
150
151 // Helper functions
152 void sleep(unsigned int ms);
153 void RGBtoHSV(float r, float g, float b, float &h, float &s, float &v);
154
155 // HighGUI Library capture device
156 CvCapture * m_VideoCapture;
157
158 // current Video image
159 IplImage * m_CurrentImage;
160 unsigned char* m_CurrentVideoTexture;
161
162 IplImage * m_PauseImage;
163
166 std::string m_VideoFileName;
167
171
172 // Repeat a video file
174
175 // Switch between CVCAM Lib and HighGui Lib
177
178 // On-the-fly undistortion of the captured video image
180 mitk::UndistortCameraImage::Pointer m_UndistortCameraImage;
181
186
191 };
192}
193#endif
itk::ImageRegionIterator< HSVPixelImageType > HSVConstIteratorType
itk::FixedArray< float, 3 > HSVPixelType
itk::Image< HSVPixelType, 2 > HSVPixelImageType
void sleep(unsigned int ms)
itk::RGBPixel< unsigned char > CharPixelType
itk::Image< CharPixelType, 2 > RGBPixelImageType
short m_GrabbingDeviceNumber
saves the grabbing device number (is -1 if a videofilename is used or if this is not initialized)
itkGetMacro(RepeatVideo, bool)
itkGetConstMacro(VideoFileName, std::string)
mitk::UndistortCameraImage::Pointer m_UndistortCameraImage
itkSetMacro(RepeatVideo, bool)
mitkClassMacro(OpenCVVideoSource, VideoSource)
itkGetConstMacro(GrabbingDeviceNumber, short)
std::string m_VideoFileName
saves the video file name (is empty if a grabbing device is used or if this is not initialized)
itk::ImageRegionIterator< RGBPixelImageType > RGBConstIteratorType
IGT Exceptions.