diff --git a/CMakeExternals/MITKData.cmake b/CMakeExternals/MITKData.cmake index 70ab82637a..a1de5f6636 100644 --- a/CMakeExternals/MITKData.cmake +++ b/CMakeExternals/MITKData.cmake @@ -1,39 +1,39 @@ #----------------------------------------------------------------------------- # MITK Data #----------------------------------------------------------------------------- # Sanity checks if(DEFINED MITK_DATA_DIR AND NOT EXISTS ${MITK_DATA_DIR}) message(FATAL_ERROR "MITK_DATA_DIR variable is defined but corresponds to non-existing directory") endif() set(proj MITK-Data) set(proj_DEPENDENCIES) set(MITK-Data_DEPENDS ${proj}) if(BUILD_TESTING) - set(revision_tag 16d96097) + set(revision_tag 66dc8282) #if(${proj}_REVISION_TAG) # set(revision_tag ${${proj}_REVISION_TAG}) #endif() ExternalProject_Add(${proj} URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/MITK-Data_${revision_tag}.tar.gz UPDATE_COMMAND "" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS ${proj_DEPENDENCIES} ) set(MITK_DATA_DIR ${ep_source_dir}/${proj}) else() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") endif(BUILD_TESTING) diff --git a/CMakeExternals/MITKData.cmake b/CMakeExternals/MITKData.cmake.BACKUP.9452.cmake similarity index 91% copy from CMakeExternals/MITKData.cmake copy to CMakeExternals/MITKData.cmake.BACKUP.9452.cmake index 70ab82637a..c2dd0c371b 100644 --- a/CMakeExternals/MITKData.cmake +++ b/CMakeExternals/MITKData.cmake.BACKUP.9452.cmake @@ -1,39 +1,43 @@ #----------------------------------------------------------------------------- # MITK Data #----------------------------------------------------------------------------- # Sanity checks if(DEFINED MITK_DATA_DIR AND NOT EXISTS ${MITK_DATA_DIR}) message(FATAL_ERROR "MITK_DATA_DIR variable is defined but corresponds to non-existing directory") endif() set(proj MITK-Data) set(proj_DEPENDENCIES) set(MITK-Data_DEPENDS ${proj}) if(BUILD_TESTING) +<<<<<<< HEAD set(revision_tag 16d96097) +======= + set(revision_tag 66dc8282) +>>>>>>> bug-14224-DefaultCalibrationFiles #if(${proj}_REVISION_TAG) # set(revision_tag ${${proj}_REVISION_TAG}) #endif() ExternalProject_Add(${proj} URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/MITK-Data_${revision_tag}.tar.gz UPDATE_COMMAND "" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS ${proj_DEPENDENCIES} ) set(MITK_DATA_DIR ${ep_source_dir}/${proj}) else() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") endif(BUILD_TESTING) diff --git a/CMakeExternals/MITKData.cmake b/CMakeExternals/MITKData.cmake.BASE.9452.cmake similarity index 96% copy from CMakeExternals/MITKData.cmake copy to CMakeExternals/MITKData.cmake.BASE.9452.cmake index 70ab82637a..a01699470f 100644 --- a/CMakeExternals/MITKData.cmake +++ b/CMakeExternals/MITKData.cmake.BASE.9452.cmake @@ -1,39 +1,39 @@ #----------------------------------------------------------------------------- # MITK Data #----------------------------------------------------------------------------- # Sanity checks if(DEFINED MITK_DATA_DIR AND NOT EXISTS ${MITK_DATA_DIR}) message(FATAL_ERROR "MITK_DATA_DIR variable is defined but corresponds to non-existing directory") endif() set(proj MITK-Data) set(proj_DEPENDENCIES) set(MITK-Data_DEPENDS ${proj}) if(BUILD_TESTING) - set(revision_tag 16d96097) + set(revision_tag 55445f45) #if(${proj}_REVISION_TAG) # set(revision_tag ${${proj}_REVISION_TAG}) #endif() ExternalProject_Add(${proj} URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/MITK-Data_${revision_tag}.tar.gz UPDATE_COMMAND "" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS ${proj_DEPENDENCIES} ) set(MITK_DATA_DIR ${ep_source_dir}/${proj}) else() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") endif(BUILD_TESTING) diff --git a/CMakeExternals/MITKData.cmake b/CMakeExternals/MITKData.cmake.LOCAL.9452.cmake similarity index 100% copy from CMakeExternals/MITKData.cmake copy to CMakeExternals/MITKData.cmake.LOCAL.9452.cmake diff --git a/CMakeExternals/MITKData.cmake b/CMakeExternals/MITKData.cmake.REMOTE.9452.cmake similarity index 96% copy from CMakeExternals/MITKData.cmake copy to CMakeExternals/MITKData.cmake.REMOTE.9452.cmake index 70ab82637a..a1de5f6636 100644 --- a/CMakeExternals/MITKData.cmake +++ b/CMakeExternals/MITKData.cmake.REMOTE.9452.cmake @@ -1,39 +1,39 @@ #----------------------------------------------------------------------------- # MITK Data #----------------------------------------------------------------------------- # Sanity checks if(DEFINED MITK_DATA_DIR AND NOT EXISTS ${MITK_DATA_DIR}) message(FATAL_ERROR "MITK_DATA_DIR variable is defined but corresponds to non-existing directory") endif() set(proj MITK-Data) set(proj_DEPENDENCIES) set(MITK-Data_DEPENDS ${proj}) if(BUILD_TESTING) - set(revision_tag 16d96097) + set(revision_tag 66dc8282) #if(${proj}_REVISION_TAG) # set(revision_tag ${${proj}_REVISION_TAG}) #endif() ExternalProject_Add(${proj} URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/MITK-Data_${revision_tag}.tar.gz UPDATE_COMMAND "" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS ${proj_DEPENDENCIES} ) set(MITK_DATA_DIR ${ep_source_dir}/${proj}) else() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") endif(BUILD_TESTING) diff --git a/Modules/ToFHardware/CMakeLists.txt b/Modules/ToFHardware/CMakeLists.txt index c36179f834..466eeb91a3 100644 --- a/Modules/ToFHardware/CMakeLists.txt +++ b/Modules/ToFHardware/CMakeLists.txt @@ -1,34 +1,34 @@ #Define the platform string IF(WIN32) IF(CMAKE_CL_64) SET(_PLATFORM_STRING "W64") ELSE(CMAKE_CL_64) SET(_PLATFORM_STRING "W32") ENDIF(CMAKE_CL_64) ELSE(WIN32) IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") SET(_PLATFORM_STRING "L64") ELSE(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") SET(_PLATFORM_STRING "L32") ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") ENDIF(WIN32) MITK_CREATE_MODULE(mitkToFHardware SUBPROJECTS MITK-ToF INCLUDE_DIRS ${MITK_BIN_DIR} INTERNAL_INCLUDE_DIRS ${INCLUDE_DIRS_INTERNAL} - DEPENDS Mitk MitkExt mitkOpenCVVideoSupport MitkIGT LegacyAdaptors + DEPENDS Mitk MitkExt mitkOpenCVVideoSupport MitkIGT LegacyAdaptors mitkCameraCalibration EXPORT_DEFINE MITK_TOFHARDWARE_EXPORT ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ) add_subdirectory(Testing) add_subdirectory(Kinect) add_subdirectory(PMD) add_subdirectory(MesaSR4000) CONFIGURE_FILE(mitkToFConfig.h.in ${PROJECT_BINARY_DIR}/mitkToFConfig.h @ONLY) #foreach(tofhardwaresubfolder_dir ${tofhardwaresubfolder_dirs}) # add_subdirectory(${tofhardwaresubfolder_dirs}) #endforeach() diff --git a/Modules/ToFHardware/Documentation/doxygen/GeneratingDeviceModules.dox b/Modules/ToFHardware/Documentation/doxygen/GeneratingDeviceModules.dox new file mode 100644 index 0000000000..05d84dce5b --- /dev/null +++ b/Modules/ToFHardware/Documentation/doxygen/GeneratingDeviceModules.dox @@ -0,0 +1,89 @@ +/** +\page GeneratingDeviceModulesPage How to generate ToF DeviceModules + +The ToF-DeviceModule-Tutorial will help you implementing a new ToF-Device easily. +Using MicroServices for this purpose will be one of our main goals, too. + +If you do not know much about MicroServices, please take a look at: + +\ref MicroServices_Overview + +\section GeneratingDeviceModulsPageSec1 Generating a ToF-Device-Module in MITK + + + In order to implement your own device, you need to code the following objects: + + + The following example shows how to implement a device, here we take the Kinect. + +
  • Creating a Sub-Folder + \n Following the Kinect-DeviceModule as a prototype, create a MODULENAME-Sub-Folder in your source directory. This MODULENAME-Folder is going to hold all the necessary files we will create in the next steps. + +
  • Create the CMake Files for our new camera-model in the MODULENAME-Folder < + + + +
  • Creating the Code Files in the MODULENAME-Folder + + +\n + +If you did everything correct, your Module should be implemented an executable MODULENAME-Project will be generated and a working device should show up in the ServiceListWidget in the Connection-Part of ToFUtil. +Warning The dll/so files are not automatically deleted. After deactivating a device, please delete the concerning files in SUPERBUILDDIR/MITK-build/bin/mitkToFHardware/BUILDTYPE + + +\section GeneratingDeviceModulsPageSec2 [OPTIONAL] Adding a Testing Sub-Directory + +If you have any Tests you want to include, a Testing-Subdirectory in the newly created MODULENAME-Folder should be created. In this Folder we are going to put a CMakeLists.txt and a files.cmake the first one will just consist + + \code + MITK_CREATE_MODULE_TESTS() + \endcode + +while the later one, the files.cmake holds Information about TestFiles you created and put in the Folder. +E.g. for the Kinect: + + \code + set(MODULE_TESTS + mitkKinectControllerTest.cpp + mitkKinectDeviceTest.cpp + ) + \endcode + +As before, feel free to take a look at one of the existing Modules and their Testing-Subfolder as the Kinect´s. + +If you managed to implement your Module properly, an executable MODULENAMETestDriver will be generated. + + +*/ diff --git a/Modules/ToFHardware/Kinect/mitkKinectDevice.h b/Modules/ToFHardware/Kinect/mitkKinectDevice.h index 37cd126a85..4ddf45aeeb 100644 --- a/Modules/ToFHardware/Kinect/mitkKinectDevice.h +++ b/Modules/ToFHardware/Kinect/mitkKinectDevice.h @@ -1,161 +1,160 @@ /*=================================================================== 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 "mitkKinectModuleExports.h" #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 MESA ToF 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 ); itkNewMacro( 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 intensityArray contains the returned intensity data as an array. \param sourceDataArray contains the complete source data from the camera device. \param requiredImageSequence the required image sequence number \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); // TODO: Buffer size currently set to 1. Once Buffer handling is working correctly, method may be reactivated // /* // * TODO: Reenable doxygen comment when uncommenting, disabled to fix doxygen warning see bug 12882 // \brief pure virtual method resetting the buffer using the specified bufferSize. Has to be implemented by sub-classes // \param bufferSize buffer size the buffer should be reset to // */ // virtual void ResetBuffer(int bufferSize) = 0; //TODO add/correct documentation for requiredImageSequence and capturedImageSequence in the GetAllImages, GetDistances, GetIntensities and GetAmplitudes methods. /*! \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 amplitude images float** m_IntensityDataBuffer; ///< buffer holding the last intensity images unsigned char** m_RGBDataBuffer; ///< buffer holding the last RGB image int m_KinectDeviceNumber; private: }; } //END mitk namespace #endif diff --git a/Modules/ToFHardware/Kinect/mitkKinectDeviceFactory.h b/Modules/ToFHardware/Kinect/mitkKinectDeviceFactory.h index 56fe9c5de2..eeff536474 100644 --- a/Modules/ToFHardware/Kinect/mitkKinectDeviceFactory.h +++ b/Modules/ToFHardware/Kinect/mitkKinectDeviceFactory.h @@ -1,76 +1,87 @@ /*=================================================================== 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 "mitkKinectModuleExports.h" #include "mitkKinectDevice.h" #include "mitkAbstractToFDeviceFactory.h" +#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: KinectDeviceFactory() { this->m_DeviceNumber = 1; } /*! \brief Defining the Factorie´s Name, here for the Kinect. */ std::string GetFactoryName() { return std::string("Kinect Factory"); } //Interating the Device name on calling the Factory std::string GetCurrentDeviceName() { std::stringstream name; if (m_DeviceNumber>1) { name << "Kinect " << m_DeviceNumber; } else { name << "Kinect "; } m_DeviceNumber++; return name.str(); } private: /*! \brief Create an instance of a KinectDevice. */ ToFCameraDevice::Pointer createToFCameraDevice() { KinectDevice::Pointer device = KinectDevice::New(); + + //Set default camera intrinsics for the kinect RGB camera. + //(OpenNI warps the distance data into the RGB space). + mitk::CameraIntrinsics::Pointer cameraIntrinsics = mitk::CameraIntrinsics::New(); + std::string pathToDefaulCalibrationFile(MITK_TOF_DATA_DIR); + pathToDefaulCalibrationFile.append("/CalibrationFiles/Kinect_RGB_camera.xml"); + cameraIntrinsics->FromXMLFile(pathToDefaulCalibrationFile); + device->SetProperty("CameraIntrinsics", mitk::CameraIntrinsicsProperty::New(cameraIntrinsics)); + return device.GetPointer(); } //Member variable as variable for our DeviceNumber int m_DeviceNumber; }; } #endif diff --git a/Modules/ToFHardware/MesaSR4000/mitkToFCameraMESASR4000DeviceFactory.h b/Modules/ToFHardware/MesaSR4000/mitkToFCameraMESASR4000DeviceFactory.h index 2ffb116ed1..da792364d4 100644 --- a/Modules/ToFHardware/MesaSR4000/mitkToFCameraMESASR4000DeviceFactory.h +++ b/Modules/ToFHardware/MesaSR4000/mitkToFCameraMESASR4000DeviceFactory.h @@ -1,74 +1,85 @@ /*=================================================================== 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 __mitkToFCameraMESASR4000DeviceFactory_h #define __mitkToFCameraMESASR4000DeviceFactory_h #include "mitkMESASR4000ModuleExports.h" #include "mitkToFCameraMESASR4000Device.h" #include "mitkAbstractToFDeviceFactory.h" +#include +#include +#include namespace mitk { /** * \brief ToFPMDRawPlayerDeviceFactory is an implementation of the factory pattern to generate MESASR4000Devices. * ToFCameraMESASR4000DeviceFactory inherits from AbstractToFDeviceFactory which is a MicroService interface. * This offers users the oppertunity to generate new Raw Player Devices via a global instance of this factory. * @ingroup ToFHardware */ class MITK_MESASR4000MODULE_EXPORT ToFCameraMESASR4000DeviceFactory : public itk::LightObject, public AbstractToFDeviceFactory { public: ToFCameraMESASR4000DeviceFactory() { this->m_DeviceNumber = 1; } /*! \brief Defining the Factorie´s Name, here for the MESASR4000DeviceFactory */ std::string GetFactoryName() { return std::string("MESA SR4000 Factory"); } std::string GetCurrentDeviceName() { std::stringstream name; if(m_DeviceNumber>1) { name << "MESA SR4000 "<< m_DeviceNumber; } else { name << "MESA SR4000"; } m_DeviceNumber++; return name.str(); } private: /*! \brief Create an instance of a ToFPMDRawDataDevice. */ ToFCameraDevice::Pointer createToFCameraDevice() { ToFCameraMESASR4000Device::Pointer device = ToFCameraMESASR4000Device::New(); + //Set default camera intrinsics for the Mesa-SR4000-camera. + mitk::CameraIntrinsics::Pointer cameraIntrinsics = mitk::CameraIntrinsics::New(); + std::string pathToDefaulCalibrationFile(MITK_TOF_DATA_DIR); + + pathToDefaulCalibrationFile.append("/CalibrationFiles/Mesa-SR4000_Camera.xml"); + cameraIntrinsics->FromXMLFile(pathToDefaulCalibrationFile); + device->SetProperty("CameraIntrinsics", mitk::CameraIntrinsicsProperty::New(cameraIntrinsics)); + return device.GetPointer(); } int m_DeviceNumber; }; } #endif diff --git a/Modules/ToFHardware/PMD/mitkToFCameraPMDCamBoardDeviceFactory.h b/Modules/ToFHardware/PMD/mitkToFCameraPMDCamBoardDeviceFactory.h index e31a04a17b..74f57d097f 100644 --- a/Modules/ToFHardware/PMD/mitkToFCameraPMDCamBoardDeviceFactory.h +++ b/Modules/ToFHardware/PMD/mitkToFCameraPMDCamBoardDeviceFactory.h @@ -1,76 +1,87 @@ /*=================================================================== 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 __mitkToFCameraPMDCamBoardDeviceFactory_h #define __mitkToFCameraPMDCamBoardDeviceFactory_h #include "mitkPMDModuleExports.h" #include "mitkToFCameraPMDCamBoardDevice.h" #include "mitkAbstractToFDeviceFactory.h" +#include +#include +#include namespace mitk { /** * \brief ToFPMDCamBoardDeviceFactory is an implementation of the factory pattern to generate CamBoard devices. * ToFPMDCamBoardDeviceFactory inherits from AbstractToFDeviceFactory which is a MicroService interface. * This offers users the oppertunity to generate new CamBoard Devices via a global instance of this factory. * @ingroup ToFHardware */ class MITK_PMDMODULE_EXPORT ToFCameraPMDCamBoardDeviceFactory : public itk::LightObject, public AbstractToFDeviceFactory { public: ToFCameraPMDCamBoardDeviceFactory() { this->m_DeviceNumber=1; } /*! \brief Defining the Factorie´s Name, here for the ToFPMDCamBoard. */ std::string GetFactoryName() { return std::string("PMD CamBoard Factory "); } std::string GetCurrentDeviceName() { std::stringstream name; if(m_DeviceNumber>1) { name << "PMD CamBoard "<< m_DeviceNumber; } else { name << "PMD CamBoard"; } m_DeviceNumber++; return name.str(); } private: /*! \brief Create an instance of a ToFPMDCamBoardDevice. */ ToFCameraDevice::Pointer createToFCameraDevice() { ToFCameraPMDCamBoardDevice::Pointer device = ToFCameraPMDCamBoardDevice::New(); + //Set default camera intrinsics for the CamBoard-camera. + mitk::CameraIntrinsics::Pointer cameraIntrinsics = mitk::CameraIntrinsics::New(); + std::string pathToDefaulCalibrationFile(MITK_TOF_DATA_DIR); + + pathToDefaulCalibrationFile.append("/CalibrationFiles/PMDCamBoard_camera.xml"); + cameraIntrinsics->FromXMLFile(pathToDefaulCalibrationFile); + device->SetProperty("CameraIntrinsics", mitk::CameraIntrinsicsProperty::New(cameraIntrinsics)); + return device.GetPointer(); } int m_DeviceNumber; }; } #endif diff --git a/Modules/ToFHardware/PMD/mitkToFCameraPMDCamCubeDeviceFactory.h b/Modules/ToFHardware/PMD/mitkToFCameraPMDCamCubeDeviceFactory.h index 89e494a407..9c9c9c35c6 100644 --- a/Modules/ToFHardware/PMD/mitkToFCameraPMDCamCubeDeviceFactory.h +++ b/Modules/ToFHardware/PMD/mitkToFCameraPMDCamCubeDeviceFactory.h @@ -1,75 +1,87 @@ /*=================================================================== 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 __mitkToFCameraPMDCamCubeDeviceFactory_h #define __mitkToFCameraPMDCamCubeDeviceFactory_h #include "mitkPMDModuleExports.h" #include "mitkToFCameraPMDCamCubeDevice.h" #include "mitkAbstractToFDeviceFactory.h" +#include +#include +#include namespace mitk { /** * \brief ToFPMDCamBoardDeviceFactory is an implementation of the factory pattern to generate Cam Cube Devices. * ToFPMDCamCubeDeviceFactory inherits from AbstractToFDeviceFactory which is a MicroService interface. * This offers users the oppertunity to generate new Cam Cube Devices via a global instance of this factory. * @ingroup ToFHardware */ class MITK_PMDMODULE_EXPORT ToFCameraPMDCamCubeDeviceFactory : public itk::LightObject, public AbstractToFDeviceFactory { public: ToFCameraPMDCamCubeDeviceFactory() { this->m_DeviceNumber=1; } /*! \brief Defining the Factorie´s Name, here for the ToFPMDCamCube. */ std::string GetFactoryName() { return std::string("PMD Camcube 2.0/3.0 Factory "); } std::string GetCurrentDeviceName() { std::stringstream name; if(m_DeviceNumber>1) { name << "PMD CamCube 2.0/3.0 "<< m_DeviceNumber; } else { name << "PMD CamCube 2.0/3.0 "; } m_DeviceNumber++; return name.str(); } private: /*! \brief Create an instance of a ToFPMDCamCubeDevice. */ ToFCameraDevice::Pointer createToFCameraDevice() { ToFCameraPMDCamCubeDevice::Pointer device = ToFCameraPMDCamCubeDevice::New(); + //Set default camera intrinsics for the CamCube Amplitude Camera. + mitk::CameraIntrinsics::Pointer cameraIntrinsics = mitk::CameraIntrinsics::New(); + std::string pathToDefaulCalibrationFile(MITK_TOF_DATA_DIR); + pathToDefaulCalibrationFile.append("/CalibrationFiles/PMDCamCube3_camera.xml"); + MITK_INFO <FromXMLFile(pathToDefaulCalibrationFile); + device->SetProperty("CameraIntrinsics", mitk::CameraIntrinsicsProperty::New(cameraIntrinsics)); + + return device.GetPointer(); } int m_DeviceNumber; }; } #endif diff --git a/Modules/ToFHardware/PMD/mitkToFCameraPMDO3DeviceFactory.h b/Modules/ToFHardware/PMD/mitkToFCameraPMDO3DeviceFactory.h index 6ddf17ac2d..37fa879413 100644 --- a/Modules/ToFHardware/PMD/mitkToFCameraPMDO3DeviceFactory.h +++ b/Modules/ToFHardware/PMD/mitkToFCameraPMDO3DeviceFactory.h @@ -1,75 +1,90 @@ /*=================================================================== 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 __mitkToFCameraPMDO3DeviceFactory_h #define __mitkToFCameraPMDO3DeviceFactory_h #include "mitkPMDModuleExports.h" #include "mitkToFCameraPMDO3Device.h" #include "mitkAbstractToFDeviceFactory.h" +#include +#include +#include + namespace mitk { /** * \brief ToFCameraPMDO3DeviceFactory is an implementation of the factory pattern to generate Do3 Devices. * ToFPMDCamCubeDeviceFactory inherits from AbstractToFDeviceFactory which is a MicroService interface. * This offers users the oppertunity to generate new Cam Cube Devices via a global instance of this factory. * @ingroup ToFHardware */ class MITK_PMDMODULE_EXPORT ToFCameraPMDO3DeviceFactory : public itk::LightObject, public AbstractToFDeviceFactory { public: ToFCameraPMDO3DeviceFactory() { this->m_DeviceNumber =1; } /*! \brief Defining the Factorie´s Name, here for the ToFPMDO3Device */ std::string GetFactoryName() { return std::string("PMD O3D Factory"); } std::string GetCurrentDeviceName() { std::stringstream name; if(m_DeviceNumber>1) { name << "PMD O3 "<< m_DeviceNumber; } else { name << "PMD O3"; } m_DeviceNumber++; return name.str(); } private: /*! \brief Create an instance of a ToFPMDO3DeviceFactory. */ ToFCameraDevice::Pointer createToFCameraDevice() { ToFCameraPMDO3Device::Pointer device = ToFCameraPMDO3Device::New(); +//-------------------------Intrinsics for 03 are missing----------------------------------- + //Set default camera intrinsics for the CamBoard-camera. + mitk::CameraIntrinsics::Pointer cameraIntrinsics = mitk::CameraIntrinsics::New(); + std::string pathToDefaulCalibrationFile(MITK_TOF_DATA_DIR); + + pathToDefaulCalibrationFile.append("/CalibrationFiles/Default_Parameters.xml"); + cameraIntrinsics->FromXMLFile(pathToDefaulCalibrationFile); + device->SetProperty("CameraIntrinsics", mitk::CameraIntrinsicsProperty::New(cameraIntrinsics)); + +//------------------------------------------------------------------------------------------ + return device.GetPointer(); } int m_DeviceNumber; }; } #endif diff --git a/Modules/ToFHardware/PMD/mitkToFCameraPMDPlayerDeviceFactory.h b/Modules/ToFHardware/PMD/mitkToFCameraPMDPlayerDeviceFactory.h index f3f7374b2d..1ec824224d 100644 --- a/Modules/ToFHardware/PMD/mitkToFCameraPMDPlayerDeviceFactory.h +++ b/Modules/ToFHardware/PMD/mitkToFCameraPMDPlayerDeviceFactory.h @@ -1,76 +1,90 @@ /*=================================================================== 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 __mitkToFCameraPMDPlayerDeviceFactory_h #define __mitkToFCameraPMDPlayerDeviceFactory_h #include "mitkPMDModuleExports.h" #include "mitkToFCameraPMDPlayerDevice.h" #include "mitkAbstractToFDeviceFactory.h" +#include +#include +#include namespace mitk { /** * \brief ToFPMDPlayerDeviceFactory is an implementation of the factory pattern to generate PMD Player Devices. * ToFPMDPlayerDeviceFactory inherits from AbstractToFDeviceFactory which is a MicroService interface. * This offers users the oppertunity to generate new PMD Player Devices via a global instance of this factory. * @ingroup ToFHardware */ class MITK_PMDMODULE_EXPORT ToFCameraPMDPlayerDeviceFactory : public itk::LightObject, public AbstractToFDeviceFactory { public: ToFCameraPMDPlayerDeviceFactory() { this->m_DeviceNumber=1; } /*! \brief Defining the Factorie´s Name, here for the ToFPMDPlayer. */ std::string GetFactoryName() { return std::string("PMD Player Factory"); } std::string GetCurrentDeviceName() { std::stringstream name; if(m_DeviceNumber>1) { name << "PMD Player "<< m_DeviceNumber; } else { name << "PMD Player"; } m_DeviceNumber++; return name.str(); } private: /*! \brief Create an instance of a ToFPMDPlayerDevice. */ ToFCameraDevice::Pointer createToFCameraDevice() { ToFCameraPMDPlayerDevice::Pointer device = ToFCameraPMDPlayerDevice::New(); +//-------------------------If no Intrinsics are specified------------------------------ + //Set default camera intrinsics for the PMD-Player. + mitk::CameraIntrinsics::Pointer cameraIntrinsics = mitk::CameraIntrinsics::New(); + std::string pathToDefaulCalibrationFile(MITK_TOF_DATA_DIR); + + pathToDefaulCalibrationFile.append("/CalibrationFiles/Default_Parameters.xml"); + cameraIntrinsics->FromXMLFile(pathToDefaulCalibrationFile); + device->SetProperty("CameraIntrinsics", mitk::CameraIntrinsicsProperty::New(cameraIntrinsics)); + +//------------------------------------------------------------------------------------------ + return device.GetPointer(); } int m_DeviceNumber; }; } #endif diff --git a/Modules/ToFHardware/PMD/mitkToFCameraPMDRawDataCamBoardDeviceFactory.h b/Modules/ToFHardware/PMD/mitkToFCameraPMDRawDataCamBoardDeviceFactory.h index bf11054fb2..9e5b9805d1 100644 --- a/Modules/ToFHardware/PMD/mitkToFCameraPMDRawDataCamBoardDeviceFactory.h +++ b/Modules/ToFHardware/PMD/mitkToFCameraPMDRawDataCamBoardDeviceFactory.h @@ -1,69 +1,80 @@ /*=================================================================== 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 __mitkToFCameraPMDRawDataCamBoardDeviceFactory_h #define __mitkToFCameraPMDRawDataCamBoardDeviceFactory_h #include "mitkPMDModuleExports.h" #include "mitkToFCameraPMDRawDataCamBoardDevice.h" #include "mitkAbstractToFDeviceFactory.h" +#include +#include +#include namespace mitk { /** * \brief ToFPMDRawPlayerDeviceFactory is an implementation of the factory pattern to generate Raw Player Devices. * ToFPMDRawPlayerDeviceFactory inherits from AbstractToFDeviceFactory which is a MicroService interface. * This offers users the oppertunity to generate new Raw Player Devices via a global instance of this factory. * @ingroup ToFHardware */ class MITK_PMDMODULE_EXPORT ToFCameraPMDRawDataCamBoardDeviceFactory : public itk::LightObject, public AbstractToFDeviceFactory { public: ToFCameraPMDRawDataCamBoardDeviceFactory() { this->m_DeviceNumber=0; } /*! \brief Defining the Factorie´s Name, here for the RawDataCamBoardDeviceFactory. */ std::string GetFactoryName() { return std::string("PMD Raw Data CamBoard Factory "); } std::string GetCurrentDeviceName() { std::stringstream name; name<<"PMD Raw Data CamBoard Device " << m_DeviceNumber++; return name.str (); } private: /*! \brief Create an instance of a RawDataCamBoardDeviceFactory. */ ToFCameraDevice::Pointer createToFCameraDevice() { ToFCameraPMDRawDataCamBoardDevice::Pointer device = ToFCameraPMDRawDataCamBoardDevice::New(); + //Set default camera intrinsics for the RawDataCamBoard-camera + mitk::CameraIntrinsics::Pointer cameraIntrinsics = mitk::CameraIntrinsics::New(); + std::string pathToDefaulCalibrationFile(MITK_TOF_DATA_DIR); + + pathToDefaulCalibrationFile.append("/CalibrationFiles/PMDCamBoard_camera.xml"); + cameraIntrinsics->FromXMLFile(pathToDefaulCalibrationFile); + device->SetProperty("CameraIntrinsics", mitk::CameraIntrinsicsProperty::New(cameraIntrinsics)); + return device.GetPointer(); } int m_DeviceNumber; }; } #endif diff --git a/Modules/ToFHardware/PMD/mitkToFCameraPMDRawDataCamCubeDeviceFactory.h b/Modules/ToFHardware/PMD/mitkToFCameraPMDRawDataCamCubeDeviceFactory.h index 91b9106a7e..f4ba0fe70b 100644 --- a/Modules/ToFHardware/PMD/mitkToFCameraPMDRawDataCamCubeDeviceFactory.h +++ b/Modules/ToFHardware/PMD/mitkToFCameraPMDRawDataCamCubeDeviceFactory.h @@ -1,75 +1,86 @@ /*=================================================================== 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 __mitkToFCameraPMDRawDataCamCubeDeviceFactory_h #define __mitkToFCameraPMDRawDataCamCubeDeviceFactory_h #include "mitkPMDModuleExports.h" #include "mitkToFCameraPMDRawDataCamCubeDevice.h" #include "mitkAbstractToFDeviceFactory.h" +#include +#include +#include namespace mitk { /** * \brief ToFPMDRawPlayerDeviceFactory is an implementation of the factory pattern to generate Raw Player Devices. * ToFPMDRawPlayerDeviceFactory inherits from AbstractToFDeviceFactory which is a MicroService interface. * This offers users the oppertunity to generate new Raw Player Devices via a global instance of this factory. * @ingroup ToFHardware */ class MITK_PMDMODULE_EXPORT ToFCameraPMDRawDataCamCubeDeviceFactory : public itk::LightObject, public AbstractToFDeviceFactory { public: ToFCameraPMDRawDataCamCubeDeviceFactory() { this->m_DeviceNumber = 1; } /*! \brief Defining the Factorie´s Name, here for the RawDataDeviceFactory. */ std::string GetFactoryName() { return std::string("PMD RAW Data Camcube Factory "); } std::string GetCurrentDeviceName() { std::stringstream name; if(m_DeviceNumber>1) { name << "PMD Raw Data CamCube 2.0/3.0 "<< m_DeviceNumber; } else { name << "PMD Raw Data CamCube 2.0/3.0"; } m_DeviceNumber++; return name.str(); } private: /*! \brief Create an instance of a ToFPMDRawDataDevice. */ ToFCameraDevice::Pointer createToFCameraDevice() { ToFCameraPMDRawDataCamCubeDevice::Pointer device = ToFCameraPMDRawDataCamCubeDevice::New(); + //Set default camera intrinsics for the RawDataCamCube-Camera. + mitk::CameraIntrinsics::Pointer cameraIntrinsics = mitk::CameraIntrinsics::New(); + std::string pathToDefaulCalibrationFile(MITK_TOF_DATA_DIR); + + pathToDefaulCalibrationFile.append("/CalibrationFiles/PMDCamCube3_camera.xml"); + cameraIntrinsics->FromXMLFile(pathToDefaulCalibrationFile); + device->SetProperty("CameraIntrinsics", mitk::CameraIntrinsicsProperty::New(cameraIntrinsics)); + return device.GetPointer(); } int m_DeviceNumber; }; } #endif diff --git a/Modules/ToFHardware/mitkToFCameraMITKPlayerDeviceFactory.h b/Modules/ToFHardware/mitkToFCameraMITKPlayerDeviceFactory.h index 24a4c2e83b..4296a2dd99 100644 --- a/Modules/ToFHardware/mitkToFCameraMITKPlayerDeviceFactory.h +++ b/Modules/ToFHardware/mitkToFCameraMITKPlayerDeviceFactory.h @@ -1,80 +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 __mitkToFCameraMITKPlayerDeviceFactory_h #define __mitkToFCameraMITKPlayerDeviceFactory_h #include "mitkToFHardwareExports.h" #include "mitkToFCameraMITKPlayerDevice.h" #include "mitkAbstractToFDeviceFactory.h" +#include +#include +#include namespace mitk { /** * \brief ToFPlayerDeviceFactory is an implementation of the factory pattern to generate ToFPlayer devices. * ToFPlayerDeviceFactory inherits from AbstractToFDeviceFactory which is a MicroService interface. * This offers users the oppertunity to generate new ToFPlayerDevices via a global instance of this factory. * @ingroup ToFHardware */ class MITK_TOFHARDWARE_EXPORT ToFCameraMITKPlayerDeviceFactory : public itk::LightObject, public AbstractToFDeviceFactory { public: ToFCameraMITKPlayerDeviceFactory() { m_DeviceNumber = 1; } /*! \brief Defining the Factorie´s Name, here for the ToFPlayer. */ std::string GetFactoryName() { return std::string("MITK Player Factory"); } std::string GetCurrentDeviceName() { std::stringstream name; if(m_DeviceNumber>1) { name << "MITK Player "<< m_DeviceNumber; } else { name << "MITK Player"; } m_DeviceNumber++; return name.str(); } private: /*! \brief Create an instance of a ToFPlayerDevice. */ ToFCameraDevice::Pointer createToFCameraDevice() { ToFCameraMITKPlayerDevice::Pointer device = ToFCameraMITKPlayerDevice::New(); +////-------------------------If no Intrinsics are specified------------------------------ +// //Set default camera intrinsics for the MITK-Player. +// mitk::CameraIntrinsics::Pointer cameraIntrinsics = mitk::CameraIntrinsics::New(); +// std::string pathToDefaulCalibrationFile(MITK_TOF_DATA_DIR); +// +// pathToDefaulCalibrationFile.append("/CalibrationFiles/Default_Parameters.xml"); +// cameraIntrinsics->FromXMLFile(pathToDefaulCalibrationFile); +// device->SetProperty("CameraIntrinsics", mitk::CameraIntrinsicsProperty::New(cameraIntrinsics)); +// +////------------------------------------------------------------------------------------------ + return device.GetPointer(); } int m_DeviceNumber; }; } #endif diff --git a/Modules/ToFHardware/mitkToFCameraPMDCamBoardControllerStub.cpp b/Modules/ToFHardware/mitkToFCameraPMDCamBoardControllerStub.cpp deleted file mode 100644 index f94fa13c00..0000000000 --- a/Modules/ToFHardware/mitkToFCameraPMDCamBoardControllerStub.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ - -#include "mitkToFCameraPMDCamBoardController.h" - -namespace mitk -{ - ToFCameraPMDCamBoardController::ToFCameraPMDCamBoardController() - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - } - - ToFCameraPMDCamBoardController::~ToFCameraPMDCamBoardController() - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - } - - bool ToFCameraPMDCamBoardController::OpenCameraConnection() - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - bool mitk::ToFCameraPMDCamBoardController::SetDistanceOffset( float offset ) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - float mitk::ToFCameraPMDCamBoardController::GetDistanceOffset() - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return 0.0; - } - - bool mitk::ToFCameraPMDCamBoardController::SetRegionOfInterest( unsigned int leftUpperCornerX, unsigned int leftUpperCornerY, unsigned int width, unsigned int height ) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - bool mitk::ToFCameraPMDCamBoardController::SetRegionOfInterest( unsigned int roi[4] ) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - unsigned int* mitk::ToFCameraPMDCamBoardController::GetRegionOfInterest() - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return NULL; - } - - bool mitk::ToFCameraPMDCamBoardController::SetExposureMode( int mode ) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - bool mitk::ToFCameraPMDCamBoardController::SetFieldOfView( float fov ) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - bool mitk::ToFCameraPMDCamBoardController::SetFPNCalibration( bool on ) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - bool mitk::ToFCameraPMDCamBoardController::SetFPPNCalibration( bool on ) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - bool mitk::ToFCameraPMDCamBoardController::SetLinearityCalibration( bool on ) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - bool mitk::ToFCameraPMDCamBoardController::SetLensCalibration( bool on ) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - bool ToFCameraPMDCamBoardController::GetAmplitudes(float* amplitudeArray) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - bool ToFCameraPMDCamBoardController::GetAmplitudes(char* sourceData, float* amplitudeArray) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - bool ToFCameraPMDCamBoardController::GetIntensities(float* intensityArray) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - bool ToFCameraPMDCamBoardController::GetIntensities(char* sourceData, float* intensityArray) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - bool ToFCameraPMDCamBoardController::GetDistances(float* distanceArray) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - bool ToFCameraPMDCamBoardController::GetDistances(char* sourceData, float* distanceArray) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - return true; - } - - void ToFCameraPMDCamBoardController::TransformCameraOutput(float* in, float* out, bool isDist) - { - MITK_WARN("ToF") << "Error: PMD CamBoard currently not available"; - } - -} diff --git a/Modules/ToFHardware/mitkToFCameraPMDCamCubeControllerStub.cpp b/Modules/ToFHardware/mitkToFCameraPMDCamCubeControllerStub.cpp deleted file mode 100644 index fdc521d1a8..0000000000 --- a/Modules/ToFHardware/mitkToFCameraPMDCamCubeControllerStub.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ -#include "mitkToFCameraPMDCamCubeController.h" - -namespace mitk -{ - ToFCameraPMDCamCubeController::ToFCameraPMDCamCubeController() - { - MITK_WARN("ToF") << "Error: PMD Camcube currently not available"; - } - - ToFCameraPMDCamCubeController::~ToFCameraPMDCamCubeController() - { - } - - bool ToFCameraPMDCamCubeController::OpenCameraConnection() - { - MITK_WARN("ToF") << "Error: PMD Camcube currently not available"; - return true; - } - - bool mitk::ToFCameraPMDCamCubeController::SetDistanceOffset( float offset ) - { - MITK_WARN("ToF") << "Error: PMD Camcube currently not available"; - return true; - } - - float mitk::ToFCameraPMDCamCubeController::GetDistanceOffset() - { - MITK_WARN("ToF") << "Error: PMD Camcube currently not available"; - return 0.0f; - } - - bool mitk::ToFCameraPMDCamCubeController::SetRegionOfInterest( unsigned int leftUpperCornerX, unsigned int leftUpperCornerY, unsigned int width, unsigned int height ) - { - MITK_WARN("ToF") << "Error: PMD Camcube currently not available"; - return true; - } - - bool mitk::ToFCameraPMDCamCubeController::SetRegionOfInterest( unsigned int roi[4] ) - { - MITK_WARN("ToF") << "Error: PMD Camcube currently not available"; - return true; - } - - unsigned int* mitk::ToFCameraPMDCamCubeController::GetRegionOfInterest() - { - MITK_WARN("ToF") << "Error: PMD Camcube currently not available"; - return NULL; - } - - bool mitk::ToFCameraPMDCamCubeController::SetExposureMode( int mode ) - { - MITK_WARN("ToF") << "Error: PMD Camcube currently not available"; - return true; - } - - bool mitk::ToFCameraPMDCamCubeController::SetFieldOfView( float fov ) - { - MITK_WARN("ToF") << "Error: PMD Camcube currently not available"; - return true; - } - - bool mitk::ToFCameraPMDCamCubeController::SetFPNCalibration( bool on ) - { - MITK_WARN("ToF") << "Error: PMD Camcube currently not available"; - return true; - } - - bool mitk::ToFCameraPMDCamCubeController::SetFPPNCalibration( bool on ) - { - MITK_WARN("ToF") << "Error: PMD Camcube currently not available"; - return true; - } - - bool mitk::ToFCameraPMDCamCubeController::SetLinearityCalibration( bool on ) - { - MITK_WARN("ToF") << "Error: PMD Camcube currently not available"; - return true; - } - - bool mitk::ToFCameraPMDCamCubeController::SetLensCalibration( bool on ) - { - MITK_WARN("ToF") << "Error: PMD Camcube currently not available"; - return true; - } -} diff --git a/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.cpp b/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.cpp index fb1b7a218f..a11cd28691 100644 --- a/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.cpp +++ b/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.cpp @@ -1,387 +1,382 @@ /*=================================================================== 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. ===================================================================*/ //#define _USE_MATH_DEFINES #include //QT headers #include #include #include //mitk headers #include "mitkToFConfig.h" #include "mitkCameraIntrinsics.h" #include "mitkCameraIntrinsicsProperty.h" //itk headers #include //Setting the View_ID const std::string QmitkToFConnectionWidget::VIEW_ID = "org.mitk.views.qmitktofconnectionwidget2"; //Constructor of QmitkToFConnectionWidget QmitkToFConnectionWidget::QmitkToFConnectionWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f) { this->m_IntegrationTime = 0; this->m_ModulationFrequency = 0; this->m_ToFImageGrabber = mitk::ToFImageGrabber::New(); //Setting m_Controls= NULL on Startup-> CreateQtPartControl will generate the Gui Widget if !m_Controls m_Controls = NULL; //Calling CreateQtPartControl CreateQtPartControl(this); } //Destructor of QmitkToFConnectionWidget QmitkToFConnectionWidget::~QmitkToFConnectionWidget() { //Keno´s MitkServiceListWidget must not be deinizialized here. Qmitk methods destroy their children automatically before self-destruction } void QmitkToFConnectionWidget::CreateQtPartControl(QWidget *parent) //Definition of CreateQtPartControll-Methode in QmitkToFConnectionWidget; Input= Pointer { if (!m_Controls) //Define if not alreaddy exists { // create GUI widgets m_Controls = new Ui::QmitkToFConnectionWidgetControls2; m_Controls->setupUi(parent); //and hide them on startup this->HideAllParameterWidgets(); // initzializing MitkServiceListWidget here std::string empty= ""; m_Controls->m_DeviceList->Initialize("ToFDeviceName", empty);// the empty could just be any kind of filter this->CreateConnections(); //OnSelectCamera(); //todo: warum geht das hier nicht? -> Sasch fragen } } //Creating the SIGNAL-SLOT-Connectuions void QmitkToFConnectionWidget::CreateConnections() { if ( m_Controls ) { //ConnectCameraButton as a trigger for OnConnectCamera() connect( (QObject*)(m_Controls->m_ConnectCameraButton), SIGNAL(clicked()),(QObject*) this, SLOT(OnConnectCamera()) ); //QmitkServiceListWidget::ServiceSelectionChanged as a Signal for the OnSlectCamera() slot connect( m_Controls->m_DeviceList, SIGNAL(ServiceSelectionChanged(mitk::ServiceReference)), this, SLOT(OnSelectCamera())); /*Creating an other Datanode structur for Kinect is done here: As soon as a Kinect is connected, the KinectParameterWidget is enabled, which can be used to trigger the KinectAcqusitionModeChanged-Method, to create a working Data-Node-structure*/ connect( m_Controls->m_KinectParameterWidget, SIGNAL(AcquisitionModeChanged()), this, SIGNAL(KinectAcquisitionModeChanged()) ); } } mitk::ToFImageGrabber::Pointer QmitkToFConnectionWidget::GetToFImageGrabber() { return m_ToFImageGrabber; } //The OnSelectCamer-Method is in charge of activating the appropiate ParameterWidgets void QmitkToFConnectionWidget::OnSelectCamera() { //Here we are getting our decvie through the QmitkServiceListWidget-Instance m_DeviceList through the GetSelectedService-Method mitk::ToFCameraDevice* device = m_Controls->m_DeviceList->GetSelectedService(); //getting the selectedCamera through a static Method used to transform the device->GetNameOfClass QString selectedCamera = QString::fromStdString(device->GetNameOfClass()); this->HideAllParameterWidgets(); //reactivating the Widgets on slecting a device if (selectedCamera.contains("PMD")) //Check if selectedCamera string contains ".." for each device { this->m_Controls->m_PMDParameterWidget->show(); //and activate the correct widget } else if (selectedCamera.contains("MESA")) { this->m_Controls->m_MESAParameterWidget->show(); } else if (selectedCamera.contains("Kinect")) { this->m_Controls->m_KinectParameterWidget->show(); } emit (selectedCamera); } //This Methods hides all Widgets (later each widget is activated on its own) void QmitkToFConnectionWidget::HideAllParameterWidgets() { this->m_Controls->m_PMDParameterWidget->hide(); this->m_Controls->m_MESAParameterWidget->hide(); this->m_Controls->m_KinectParameterWidget->hide(); } //OnConnectCamera-Method; represents one of the main parts of ToFConnectionWidget2. void QmitkToFConnectionWidget::OnConnectCamera() { //Introducing the boolean variable playerMode and set it to false by default bool playerMode = false; //After connecting a device if (m_Controls->m_ConnectCameraButton->text()=="Connect") { //Reset the status of some GUI-Elements m_Controls->m_ConnectCameraButton->setEnabled(false); //ConnectCameraButton gets disabled, what leads to other changes later m_Controls->m_DeviceList->setEnabled(false); //Deactivating the Instance of QmitkServiceListWidget //repaint the widget this->repaint(); QString tmpFileName(""); QString fileFilter(""); //Getting the device- and the slectedCamera-variables using the ServiceListWidget as we did it in the CameraSelect-Method mitk::ToFCameraDevice* device = m_Controls->m_DeviceList->GetSelectedService(); QString selectedCamera = QString::fromStdString(device->GetNameOfClass()); emit ToFCameraSelected(selectedCamera); //Creating a new instance of m_ToFImageGrabber this->m_ToFImageGrabber = NULL; this->m_ToFImageGrabber = mitk::ToFImageGrabber::New(); //Feeding it with the Info from ServiceListWidget this->m_ToFImageGrabber->SetCameraDevice(device); // Calling Alex FixForKinect, if the Kinect is selected if (selectedCamera.contains("Kinect") ) { MITK_INFO<< "Kinect is connected here"; //If the particular property is selected, the suitable data-node will be generated this->m_ToFImageGrabber->SetBoolProperty("RGB", m_Controls->m_KinectParameterWidget->IsAcquisitionModeRGB());//-------------------------------------------------------- this->m_ToFImageGrabber->SetBoolProperty("IR", m_Controls->m_KinectParameterWidget->IsAcquisitionModeIR()); } //Activation of "PlayerMode". If the selectedCamera String contains "Player", we start the Player Mode if (selectedCamera.contains("Player")) { playerMode = true; //IF PMD-Player selected if (selectedCamera.contains("PMD")) { fileFilter.append("PMD Files (*.pmd)"); //And seting the corresponding fileFilter } else { fileFilter.append("NRRD Images (*.nrrd);;PIC Images - deprecated (*.pic)"); } } // if a player was selected, the playerMode-variable is true, and we will enter the following code if (playerMode) { //open a QFileDialog to chose the corresponding file from the disc tmpFileName = QFileDialog::getOpenFileName(NULL, "Play Image From...", "", fileFilter); //If no fileName is returned by the Dialog,Button and Widget have to return to default(disconnected) + Opening a MessageBox if (tmpFileName.isEmpty()) { m_Controls->m_ConnectCameraButton->setChecked(false); m_Controls->m_ConnectCameraButton->setEnabled(true); //re-enabling the ConnectCameraButton m_Controls->m_DeviceList->setEnabled(true); //Reactivating ServiceListWidget this->OnSelectCamera(); //Calling the OnSelctCamera-Method -> Hides all Widget and just activates the needed ones QMessageBox::information( this, "Template functionality", "Please select a valid image before starting some action."); return; } if(selectedCamera.contains("PMDPlayer")) //If PMD-Player is selected, set ToFImageGrabberProperty correspondingly { this->m_ToFImageGrabber->SetStringProperty("PMDFileName", tmpFileName.toStdString().c_str() ); } else //Default action { std::string msg = ""; try { //get 3 corresponding file names std::string dir = itksys::SystemTools::GetFilenamePath( tmpFileName.toStdString() ); std::string baseFilename = itksys::SystemTools::GetFilenameWithoutLastExtension( tmpFileName.toStdString() ); std::string extension = itksys::SystemTools::GetFilenameLastExtension( tmpFileName.toStdString() ); //"Incorrect format"-warning while using .nrrd or .pic files if (extension != ".pic" && extension != ".nrrd") { msg = msg + "Invalid file format, please select a \".nrrd\"-file"; throw std::logic_error(msg.c_str()); } //Checking for npos. If available, check for the Amplitude-, Intensity- and RGBImage int found = baseFilename.rfind("_DistanceImage"); //Defining "found" variable+checking if baseFilname contains "_DistanceImage". If not, found == npos(0) if (found == std::string::npos) //If found =0 { found = baseFilename.rfind("_AmplitudeImage"); //If "_AmplitudeImage" is found, the found variable is 1-> the next if statment is false } if (found == std::string::npos) { found = baseFilename.rfind("_IntensityImage"); //found = true if baseFilename cotains "_IntesityImage" } if (found == std::string::npos) { found = baseFilename.rfind("_RGBImage"); } if (found == std::string::npos) //If none of the Nodes is found, display an error { msg = msg + "Input file name must end with \"_DistanceImage\", \"_AmplitudeImage\", \"_IntensityImage\" or \"_RGBImage\"!"; throw std::logic_error(msg.c_str()); } std::string baseFilenamePrefix = baseFilename.substr(0,found);//Set the baseFilenamePrefix as a substring from baseFilname //Set corresponding FileNames std::string distanceImageFileName = dir + "/" + baseFilenamePrefix + "_DistanceImage" + extension; //Set the name as: directory+FilenamePrefix+""+extension std::string amplitudeImageFileName = dir + "/" + baseFilenamePrefix + "_AmplitudeImage" + extension; std::string intensityImageFileName = dir + "/" + baseFilenamePrefix + "_IntensityImage" + extension; std::string rgbImageFileName = dir + "/" + baseFilenamePrefix + "_RGBImage" + extension; if (!itksys::SystemTools::FileExists(distanceImageFileName.c_str(), true)) { this->m_ToFImageGrabber->SetStringProperty("DistanceImageFileName", ""); } else { this->m_ToFImageGrabber->SetStringProperty("DistanceImageFileName", distanceImageFileName.c_str()); } if (!itksys::SystemTools::FileExists(amplitudeImageFileName.c_str(), true)) { } else { this->m_ToFImageGrabber->SetStringProperty("AmplitudeImageFileName", amplitudeImageFileName.c_str()); } if (!itksys::SystemTools::FileExists(intensityImageFileName.c_str(), true)) { this->m_ToFImageGrabber->SetStringProperty("IntensityImageFileName", ""); } else { this->m_ToFImageGrabber->SetStringProperty("IntensityImageFileName", intensityImageFileName.c_str()); } if (!itksys::SystemTools::FileExists(rgbImageFileName.c_str(), true)) { this->m_ToFImageGrabber->SetStringProperty("RGBImageFileName", ""); } else { this->m_ToFImageGrabber->SetStringProperty("RGBImageFileName", rgbImageFileName.c_str()); } } catch (std::exception &e) { MITK_ERROR << e.what(); QMessageBox::critical( this, "Error", e.what() ); m_Controls->m_ConnectCameraButton->setChecked(false); m_Controls->m_ConnectCameraButton->setEnabled(true); m_Controls->m_DeviceList->setEnabled(true); this->OnSelectCamera(); return; } } } //End "PlayerMode" m_Controls->m_ConnectCameraButton->setText("Disconnect"); //Reset the ConnectCameraButton to disconnected //if a connection could be established try { if (this->m_ToFImageGrabber->ConnectCamera()) { this->m_Controls->m_PMDParameterWidget->SetToFImageGrabber(this->m_ToFImageGrabber); this->m_Controls->m_MESAParameterWidget->SetToFImageGrabber(this->m_ToFImageGrabber); this->m_Controls->m_KinectParameterWidget->SetToFImageGrabber(this->m_ToFImageGrabber); //Activating the respective widgets if (selectedCamera.contains("PMD")) { this->m_Controls->m_PMDParameterWidget->ActivateAllParameters(); } else if (selectedCamera.contains("MESA")) { this->m_Controls->m_MESAParameterWidget->ActivateAllParameters(); } else if (selectedCamera.contains("Kinect")) { this->m_Controls->m_KinectParameterWidget->ActivateAllParameters(); } else { this->HideAllParameterWidgets(); } // send connect signal to the caller functionality emit ToFCameraConnected(); } else //##### TODO: Remove this else part once all controllers are throwing exceptions //if they cannot to any device! { //Throw an error if the Connection failed and reset the Widgets <- better catch an exception! QMessageBox::critical( this, "Error", "Connection failed. Check if you have installed the latest driver for your system." ); m_Controls->m_ConnectCameraButton->setChecked(false); m_Controls->m_ConnectCameraButton->setEnabled(true); m_Controls->m_ConnectCameraButton->setText("Connect"); m_Controls->m_DeviceList->setEnabled(true); //Reactivating ServiceListWidget this->OnSelectCamera(); return; } }catch(std::exception &e) { //catch exceptions of camera which cannot connect give a better reason QMessageBox::critical( this, "Connection failed.", e.what() ); m_Controls->m_ConnectCameraButton->setChecked(false); m_Controls->m_ConnectCameraButton->setEnabled(true); m_Controls->m_ConnectCameraButton->setText("Connect"); m_Controls->m_DeviceList->setEnabled(true); //Reactivating ServiceListWidget this->OnSelectCamera(); return; } m_Controls->m_ConnectCameraButton->setEnabled(true); // ask wether camera parameters (intrinsics, ...) should be loaded if (QMessageBox::question(this,"Camera parameters","Do you want to specify your own camera intrinsics?",QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes) { - MITK_INFO<<"Yes"; QString fileName = QFileDialog::getOpenFileName(this,"Open camera intrinsics","/","*.xml"); mitk::CameraIntrinsics::Pointer cameraIntrinsics = mitk::CameraIntrinsics::New(); cameraIntrinsics->FromXMLFile(fileName.toStdString()); this->m_ToFImageGrabber->SetProperty("CameraIntrinsics",mitk::CameraIntrinsicsProperty::New(cameraIntrinsics)); } - else - { - MITK_INFO<<"No"; - } } else if (m_Controls->m_ConnectCameraButton->text()=="Disconnect") { this->m_ToFImageGrabber->StopCamera(); this->m_ToFImageGrabber->DisconnectCamera(); m_Controls->m_ConnectCameraButton->setText("Connect"); m_Controls->m_DeviceList->setEnabled(true); //Reactivating ServiceListWidget this->OnSelectCamera(); // send disconnect signal to the caller functionality emit ToFCameraDisconnected(); } } diff --git a/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.cpp b/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.cpp index a5e308f9f9..3fde750bdb 100644 --- a/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.cpp +++ b/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.cpp @@ -1,616 +1,618 @@ /*=================================================================== 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. ===================================================================*/ // Blueberry #include #include #include // Qmitk #include "QmitkToFUtilView.h" #include #include // Qt #include #include //QT headers #include #include #include // MITK #include #include #include #include #include #include #include #include #include //itk headers #include // VTK #include // ITK #include const std::string QmitkToFUtilView::VIEW_ID = "org.mitk.views.tofutil"; //Constructor QmitkToFUtilView::QmitkToFUtilView() : QmitkAbstractView() , m_Controls(NULL), m_MultiWidget( NULL ) , m_MitkDistanceImage(NULL), m_MitkAmplitudeImage(NULL), m_MitkIntensityImage(NULL), m_Surface(NULL) , m_DistanceImageNode(NULL), m_AmplitudeImageNode(NULL), m_IntensityImageNode(NULL), m_RGBImageNode(NULL), m_SurfaceNode(NULL) , m_ToFImageRecorder(NULL), m_ToFImageGrabber(NULL), m_ToFDistanceImageToSurfaceFilter(NULL), m_ToFCompositeFilter(NULL) , m_2DDisplayCount(0) , m_RealTimeClock(NULL) , m_StepsForFramerate(100) , m_2DTimeBefore(0.0) , m_2DTimeAfter(0.0) , m_CameraIntrinsics(NULL) { this->m_Frametimer = new QTimer(this); this->m_ToFDistanceImageToSurfaceFilter = mitk::ToFDistanceImageToSurfaceFilter::New(); this->m_ToFCompositeFilter = mitk::ToFCompositeFilter::New(); this->m_ToFImageRecorder = mitk::ToFImageRecorder::New(); this->m_ToFSurfaceVtkMapper3D = mitk::ToFSurfaceVtkMapper3D::New(); } //Destructor, specifically calling OnToFCameraStopped() and OnToFCammeraDiconnected() QmitkToFUtilView::~QmitkToFUtilView() { OnToFCameraStopped(); OnToFCameraDisconnected(); } //Createing the PartControl Signal-Slot principal void QmitkToFUtilView::CreateQtPartControl( QWidget *parent ) { // build up qt view, unless already done if ( !m_Controls ) { // create GUI widgets from the Qt Designer's .ui file m_Controls = new Ui::QmitkToFUtilViewControls; m_Controls->setupUi( parent ); //Looking for Input and Defining reaction connect(m_Frametimer, SIGNAL(timeout()), this, SLOT(OnUpdateCamera())); connect( (QObject*)(m_Controls->m_ToFConnectionWidget), SIGNAL(KinectAcquisitionModeChanged()), this, SLOT(OnKinectAcquisitionModeChanged()) ); // Todo in Widget2 connect( (QObject*)(m_Controls->m_ToFConnectionWidget), SIGNAL(ToFCameraConnected()), this, SLOT(OnToFCameraConnected()) ); connect( (QObject*)(m_Controls->m_ToFConnectionWidget), SIGNAL(ToFCameraDisconnected()), this, SLOT(OnToFCameraDisconnected()) ); connect( (QObject*)(m_Controls->m_ToFConnectionWidget), SIGNAL(ToFCameraSelected(const QString)), this, SLOT(OnToFCameraSelected(const QString)) ); connect( (QObject*)(m_Controls->m_ToFRecorderWidget), SIGNAL(ToFCameraStarted()), this, SLOT(OnToFCameraStarted()) ); connect( (QObject*)(m_Controls->m_ToFRecorderWidget), SIGNAL(ToFCameraStopped()), this, SLOT(OnToFCameraStopped()) ); connect( (QObject*)(m_Controls->m_ToFRecorderWidget), SIGNAL(RecordingStarted()), this, SLOT(OnToFCameraStopped()) ); connect( (QObject*)(m_Controls->m_ToFRecorderWidget), SIGNAL(RecordingStopped()), this, SLOT(OnToFCameraStarted()) ); connect( (QObject*)(m_Controls->m_SurfaceCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnSurfaceCheckboxChecked(bool)) ); connect( (QObject*)(m_Controls->m_TextureCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnTextureCheckBoxChecked(bool)) ); connect( (QObject*)(m_Controls->m_KinectTextureCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnKinectRGBTextureCheckBoxChecked(bool)) ); } } //SetFocus-Method -> actually seting Focus to the Recorder void QmitkToFUtilView::SetFocus() { m_Controls->m_ToFRecorderWidget->setFocus(); } //Activated-Method->Generating RenderWindow void QmitkToFUtilView::Activated() { //get the current RenderWindowPart or open a new one if there is none if(this->GetRenderWindowPart(OPEN)) { mitk::ILinkedRenderWindowPart* linkedRenderWindowPart = dynamic_cast(this->GetRenderWindowPart()); if(linkedRenderWindowPart == 0) { MITK_ERROR << "No linked StdMultiWidget avaiable!!!"; } else { linkedRenderWindowPart->EnableSlicingPlanes(false); } GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Axial); GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetSliceNavigationController()->SliceLockedOn(); GetRenderWindowPart()->GetQmitkRenderWindow("sagittal")->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Axial); GetRenderWindowPart()->GetQmitkRenderWindow("sagittal")->GetSliceNavigationController()->SliceLockedOn(); GetRenderWindowPart()->GetQmitkRenderWindow("coronal")->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Axial); GetRenderWindowPart()->GetQmitkRenderWindow("coronal")->GetSliceNavigationController()->SliceLockedOn(); this->GetRenderWindowPart()->GetRenderingManager()->InitializeViews(); this->UseToFVisibilitySettings(true); if (this->m_ToFCompositeFilter) { m_Controls->m_ToFCompositeFilterWidget->SetToFCompositeFilter(this->m_ToFCompositeFilter); } if (this->GetDataStorage()) { m_Controls->m_ToFCompositeFilterWidget->SetDataStorage(this->GetDataStorage()); } if (this->m_ToFImageGrabber.IsNull()) { m_Controls->m_ToFRecorderWidget->setEnabled(false); m_Controls->m_ToFVisualisationSettingsWidget->setEnabled(false); m_Controls->m_ToFCompositeFilterWidget->setEnabled(false); m_Controls->tofMeasurementWidget->setEnabled(false); m_Controls->SurfacePropertiesBox->setEnabled(false); } } } //ZomnnieView-Method -> Resetting GUI to default. Why not just QmitkToFUtilView()?! void QmitkToFUtilView::ActivatedZombieView(berry::IWorkbenchPartReference::Pointer /*zombieView*/) { ResetGUIToDefault(); } void QmitkToFUtilView::Deactivated() { } void QmitkToFUtilView::Visible() { } //Reset of the ToFUtilView void QmitkToFUtilView::Hidden() { ResetGUIToDefault(); } void QmitkToFUtilView::OnToFCameraConnected() { MITK_DEBUG <<"OnToFCameraConnected"; this->m_2DDisplayCount = 0; this->m_ToFImageGrabber = m_Controls->m_ToFConnectionWidget->GetToFImageGrabber(); // initialize surface generation this->m_ToFDistanceImageToSurfaceFilter = mitk::ToFDistanceImageToSurfaceFilter::New(); this->m_ToFSurfaceVtkMapper3D = mitk::ToFSurfaceVtkMapper3D::New(); // initialize ToFImageRecorder and ToFRecorderWidget this->m_ToFImageRecorder = mitk::ToFImageRecorder::New(); this->m_ToFImageRecorder->SetCameraDevice(this->m_ToFImageGrabber->GetCameraDevice()); m_Controls->m_ToFRecorderWidget->SetParameter(this->m_ToFImageGrabber, this->m_ToFImageRecorder); m_Controls->m_ToFRecorderWidget->setEnabled(true); m_Controls->m_ToFRecorderWidget->ResetGUIToInitial(); m_Controls->m_ToFVisualisationSettingsWidget->setEnabled(false); // initialize ToFCompositeFilterWidget this->m_ToFCompositeFilter = mitk::ToFCompositeFilter::New(); if (this->m_ToFCompositeFilter) { m_Controls->m_ToFCompositeFilterWidget->SetToFCompositeFilter(this->m_ToFCompositeFilter); } if (this->GetDataStorage()) { m_Controls->m_ToFCompositeFilterWidget->SetDataStorage(this->GetDataStorage()); } // initialize measurement widget m_Controls->tofMeasurementWidget->InitializeWidget(this->GetRenderWindowPart()->GetQmitkRenderWindows(),this->GetDataStorage(), this->m_ToFDistanceImageToSurfaceFilter->GetCameraIntrinsics()); this->m_RealTimeClock = mitk::RealTimeClock::New(); this->m_2DTimeBefore = this->m_RealTimeClock->GetCurrentStamp(); this->RequestRenderWindowUpdate(); } void QmitkToFUtilView::ResetGUIToDefault() { if(this->GetRenderWindowPart()) { mitk::ILinkedRenderWindowPart* linkedRenderWindowPart = dynamic_cast(this->GetRenderWindowPart()); if(linkedRenderWindowPart == 0) { MITK_ERROR << "No linked StdMultiWidget avaiable!!!"; } else { linkedRenderWindowPart->EnableSlicingPlanes(true); } GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Axial); GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetSliceNavigationController()->SliceLockedOff(); GetRenderWindowPart()->GetQmitkRenderWindow("sagittal")->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Sagittal); GetRenderWindowPart()->GetQmitkRenderWindow("sagittal")->GetSliceNavigationController()->SliceLockedOff(); GetRenderWindowPart()->GetQmitkRenderWindow("coronal")->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Frontal); GetRenderWindowPart()->GetQmitkRenderWindow("coronal")->GetSliceNavigationController()->SliceLockedOff(); this->UseToFVisibilitySettings(false); //global reinit this->GetRenderWindowPart()->GetRenderingManager()->InitializeViews(); this->RequestRenderWindowUpdate(); } } void QmitkToFUtilView::OnToFCameraDisconnected() { m_Controls->m_ToFRecorderWidget->OnStop(); m_Controls->m_ToFRecorderWidget->setEnabled(false); m_Controls->m_ToFVisualisationSettingsWidget->setEnabled(false); m_Controls->tofMeasurementWidget->setEnabled(false); m_Controls->SurfacePropertiesBox->setEnabled(false); //clean up measurement widget m_Controls->tofMeasurementWidget->CleanUpWidget(); } void QmitkToFUtilView::OnKinectAcquisitionModeChanged() { if (m_ToFCompositeFilter.IsNotNull()&&m_ToFImageGrabber.IsNotNull()) { if (m_SelectedCamera.contains("Kinect")) { if (m_ToFImageGrabber->GetBoolProperty("RGB")) { this->m_RGBImageNode = ReplaceNodeData("RGB image",this->m_ToFImageGrabber->GetOutput(3)); this->m_ToFDistanceImageToSurfaceFilter->SetInput(3,this->m_ToFImageGrabber->GetOutput(3)); } else if (m_ToFImageGrabber->GetBoolProperty("IR")) { this->m_MitkAmplitudeImage = m_ToFCompositeFilter->GetOutput(1); this->m_AmplitudeImageNode = ReplaceNodeData("Amplitude image",m_MitkAmplitudeImage); } } this->UseToFVisibilitySettings(true); } } void QmitkToFUtilView::OnToFCameraStarted() { if (m_ToFImageGrabber.IsNotNull()) { // initialize camera intrinsics if (this->m_ToFImageGrabber->GetProperty("CameraIntrinsics")) { m_CameraIntrinsics = dynamic_cast(this->m_ToFImageGrabber->GetProperty("CameraIntrinsics"))->GetValue(); + MITK_INFO << m_CameraIntrinsics->ToString(); } else { m_CameraIntrinsics = NULL; + MITK_ERROR << "No camera intrinsics were found!"; } // initial update of image grabber this->m_ToFImageGrabber->Update(); this->m_ToFCompositeFilter->SetInput(0,this->m_ToFImageGrabber->GetOutput(0)); this->m_ToFCompositeFilter->SetInput(1,this->m_ToFImageGrabber->GetOutput(1)); this->m_ToFCompositeFilter->SetInput(2,this->m_ToFImageGrabber->GetOutput(2)); // initial update of composite filter this->m_ToFCompositeFilter->Update(); this->m_MitkDistanceImage = m_ToFCompositeFilter->GetOutput(0); this->m_DistanceImageNode = ReplaceNodeData("Distance image",m_MitkDistanceImage); std::string rgbFileName; m_ToFImageGrabber->GetCameraDevice()->GetStringProperty("RGBImageFileName",rgbFileName); if ((m_SelectedCamera.contains("Kinect"))||(rgbFileName!="")) { //set the reconstruction mode for kinect this->m_ToFDistanceImageToSurfaceFilter->SetReconstructionMode(mitk::ToFDistanceImageToSurfaceFilter::Kinect); if (rgbFileName!="" || m_ToFImageGrabber->GetBoolProperty("RGB") ) { this->m_RGBImageNode = ReplaceNodeData("RGB image",this->m_ToFImageGrabber->GetOutput(3)); } else if (m_ToFImageGrabber->GetBoolProperty("IR")) { this->m_MitkAmplitudeImage = m_ToFCompositeFilter->GetOutput(1); } } else { this->m_RGBImageNode = NULL; this->m_MitkAmplitudeImage = m_ToFCompositeFilter->GetOutput(1); this->m_AmplitudeImageNode = ReplaceNodeData("Amplitude image",m_MitkAmplitudeImage); this->m_MitkIntensityImage = m_ToFCompositeFilter->GetOutput(2); this->m_IntensityImageNode = ReplaceNodeData("Intensity image",m_MitkIntensityImage); } this->m_AmplitudeImageNode = ReplaceNodeData("Amplitude image",m_MitkAmplitudeImage); this->m_IntensityImageNode = ReplaceNodeData("Intensity image",m_MitkIntensityImage); this->m_ToFDistanceImageToSurfaceFilter->SetInput(0,m_MitkDistanceImage); this->m_ToFDistanceImageToSurfaceFilter->SetInput(1,m_MitkAmplitudeImage); this->m_ToFDistanceImageToSurfaceFilter->SetInput(2,m_MitkIntensityImage); this->m_Surface = this->m_ToFDistanceImageToSurfaceFilter->GetOutput(0); this->m_SurfaceNode = ReplaceNodeData("Surface",m_Surface); this->UseToFVisibilitySettings(true); m_Controls->m_ToFCompositeFilterWidget->UpdateFilterParameter(); // initialize visualization widget m_Controls->m_ToFVisualisationSettingsWidget->Initialize(this->m_DistanceImageNode, this->m_AmplitudeImageNode, this->m_IntensityImageNode); // set distance image to measurement widget m_Controls->tofMeasurementWidget->SetDistanceImage(m_MitkDistanceImage); this->m_Frametimer->start(0); m_Controls->m_ToFVisualisationSettingsWidget->setEnabled(true); m_Controls->m_ToFCompositeFilterWidget->setEnabled(true); m_Controls->tofMeasurementWidget->setEnabled(true); m_Controls->SurfacePropertiesBox->setEnabled(true); if (m_Controls->m_TextureCheckBox->isChecked()) { OnTextureCheckBoxChecked(true); } if (m_Controls->m_KinectTextureCheckBox->isChecked()) { OnKinectRGBTextureCheckBoxChecked(true); } } m_Controls->m_TextureCheckBox->setEnabled(true); } void QmitkToFUtilView::OnToFCameraStopped() { m_Controls->m_ToFVisualisationSettingsWidget->setEnabled(false); m_Controls->m_ToFCompositeFilterWidget->setEnabled(false); m_Controls->SurfacePropertiesBox->setEnabled(false); this->m_Frametimer->stop(); } void QmitkToFUtilView::OnToFCameraSelected(const QString selected) { m_SelectedCamera = selected; if ((selected.contains("CamBoard"))||(selected.contains("O3D"))) { MITK_INFO<<"Surface representation currently not available for CamBoard and O3. Intrinsic parameters missing."; this->m_Controls->m_SurfaceCheckBox->setEnabled(false); this->m_Controls->m_TextureCheckBox->setEnabled(false); this->m_Controls->m_KinectTextureCheckBox->setEnabled(false); this->m_Controls->m_SurfaceCheckBox->setChecked(false); this->m_Controls->m_TextureCheckBox->setChecked(false); this->m_Controls->m_KinectTextureCheckBox->setChecked(false); } else { this->m_Controls->m_SurfaceCheckBox->setEnabled(true); this->m_Controls->m_TextureCheckBox->setEnabled(true); this->m_Controls->m_KinectTextureCheckBox->setEnabled(true); } } void QmitkToFUtilView::OnSurfaceCheckboxChecked(bool checked) { if(checked) { //initialize the surface once MITK_DEBUG << "OnSurfaceCheckboxChecked true"; this->m_SurfaceNode->SetData(this->m_Surface); this->m_SurfaceNode->SetMapper(mitk::BaseRenderer::Standard3D, m_ToFSurfaceVtkMapper3D); //we need to initialize (reinit) the surface, to make it fit into the renderwindow this->GetRenderWindowPart()->GetRenderingManager()->InitializeViews( this->m_Surface->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_3DWINDOWS, true); //the default camera position is rather unfortunate, //that's why we set our own position according to the surface center mitk::Point3D surfaceCenter= this->m_Surface->GetGeometry()->GetCenter(); vtkCamera* camera3d = GetRenderWindowPart()->GetQmitkRenderWindow("3d")->GetRenderer()->GetVtkRenderer()->GetActiveCamera(); //1m distance to camera should be a nice default value for most cameras camera3d->SetPosition(0,0,-1000); camera3d->SetViewUp(0,-1,0); camera3d->SetFocalPoint(0,0,surfaceCenter[2]); camera3d->SetViewAngle(40); camera3d->SetClippingRange(1, 10000); } } void QmitkToFUtilView::OnUpdateCamera() { //##### Code for surface ##### if (m_Controls->m_SurfaceCheckBox->isChecked()) { // update surface m_ToFDistanceImageToSurfaceFilter->SetTextureIndex(m_Controls->m_ToFVisualisationSettingsWidget->GetSelectedImageIndex()); //if the user wants to see the texture, it has to be updated for every frame if(m_Controls->m_KinectTextureCheckBox->isChecked() && (m_SelectedCamera.contains("Kinect")) && (m_ToFImageGrabber->GetBoolProperty("RGB"))) { //remove the vtkScalarsToColors object, if there was one. this->m_ToFSurfaceVtkMapper3D->SetVtkScalarsToColors(NULL); //set RGB-iamge as texture this->m_ToFSurfaceVtkMapper3D->SetTexture((this->m_ToFImageGrabber->GetOutput(3)->GetVtkImageData())); } else { //we have to delete the texture, if there was one. this->m_ToFSurfaceVtkMapper3D->SetTexture(NULL); //get the colortransferfunction from the visualization widget this->m_ToFSurfaceVtkMapper3D->SetVtkScalarsToColors(m_Controls->m_ToFVisualisationSettingsWidget->GetSelectedColorTransferFunction()); } //update pipeline this->m_Surface->Update(); } //##### End code for surface ##### else { // update pipeline this->m_MitkDistanceImage->Update(); } this->RequestRenderWindowUpdate(); this->m_2DDisplayCount++; if ((this->m_2DDisplayCount % this->m_StepsForFramerate) == 0) { this->m_2DTimeAfter = this->m_RealTimeClock->GetCurrentStamp() - this->m_2DTimeBefore; MITK_INFO << " 2D-Display-framerate (fps): " << this->m_StepsForFramerate / (this->m_2DTimeAfter/1000); this->m_2DTimeBefore = this->m_RealTimeClock->GetCurrentStamp(); } } void QmitkToFUtilView::OnTextureCheckBoxChecked(bool checked) { if(m_SurfaceNode.IsNotNull()) { if (checked) { this->m_SurfaceNode->SetBoolProperty("scalar visibility", true); } else { this->m_SurfaceNode->SetBoolProperty("scalar visibility", false); } } } void QmitkToFUtilView::OnKinectRGBTextureCheckBoxChecked(bool checked) { if((m_SelectedCamera.contains("Kinect")) && (m_ToFImageGrabber->GetBoolProperty("RGB"))) { if (checked) { //define the dimensions of the texture this->m_ToFDistanceImageToSurfaceFilter->SetTextureImageWidth(this->m_ToFImageGrabber->GetOutput(3)->GetDimension(0)); this->m_ToFDistanceImageToSurfaceFilter->SetTextureImageHeight(this->m_ToFImageGrabber->GetOutput(3)->GetDimension(1)); } } } void QmitkToFUtilView::OnChangeCoronalWindowOutput(int index) { this->OnToFCameraStopped(); if(index == 0) { if(this->m_IntensityImageNode.IsNotNull()) this->m_IntensityImageNode->SetVisibility(false); if(this->m_RGBImageNode.IsNotNull()) this->m_RGBImageNode->SetVisibility(true); } else if(index == 1) { if(this->m_IntensityImageNode.IsNotNull()) this->m_IntensityImageNode->SetVisibility(true); if(this->m_RGBImageNode.IsNotNull()) this->m_RGBImageNode->SetVisibility(false); } this->RequestRenderWindowUpdate(); this->OnToFCameraStarted(); } mitk::DataNode::Pointer QmitkToFUtilView::ReplaceNodeData( std::string nodeName, mitk::BaseData* data ) { mitk::DataNode::Pointer node = this->GetDataStorage()->GetNamedNode(nodeName); if (node.IsNull()) { node = mitk::DataNode::New(); node->SetData(data); node->SetName(nodeName); node->SetBoolProperty("binary",false); this->GetDataStorage()->Add(node); } else { node->SetData(data); } return node; } void QmitkToFUtilView::UseToFVisibilitySettings(bool useToF) { // set node properties if (m_DistanceImageNode.IsNotNull()) { this->m_DistanceImageNode->SetProperty( "visible" , mitk::BoolProperty::New( true )); this->m_DistanceImageNode->SetVisibility( !useToF, mitk::BaseRenderer::GetInstance(GetRenderWindowPart()->GetQmitkRenderWindow("sagittal")->GetRenderWindow() ) ); this->m_DistanceImageNode->SetVisibility( !useToF, mitk::BaseRenderer::GetInstance(GetRenderWindowPart()->GetQmitkRenderWindow("coronal")->GetRenderWindow() ) ); this->m_DistanceImageNode->SetVisibility( !useToF, mitk::BaseRenderer::GetInstance(GetRenderWindowPart()->GetQmitkRenderWindow("3d")->GetRenderWindow() ) ); this->m_DistanceImageNode->SetBoolProperty("use color",!useToF); this->m_DistanceImageNode->GetPropertyList()->DeleteProperty("LookupTable"); } if (m_AmplitudeImageNode.IsNotNull()) { if ((m_SelectedCamera.contains("Kinect"))&&(m_ToFImageGrabber->GetBoolProperty("RGB"))) { this->m_AmplitudeImageNode->SetProperty( "visible" , mitk::BoolProperty::New( false )); } else { this->m_AmplitudeImageNode->SetProperty( "visible" , mitk::BoolProperty::New( true )); } this->m_AmplitudeImageNode->SetVisibility( !useToF, mitk::BaseRenderer::GetInstance(GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetRenderWindow() ) ); this->m_AmplitudeImageNode->SetVisibility( !useToF, mitk::BaseRenderer::GetInstance(GetRenderWindowPart()->GetQmitkRenderWindow("coronal")->GetRenderWindow() ) ); this->m_AmplitudeImageNode->SetVisibility( !useToF, mitk::BaseRenderer::GetInstance(GetRenderWindowPart()->GetQmitkRenderWindow("3d")->GetRenderWindow() ) ); this->m_AmplitudeImageNode->SetBoolProperty("use color",!useToF); this->m_AmplitudeImageNode->GetPropertyList()->DeleteProperty("LookupTable"); } if (m_IntensityImageNode.IsNotNull()) { if (m_SelectedCamera.contains("Kinect")) { this->m_IntensityImageNode->SetProperty( "visible" , mitk::BoolProperty::New( false )); } else { this->m_IntensityImageNode->SetProperty( "visible" , mitk::BoolProperty::New( true )); this->m_IntensityImageNode->SetVisibility( !useToF, mitk::BaseRenderer::GetInstance(GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetRenderWindow() ) ); this->m_IntensityImageNode->SetVisibility( !useToF, mitk::BaseRenderer::GetInstance(GetRenderWindowPart()->GetQmitkRenderWindow("sagittal")->GetRenderWindow() ) ); this->m_IntensityImageNode->SetVisibility( !useToF, mitk::BaseRenderer::GetInstance(GetRenderWindowPart()->GetQmitkRenderWindow("3d")->GetRenderWindow() ) ); this->m_IntensityImageNode->SetBoolProperty("use color",!useToF); this->m_IntensityImageNode->GetPropertyList()->DeleteProperty("LookupTable"); } } if ((m_RGBImageNode.IsNotNull())) { if ((m_SelectedCamera.contains("Kinect"))&&(m_ToFImageGrabber->GetBoolProperty("IR"))) { this->m_RGBImageNode->SetProperty( "visible" , mitk::BoolProperty::New( false )); } else { this->m_RGBImageNode->SetProperty( "visible" , mitk::BoolProperty::New( true )); this->m_RGBImageNode->SetVisibility( !useToF, mitk::BaseRenderer::GetInstance(GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetRenderWindow() ) ); this->m_RGBImageNode->SetVisibility( !useToF, mitk::BaseRenderer::GetInstance(GetRenderWindowPart()->GetQmitkRenderWindow("sagittal")->GetRenderWindow() ) ); this->m_RGBImageNode->SetVisibility( !useToF, mitk::BaseRenderer::GetInstance(GetRenderWindowPart()->GetQmitkRenderWindow("3d")->GetRenderWindow() ) ); } } // initialize images if (m_MitkDistanceImage.IsNotNull()) { this->GetRenderWindowPart()->GetRenderingManager()->InitializeViews( this->m_MitkDistanceImage->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_2DWINDOWS, true); } if(this->m_SurfaceNode.IsNotNull()) { QHash renderWindowHashMap = this->GetRenderWindowPart()->GetQmitkRenderWindows(); QHashIterator i(renderWindowHashMap); while (i.hasNext()){ i.next(); this->m_SurfaceNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(i.value()->GetRenderWindow()) ); } this->m_SurfaceNode->SetVisibility( true, mitk::BaseRenderer::GetInstance(GetRenderWindowPart()->GetQmitkRenderWindow("3d")->GetRenderWindow() ) ); } //disable/enable gradient background this->GetRenderWindowPart()->EnableDecorations(!useToF, QStringList(QString("background"))); }