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

Interface for all representations of Microsoft Kinect V2 devices. Kinect2Device internally holds an instance of Kinect2Controller and starts a thread that continuously grabs images from the controller. A buffer structure buffers the last acquired images to provide the image data loss-less. More...

#include <mitkKinectV2Device.h>

Inheritance diagram for mitk::KinectV2Device:
mitk::ToFCameraDevice

Public Member Functions

 mitkClassMacro (KinectV2Device, ToFCameraDevice)
 
 itkFactorylessNewMacro (Self)
 
 itkCloneMacro (Self) itkSetMacro(PrintFrameRate
 
virtual bool OnConnectCamera ()
 opens a connection to the ToF camera
 
virtual bool DisconnectCamera ()
 closes the connection to the camera
 
virtual void StartCamera ()
 starts the continuous updating of the camera. A separate thread updates the source data, the main thread processes the source data and creates images and coordinates
 
virtual void StopCamera ()
 stops the continuous updating of the camera
 
virtual void UpdateCamera ()
 updates the camera for image acquisition
 
virtual bool IsCameraActive ()
 returns whether the camera is currently active or not
 
virtual void GetAmplitudes (float *amplitudeArray, int &imageSequence)
 gets the amplitude data from the ToF camera as the strength of the active illumination of every pixel. Caution! The user is responsible for allocating and deleting the images. These values can be used to determine the quality of the distance values. The higher the amplitude value, the higher the accuracy of the according distance value
 
virtual void GetIntensities (float *intensityArray, int &imageSequence)
 Does nothing for Kinect V2 as there is no intensity data provided by the device.
 
virtual void GetDistances (float *distanceArray, int &imageSequence)
 gets the distance data from the ToF camera measuring the distance between the camera and the different object points in millimeters. Caution! The user is responsible for allocating and deleting the images.
 
virtual void GetAllImages (float *distanceArray, float *amplitudeArray, float *intensityArray, char *sourceDataArray, int requiredImageSequence, int &capturedImageSequence, unsigned char *rgbDataArray=nullptr)
 gets the 3 images (distance, amplitude, intensity) from the ToF camera. Caution! The user is responsible for allocating and deleting the images.
 
KinectV2Controller::Pointer GetController ()
 returns the corresponding camera controller
 
int GetRGBCaptureWidth ()
 returns the width of the RGB image
 
int GetRGBCaptureHeight ()
 returns the height of the RGB image
 
- Public Member Functions inherited from mitk::ToFCameraDevice
 mitkClassMacroItkParent (ToFCameraDevice, itk::Object)
 
virtual bool ConnectCamera ()
 ConnectCamera Internally calls OnConnectCamera() of the respective device implementation.
 
virtual bool IsCameraConnected ()
 returns true if the camera is connected
 
 itkGetMacro (CaptureWidth, int)
 get the currently set capture width
 
 itkGetMacro (CaptureHeight, int)
 get the currently set capture height
 
 itkGetMacro (SourceDataSize, int)
 get the currently set source data size
 
 itkGetMacro (BufferSize, int)
 get the currently set buffer size
 
 itkGetMacro (MaxBufferSize, int)
 get the currently set max buffer size
 
void SetBoolProperty (const char *propertyKey, bool boolValue)
 set a bool property in the property list
 
void SetIntProperty (const char *propertyKey, int intValue)
 set an int property in the property list
 
void SetFloatProperty (const char *propertyKey, float floatValue)
 set a float property in the property list
 
void SetStringProperty (const char *propertyKey, const char *stringValue)
 set a string property in the property list
 
virtual void SetProperty (const char *propertyKey, BaseProperty *propertyValue)
 set a BaseProperty property in the property list
 
virtual BaseProperty * GetProperty (const char *propertyKey)
 get a BaseProperty from the property list
 
bool GetBoolProperty (const char *propertyKey, bool &boolValue)
 get a bool from the property list
 
bool GetStringProperty (const char *propertyKey, std::string &string)
 get a string from the property list
 
bool GetIntProperty (const char *propertyKey, int &integer)
 get an int from the property list
 

Public Attributes

 bool
 

Protected Member Functions

 KinectV2Device ()
 
 ~KinectV2Device ()
 
- Protected Member Functions inherited from mitk::ToFCameraDevice
 ToFCameraDevice ()
 
 ~ToFCameraDevice () override
 
virtual void AllocatePixelArrays ()
 method for allocating memory for pixel arrays m_IntensityArray, m_DistanceArray and m_AmplitudeArray
 
virtual void CleanupPixelArrays ()
 method for cleanup memory allocated for pixel arrays m_IntensityArray, m_DistanceArray and m_AmplitudeArray
 

Static Protected Member Functions

static ITK_THREAD_RETURN_TYPE Acquire (void *pInfoStruct)
 Thread method continuously acquiring images from the ToF hardware.
 

Protected Attributes

KinectV2Controller::Pointer m_Controller
 corresponding CameraController
 
float ** m_DistanceDataBuffer
 buffer holding the last distance images
 
float ** m_AmplitudeDataBuffer
 buffer holding the last amplitude images
 
unsigned char ** m_RGBDataBuffer
 buffer holding the last RGB image
 
size_t m_DepthBufferSize
 Size of depth buffer (i.e. memory size of depth and infrared image)
 
size_t m_RGBBufferSize
 Size of RGB buffer (i.e. memory size of RGB image)
 
vtkSmartPointer< vtkPolyData > m_PolyData
 Surface generated via the Kinect V2 SDK with default/unknown calibration.
 
- Protected Attributes inherited from mitk::ToFCameraDevice
float * m_IntensityArray
 float array holding the intensity image
 
float * m_DistanceArray
 float array holding the distance image
 
float * m_AmplitudeArray
 float array holding the amplitude image
 
int m_BufferSize
 buffer size of the image buffer needed for loss-less acquisition of range data
 
int m_MaxBufferSize
 maximal buffer size needed for initialization of data arrays. Default value is 100.
 
int m_CurrentPos
 current position in the buffer which will be retrieved by the Get methods
 
int m_FreePos
 current position in the buffer which will be filled with data acquired from the hardware
 
int m_CaptureWidth
 width of the range image (x dimension)
 
int m_CaptureHeight
 height of the range image (y dimension)
 
int m_PixelNumber
 number of pixels in the range image (m_CaptureWidth*m_CaptureHeight)
 
int m_RGBImageWidth
 width of the RGB image (x dimension)
 
int m_RGBImageHeight
 height of the RGB image (y dimension)
 
int m_RGBPixelNumber
 number of pixels in the range image (m_RGBImageWidth*m_RGBImageHeight)
 
int m_SourceDataSize
 size of the PMD source data
 
std::mutex m_ImageMutex
 mutex for images provided by the range camera
 
std::mutex m_CameraActiveMutex
 mutex for the cameraActive flag
 
std::thread m_Thread
 
bool m_CameraActive
 flag indicating if the camera is currently active or not. Caution: thread safe access only!
 
bool m_CameraConnected
 flag indicating if the camera is successfully connected or not. Caution: thread safe access only!
 
int m_ImageSequence
 counter for acquired images
 
PropertyList::Pointer m_PropertyList
 a list of the corresponding properties
 

Static Protected Attributes

static bool m_PrintFrameRate = false
 prints the framerate to the console every 100 frames, deactivated by default
 

Detailed Description

Interface for all representations of Microsoft Kinect V2 devices. Kinect2Device internally holds an instance of Kinect2Controller and starts a thread that continuously grabs images from the controller. A buffer structure buffers the last acquired images to provide the image data loss-less.

Exceptions
mitkExceptionIn case of no connection, an exception is thrown!

Definition at line 41 of file mitkKinectV2Device.h.

Constructor & Destructor Documentation

◆ KinectV2Device()

mitk::KinectV2Device::KinectV2Device ( )
protected

Definition at line 27 of file mitkKinectV2Device.cpp.

◆ ~KinectV2Device()

mitk::KinectV2Device::~KinectV2Device ( )
protected

Definition at line 38 of file mitkKinectV2Device.cpp.

Member Function Documentation

◆ Acquire()

ITK_THREAD_RETURN_TYPE mitk::KinectV2Device::Acquire ( void * pInfoStruct)
staticprotected

Thread method continuously acquiring images from the ToF hardware.

Definition at line 176 of file mitkKinectV2Device.cpp.

◆ DisconnectCamera()

bool mitk::KinectV2Device::DisconnectCamera ( )
virtual

closes the connection to the camera

Implements mitk::ToFCameraDevice.

Definition at line 91 of file mitkKinectV2Device.cpp.

◆ GetAllImages()

void mitk::KinectV2Device::GetAllImages ( float * distanceArray,
float * amplitudeArray,
float * intensityArray,
char * sourceDataArray,
int requiredImageSequence,
int & capturedImageSequence,
unsigned char * rgbDataArray = nullptr )
virtual

gets the 3 images (distance, amplitude, intensity) from the ToF camera. Caution! The user is responsible for allocating and deleting the images.

Parameters
distanceArrayContains the distance data as an array.
amplitudeArrayContains the infrared image.
intensityArrayDoes nothing for Kinect V2.
sourceDataArrayDoes nothing for Kinect V2.
requiredImageSequenceThe required image sequence number.
capturedImageSequenceDoes nothing for Kinect V2.
rgbDataArray

Implements mitk::ToFCameraDevice.

Definition at line 288 of file mitkKinectV2Device.cpp.

◆ GetAmplitudes()

void mitk::KinectV2Device::GetAmplitudes ( float * amplitudeArray,
int & imageSequence )
virtual

gets the amplitude data from the ToF camera as the strength of the active illumination of every pixel. Caution! The user is responsible for allocating and deleting the images. These values can be used to determine the quality of the distance values. The higher the amplitude value, the higher the accuracy of the according distance value

Parameters
imageSequencethe actually captured image sequence number
amplitudeArraycontains the returned amplitude data as an array.

Implements mitk::ToFCameraDevice.

Definition at line 254 of file mitkKinectV2Device.cpp.

◆ GetController()

KinectV2Controller::Pointer mitk::KinectV2Device::GetController ( )

returns the corresponding camera controller

Definition at line 339 of file mitkKinectV2Device.cpp.

◆ GetDistances()

void mitk::KinectV2Device::GetDistances ( float * distanceArray,
int & imageSequence )
virtual

gets the distance data from the ToF camera measuring the distance between the camera and the different object points in millimeters. Caution! The user is responsible for allocating and deleting the images.

Parameters
distanceArraycontains the returned distances data as an array.
imageSequencethe actually captured image sequence number

Implements mitk::ToFCameraDevice.

Definition at line 273 of file mitkKinectV2Device.cpp.

◆ GetIntensities()

void mitk::KinectV2Device::GetIntensities ( float * intensityArray,
int & imageSequence )
virtual

Does nothing for Kinect V2 as there is no intensity data provided by the device.

The method is an empty implementation, because the interface (ToFCameraDevice) requires it.

Implements mitk::ToFCameraDevice.

Definition at line 269 of file mitkKinectV2Device.cpp.

◆ GetRGBCaptureHeight()

int mitk::KinectV2Device::GetRGBCaptureHeight ( )
virtual

returns the height of the RGB image

Reimplemented from mitk::ToFCameraDevice.

Definition at line 349 of file mitkKinectV2Device.cpp.

◆ GetRGBCaptureWidth()

int mitk::KinectV2Device::GetRGBCaptureWidth ( )
virtual

returns the width of the RGB image

Reimplemented from mitk::ToFCameraDevice.

Definition at line 344 of file mitkKinectV2Device.cpp.

◆ IsCameraActive()

bool mitk::KinectV2Device::IsCameraActive ( )
virtual

returns whether the camera is currently active or not

Reimplemented from mitk::ToFCameraDevice.

Definition at line 160 of file mitkKinectV2Device.cpp.

◆ itkCloneMacro()

mitk::KinectV2Device::itkCloneMacro ( Self )

Prints the framerate to the console every 100 frames. Mainly for debugging, deactivated by default. Refers to a static variable, means it is acivated/deactivated for all instances.

◆ itkFactorylessNewMacro()

mitk::KinectV2Device::itkFactorylessNewMacro ( Self )

◆ mitkClassMacro()

mitk::KinectV2Device::mitkClassMacro ( KinectV2Device ,
ToFCameraDevice  )

◆ OnConnectCamera()

bool mitk::KinectV2Device::OnConnectCamera ( )
virtual

opens a connection to the ToF camera

Exceptions
mitkExceptionIn case of no connection, an exception is thrown!

Implements mitk::ToFCameraDevice.

Definition at line 47 of file mitkKinectV2Device.cpp.

◆ StartCamera()

void mitk::KinectV2Device::StartCamera ( )
virtual

starts the continuous updating of the camera. A separate thread updates the source data, the main thread processes the source data and creates images and coordinates

Exceptions
mitkExceptionIn case of no connection, an exception is thrown!

Implements mitk::ToFCameraDevice.

Definition at line 120 of file mitkKinectV2Device.cpp.

◆ StopCamera()

void mitk::KinectV2Device::StopCamera ( )
virtual

stops the continuous updating of the camera

Reimplemented from mitk::ToFCameraDevice.

Definition at line 146 of file mitkKinectV2Device.cpp.

◆ UpdateCamera()

void mitk::KinectV2Device::UpdateCamera ( )
virtual

updates the camera for image acquisition

Exceptions
mitkExceptionIn case of no connection, an exception is thrown!

Implements mitk::ToFCameraDevice.

Definition at line 168 of file mitkKinectV2Device.cpp.

Member Data Documentation

◆ bool

mitk::KinectV2Device::bool

Definition at line 53 of file mitkKinectV2Device.h.

◆ m_AmplitudeDataBuffer

float** mitk::KinectV2Device::m_AmplitudeDataBuffer
protected

buffer holding the last amplitude images

Definition at line 143 of file mitkKinectV2Device.h.

◆ m_Controller

KinectV2Controller::Pointer mitk::KinectV2Device::m_Controller
protected

corresponding CameraController

Definition at line 140 of file mitkKinectV2Device.h.

◆ m_DepthBufferSize

size_t mitk::KinectV2Device::m_DepthBufferSize
protected

Size of depth buffer (i.e. memory size of depth and infrared image)

Definition at line 148 of file mitkKinectV2Device.h.

◆ m_DistanceDataBuffer

float** mitk::KinectV2Device::m_DistanceDataBuffer
protected

buffer holding the last distance images

Definition at line 142 of file mitkKinectV2Device.h.

◆ m_PolyData

vtkSmartPointer<vtkPolyData> mitk::KinectV2Device::m_PolyData
protected

Surface generated via the Kinect V2 SDK with default/unknown calibration.

Definition at line 151 of file mitkKinectV2Device.h.

◆ m_PrintFrameRate

bool mitk::KinectV2Device::m_PrintFrameRate = false
staticprotected

prints the framerate to the console every 100 frames, deactivated by default

Definition at line 138 of file mitkKinectV2Device.h.

◆ m_RGBBufferSize

size_t mitk::KinectV2Device::m_RGBBufferSize
protected

Size of RGB buffer (i.e. memory size of RGB image)

Definition at line 149 of file mitkKinectV2Device.h.

◆ m_RGBDataBuffer

unsigned char** mitk::KinectV2Device::m_RGBDataBuffer
protected

buffer holding the last RGB image

Definition at line 144 of file mitkKinectV2Device.h.


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