MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitk::USVideoDevice Class Reference

A mitk::USVideoDevice is the common class for video only devices. They capture video input either from a file or from a device and transform the output into an mitk::USImage with attached metadata. This simple implementation does only capture and display 2d images without registration for example. More...

#include <mitkUSVideoDevice.h>

Inheritance diagram for mitk::USVideoDevice:
mitk::USDevice

Public Member Functions

 mitkClassMacro (USVideoDevice, mitk::USDevice)
 
 mitkNewMacro3Param (Self, int, std::string, std::string)
 
 mitkNewMacro3Param (Self, std::string, std::string, std::string)
 
 mitkNewMacro2Param (Self, int, mitk::USImageMetadata::Pointer)
 
 mitkNewMacro2Param (Self, std::string, mitk::USImageMetadata::Pointer)
 
std::string GetDeviceClass () override
 
itk::SmartPointer< USAbstractControlInterfaceGetControlInterfaceCustom () override
 
void UnregisterOnService ()
 Remove this device from the micro service. This method is public for mitk::USVideoDevice, because this devices can be completly removed. This is not possible for API devices, which should be available while their sub module is loaded.
 
USImageSource::Pointer GetUSImageSource () override
 
std::vector< mitk::USProbe::Pointer > GetAllProbes () override
 Return all probes for this USVideoDevice or an empty vector it no probes were set Returns a std::vector of all probes that exist for this USVideoDevice if there were probes set while creating or modifying this USVideoDevice. Otherwise it returns an empty vector. Therefore always check if vector is filled, before using it!
 
void DeleteAllProbes () override
 Cleans the std::vector containing all configured probes.
 
mitk::USProbe::Pointer GetCurrentProbe () override
 Return current active probe for this USVideoDevice Returns a pointer to the probe that is currently in use. If there were probes set while creating or modifying this USVideoDevice. Returns null otherwise.
 
void AddNewProbe (mitk::USProbe::Pointer probe) override
 adds a new probe to the device
 
mitk::USProbe::Pointer GetProbeByName (std::string name) override
 get the probe by its name Returns a pointer to the probe identified by the given name. If no probe of given name exists for this Device 0 is returned.
 
void RemoveProbeByName (std::string name) override
 Removes the Probe with the given name.
 
bool GetIsSourceFile ()
 True, if this Device plays back a file, false if it recieves data from a device.
 
void SetDefaultProbeAsCurrentProbe () override
 Sets the first existing probe or the default probe of the video device as the current probe of it.
 
void SetCurrentProbe (std::string probename) override
 Sets the probe with the given name as current probe if the named probe exists.
 
void SetSpacing (double xSpacing, double ySpacing) override
 Sets the given spacing of the current depth of the current probe.
 
 itkGetMacro (ImageVector, std::vector< mitk::Image::Pointer >)
 
 itkGetMacro (DeviceID, int)
 
 itkGetMacro (FilePath, std::string)
 
- Public Member Functions inherited from mitk::USDevice
 mitkClassMacro (USDevice, mitk::ImageSource)
 
 itkSetMacro (SpawnAcquireThread, bool)
 
 itkGetMacro (SpawnAcquireThread, bool)
 
 mitkNewMessage2Macro (PropertyChanged, const std::string &, const std::string &)
 Event for being notified about changes of the micro service properties. This event can be used if no micro service context is available.
 
virtual itk::SmartPointer< USControlInterfaceBModeGetControlInterfaceBMode ()
 Default getter for the b mode control interface. Has to be implemented in a subclass if a b mode control interface is available. Default implementation returns null.
 
virtual itk::SmartPointer< USControlInterfaceProbesGetControlInterfaceProbes ()
 Default getter for the probes control interface. Has to be implemented in a subclass if a probes control interface is available. Default implementation returns null.
 
virtual itk::SmartPointer< USControlInterfaceDopplerGetControlInterfaceDoppler ()
 Default getter for the doppler control interface. Has to be implemented in a subclass if a doppler control interface is available. Default implementation returns null.
 
