Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitk::USImageVideoSource Class Reference

This class can be pointed to a video file or a videodevice and delivers USImages. More...

#include <mitkUSImageVideoSource.h>

Inheritance diagram for mitk::USImageVideoSource:
Collaboration diagram for mitk::USImageVideoSource:

Classes

struct  USImageCropping
 Defines a region of interest by distances to the four image borders. More...
 
struct  USImageRoi
 Defines a region of interest by top left and bottom right corner. More...
 

Public Member Functions

 mitkClassMacroItkParent (USImageVideoSource, itk::ProcessObject)
 
Pointer Clone () const
 
void SetVideoFileInput (std::string path)
 Opens a video file for streaming. If nothing goes wrong, the VideoSource is ready to deliver images after calling this function. More...
 
void SetCameraInput (int deviceID)
 Opens a video device for streaming. Takes the Device id. Try -1 for "grab the first you can get" which works quite well if only one device is available. If nothing goes wrong, the VideoSource is ready to deliver images after calling this function. More...
 
void ReleaseInput ()
 
void SetColorOutput (bool isColor)
 Sets the output image to rgb or grayscale. Output is color by default and can be set to color by passing true, or to grayscale again by passing false. More...
 
void SetRegionOfInterest (int topLeftX, int topLeftY, int bottomRightX, int bottomRightY)
 Defines the cropping area. The rectangle will be justified to the image borders if the given rectangle is larger than the video source. If a correct rectangle is given, the dimensions of the output image will be equal to those of the rectangle. More...
 
void SetRegionOfInterest (USImageRoi regionOfInterest)
 Defines the cropping area. The rectangle will be justified to the image borders if the given rectangle is larger than the video source. If a correct rectangle is given, the dimensions of the output image will be equal to those of the rectangle. More...
 
void SetCropping (USImageCropping cropping)
 Defines the cropping area. The rectangle will be justified to the image borders if the given rectangle is larger than the video source. If a correct rectangle is given, the dimensions of the output image will be equal to those of the rectangle. More...
 
void RemoveRegionOfInterest ()
 
void OverrideResolution (int width, int height)
 This is a workaround for a problem that happens with some video device drivers. More...
 
virtual bool GetIsVideoReady ()
 
virtual bool GetResolutionOverride ()
 
virtual void SetResolutionOverride (bool _arg)
 
virtual bool GetIsGreyscale ()
 
virtual int GetResolutionOverrideWidth ()
 
virtual int GetResolutionOverrideHeight ()
 
int GetImageHeight ()
 
int GetImageWidth ()
 
USImageCropping GetCropping ()
 
USImageRoi GetRegionOfInterest ()
 
bool GetIsReady ()
 Returns true if images can be delivered. More...
 
- Public Member Functions inherited from mitk::USImageSource
 mitkClassMacroItkParent (USImageSource, itk::Object)
 
virtual mitk::BasicCombinationOpenCVImageFilter::Pointer GetImageFilter ()
 
void PushFilter (AbstractOpenCVImageFilter::Pointer filter)
 
bool RemoveFilter (AbstractOpenCVImageFilter::Pointer filter)
 
bool GetIsFilterInThePipeline (AbstractOpenCVImageFilter::Pointer filter)
 
mitk::Image::Pointer GetNextImage ()
 Retrieves the next frame. This will typically be the next frame in a file or the last cached file in a device. The image is filtered if a filter was set by mitk::USImageSource::SetImageFilter(). More...
 

Static Public Member Functions

static Pointer New ()
 

Protected Member Functions

 USImageVideoSource ()
 
virtual ~USImageVideoSource ()
 
virtual void GetNextRawImage (cv::Mat &image) override
 Next image is gathered from the image source. More...
 
virtual void GetNextRawImage (mitk::Image::Pointer &image) override
 Next image is gathered from the image source. More...
 
- Protected Member Functions inherited from mitk::USImageSource
 USImageSource ()
 
virtual ~USImageSource ()
 

Protected Attributes

cv::VideoCapture * m_VideoCapture
 The source of the video, managed internally. More...
 
bool m_IsVideoReady
 If true, a frame can be grabbed anytime. More...
 
bool m_IsGreyscale
 If true, image output will be greyscale. More...
 
bool m_IsCropped
 If true, image will be cropped according to settings of crop filter. More...
 
int m_ResolutionOverrideWidth
 
