Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
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_HEADER_INCLUDED_
14 #define MITKUSImageVideoSource_H_HEADER_INCLUDED_
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 {
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 /* MITKUSImageVideoSource_H_HEADER_INCLUDED_ */
Defines a region of interest by distances to the four image borders.
ConvertGrayscaleOpenCVImageFilter::Pointer m_GrayscaleFilter
cv::VideoCapture * m_VideoCapture
The source of the video, managed internally.
DataCollection - Class to facilitate loading/accessing structured data.
This is an abstract superclass for delivering USImages. Each subclass must implement the method mitk:...
This class can be pointed to a video file or a videodevice and delivers USImages. ...
CropOpenCVImageFilter::Pointer m_CropFilter
Defines a region of interest by top left and bottom right corner.
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:49
mitk::Image::Pointer image
USImageRoi(unsigned int topLeftX, unsigned int topLeftY, unsigned int bottomRightX, unsigned int bottomRightY)
bool m_IsVideoReady
If true, a frame can be grabbed anytime.
#define MITKUS_EXPORT
Definition: MitkUSExports.h:15
bool m_IsGreyscale
If true, image output will be greyscale.
USImageCropping(unsigned int top, unsigned int bottom, unsigned int left, unsigned int right)
bool m_IsCropped
If true, image will be cropped according to settings of crop filter.