bool Initialize ()
 Changes device state to mitk::USDevice::State_Initialized. During initialization the virtual method mitk::USDevice::OnInitialization will be called. If this method returns false the initialization process will be canceled. Otherwise the mitk::USDevice is registered in a micro service.
 
bool Connect ()
 Connects this device. A connected device is ready to deliver images (i.e. be Activated). A Connected Device can be active. A disconnected Device cannot be active. Internally calls onConnect and then registers the device with the service. A device usually should override the OnConnection() method, but never the Connect() method, since this will possibly exclude the device from normal service management. The exact flow of events is:

  1. Check if the device is already connected. If yes, return true anyway, but don't do anything.

 
void ConnectAsynchron ()
 
bool Disconnect ()
 Works analogously to mitk::USDevice::Connect(). Don't override this Method, but onDisconnection instead.
 
bool Activate ()
 Activates this device. After the activation process, the device will start to produce images. This Method will fail, if the device is not connected.
 
void Deactivate ()
 Deactivates this device. After the deactivation process, the device will no longer produce images, but still be connected.
 
virtual void SetIsFreezed (bool freeze)
 Can toggle if ultrasound image is currently updated or freezed.
 
virtual bool GetIsFreezed ()
 
void PushFilter (AbstractOpenCVImageFilter::Pointer filter)
 
void PushFilterIfNotPushedBefore (AbstractOpenCVImageFilter::Pointer filter)
 
bool RemoveFilter (AbstractOpenCVImageFilter::Pointer filter)
 
void ProbeChanged (std::string probename)
 To be called when the used probe changed. Will update the service properties.
 
void DepthChanged (double depth)
 To be called when the scanning depth of the probe changed. Will update the service properties.
 
void UpdateServiceProperty (std::string key, std::string value)
 Given property is updated in the device micro service. This method is mainly for being used by the control interface superclasses. You do not need to call it by yoursefs in your concrete control interface classes.
 
void UpdateServiceProperty (std::string key, double value)
 
void UpdateServiceProperty (std::string key, bool value)
 
bool GetIsInitialized ()
 True, if the device object is created and initialized, false otherwise.
 
bool GetIsActive ()
 True, if the device is currently generating image data, false otherwise.
 
bool GetIsConnected ()
 True, if the device is currently ready to start transmitting image data or is already transmitting image data. A disconnected device cannot be activated.
 
mitk::USDevice::USImageCropArea GetCropArea ()
 
unsigned int GetSizeOfImageVector ()
 
 DEPRECATED (std::string GetDeviceManufacturer())
 Deprecated -> use GetManufacturer() instead.
 
 DEPRECATED (std::string GetDeviceModel())
 Deprecated -> use GetName() instead.
 
 DEPRECATED (std::string GetDeviceComment())
 Deprecated -> use GetCommend() instead.
 
 itkGetMacro (Manufacturer, std::string)
 
 itkGetMacro (Name, std::string)
 
 itkGetMacro (Comment, std::string)
 
void SetManufacturer (std::string manufacturer)
 
void SetName (std::string name)
 
void SetComment (std::string comment)
 
 itkGetMacro (DeviceState, DeviceStates)
 
 itkGetMacro (ServiceProperties, us::ServiceProperties)
 
void GrabImage ()
 

Static Public Member Functions

static std::string GetDeviceClassStatic ()
 
- Static Public Member Functions inherited from mitk::USDevice
static mitk::USDevice::PropertyKeys GetPropertyKeys ()
 

Protected Member Functions

 USVideoDevice (int videoDeviceNumber, std::string manufacturer, std::string model)
 Creates a new device that will deliver USImages taken from a video device. under windows, try -1 for device number, which will grab the first available one (Open CV functionality)
 
 USVideoDevice (std::string videoFilePath, std::string manufacturer, std::string model)
 Creates a new device that will deliver USImages taken from a video file.
 
 USVideoDevice (int videoDeviceNumber, mitk::USImageMetadata::Pointer metadata)
 Creates a new device that will deliver USImages taken from a video device. under windows, try -1 for device number, which will grab the first available one (Open CV functionality)
 
 USVideoDevice (std::string videoFilePath, mitk::USImageMetadata::Pointer metadata)
 Creates a new device that will deliver USImages taken from a video file.
 
 ~USVideoDevice () override
 