int m_ResolutionOverrideHeight
 
bool m_ResolutionOverride
 
ConvertGrayscaleOpenCVImageFilter::Pointer m_GrayscaleFilter
 
CropOpenCVImageFilter::Pointer m_CropFilter
 
- Protected Attributes inherited from mitk::USImageSource
mitk::OpenCVToMitkImageFilter::Pointer m_OpenCVToMitkFilter
 Used to convert from OpenCV Images to MITK Images. More...
 
mitk::ImageToOpenCVImageFilter::Pointer m_MitkToOpenCVFilter
 Used to convert from MITK Images to OpenCV Images. More...
 

Additional Inherited Members

- Static Public Attributes inherited from mitk::USImageSource
static const char * IMAGE_PROPERTY_IDENTIFIER
 

Detailed Description

This class can be pointed to a video file or a videodevice and delivers USImages.

Images are in color by default, but can be set to greyscale via SetColorOutput(false), which significantly improves performance.

Images can also be cropped to a region of interest, further increasing performance.

Definition at line 43 of file mitkUSImageVideoSource.h.

Constructor & Destructor Documentation

mitk::USImageVideoSource::USImageVideoSource ( )
protected

Definition at line 28 of file mitkUSImageVideoSource.cpp.

mitk::USImageVideoSource::~USImageVideoSource ( )
protectedvirtual

Definition at line 41 of file mitkUSImageVideoSource.cpp.

Member Function Documentation

Pointer mitk::USImageVideoSource::Clone ( ) const
int mitk::USImageVideoSource::GetImageHeight ( )

Definition at line 99 of file mitkUSImageVideoSource.cpp.

int mitk::USImageVideoSource::GetImageWidth ( )

Definition at line 105 of file mitkUSImageVideoSource.cpp.

virtual bool mitk::USImageVideoSource::GetIsGreyscale ( )
virtual
bool mitk::USImageVideoSource::GetIsReady ( )

Returns true if images can be delivered.

Only if true is returned one can retrieve images via mitk::USImageVideoSource::GetNextImage(). If false is returned, behaviour is undefined.

Definition at line 111 of file mitkUSImageVideoSource.cpp.

virtual bool mitk::USImageVideoSource::GetIsVideoReady ( )
virtual
void mitk::USImageVideoSource::GetNextRawImage ( cv::Mat &  image)
overrideprotectedvirtual

Next image is gathered from the image source.

Parameters
[out]imagean OpenCV-Matrix containing this image

Reimplemented from mitk::USImageSource.

Definition at line 184 of file mitkUSImageVideoSource.cpp.

void mitk::USImageVideoSource::GetNextRawImage ( mitk::Image::Pointer image)
overrideprotectedvirtual

Next image is gathered from the image source.

Parameters
[out]imagean mitk::Image containing this image

Implements mitk::USImageSource.

Definition at line 198 of file mitkUSImageVideoSource.cpp.

mitk::USImageVideoSource::USImageRoi mitk::USImageVideoSource::GetRegionOfInterest ( )

Definition at line 171 of file mitkUSImageVideoSource.cpp.

virtual bool mitk::USImageVideoSource::GetResolutionOverride ( )
virtual
virtual int mitk::USImageVideoSource::GetResolutionOverrideHeight ( )
virtual
virtual int mitk::USImageVideoSource::GetResolutionOverrideWidth ( )
virtual
mitk::USImageVideoSource::mitkClassMacroItkParent ( USImageVideoSource  ,
itk::ProcessObject   
)
static Pointer mitk::USImageVideoSource::New ( )
static
void mitk::USImageVideoSource::OverrideResolution ( int  width,
int  height 
)

This is a workaround for a problem that happens with some video device drivers.

If you encounter OpenCV Warnings that buffer sizes do not match while calling getNextFrame, then do the following: Using the drivers control panel to force a certain resolution, then call this method with the same Dimensions after opening the device. Before retrieving images one should call mitk::USImageVideoSource::isReady().

Definition at line 217 of file mitkUSImageVideoSource.cpp.

void mitk::USImageVideoSource::ReleaseInput ( )

Definition at line 79 of file mitkUSImageVideoSource.cpp.

void mitk::USImageVideoSource::RemoveRegionOfInterest ( )

/brief Removes the region of interest. Produced images will be uncropped after call of this method.

Definition at line 178 of file mitkUSImageVideoSource.cpp.

