diff --git a/Modules/ToFHardware/Kinect/mitkKinectController.h b/Modules/ToFHardware/Kinect/mitkKinectController.h index f565dbbb84..e9ebaea2c6 100644 --- a/Modules/ToFHardware/Kinect/mitkKinectController.h +++ b/Modules/ToFHardware/Kinect/mitkKinectController.h @@ -1,94 +1,94 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkKinectController_h #define __mitkKinectController_h -#include +#include #include "mitkCommon.h" #include "mitkToFConfig.h" #include "itkObject.h" #include "itkObjectFactory.h" namespace mitk { /** * @brief Interface to the Kinect camera * * * @ingroup ToFHardware */ class MITK_KINECTMODULE_EXPORT KinectController : public itk::Object { public: mitkClassMacro( KinectController , itk::Object ); itkFactorylessNewMacro(Self) itkCloneMacro(Self) unsigned int GetCaptureWidth() const; unsigned int GetCaptureHeight() const; bool GetUseIR() const; void SetUseIR(bool useIR); /*! \brief opens a connection to the Kinect camera. \throws mitkException In case of no connection, an exception is thrown! */ virtual bool OpenCameraConnection(); /*! \brief closes the connection to the camera */ virtual bool CloseCameraConnection(); /*! \brief updates the camera. The update function of the hardware interface is called only when new data is available \throws mitkException In case of no connection, an exception is thrown! */ virtual bool UpdateCamera(); /*! \brief acquire new distance data from the Kinect camera \param distances pointer to memory location where distances should be stored */ void GetDistances(float* distances); void GetAmplitudes(float* amplitudes); void GetIntensities(float* intensities); /*! \brief acquire new rgb data from the Kinect camera \param rgb pointer to memory location where rgb information should be stored */ void GetRgb(unsigned char* rgb); /*! \brief convenience method for faster access to distance and rgb data \param distances pointer to memory location where distances should be stored \param rgb pointer to memory location where rgb information should be stored */ void GetAllData(float* distances, float* amplitudes, unsigned char* rgb); protected: KinectController(); ~KinectController(); private: class KinectControllerPrivate; KinectControllerPrivate *d; }; } //END mitk namespace #endif diff --git a/Modules/ToFHardware/Kinect/mitkKinectDevice.h b/Modules/ToFHardware/Kinect/mitkKinectDevice.h index 9bb272a2eb..1f2d06c7d5 100644 --- a/Modules/ToFHardware/Kinect/mitkKinectDevice.h +++ b/Modules/ToFHardware/Kinect/mitkKinectDevice.h @@ -1,148 +1,148 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkKinectDevice_h #define __mitkKinectDevice_h -#include +#include #include "mitkCommon.h" #include "mitkToFCameraDevice.h" #include "mitkKinectController.h" #include "itkObject.h" #include "itkObjectFactory.h" #include "itkMultiThreader.h" #include "itkFastMutexLock.h" namespace mitk { /** * @brief Interface for all representations of Kinect devices. * KinectDevice internally holds an instance of KinectController 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. * * \throws mitkException In case of no connection, an exception is thrown! * * @ingroup ToFHardware */ class MITK_KINECTMODULE_EXPORT KinectDevice : public ToFCameraDevice { public: mitkClassMacro( KinectDevice , ToFCameraDevice ); itkFactorylessNewMacro(Self) itkCloneMacro(Self) /*! \brief opens a connection to the ToF camera \throws mitkException In case of no connection, an exception is thrown! */ virtual bool OnConnectCamera(); /*! \brief closes the connection to the camera */ virtual bool DisconnectCamera(); /*! \brief 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 \throws mitkException In case of no connection, an exception is thrown! */ virtual void StartCamera(); /*! \brief stops the continuous updating of the camera */ virtual void StopCamera(); /*! \brief updates the camera for image acquisition \throws mitkException In case of no connection, an exception is thrown! */ virtual void UpdateCamera(); /*! \brief returns whether the camera is currently active or not */ virtual bool IsCameraActive(); /*! \brief 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 \param imageSequence the actually captured image sequence number \param amplitudeArray contains the returned amplitude data as an array. */ virtual void GetAmplitudes(float* amplitudeArray, int& imageSequence); /*! \brief gets the intensity data from the ToF camera as a greyscale image. Caution! The user is responsible for allocating and deleting the images. \param intensityArray contains the returned intensities data as an array. \param imageSequence the actually captured image sequence number */ virtual void GetIntensities(float* intensityArray, int& imageSequence); /*! \brief 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. \param distanceArray contains the returned distances data as an array. \param imageSequence the actually captured image sequence number */ virtual void GetDistances(float* distanceArray, int& imageSequence); /*! \brief gets the 3 images (distance, amplitude, intensity) from the ToF camera. Caution! The user is responsible for allocating and deleting the images. \param distanceArray contains the returned distance data as an array. \param amplitudeArray contains the returned amplitude data as an array. \param capturedImageSequence the actually captured image sequence number. */ virtual void GetAllImages(float* distanceArray, float* amplitudeArray, float* intensityArray, char* sourceDataArray, int requiredImageSequence, int& capturedImageSequence, unsigned char* rgbDataArray=NULL); /*! \brief returns the corresponding camera controller */ KinectController::Pointer GetController(); /*! \brief set a BaseProperty */ virtual void SetProperty( const char *propertyKey, BaseProperty* propertyValue ); /*! \brief returns the width of the RGB image */ int GetRGBCaptureWidth(); /*! \brief returns the height of the RGB image */ int GetRGBCaptureHeight(); protected: KinectDevice(); ~KinectDevice(); /*! \brief Thread method continuously acquiring images from the ToF hardware */ static ITK_THREAD_RETURN_TYPE Acquire(void* pInfoStruct); /*! \brief moves the position pointer m_CurrentPos to the next position in the buffer if that's not the next free position to prevent reading from an empty buffer */ void GetNextPos(); KinectController::Pointer m_Controller; ///< corresponding CameraController float** m_DistanceDataBuffer; ///< buffer holding the last distance images float** m_AmplitudeDataBuffer; ///< buffer holding the last infra-red (IR) images unsigned char** m_RGBDataBuffer; ///< buffer holding the last RGB image private: }; } //END mitk namespace #endif diff --git a/Modules/ToFHardware/Kinect/mitkKinectDeviceFactory.h b/Modules/ToFHardware/Kinect/mitkKinectDeviceFactory.h index dae46597e9..4569551d5f 100644 --- a/Modules/ToFHardware/Kinect/mitkKinectDeviceFactory.h +++ b/Modules/ToFHardware/Kinect/mitkKinectDeviceFactory.h @@ -1,99 +1,99 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkKinectDeviceFactory_h #define __mitkKinectDeviceFactory_h -#include +#include #include "mitkKinectDevice.h" #include "mitkAbstractToFDeviceFactory.h" #include #include // Microservices #include #include #include #include #include #include namespace mitk { /** * \brief KinectDeviceFactory is an implementation of the factory pattern to generate Microsoft Kinect devices. * KinectDeviceFactory inherits from AbstractToFDeviceFactory which is a MicroService interface. * This offers users the oppertunity to generate new KinectDevices via a global instance of this factory. * @ingroup ToFHardware */ class MITK_KINECTMODULE_EXPORT KinectDeviceFactory : public itk::LightObject, public AbstractToFDeviceFactory { public: /** * @brief KinectDeviceFactory Default contructor. * This factory internally counts all kinect devices starting at 1. */ KinectDeviceFactory() { } /*! \brief Get the name of the factory, here for the Kinect. */ std::string GetFactoryName() { return std::string("Kinect Factory"); } /** * @brief GetDeviceNamePrefix Main part of a device name. */ std::string GetDeviceNamePrefix() { return std::string("Kinect"); } private: /*! \brief Create an instance of a KinectDevice. */ ToFCameraDevice::Pointer CreateToFCameraDevice() { KinectDevice::Pointer device = KinectDevice::New(); device->SetBoolProperty("HasRGBImage", true); device->SetBoolProperty("HasAmplitudeImage", false); device->SetBoolProperty("HasIntensityImage", false); device->SetBoolProperty("KinectReconstructionMode", true); return device.GetPointer(); } /** * @brief GetIntrinsicsResource Get the resource of the * default camera intrinsics for a kinect. If you want to * use your own camera intrinsics, just overwrit the * CameraIntrinsicsProperty of your device. * @return A resource path to the camera .xml file. */ us::ModuleResource GetIntrinsicsResource() { us::Module* module = us::GetModuleContext()->GetModule(); return module->GetResource("CalibrationFiles/Kinect_RGB_camera.xml"); } }; } #endif diff --git a/Modules/ToFHardware/KinectV2/mitkKinectV2Controller.h b/Modules/ToFHardware/KinectV2/mitkKinectV2Controller.h index bf5d9f1b94..b37ea62a02 100644 --- a/Modules/ToFHardware/KinectV2/mitkKinectV2Controller.h +++ b/Modules/ToFHardware/KinectV2/mitkKinectV2Controller.h @@ -1,104 +1,104 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkKinectV2Controller_h #define __mitkKinectV2Controller_h -#include +#include #include #include "mitkToFConfig.h" #include #include #include #include namespace mitk { /** * @brief Interface to the Kinect 2 camera. Currently, the Microsoft SDK is used. * * @ingroup ToFHardware */ class MITK_KINECTV2MODULE_EXPORT KinectV2Controller : public itk::Object { public: mitkClassMacro( KinectV2Controller , itk::Object ); itkFactorylessNewMacro(Self) itkCloneMacro(Self) int GetRGBCaptureWidth() const; int GetRGBCaptureHeight() const; int GetDepthCaptureWidth() const; int GetDepthCaptureHeight() const; /** \brief Setup MultiFrameReader of Kinect V2. * This reader can acquire different types of data. Here it is used * to acquire depth, RGB and infrared images. */ bool InitializeMultiFrameReader(); /*! \brief opens a connection to the Kinect V2 camera. \throws mitkException In case of no connection, an exception is thrown! */ virtual bool OpenCameraConnection(); /*! \brief closes the connection to the camera */ virtual bool CloseCameraConnection(); /*! \brief updates the camera. The update function of the hardware interface is called only when new data is available \throws mitkException In case of no connection, an exception is thrown! */ virtual bool UpdateCamera(); /*! \brief acquire new distance data from the Kinect camera \param distances pointer to memory location where distances should be stored */ void GetDistances(float* distances); void GetAmplitudes(float* amplitudes); void GetIntensities(float* intensities); vtkSmartPointer GetVtkPolyData(); /*! \brief acquire new rgb data from the Kinect camera \param rgb pointer to memory location where rgb information should be stored */ void GetRgb(unsigned char* rgb); /*! \brief convenience method for faster access to distance and rgb data \param distances pointer to memory location where distances should be stored \param rgb pointer to memory location where rgb information should be stored */ void GetAllData(float* distances, float* amplitudes, unsigned char* rgb); protected: KinectV2Controller(); ~KinectV2Controller(); private: class KinectV2ControllerPrivate; KinectV2ControllerPrivate *d; }; } //END mitk namespace #endif diff --git a/Modules/ToFHardware/KinectV2/mitkKinectV2Device.h b/Modules/ToFHardware/KinectV2/mitkKinectV2Device.h index 86baca8844..bea50d4c25 100644 --- a/Modules/ToFHardware/KinectV2/mitkKinectV2Device.h +++ b/Modules/ToFHardware/KinectV2/mitkKinectV2Device.h @@ -1,148 +1,148 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkKinectV2Device_h #define __mitkKinectV2Device_h #include -#include +#include #include "mitkToFCameraDevice.h" #include "mitkKinectV2Controller.h" #include #include #include #include #include #include namespace mitk { /** * @brief 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. * * \throws mitkException In case of no connection, an exception is thrown! * * @ingroup ToFHardware */ class MITK_KINECTV2MODULE_EXPORT KinectV2Device : public ToFCameraDevice { public: mitkClassMacro( KinectV2Device , ToFCameraDevice ); itkFactorylessNewMacro(Self) itkCloneMacro(Self) /*! \brief opens a connection to the ToF camera \throws mitkException In case of no connection, an exception is thrown! */ virtual bool OnConnectCamera(); /*! \brief closes the connection to the camera */ virtual bool DisconnectCamera(); /*! \brief 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 \throws mitkException In case of no connection, an exception is thrown! */ virtual void StartCamera(); /*! \brief stops the continuous updating of the camera */ virtual void StopCamera(); /*! \brief updates the camera for image acquisition \throws mitkException In case of no connection, an exception is thrown! */ virtual void UpdateCamera(); /*! \brief returns whether the camera is currently active or not */ virtual bool IsCameraActive(); /*! \brief 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 \param imageSequence the actually captured image sequence number \param amplitudeArray contains the returned amplitude data as an array. */ virtual void GetAmplitudes(float* amplitudeArray, int& imageSequence); /*! \brief 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. */ virtual void GetIntensities(float* intensityArray, int& imageSequence); /*! \brief 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. \param distanceArray contains the returned distances data as an array. \param imageSequence the actually captured image sequence number */ virtual void GetDistances(float* distanceArray, int& imageSequence); /*! \brief gets the 3 images (distance, amplitude, intensity) from the ToF camera. Caution! The user is responsible for allocating and deleting the images. \param distanceArray Contains the distance data as an array. \param amplitudeArray Contains the infrared image. \param intensityArray Does nothing for Kinect V2. \param sourceDataArray Does nothing for Kinect V2. \param requiredImageSequence The required image sequence number. \param capturedImageSequence Does nothing for Kinect V2. */ virtual void GetAllImages(float* distanceArray, float* amplitudeArray, float* intensityArray, char* sourceDataArray, int requiredImageSequence, int& capturedImageSequence, unsigned char* rgbDataArray=NULL); /*! \brief returns the corresponding camera controller */ KinectV2Controller::Pointer GetController(); /*! \brief returns the width of the RGB image */ int GetRGBCaptureWidth(); /*! \brief returns the height of the RGB image */ int GetRGBCaptureHeight(); protected: KinectV2Device(); ~KinectV2Device(); /*! \brief Thread method continuously acquiring images from the ToF hardware */ static ITK_THREAD_RETURN_TYPE Acquire(void* pInfoStruct); 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 m_PolyData; ///< Surface generated via the Kinect V2 SDK with default/unknown calibration. }; } //END mitk namespace #endif diff --git a/Modules/ToFHardware/KinectV2/mitkKinectV2DeviceFactory.h b/Modules/ToFHardware/KinectV2/mitkKinectV2DeviceFactory.h index dc881e494a..c819c6af66 100644 --- a/Modules/ToFHardware/KinectV2/mitkKinectV2DeviceFactory.h +++ b/Modules/ToFHardware/KinectV2/mitkKinectV2DeviceFactory.h @@ -1,98 +1,98 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkKinectV2DeviceFactory_h #define __mitkKinectV2DeviceFactory_h -#include +#include #include "mitkKinectV2Device.h" #include "mitkAbstractToFDeviceFactory.h" #include #include // Microservices #include #include #include #include #include #include namespace mitk { /** * \brief KinectDeviceFactory is an implementation of the factory pattern to generate Microsoft Kinect V2 devices. * KinectDeviceFactory inherits from AbstractToFDeviceFactory which is a MicroService interface. * This offers users the oppertunity to generate new KinectDevices via a global instance of this factory. * @ingroup ToFHardware */ class MITK_KINECTV2MODULE_EXPORT KinectV2DeviceFactory : public itk::LightObject, public AbstractToFDeviceFactory { public: KinectV2DeviceFactory() { } /** * @brief GetFactoryName Get the name of the factory. * @return Name as human readable string. */ std::string GetFactoryName() { return std::string("Kinect V2 Factory"); } /** * @brief GetDeviceNamePrefix Main part of a device name. * * The string for the kinect 2 is "Kinect V2" on purpose, * to distinguish a "Kinect V2" device from a secondary * connected "Kinect 2" (in case you have connected 2x * "Kinect" and 1x Kinect V2). This case is rare, but * we should be able to distinguish between cameras. */ std::string GetDeviceNamePrefix() { return std::string("Kinect V2"); } private: /*! \brief Create an instance of a KinectDevice. */ ToFCameraDevice::Pointer CreateToFCameraDevice() { KinectV2Device::Pointer device = KinectV2Device::New(); device->SetBoolProperty("HasRGBImage", true); device->SetBoolProperty("HasAmplitudeImage", true); device->SetBoolProperty("HasIntensityImage", false); device->SetBoolProperty("KinectReconstructionMode", true); device->SetBoolProperty("RGBImageHasDifferentResolution", true); device->SetBoolProperty("HasSurface", true); device->SetBoolProperty("HasTextureCoordinates", true); return device.GetPointer(); } us::ModuleResource GetIntrinsicsResource() { us::Module* module = us::GetModuleContext()->GetModule(); return module->GetResource("CalibrationFiles/KinectV2_IR_camera.xml"); } }; } #endif