void Init ()
 Initializes common properties for all constructors.
 
bool OnInitialization () override
 Is called during the initialization process. Returns true if successful and false if unsuccessful. Additionally, you may throw an exception to clarify what went wrong.
 
bool OnConnection () override
 Is called during the connection process. Returns true if successful and false if unsuccessful. Additionally, you may throw an exception to clarify what went wrong.
 
bool OnDisconnection () override
 Is called during the disconnection process. Returns true if successful and false if unsuccessful. Additionally, you may throw an exception to clarify what went wrong.
 
bool OnActivation () override
 Is called during the activation process. After this method is finsihed, the device should be generating images.
 
bool OnDeactivation () override
 Is called during the deactivation process. After a call to this method the device should still be connected, but not producing images anymore.
 
void GenerateData () override
 Grabs the next frame from the Video input. This method is called internally, whenever Update() is invoked by an Output.
 
- Protected Member Functions inherited from mitk::USDevice
virtual void SetImageVector (std::vector< mitk::Image::Pointer > vec)
 
void Acquire ()
 
void ConnectThread ()
 
void ProvideViaOIGTL ()
 Registers an OpenIGTLink device as a microservice so that we can send the images of this device via the network.
 
void DisableOIGTL ()
 Deregisters the microservices for OpenIGTLink.
 
us::ServiceProperties ConstructServiceProperties ()
 This Method constructs the service properties which can later be used to register the object with the Microservices Return service properties.
 
void UnregisterOnService ()
 Remove this device from the micro service.
 
virtual void OnFreeze (bool)
 Called when mitk::USDevice::SetIsFreezed() is called. Subclasses can overwrite this method to do additional actions. Default implementation does noting.
 
 USDevice (std::string manufacturer, std::string model)
 Enforces minimal Metadata to be set.
 
 USDevice (mitk::USImageMetadata::Pointer metadata)
 Constructs a device with the given Metadata. Make sure the Metadata contains meaningful content!
 
 ~USDevice () override
 
void GenerateData () override
 Grabs the next frame from the Video input. This method is called internally, whenever Update() is invoked by an Output.
 
std::string GetServicePropertyLabel ()
 

Protected Attributes

mitk::USImageVideoSource::Pointer m_Source
 The image source that we use to aquire data.
 
bool m_SourceIsFile
 True, if this source plays back a file, false if it recieves data from a device.
 
int m_DeviceID
 The device id to connect to. Undefined, if m_SourceIsFile == true;.
 
std::string m_FilePath
 The Filepath id to connect to. Undefined, if m_SourceIsFile == false;.
 
itk::SmartPointer< USVideoDeviceCustomControlsm_ControlInterfaceCustom
 custom control interface for us video device
 
std::vector< mitk::USProbe::Pointer > m_Probes
 probes for this USVideoDevice
 
mitk::USProbe::Pointer m_CurrentProbe
 probe that is currently in use
 
- Protected Attributes inherited from mitk::USDevice
std::condition_variable m_FreezeBarrier
 
std::mutex m_FreezeMutex
 
std::mutex m_ImageMutex
 mutex for images provided by the image source
 
std::thread m_Thread
 
std::vector< mitk::Image::Pointer > m_ImageVector
 
mitk::Vector3D m_Spacing
 
mitk::IGTLServer::Pointer m_IGTLServer
 
mitk::IGTLMessageProvider::Pointer m_IGTLMessageProvider
 
mitk::ImageToIGTLMessageFilter::Pointer m_ImageToIGTLMsgFilter
 
bool m_IsFreezed
 
DeviceStates m_DeviceState
 
USImageCropArea m_CropArea
 
unsigned int m_NumberOfOutputs
 
us::ServiceProperties m_ServiceProperties
 Properties of the device's Microservice.
 