void mitk::USImageVideoSource::SetCameraInput ( int  deviceID)

Opens a video device for streaming. Takes the Device id. Try -1 for "grab the first you can get" which works quite well if only one device is available. If nothing goes wrong, the VideoSource is ready to deliver images after calling this function.

Definition at line 63 of file mitkUSImageVideoSource.cpp.

void mitk::USImageVideoSource::SetColorOutput ( bool  isColor)

Sets the output image to rgb or grayscale. Output is color by default and can be set to color by passing true, or to grayscale again by passing false.

Definition at line 86 of file mitkUSImageVideoSource.cpp.

void mitk::USImageVideoSource::SetCropping ( USImageCropping  cropping)

Defines the cropping area. The rectangle will be justified to the image borders if the given rectangle is larger than the video source. If a correct rectangle is given, the dimensions of the output image will be equal to those of the rectangle.

Parameters
croppingstruct defining distances to the four image borders

Definition at line 134 of file mitkUSImageVideoSource.cpp.

References mitk::USImageVideoSource::USImageCropping::bottom, mitk::USImageVideoSource::USImageCropping::left, mitk::USImageVideoSource::USImageCropping::right, and mitk::USImageVideoSource::USImageCropping::top.

void mitk::USImageVideoSource::SetRegionOfInterest ( int  topLeftX,
int  topLeftY,
int  bottomRightX,
int  bottomRightY 
)

Defines the cropping area. The rectangle will be justified to the image borders if the given rectangle is larger than the video source. If a correct rectangle is given, the dimensions of the output image will be equal to those of the rectangle.

Definition at line 118 of file mitkUSImageVideoSource.cpp.

void mitk::USImageVideoSource::SetRegionOfInterest ( USImageRoi  regionOfInterest)

Defines the cropping area. The rectangle will be justified to the image borders if the given rectangle is larger than the video source. If a correct rectangle is given, the dimensions of the output image will be equal to those of the rectangle.

Parameters
regionOfIntereststruct defining x and y coordinates of top left and bottom right corner

Definition at line 129 of file mitkUSImageVideoSource.cpp.

References mitk::USImageVideoSource::USImageRoi::bottomRightX, mitk::USImageVideoSource::USImageRoi::bottomRightY, mitk::USImageVideoSource::USImageRoi::topLeftX, and mitk::USImageVideoSource::USImageRoi::topLeftY.

virtual void mitk::USImageVideoSource::SetResolutionOverride ( bool  _arg)
virtual
void mitk::USImageVideoSource::SetVideoFileInput ( std::string  path)

Opens a video file for streaming. If nothing goes wrong, the VideoSource is ready to deliver images after calling this function.

Definition at line 47 of file mitkUSImageVideoSource.cpp.

Member Data Documentation

CropOpenCVImageFilter::Pointer mitk::USImageVideoSource::m_CropFilter
protected

Definition at line 218 of file mitkUSImageVideoSource.h.

ConvertGrayscaleOpenCVImageFilter::Pointer mitk::USImageVideoSource::m_GrayscaleFilter
protected

Definition at line 217 of file mitkUSImageVideoSource.h.

bool mitk::USImageVideoSource::m_IsCropped
protected

If true, image will be cropped according to settings of crop filter.

Definition at line 208 of file mitkUSImageVideoSource.h.

bool mitk::USImageVideoSource::m_IsGreyscale
protected

If true, image output will be greyscale.

Definition at line 203 of file mitkUSImageVideoSource.h.

bool mitk::USImageVideoSource::m_IsVideoReady
protected

If true, a frame can be grabbed anytime.

Definition at line 198 of file mitkUSImageVideoSource.h.

bool mitk::USImageVideoSource::m_ResolutionOverride
protected

Definition at line 215 of file mitkUSImageVideoSource.h.

int mitk::USImageVideoSource::m_ResolutionOverrideHeight
protected

Definition at line 214 of file mitkUSImageVideoSource.h.

int mitk::USImageVideoSource::m_ResolutionOverrideWidth
protected

These Variables determined whether Resolution Override is on, what dimensions to use.

Definition at line 213 of file mitkUSImageVideoSource.h.

cv::VideoCapture* mitk::USImageVideoSource::m_VideoCapture
protected

The source of the video, managed internally.

Definition at line 193 of file mitkUSImageVideoSource.h.


The documentation for this class was generated from the following files: