Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkUSImageVideoSource.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkUSImageVideoSource_h
14 #define mitkUSImageVideoSource_h
15 
16 // ITK
17 #include <itkProcessObject.h>
18 
19 // MITK
20 #include "mitkUSImageSource.h"
24 
25 // OpenCV
26 #include <opencv2/videoio.hpp>
27 
28 namespace mitk {
39  class MITKUS_EXPORT USImageVideoSource : public mitk::USImageSource
40  {
41  public:
42  mitkClassMacroItkParent(USImageVideoSource, itk::ProcessObject);
43  itkFactorylessNewMacro(Self);
44  itkCloneMacro(Self);
45 
49  struct USImageRoi
50  {
51  int topLeftX;
52  int topLeftY;
55 
57  : topLeftX(0), topLeftY(0), bottomRightX(0), bottomRightY(0) { };
58  USImageRoi(unsigned int topLeftX, unsigned int topLeftY, unsigned int bottomRightX, unsigned int bottomRightY)
59  : topLeftX(topLeftX), topLeftY(topLeftY), bottomRightX(bottomRightX), bottomRightY(bottomRightY) { };
60  };
61 
66  {
67  unsigned int top;
68  unsigned int bottom;
69  unsigned int left;
70  unsigned int right;
71 
73  : top(0), bottom(0), left(0), right(0) { };
74  USImageCropping(unsigned int top, unsigned int bottom, unsigned int left, unsigned int right)
75  : top(top), bottom(bottom), left(left), right(right) { };
76  };
77 
82  void SetVideoFileInput(std::string path);
83 
89  void SetCameraInput(int deviceID);
90 
91  void ReleaseInput();
92 
98  void SetColorOutput(bool isColor);
99 
107  void SetRegionOfInterest(int topLeftX, int topLeftY, int bottomRightX, int bottomRightY);
108 
118  void SetRegionOfInterest(USImageRoi regionOfInterest);
119 
129  void SetCropping(USImageCropping cropping);
130 
135  void RemoveRegionOfInterest();
136 
145  void OverrideResolution(int width, int height);
146 
147  // Getter & Setter
148  itkGetMacro(IsVideoReady, bool);
149  itkGetMacro(ResolutionOverride, bool);
150  itkSetMacro(ResolutionOverride, bool);
151  itkGetMacro(IsGreyscale,bool);
152  itkGetMacro(ResolutionOverrideWidth,int);
153  itkGetMacro(ResolutionOverrideHeight,int);
154  int GetImageHeight();
155  int GetImageWidth();
156  USImageCropping GetCropping();
157  USImageRoi GetRegionOfInterest();
158 
166  bool GetIsReady();
167 
168  protected:
170  ~USImageVideoSource() override;
171 
177  void GetNextRawImage( std::vector<cv::Mat>& image ) override;
178 
184  void GetNextRawImage( std::vector<mitk::Image::Pointer>& image ) override;
185 
189  cv::VideoCapture* m_VideoCapture;
190 
195 
200 
205 
212 
213  ConvertGrayscaleOpenCVImageFilter::Pointer m_GrayscaleFilter;
214  CropOpenCVImageFilter::Pointer m_CropFilter;
215  };
216 } // namespace mitk
217 #endif
mitk::USImageVideoSource::m_IsGreyscale
bool m_IsGreyscale
If true, image output will be greyscale.
Definition: mitkUSImageVideoSource.h:199
mitkConvertGrayscaleOpenCVImageFilter.h
mitk::USImageVideoSource::m_GrayscaleFilter
ConvertGrayscaleOpenCVImageFilter::Pointer m_GrayscaleFilter
Definition: mitkUSImageVideoSource.h:213
mitk::USImageVideoSource::USImageCropping::USImageCropping
USImageCropping()
Definition: mitkUSImageVideoSource.h:72
mitk::USImageVideoSource::m_IsCropped
bool m_IsCropped
If true, image will be cropped according to settings of crop filter.
Definition: mitkUSImageVideoSource.h:204
mitk::USImageVideoSource::m_IsVideoReady
bool m_IsVideoReady
If true, a frame can be grabbed anytime.
Definition: mitkUSImageVideoSource.h:194
mitk::USImageVideoSource::USImageCropping
Defines a region of interest by distances to the four image borders.
Definition: mitkUSImageVideoSource.h:65
mitk::USImageVideoSource::USImageRoi::topLeftX
int topLeftX
Definition: mitkUSImageVideoSource.h:51
mitk::USImageVideoSource::USImageRoi
Defines a region of interest by top left and bottom right corner.
Definition: mitkUSImageVideoSource.h:49
mitk::USImageVideoSource::USImageRoi::USImageRoi
USImageRoi()
Definition: mitkUSImageVideoSource.h:56
mitkBasicCombinationOpenCVImageFilter.h
mitk::USImageVideoSource::USImageRoi::topLeftY
int topLeftY
Definition: mitkUSImageVideoSource.h:52
mitk::USImageVideoSource::m_CropFilter
CropOpenCVImageFilter::Pointer m_CropFilter
Definition: mitkUSImageVideoSource.h:214
mitk::USImageVideoSource
This class can be pointed to a video file or a videodevice and delivers USImages.
Definition: mitkUSImageVideoSource.h:39
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk::USImageVideoSource::USImageRoi::bottomRightY
int bottomRightY
Definition: mitkUSImageVideoSource.h:54
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::USImageVideoSource::USImageCropping::USImageCropping
USImageCropping(unsigned int top, unsigned int bottom, unsigned int left, unsigned int right)
Definition: mitkUSImageVideoSource.h:74
mitk::USImageSource
This is an abstract superclass for delivering USImages. Each subclass must implement the method mitk:...
Definition: mitkUSImageSource.h:38
mitk::USImageVideoSource::m_ResolutionOverride
bool m_ResolutionOverride
Definition: mitkUSImageVideoSource.h:211
mitk::USImageVideoSource::USImageCropping::top
unsigned int top
Definition: mitkUSImageVideoSource.h:67
mitk::USImageVideoSource::m_VideoCapture
cv::VideoCapture * m_VideoCapture
The source of the video, managed internally.
Definition: mitkUSImageVideoSource.h:189
mitk::USImageVideoSource::USImageRoi::bottomRightX
int bottomRightX
Definition: mitkUSImageVideoSource.h:53
mitk::USImageVideoSource::USImageCropping::right
unsigned int right
Definition: mitkUSImageVideoSource.h:70
mitkCropOpenCVImageFilter.h
mitk::USImageVideoSource::USImageCropping::bottom
unsigned int bottom
Definition: mitkUSImageVideoSource.h:68
mitk::USImageVideoSource::USImageCropping::left
unsigned int left
Definition: mitkUSImageVideoSource.h:69
mitkUSImageSource.h
mitk::USImageVideoSource::USImageRoi::USImageRoi
USImageRoi(unsigned int topLeftX, unsigned int topLeftY, unsigned int bottomRightX, unsigned int bottomRightY)
Definition: mitkUSImageVideoSource.h:58
mitk::USImageVideoSource::m_ResolutionOverrideWidth
int m_ResolutionOverrideWidth
Definition: mitkUSImageVideoSource.h:209
mitk::USImageVideoSource::m_ResolutionOverrideHeight
int m_ResolutionOverrideHeight
Definition: mitkUSImageVideoSource.h:210