us::ServiceRegistration< Self > m_ServiceRegistration
 The device's ServiceRegistration object that allows to modify it's Microservice registraton details.
 

Additional Inherited Members

- Public Types inherited from mitk::USDevice
enum  DeviceStates { State_NoState , State_Initialized , State_Connected , State_Activated }
 

Detailed Description

A mitk::USVideoDevice is the common class for video only devices. They capture video input either from a file or from a device and transform the output into an mitk::USImage with attached metadata. This simple implementation does only capture and display 2d images without registration for example.

Definition at line 40 of file mitkUSVideoDevice.h.

Constructor & Destructor Documentation

◆ USVideoDevice() [1/4]

mitk::USVideoDevice::USVideoDevice ( int videoDeviceNumber,
std::string manufacturer,
std::string model )
protected

Creates a new device that will deliver USImages taken from a video device. under windows, try -1 for device number, which will grab the first available one (Open CV functionality)

Definition at line 16 of file mitkUSVideoDevice.cpp.

◆ USVideoDevice() [2/4]

mitk::USVideoDevice::USVideoDevice ( std::string videoFilePath,
std::string manufacturer,
std::string model )
protected

Creates a new device that will deliver USImages taken from a video file.

Definition at line 24 of file mitkUSVideoDevice.cpp.

◆ USVideoDevice() [3/4]

mitk::USVideoDevice::USVideoDevice ( int videoDeviceNumber,
mitk::USImageMetadata::Pointer metadata )
protected

Creates a new device that will deliver USImages taken from a video device. under windows, try -1 for device number, which will grab the first available one (Open CV functionality)

Definition at line 31 of file mitkUSVideoDevice.cpp.

◆ USVideoDevice() [4/4]

mitk::USVideoDevice::USVideoDevice ( std::string videoFilePath,
mitk::USImageMetadata::Pointer metadata )
protected

Creates a new device that will deliver USImages taken from a video file.

Definition at line 39 of file mitkUSVideoDevice.cpp.

◆ ~USVideoDevice()

mitk::USVideoDevice::~USVideoDevice ( )
overrideprotected

Definition at line 46 of file mitkUSVideoDevice.cpp.

Member Function Documentation

◆ AddNewProbe()

void mitk::USVideoDevice::AddNewProbe ( mitk::USProbe::Pointer probe)
overridevirtual

adds a new probe to the device

Reimplemented from mitk::USDevice.

Definition at line 208 of file mitkUSVideoDevice.cpp.

◆ DeleteAllProbes()

void mitk::USVideoDevice::DeleteAllProbes ( )
overridevirtual

Cleans the std::vector containing all configured probes.

Reimplemented from mitk::USDevice.

Definition at line 167 of file mitkUSVideoDevice.cpp.

◆ GenerateData()

void mitk::USVideoDevice::GenerateData ( )
overrideprotected

Grabs the next frame from the Video input. This method is called internally, whenever Update() is invoked by an Output.

Definition at line 125 of file mitkUSVideoDevice.cpp.

◆ GetAllProbes()

std::vector< mitk::USProbe::Pointer > mitk::USVideoDevice::GetAllProbes ( )
overridevirtual

Return all probes for this USVideoDevice or an empty vector it no probes were set Returns a std::vector of all probes that exist for this USVideoDevice if there were probes set while creating or modifying this USVideoDevice. Otherwise it returns an empty vector. Therefore always check if vector is filled, before using it!

Implements mitk::USDevice.

Definition at line 158 of file mitkUSVideoDevice.cpp.

◆ GetControlInterfaceCustom()

mitk::USAbstractControlInterface::Pointer mitk::USVideoDevice::GetControlInterfaceCustom ( )
overridevirtual

Getter for the custom control interface which was created during the construction process of mitk::USVideoDevice.

Returns
custom control interface of the video device

Reimplemented from mitk::USDevice.

Definition at line 74 of file mitkUSVideoDevice.cpp.

◆ GetCurrentProbe()

mitk::USProbe::Pointer mitk::USVideoDevice::GetCurrentProbe ( )
overridevirtual

Return current active probe for this USVideoDevice Returns a pointer to the probe that is currently in use. If there were probes set while creating or modifying this USVideoDevice. Returns null otherwise.

Implements mitk::USDevice.

Definition at line 172 of file mitkUSVideoDevice.cpp.

◆ GetDeviceClass()

std::string mitk::USVideoDevice::GetDeviceClass ( )
overridevirtual
Returns
the qualified name of this class (as returned by GetDeviceClassStatic())

Implements mitk::USDevice.

Definition at line 64 of file mitkUSVideoDevice.cpp.

◆ GetDeviceClassStatic()

std::string mitk::USVideoDevice::GetDeviceClassStatic ( )
static

This methode is necessary instead of a static member attribute to avoid "static initialization order fiasco" when an instance of this class is used in a module activator.

Returns
the qualified name of this class

Definition at line 69 of file mitkUSVideoDevice.cpp.

◆ GetIsSourceFile()

bool mitk::USVideoDevice::GetIsSourceFile ( )

True, if this Device plays back a file, false if it recieves data from a device.

Definition at line 213 of file mitkUSVideoDevice.cpp.

◆ GetProbeByName()

mitk::USProbe::Pointer mitk::USVideoDevice::GetProbeByName ( std::string name)
overridevirtual

get the probe by its name Returns a pointer to the probe identified by the given name. If no probe of given name exists for this Device 0 is returned.

Implements mitk::USDevice.

Definition at line 184 of file mitkUSVideoDevice.cpp.

◆ GetUSImageSource()

mitk::USImageSource::Pointer mitk::USVideoDevice::GetUSImageSource ( )
overridevirtual
Returns
mitk::USImageSource connected to this device

Implements mitk::USDevice.

Definition at line 153 of file mitkUSVideoDevice.cpp.

◆ Init()

void mitk::USVideoDevice::Init ( )
protected

Initializes common properties for all constructors.

Definition at line 52 of file mitkUSVideoDevice.cpp.

◆ itkGetMacro() [1/3]

mitk::USVideoDevice::itkGetMacro ( DeviceID ,
int  )

◆ itkGetMacro() [2/3]

mitk::USVideoDevice::itkGetMacro ( FilePath ,
std::string  )

◆ itkGetMacro() [3/3]

mitk::USVideoDevice::itkGetMacro ( ImageVector ,
std::vector< mitk::Image::Pointer >  )

◆ mitkClassMacro()

mitk::USVideoDevice::mitkClassMacro ( USVideoDevice ,
mitk::USDevice  )

◆ mitkNewMacro2Param() [1/2]

mitk::USVideoDevice::mitkNewMacro2Param ( Self ,
int ,
mitk::USImageMetadata::Pointer  )

◆ mitkNewMacro2Param() [2/2]

mitk::USVideoDevice::mitkNewMacro2Param ( Self ,
std::string ,
mitk::USImageMetadata::Pointer  )

◆ mitkNewMacro3Param() [1/2]

mitk::USVideoDevice::mitkNewMacro3Param ( Self ,
int ,
std::string ,
std::string  )

◆ mitkNewMacro3Param() [2/2]

mitk::USVideoDevice::mitkNewMacro3Param ( Self ,
std::string ,
std::string ,
std::string  )

◆ OnActivation()

bool mitk::USVideoDevice::OnActivation ( )
overrideprotectedvirtual

Is called during the activation process. After this method is finsihed, the device should be generating images.

Implements mitk::USDevice.

Definition at line 106 of file mitkUSVideoDevice.cpp.

◆ OnConnection()

bool mitk::USVideoDevice::OnConnection ( )
overrideprotectedvirtual

Is called during the connection process. Returns true if successful and false if unsuccessful. Additionally, you may throw an exception to clarify what went wrong.

Implements mitk::USDevice.

Definition at line 85 of file mitkUSVideoDevice.cpp.

◆ OnDeactivation()

bool mitk::USVideoDevice::OnDeactivation ( )
overrideprotectedvirtual

Is called during the deactivation process. After a call to this method the device should still be connected, but not producing images anymore.

Implements mitk::USDevice.

Definition at line 119 of file mitkUSVideoDevice.cpp.

◆ OnDisconnection()

bool mitk::USVideoDevice::OnDisconnection ( )
overrideprotectedvirtual

Is called during the disconnection process. Returns true if successful and false if unsuccessful. Additionally, you may throw an exception to clarify what went wrong.

Implements mitk::USDevice.

Definition at line 97 of file mitkUSVideoDevice.cpp.

◆ OnInitialization()

bool mitk::USVideoDevice::OnInitialization ( )
overrideprotectedvirtual

Is called during the initialization process. Returns true if successful and false if unsuccessful. Additionally, you may throw an exception to clarify what went wrong.

Implements mitk::USDevice.

Definition at line 79 of file mitkUSVideoDevice.cpp.

◆ RemoveProbeByName()

void mitk::USVideoDevice::RemoveProbeByName ( std::string name)
overridevirtual

Removes the Probe with the given name.

Reimplemented from mitk::USDevice.

Definition at line 195 of file mitkUSVideoDevice.cpp.

◆ SetCurrentProbe()

void mitk::USVideoDevice::SetCurrentProbe ( std::string probename)
overridevirtual

Sets the probe with the given name as current probe if the named probe exists.

Reimplemented from mitk::USDevice.

Definition at line 232 of file mitkUSVideoDevice.cpp.

◆ SetDefaultProbeAsCurrentProbe()

void mitk::USVideoDevice::SetDefaultProbeAsCurrentProbe ( )
overridevirtual

Sets the first existing probe or the default probe of the video device as the current probe of it.

Reimplemented from mitk::USDevice.

Definition at line 218 of file mitkUSVideoDevice.cpp.

◆ SetSpacing()

void mitk::USVideoDevice::SetSpacing ( double xSpacing,
double ySpacing )
overridevirtual

Sets the given spacing of the current depth of the current probe.

Reimplemented from mitk::USDevice.

Definition at line 238 of file mitkUSVideoDevice.cpp.

◆ UnregisterOnService()

void mitk::USVideoDevice::UnregisterOnService ( )

Remove this device from the micro service. This method is public for mitk::USVideoDevice, because this devices can be completly removed. This is not possible for API devices, which should be available while their sub module is loaded.

Definition at line 145 of file mitkUSVideoDevice.cpp.

Member Data Documentation

◆ m_ControlInterfaceCustom

itk::SmartPointer<USVideoDeviceCustomControls> mitk::USVideoDevice::m_ControlInterfaceCustom
protected

custom control interface for us video device

Definition at line 234 of file mitkUSVideoDevice.h.

◆ m_CurrentProbe

mitk::USProbe::Pointer mitk::USVideoDevice::m_CurrentProbe
protected

probe that is currently in use

Definition at line 244 of file mitkUSVideoDevice.h.

◆ m_DeviceID

int mitk::USVideoDevice::m_DeviceID
protected

The device id to connect to. Undefined, if m_SourceIsFile == true;.

Definition at line 224 of file mitkUSVideoDevice.h.

◆ m_FilePath

std::string mitk::USVideoDevice::m_FilePath
protected

The Filepath id to connect to. Undefined, if m_SourceIsFile == false;.

Definition at line 229 of file mitkUSVideoDevice.h.

◆ m_Probes

std::vector< mitk::USProbe::Pointer > mitk::USVideoDevice::m_Probes
protected

probes for this USVideoDevice

Definition at line 239 of file mitkUSVideoDevice.h.

◆ m_Source

mitk::USImageVideoSource::Pointer mitk::USVideoDevice::m_Source
protected

The image source that we use to aquire data.

Definition at line 214 of file mitkUSVideoDevice.h.

◆ m_SourceIsFile

bool mitk::USVideoDevice::m_SourceIsFile
protected

True, if this source plays back a file, false if it recieves data from a device.

Definition at line 219 of file mitkUSVideoDevice.h.


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