diff --git a/Modules/ToFHardware/Testing/files.cmake b/Modules/ToFHardware/Testing/files.cmake index 77fd5af217..c2997f92f5 100644 --- a/Modules/ToFHardware/Testing/files.cmake +++ b/Modules/ToFHardware/Testing/files.cmake @@ -1,30 +1,29 @@ set(MODULE_TESTS mitkThreadedToFRawDataReconstructionTest.cpp mitkToFCameraMITKPlayerControllerTest.cpp mitkToFCameraMITKPlayerDeviceTest.cpp mitkToFCameraPMDCamBoardControllerTest.cpp mitkToFCameraPMDCamBoardDeviceTest.cpp #mitkToFCameraPMDRawDataCamBoardDeviceTest.cpp mitkToFCameraPMDCamCubeControllerTest.cpp mitkToFCameraPMDCamCubeDeviceTest.cpp #mitkToFCameraPMDRawDataCamCubeDeviceTest.cpp mitkToFCameraPMDControllerTest.cpp mitkToFCameraPMDDeviceTest.cpp mitkToFCameraPMDRawDataDeviceTest.cpp mitkToFCameraPMDMITKPlayerControllerTest.cpp mitkToFCameraPMDMITKPlayerDeviceTest.cpp mitkToFCameraPMDO3ControllerTest.cpp mitkToFCameraPMDO3DeviceTest.cpp mitkToFCameraPMDPlayerControllerTest.cpp mitkToFCameraPMDPlayerDeviceTest.cpp mitkToFImageCsvWriterTest.cpp mitkToFImageGrabberTest.cpp - mitkToFImageGrabberCreatorTest.cpp mitkToFImageRecorderTest.cpp mitkToFImageRecorderFilterTest.cpp mitkToFImageWriterTest.cpp mitkToFNrrdImageWriterTest.cpp mitkToFPicImageWriterTest.cpp mitkToFOpenCVImageGrabberTest.cpp ) diff --git a/Modules/ToFHardware/Testing/mitkToFImageGrabberCreatorTest.cpp b/Modules/ToFHardware/Testing/mitkToFImageGrabberCreatorTest.cpp deleted file mode 100644 index cbcf0cf5b9..0000000000 --- a/Modules/ToFHardware/Testing/mitkToFImageGrabberCreatorTest.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2010-03-12 14:05:50 +0100 (Fr, 12 Mrz 2010) $ -Version: $Revision: 16010 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -/**Documentation - * test for the class "ToFImageGrabberCreatorCreator". - */ -int mitkToFImageGrabberCreatorTest(int /* argc */, char* /*argv*/[]) -{ - MITK_TEST_BEGIN("ToFImageGrabberCreator"); - - MITK_TEST_CONDITION_REQUIRED(mitk::ToFImageGrabberCreator::GetInstance()!=NULL,"Test GetInstance()"); - mitk::ToFImageGrabber::Pointer imageGrabber = NULL; - // ToFCameraMITKPlayer - imageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetMITKPlayerImageGrabber(); - MITK_TEST_CONDITION_REQUIRED(imageGrabber.IsNotNull(),"Test if MITKPlayerImageGrabber could be created"); - mitk::ToFCameraMITKPlayerDevice* mitkPlayerDevice - = dynamic_cast(imageGrabber->GetCameraDevice()); - MITK_TEST_CONDITION_REQUIRED(mitkPlayerDevice!=NULL,"Test if image grabber was initialized with ToFCameraMITKPlayerDevice"); - // ToFCameraPMDCamCube - imageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDCamCubeImageGrabber(); - MITK_TEST_CONDITION_REQUIRED(imageGrabber.IsNotNull(),"Test if MITKPlayerImageGrabber could be created"); - mitk::ToFCameraPMDCamCubeDevice* camCubeDevice - = dynamic_cast(imageGrabber->GetCameraDevice()); - MITK_TEST_CONDITION_REQUIRED(camCubeDevice!=NULL,"Test if image grabber was initialized with ToFCameraPMDCamCubeDevice"); - // ToFCameraPMDRawDataCamCube - imageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDRawDataCamCubeImageGrabber(); - MITK_TEST_CONDITION_REQUIRED(imageGrabber.IsNotNull(),"Test if MITKPlayerImageGrabber could be created"); - mitk::ToFCameraPMDRawDataCamCubeDevice* camCubeRawDevice - = dynamic_cast(imageGrabber->GetCameraDevice()); - MITK_TEST_CONDITION_REQUIRED(camCubeRawDevice!=NULL,"Test if image grabber was initialized"); - MITK_TEST_CONDITION_REQUIRED(!strcmp(camCubeRawDevice->GetNameOfClass(), "ToFCameraPMDRawDataCamCubeDevice"), "Test if image grabber was initialized with ToFCameraPMDRawDataCamCubeDevice"); - // ToFCameraPMDCamBoard - imageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDCamBoardImageGrabber(); - MITK_TEST_CONDITION_REQUIRED(imageGrabber.IsNotNull(),"Test if MITKPlayerImageGrabber could be created"); - mitk::ToFCameraPMDCamBoardDevice* camBoardDevice - = dynamic_cast(imageGrabber->GetCameraDevice()); - MITK_TEST_CONDITION_REQUIRED(camBoardDevice!=NULL,"Test if image grabber was initialized with ToFCameraPMDCamBoardDevice"); - // ToFCameraPMDRawDataCamBoard - imageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDRawDataCamBoardImageGrabber(); - MITK_TEST_CONDITION_REQUIRED(imageGrabber.IsNotNull(),"Test if MITKPlayerImageGrabber could be created"); - mitk::ToFCameraPMDRawDataCamBoardDevice* camBoardRawDevice - = dynamic_cast(imageGrabber->GetCameraDevice()); - MITK_TEST_CONDITION_REQUIRED(camBoardRawDevice!=NULL,"Test if image grabber was initialized with ToFCameraPMDRawDataCamBoardDevice"); - MITK_TEST_CONDITION_REQUIRED(!strcmp(camBoardRawDevice->GetNameOfClass(), "ToFCameraPMDRawDataCamBoardDevice"), "Test if image grabber was initialized with ToFCameraPMDRawDataCamCubeDevice"); - // ToFCameraPMDPlayer - imageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDPlayerImageGrabber(); - MITK_TEST_CONDITION_REQUIRED(imageGrabber.IsNotNull(),"Test if MITKPlayerImageGrabber could be created"); - mitk::ToFCameraPMDPlayerDevice* pmdPlayerDevice - = dynamic_cast(imageGrabber->GetCameraDevice()); - MITK_TEST_CONDITION_REQUIRED(pmdPlayerDevice!=NULL,"Test if image grabber was initialized with ToFCameraPMDPlayerDevice"); - // ToFCameraPMDMITKPlayer - imageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDMITKPlayerImageGrabber(); - MITK_TEST_CONDITION_REQUIRED(imageGrabber.IsNotNull(),"Test if MITKPlayerImageGrabber could be created"); - mitk::ToFCameraPMDMITKPlayerDevice* pmdMITKPlayerDevice - = dynamic_cast(imageGrabber->GetCameraDevice()); - MITK_TEST_CONDITION_REQUIRED(pmdMITKPlayerDevice!=NULL,"Test if image grabber was initialized with ToFCameraPMDMITKPlayerDevice"); - - MITK_TEST_END(); -} - - diff --git a/Modules/ToFHardware/Testing/mitkToFOpenCVImageGrabberTest.cpp b/Modules/ToFHardware/Testing/mitkToFOpenCVImageGrabberTest.cpp index 98150702c5..4418d9da61 100644 --- a/Modules/ToFHardware/Testing/mitkToFOpenCVImageGrabberTest.cpp +++ b/Modules/ToFHardware/Testing/mitkToFOpenCVImageGrabberTest.cpp @@ -1,99 +1,100 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-12 14:05:50 +0100 (Fr, 12 Mrz 2010) $ Version: $Revision: 16010 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include #include #include #include +#include #include -#include static bool CompareImages(mitk::Image::Pointer mitkImage, cv::Mat openCVImage) { float equal = true; if ((mitkImage->GetDimension(0)!=openCVImage.cols)||(mitkImage->GetDimension(1)!=openCVImage.rows)) { equal = false; } for (unsigned int i=0; iGetPixelValueByIndex(currentIndex); float openCVImageValue = openCVImage.at(j,i); if (!mitk::Equal(mitkImageValue,openCVImageValue)) { equal = false; } } } return equal; } /**Documentation * test for the class "ToFOpenCVImageGrabber". */ int mitkToFOpenCVImageGrabberTest(int /* argc */, char* /*argv*/[]) { MITK_TEST_BEGIN("ToFOpenCVImageGrabber"); std::string dirName = MITK_TOF_DATA_DIR; - mitk::ToFImageGrabber::Pointer tofImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetMITKPlayerImageGrabber(); + mitk::ToFImageGrabber::Pointer tofImageGrabber = mitk::ToFImageGrabber::New(); + tofImageGrabber->SetCameraDevice(mitk::ToFCameraMITKPlayerDevice::New()); std::string distanceFileName = dirName + "/PMDCamCube2_MF0_IT0_1Images_DistanceImage.pic"; tofImageGrabber->SetProperty("DistanceImageFileName",mitk::StringProperty::New(distanceFileName)); std::string amplitudeFileName = dirName + "/PMDCamCube2_MF0_IT0_1Images_AmplitudeImage.pic"; tofImageGrabber->SetProperty("AmplitudeImageFileName",mitk::StringProperty::New(amplitudeFileName)); std::string intensityFileName = dirName + "/PMDCamCube2_MF0_IT0_1Images_IntensityImage.pic"; tofImageGrabber->SetProperty("IntensityImageFileName",mitk::StringProperty::New(intensityFileName)); mitk::PicFileReader::Pointer mitkFileReader = mitk::PicFileReader::New(); mitkFileReader->SetFileName(distanceFileName); mitkFileReader->Update(); mitk::Image::Pointer image = mitkFileReader->GetOutput(); mitk::ToFOpenCVImageGrabber::Pointer tofOpenCVImageGrabber = mitk::ToFOpenCVImageGrabber::New(); tofOpenCVImageGrabber->SetToFImageGrabber(tofImageGrabber); MITK_TEST_CONDITION_REQUIRED(tofImageGrabber==tofOpenCVImageGrabber->GetToFImageGrabber(),"Test Set/GetToFImageGrabber()"); MITK_TEST_OUTPUT(<<"Call StartCapturing()"); tofOpenCVImageGrabber->StartCapturing(); cv::Mat cvImage = tofOpenCVImageGrabber->GetImage(); MITK_TEST_CONDITION_REQUIRED(CompareImages(image,cvImage),"Test distance image"); mitkFileReader->SetFileName(amplitudeFileName); mitkFileReader->Update(); image = mitkFileReader->GetOutput(); tofOpenCVImageGrabber->SetImageType(1); cvImage = tofOpenCVImageGrabber->GetImage(); MITK_TEST_CONDITION_REQUIRED(CompareImages(image,cvImage),"Test amplitude image"); mitkFileReader->SetFileName(intensityFileName); mitkFileReader->Update(); image = mitkFileReader->GetOutput(); tofOpenCVImageGrabber->SetImageType(2); cvImage = tofOpenCVImageGrabber->GetImage(); MITK_TEST_CONDITION_REQUIRED(CompareImages(image,cvImage),"Test intensity image"); MITK_TEST_OUTPUT(<<"Call StopCapturing()"); tofOpenCVImageGrabber->StopCapturing(); MITK_TEST_END(); } diff --git a/Modules/ToFHardware/files.cmake b/Modules/ToFHardware/files.cmake index 03e6cd4390..ae37b3d22f 100644 --- a/Modules/ToFHardware/files.cmake +++ b/Modules/ToFHardware/files.cmake @@ -1,96 +1,95 @@ set(CPP_FILES - mitkToFImageGrabberCreator.cpp mitkToFImageGrabber.cpp mitkToFOpenCVImageGrabber.cpp mitkToFCameraDevice.cpp mitkToFCameraMITKPlayerController.cpp mitkToFCameraMITKPlayerDevice.cpp mitkToFCameraPMDDevice.cpp mitkToFCameraPMDRawDataDevice.cpp mitkToFCameraPMDPlayerDevice.cpp mitkToFCameraPMDMITKPlayerDevice.cpp mitkToFCameraPMDO3Device.cpp mitkToFCameraPMDCamCubeDevice.cpp mitkToFCameraPMDRawDataCamCubeDevice.cpp mitkToFCameraPMDCamBoardDevice.cpp mitkToFCameraPMDRawDataCamBoardDevice.cpp mitkToFCameraMESADevice.cpp mitkToFCameraMESASR4000Device.cpp mitkToFImageRecorder.cpp mitkToFImageRecorderFilter.cpp mitkToFImageWriter.cpp mitkToFNrrdImageWriter.cpp mitkToFPicImageWriter.cpp mitkToFImageCsvWriter.cpp mitkThreadedToFRawDataReconstruction.cpp ) if(MITK_USE_TOF_PMDCAMCUBE) set(CPP_FILES ${CPP_FILES} mitkToFCameraPMDMITKPlayerController.cpp mitkToFCameraPMDCamCubeController.cpp mitkToFCameraPMDController.cpp ) if(WIN32) if(CMAKE_CL_64) set(CPP_FILES ${CPP_FILES} mitkToFCameraPMDPlayerControllerStub.cpp) else(CMAKE_CL_64) set(CPP_FILES ${CPP_FILES} mitkToFCameraPMDPlayerController.cpp) endif(CMAKE_CL_64) else(WIN32) set(CPP_FILES ${CPP_FILES} mitkToFCameraPMDPlayerControllerStub.cpp) endif(WIN32) else() set(CPP_FILES ${CPP_FILES} mitkToFCameraPMDMITKPlayerControllerStub.cpp mitkToFCameraPMDCamCubeControllerStub.cpp mitkToFCameraPMDPlayerControllerStub.cpp ) endif(MITK_USE_TOF_PMDCAMCUBE) if(MITK_USE_TOF_PMDCAMBOARD) set(CPP_FILES ${CPP_FILES} mitkToFCameraPMDCamBoardController.cpp mitkToFCameraPMDController.cpp ) else() set(CPP_FILES ${CPP_FILES} mitkToFCameraPMDCamBoardControllerStub.cpp ) endif(MITK_USE_TOF_PMDCAMBOARD) if(MITK_USE_TOF_PMDO3) set(CPP_FILES ${CPP_FILES} mitkToFCameraPMDO3Controller.cpp mitkToFCameraPMDController.cpp ) else() set(CPP_FILES ${CPP_FILES} mitkToFCameraPMDO3ControllerStub.cpp ) endif(MITK_USE_TOF_PMDO3) if(NOT MITK_USE_TOF_PMDCAMCUBE) if(NOT MITK_USE_TOF_PMDCAMBOARD) if(NOT MITK_USE_TOF_PMDO3) set(CPP_FILES ${CPP_FILES} mitkToFCameraPMDControllerStub.cpp ) endif(NOT MITK_USE_TOF_PMDO3) endif(NOT MITK_USE_TOF_PMDCAMBOARD) endif(NOT MITK_USE_TOF_PMDCAMCUBE) if(MITK_USE_TOF_MESASR4000) set(CPP_FILES ${CPP_FILES} mitkToFCameraMESASR4000Controller.cpp mitkToFCameraMESAController.cpp ) else() set(CPP_FILES ${CPP_FILES} mitkToFCameraMESAControllerStub.cpp mitkToFCameraMESASR4000ControllerStub.cpp ) endif(MITK_USE_TOF_MESASR4000) diff --git a/Modules/ToFHardware/mitkToFImageGrabber.h b/Modules/ToFHardware/mitkToFImageGrabber.h index fa02437c58..9e46100624 100644 --- a/Modules/ToFHardware/mitkToFImageGrabber.h +++ b/Modules/ToFHardware/mitkToFImageGrabber.h @@ -1,173 +1,172 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile$ Language: C++ Date: $Date: 2010-05-27 16:06:53 +0200 (Do, 27 Mai 2010) $ Version: $Revision: $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __mitkToFImageGrabber_h #define __mitkToFImageGrabber_h #include "mitkToFHardwareExports.h" #include "mitkCommon.h" #include "mitkImageSource.h" #include "mitkToFCameraDevice.h" #include "itkObject.h" #include "itkObjectFactory.h" namespace mitk { /**Documentation * \brief Image source providing ToF images. Interface for filters provided in ToFProcessing module * * This class internally holds a ToFCameraDevice to access the images acquired by a ToF camera. - * A pre-configured instance for a specific ToF camera (e.g. PMD CamCube 3) can be obtained using - * the class ToFImageGrabberCreator. + * * Provided images include: distance image (output 0), amplitude image (output 1), intensity image (output 2) * * \ingroup ToFHardware */ class MITK_TOFHARDWARE_EXPORT ToFImageGrabber : public mitk::ImageSource { public: mitkClassMacro( ToFImageGrabber , ImageSource ); itkNewMacro( Self ); /*! \brief Establish a connection to the ToF camera \param device specifies the actually used ToF Camera. 0: PMD O3D, 1: PMD CamCube 2.0 */ virtual bool ConnectCamera(); /*! \brief Disconnects the ToF 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 */ virtual void StartCamera(); /*! \brief Stops the continuous updating of the camera */ virtual void StopCamera(); /*! \brief Returns true if the camera is connected and started */ virtual bool IsCameraActive(); /*! \brief Sets the ToF device, the image grabber is grabbing the images from \param aToFCameraDevice device internally used for grabbing the images from the camera */ void SetCameraDevice(ToFCameraDevice* aToFCameraDevice); /*! \brief Get the currently set ToF camera device \return device currently used for grabbing images from the camera */ ToFCameraDevice* GetCameraDevice(); /*! \brief Set the modulation frequency used by the ToF camera. For default values see the corresponding device classes \param modulationFrequency modulation frequency in Hz */ int SetModulationFrequency(int modulationFrequency); /*! \brief Get the modulation frequency used by the ToF camera. \return modulation frequency in MHz */ int GetModulationFrequency(); /*! \brief Set the integration time used by the ToF camera. For default values see the corresponding device classes \param integrationTime integration time in ms */ int SetIntegrationTime(int integrationTime); /*! \brief Get the integration time in used by the ToF camera. \return integration time in ms */ int GetIntegrationTime(); /*! \brief Get the dimension in x direction of the ToF image \return width of the image */ int GetCaptureWidth(); /*! \brief Get the dimension in y direction of the ToF image \return height of the image */ int GetCaptureHeight(); /*! \brief Get the number of pixel in the ToF image \return number of pixel */ int GetPixelNumber(); // properties void SetBoolProperty( const char* propertyKey, bool boolValue ); void SetIntProperty( const char* propertyKey, int intValue ); void SetFloatProperty( const char* propertyKey, float floatValue ); void SetStringProperty( const char* propertyKey, const char* stringValue ); void SetProperty( const char *propertyKey, BaseProperty* propertyValue ); protected: /// /// called when the ToFCameraDevice was modified /// void OnToFCameraDeviceModified(); /*! \brief clean up memory allocated for the image arrays m_IntensityArray, m_DistanceArray, m_AmplitudeArray and m_SourceDataArray */ virtual void CleanUpImageArrays(); /*! \brief Allocate memory for the image arrays m_IntensityArray, m_DistanceArray, m_AmplitudeArray and m_SourceDataArray */ virtual void AllocateImageArrays(); ToFCameraDevice::Pointer m_ToFCameraDevice; ///< Device allowing acces to ToF image data int m_CaptureWidth; ///< Width of the captured ToF image int m_CaptureHeight; ///< Height of the captured ToF image int m_PixelNumber; ///< Number of pixels in the image int m_ImageSequence; ///< counter for currently acquired images int m_SourceDataSize; ///< size of the source data in bytes float* m_IntensityArray; ///< member holding the current intensity array float* m_DistanceArray; ///< member holding the current distance array float* m_AmplitudeArray; ///< member holding the current amplitude array char* m_SourceDataArray;///< member holding the current source data array unsigned long m_DeviceObserverTag; ///< tag of the oberver for the the ToFCameraDevice ToFImageGrabber(); ~ToFImageGrabber(); /*! \brief Method generating the outputs of this filter. Called in the updated process of the pipeline. 0: distance image 1: amplitude image 2: intensity image */ void GenerateData(); private: }; } //END mitk namespace #endif diff --git a/Modules/ToFHardware/mitkToFImageGrabberCreator.cpp b/Modules/ToFHardware/mitkToFImageGrabberCreator.cpp deleted file mode 100644 index e3093d0656..0000000000 --- a/Modules/ToFHardware/mitkToFImageGrabberCreator.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Module: $RCSfile$ -Language: C++ -Date: $Date: 2010-05-27 16:06:53 +0200 (Do, 27 Mai 2010) $ -Version: $Revision: $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ -#include "mitkToFImageGrabberCreator.h" -#include "mitkToFImageGrabber.h" -#include "mitkToFCameraPMDCamCubeDevice.h" -#include "mitkToFCameraPMDRawDataCamCubeDevice.h" -#include "mitkToFCameraPMDCamBoardDevice.h" -#include "mitkToFCameraPMDRawDataCamBoardDevice.h" -#include "mitkToFCameraPMDO3Device.h" -#include "mitkToFCameraPMDPlayerDevice.h" -#include "mitkToFCameraPMDMITKPlayerDevice.h" -#include "mitkToFCameraMITKPlayerDevice.h" -#include "mitkToFCameraMESASR4000Device.h" - -namespace mitk -{ - - ToFImageGrabberCreator::Pointer ToFImageGrabberCreator::s_Instance = NULL; - - ToFImageGrabberCreator::ToFImageGrabberCreator() - { - m_ToFImageGrabber = mitk::ToFImageGrabber::New(); - } - - ToFImageGrabberCreator::~ToFImageGrabberCreator() - { - } - - ToFImageGrabberCreator* ToFImageGrabberCreator::GetInstance() - { - if ( !ToFImageGrabberCreator::s_Instance ) - { - s_Instance = ToFImageGrabberCreator::New(); - } - return s_Instance; - } - - ToFImageGrabber::Pointer ToFImageGrabberCreator::GetPMDCamCubeImageGrabber() - { - m_ToFCameraDevice = mitk::ToFCameraPMDCamCubeDevice::New(); - m_ToFImageGrabber->SetCameraDevice(m_ToFCameraDevice); - return m_ToFImageGrabber; - } - - ToFImageGrabber::Pointer ToFImageGrabberCreator::GetPMDRawDataCamCubeImageGrabber() - { - m_ToFCameraDevice = mitk::ToFCameraPMDRawDataCamCubeDevice::New(); - m_ToFImageGrabber->SetCameraDevice(m_ToFCameraDevice); - return m_ToFImageGrabber; - } - - ToFImageGrabber::Pointer ToFImageGrabberCreator::GetPMDO3ImageGrabber() - { - m_ToFCameraDevice = mitk::ToFCameraPMDO3Device::New(); - m_ToFImageGrabber->SetCameraDevice(m_ToFCameraDevice); - return m_ToFImageGrabber; - } - - ToFImageGrabber::Pointer ToFImageGrabberCreator::GetPMDCamBoardImageGrabber() - { - m_ToFCameraDevice = mitk::ToFCameraPMDCamBoardDevice::New(); - m_ToFImageGrabber->SetCameraDevice(m_ToFCameraDevice); - return m_ToFImageGrabber; - } - - ToFImageGrabber::Pointer ToFImageGrabberCreator::GetPMDRawDataCamBoardImageGrabber() - { - m_ToFCameraDevice = mitk::ToFCameraPMDRawDataCamBoardDevice::New(); - m_ToFImageGrabber->SetCameraDevice(m_ToFCameraDevice); - return m_ToFImageGrabber; - } - - ToFImageGrabber::Pointer ToFImageGrabberCreator::GetPMDPlayerImageGrabber() - { - m_ToFCameraDevice = mitk::ToFCameraPMDPlayerDevice::New(); - m_ToFImageGrabber->SetCameraDevice(m_ToFCameraDevice); - return m_ToFImageGrabber; - } - - ToFImageGrabber::Pointer ToFImageGrabberCreator::GetPMDMITKPlayerImageGrabber() - { - m_ToFCameraDevice = mitk::ToFCameraPMDMITKPlayerDevice::New(); - m_ToFImageGrabber->SetCameraDevice(m_ToFCameraDevice); - return m_ToFImageGrabber; - } - - ToFImageGrabber::Pointer ToFImageGrabberCreator::GetMITKPlayerImageGrabber() - { - m_ToFCameraDevice = mitk::ToFCameraMITKPlayerDevice::New(); - m_ToFImageGrabber->SetCameraDevice(m_ToFCameraDevice); - return m_ToFImageGrabber; - } - - ToFImageGrabber::Pointer ToFImageGrabberCreator::GetMESASR4000ImageGrabber() - { - m_ToFCameraDevice = mitk::ToFCameraMESASR4000Device::New(); - m_ToFImageGrabber->SetCameraDevice(m_ToFCameraDevice); - return m_ToFImageGrabber; - } - -} diff --git a/Modules/ToFHardware/mitkToFImageGrabberCreator.h b/Modules/ToFHardware/mitkToFImageGrabberCreator.h deleted file mode 100644 index af32c44505..0000000000 --- a/Modules/ToFHardware/mitkToFImageGrabberCreator.h +++ /dev/null @@ -1,114 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Module: $RCSfile$ -Language: C++ -Date: $Date: 2010-05-27 16:06:53 +0200 (Do, 27 Mai 2010) $ -Version: $Revision: $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ -#ifndef __mitkToFImageGrabberCreator_h -#define __mitkToFImageGrabberCreator_h - -#include "mitkToFHardwareExports.h" -#include "mitkCommon.h" -#include "mitkToFImageGrabber.h" -#include "mitkToFCameraDevice.h" - -#include "itkObject.h" -#include "itkObjectFactory.h" - -namespace mitk -{ - /** - * @brief Class providing ready-to-use instances of ToFImageGrabbers - * This singleton can be used to create ToFImageGrabber objects of - * the supported ToF cameras. The ImageGrabbers are already initialized - * with the correct device object. - * When new hardware is added to MITK-ToF they should also be included in - * this creator class. - * - * @ingroup ToFHardware - */ - class MITK_TOFHARDWARE_EXPORT ToFImageGrabberCreator : public itk::Object - { - public: - - mitkClassMacro( ToFImageGrabberCreator , itk::Object ); - - itkNewMacro( Self ); - - /*! - \brief Get the RenderingManager singleton instance. - */ - static ToFImageGrabberCreator* GetInstance(); - - /*! - \brief Create a ImageGrabber object with a PMD CamCube Camera - */ - ToFImageGrabber::Pointer GetPMDCamCubeImageGrabber(); - - /*! - \brief Create a ImageGrabber object with a PMD raw data CamCube Camera - */ - ToFImageGrabber::Pointer GetPMDRawDataCamCubeImageGrabber(); - - /*! - \brief Create a ImageGrabber object with a PMD O3 Camera - */ - ToFImageGrabber::Pointer GetPMDO3ImageGrabber(); - - /*! - \brief Create a ImageGrabber object with a PMD CamBoard Camera - */ - ToFImageGrabber::Pointer GetPMDCamBoardImageGrabber(); - - /*! - \brief Create a ImageGrabber object with a PMD raw data CamBoard Camera - */ - ToFImageGrabber::Pointer GetPMDRawDataCamBoardImageGrabber(); - - /*! - \brief Create a ImageGrabber object with a PMD Player Camera - */ - ToFImageGrabber::Pointer GetPMDPlayerImageGrabber(); - - /*! - \brief Create a ImageGrabber object with a PMD MITK Player Camera - */ - ToFImageGrabber::Pointer GetPMDMITKPlayerImageGrabber(); - - /*! - \brief Create a ImageGrabber object with a MITK Player Camera - */ - ToFImageGrabber::Pointer GetMITKPlayerImageGrabber(); - - /*! - \brief Create a ImageGrabber object with a MESA SR4000 Camera - */ - ToFImageGrabber::Pointer GetMESASR4000ImageGrabber(); - - protected: - - static ToFImageGrabberCreator::Pointer s_Instance; ///< Instance to the singleton ToFImageGrabberCreator. Can be accessed by GetInstance() - - ToFCameraDevice::Pointer m_ToFCameraDevice; ///< ToFCameraDevice currently used in the provided ToFImageGrabber - - ToFImageGrabber::Pointer m_ToFImageGrabber; ///< ToFImageGrabber that will be returned configured with the specific ToFCameraDevice - - ToFImageGrabberCreator(); - - ~ToFImageGrabberCreator(); - private: - - }; -} //END mitk namespace -#endif diff --git a/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.cpp b/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.cpp index 325e52f9fe..17f50c9982 100644 --- a/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.cpp +++ b/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.cpp @@ -1,346 +1,352 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile$ Language: C++ Date: $Date: 2009-05-20 13:35:09 +0200 (Mi, 20 Mai 2009) $ Version: $Revision: 17332 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ //#define _USE_MATH_DEFINES #include //QT headers #include #include #include //mitk headers #include "mitkToFConfig.h" -#include +#include "mitkToFCameraPMDCamCubeDevice.h" +#include "mitkToFCameraPMDRawDataCamCubeDevice.h" +#include "mitkToFCameraPMDCamBoardDevice.h" +#include "mitkToFCameraPMDRawDataCamBoardDevice.h" +#include "mitkToFCameraPMDO3Device.h" +#include "mitkToFCameraPMDPlayerDevice.h" +#include "mitkToFCameraPMDMITKPlayerDevice.h" +#include "mitkToFCameraMITKPlayerDevice.h" +#include "mitkToFCameraMESASR4000Device.h" //itk headers #include const std::string QmitkToFConnectionWidget::VIEW_ID = "org.mitk.views.qmitktofconnectionwidget"; QmitkToFConnectionWidget::QmitkToFConnectionWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f) { this->m_IntegrationTime = 0; this->m_ModulationFrequency = 0; - this->m_ToFImageGrabber = NULL; - + this->m_ToFImageGrabber = mitk::ToFImageGrabber::New(); m_Controls = NULL; CreateQtPartControl(this); } QmitkToFConnectionWidget::~QmitkToFConnectionWidget() { } void QmitkToFConnectionWidget::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkToFConnectionWidgetControls; m_Controls->setupUi(parent); this->CreateConnections(); // set available cameras to combo box QString string(MITK_TOF_CAMERAS); string.replace(";"," "); QStringList list = string.split(","); m_Controls->m_SelectCameraCombobox->addItems(list); ShowParameterWidget(); } } void QmitkToFConnectionWidget::CreateConnections() { if ( m_Controls ) { connect( (QObject*)(m_Controls->m_ConnectCameraButton), SIGNAL(clicked()),(QObject*) this, SLOT(OnConnectCamera()) ); connect( m_Controls->m_SelectCameraCombobox, SIGNAL(currentIndexChanged(const QString)), this, SLOT(OnSelectCamera(const QString)) ); connect( m_Controls->m_SelectCameraCombobox, SIGNAL(activated(const QString)), this, SLOT(OnSelectCamera(const QString)) ); connect( m_Controls->m_SelectCameraCombobox, SIGNAL(activated(const QString)), this, SIGNAL(ToFCameraSelected(const QString)) ); } } void QmitkToFConnectionWidget::ShowParameterWidget() { QString selectedCamera = m_Controls->m_SelectCameraCombobox->currentText(); if ((selectedCamera == "PMD CamCube 2.0/3.0")||(selectedCamera == "PMD CamBoard")||(selectedCamera=="PMD O3D")|| (selectedCamera=="PMD CamBoardRaw")||(selectedCamera=="PMD CamCubeRaw") ) { ShowPMDParameterWidget(); } else if (selectedCamera=="MESA Swissranger 4000") { ShowMESAParameterWidget(); } else { this->m_Controls->m_PMDParameterWidget->hide(); this->m_Controls->m_MESAParameterWidget->hide(); } } void QmitkToFConnectionWidget::ShowPMDParameterWidget() { this->m_Controls->m_PMDParameterWidget->show(); this->m_Controls->m_MESAParameterWidget->hide(); } void QmitkToFConnectionWidget::ShowMESAParameterWidget() { this->m_Controls->m_PMDParameterWidget->hide(); this->m_Controls->m_MESAParameterWidget->show(); } void QmitkToFConnectionWidget::ShowPlayerParameterWidget() { this->m_Controls->m_PMDParameterWidget->hide(); this->m_Controls->m_MESAParameterWidget->hide(); } mitk::ToFImageGrabber* QmitkToFConnectionWidget::GetToFImageGrabber() { return m_ToFImageGrabber; } void QmitkToFConnectionWidget::OnSelectCamera(const QString selectedText) { if (selectedText == "PMD CamCube 2.0/3.0" || selectedText == "PMD CamCubeRaw 2.0/3.0" ) // PMD camcube 2 { ShowPMDParameterWidget(); } else if (selectedText == "PMD CamBoard" || selectedText == "PMD CamBoardRaw" ) // pmd camboard { ShowPMDParameterWidget(); } else if (selectedText == "PMD O3D") // pmd O3d { ShowPMDParameterWidget(); } else if (selectedText == "MESA Swissranger 4000") // MESA 4000 { ShowMESAParameterWidget(); } else if (selectedText == "PMD Player") // pmd file player { ShowPlayerParameterWidget(); } else if (selectedText == "PMD Raw Data Player") // pmd raw data player { ShowPlayerParameterWidget(); } else if (selectedText == "MITK Player") // mitk player { ShowPlayerParameterWidget(); } } void QmitkToFConnectionWidget::OnConnectCamera() { bool playerMode = false; if (m_Controls->m_ConnectCameraButton->text()=="Connect") { //reset the status of the GUI buttons m_Controls->m_ConnectCameraButton->setEnabled(false); m_Controls->m_SelectCameraCombobox->setEnabled(false); //repaint the widget this->repaint(); QString tmpFileName(""); QString fileFilter(""); //select the camera to connect with QString selectedCamera = m_Controls->m_SelectCameraCombobox->currentText(); if (selectedCamera == "PMD CamCube 2.0/3.0") { //PMD CamCube - this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDCamCubeImageGrabber(); + this->m_ToFImageGrabber->SetCameraDevice(mitk::ToFCameraPMDCamCubeDevice::New()); } else if (selectedCamera == "PMD CamCubeRaw 2.0/3.0") { //PMD CamCube - this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDRawDataCamCubeImageGrabber(); + this->m_ToFImageGrabber->SetCameraDevice(mitk::ToFCameraPMDRawDataCamCubeDevice::New()); } else if (selectedCamera == "PMD CamBoard") { //PMD CamBoard - this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDCamBoardImageGrabber(); + this->m_ToFImageGrabber->SetCameraDevice(mitk::ToFCameraPMDCamBoardDevice::New()); } else if (selectedCamera == "PMD CamBoardRaw") { //PMD CamBoard - this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDRawDataCamBoardImageGrabber(); + this->m_ToFImageGrabber->SetCameraDevice(mitk::ToFCameraPMDRawDataCamBoardDevice::New()); } else if (selectedCamera == "PMD O3D") {//PMD O3 - this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDO3ImageGrabber(); + this->m_ToFImageGrabber->SetCameraDevice(mitk::ToFCameraPMDO3Device::New()); } else if (selectedCamera == "MESA Swissranger 4000") {//MESA SR4000 - this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetMESASR4000ImageGrabber(); - } + this->m_ToFImageGrabber->SetCameraDevice(mitk::ToFCameraMESASR4000Device::New()); + } else if (selectedCamera == "PMD Player") {//PMD player playerMode = true; fileFilter.append("PMD Files (*.pmd)"); - this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDPlayerImageGrabber(); + this->m_ToFImageGrabber->SetCameraDevice(mitk::ToFCameraPMDPlayerDevice::New()); } else if (selectedCamera == "PMD Raw Data Player") {//PMD MITK player playerMode = true; fileFilter.append("NRRD Images (*.nrrd);;PIC Images - deprecated (*.pic)"); - this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDMITKPlayerImageGrabber(); + this->m_ToFImageGrabber->SetCameraDevice(mitk::ToFCameraPMDRawDataDevice::New()); } else if (selectedCamera == "MITK Player") {//MITK player playerMode = true; fileFilter.append("NRRD Images (*.nrrd);;PIC Images - deprecated (*.pic)"); - this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetMITKPlayerImageGrabber(); + this->m_ToFImageGrabber->SetCameraDevice(mitk::ToFCameraMITKPlayerDevice::New()); } // if a player was selected ... if (playerMode) { //... open a QFileDialog to chose the corresponding file from the disc tmpFileName = QFileDialog::getOpenFileName(NULL, "Play Image From...", "", fileFilter); if (tmpFileName.isEmpty()) { m_Controls->m_ConnectCameraButton->setChecked(false); m_Controls->m_ConnectCameraButton->setEnabled(true); m_Controls->m_SelectCameraCombobox->setEnabled(true); this->OnSelectCamera(m_Controls->m_SelectCameraCombobox->currentText()); QMessageBox::information( this, "Template functionality", "Please select a valid image before starting some action."); return; } if(selectedCamera == "PMD Player") { //set the PMD file name this->m_ToFImageGrabber->SetStringProperty("PMDFileName", tmpFileName.toStdString().c_str() ); } if (selectedCamera == "PMD Raw Data Player" || selectedCamera == "MITK Player") { 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() ); if (extension != ".pic" && extension != ".nrrd") { msg = msg + "Invalid file format, please select a \".nrrd\"-file"; throw std::logic_error(msg.c_str()); } int found = baseFilename.rfind("_DistanceImage"); if (found == std::string::npos) { found = baseFilename.rfind("_AmplitudeImage"); } if (found == std::string::npos) { found = baseFilename.rfind("_IntensityImage"); } if (found == std::string::npos) { msg = msg + "Input file name must end with \"_DistanceImage.pic\", \"_AmplitudeImage.pic\" or \"_IntensityImage.pic\"!"; throw std::logic_error(msg.c_str()); } std::string baseFilenamePrefix = baseFilename.substr(0,found); std::string distanceImageFileName = dir + "/" + baseFilenamePrefix + "_DistanceImage" + extension; std::string amplitudeImageFileName = dir + "/" + baseFilenamePrefix + "_AmplitudeImage" + extension; std::string intensityImageFileName = dir + "/" + baseFilenamePrefix + "_IntensityImage" + extension; if (!itksys::SystemTools::FileExists(distanceImageFileName.c_str(), true)) { msg = msg + "Inputfile not exist! " + distanceImageFileName; throw std::logic_error(msg.c_str()); } if (!itksys::SystemTools::FileExists(amplitudeImageFileName.c_str(), true)) { msg = msg + "Inputfile not exist! " + amplitudeImageFileName; throw std::logic_error(msg.c_str()); } if (!itksys::SystemTools::FileExists(intensityImageFileName.c_str(), true)) { msg = msg + "Inputfile not exist! " + intensityImageFileName; throw std::logic_error(msg.c_str()); } //set the file names this->m_ToFImageGrabber->SetStringProperty("DistanceImageFileName", distanceImageFileName.c_str()); this->m_ToFImageGrabber->SetStringProperty("AmplitudeImageFileName", amplitudeImageFileName.c_str()); this->m_ToFImageGrabber->SetStringProperty("IntensityImageFileName", intensityImageFileName.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_SelectCameraCombobox->setEnabled(true); this->OnSelectCamera(m_Controls->m_SelectCameraCombobox->currentText()); return; } } } //if a connection could be established if (this->m_ToFImageGrabber->ConnectCamera()) { this->m_Controls->m_PMDParameterWidget->SetToFImageGrabber(this->m_ToFImageGrabber); this->m_Controls->m_MESAParameterWidget->SetToFImageGrabber(this->m_ToFImageGrabber); if ((selectedCamera == "PMD CamCube 2.0/3.0")||(selectedCamera == "PMD CamBoard")||(selectedCamera=="PMD O3D")|| (selectedCamera=="PMD CamBoardRaw")||(selectedCamera=="PMD CamCubeRaw 2.0/3.0")) { this->m_Controls->m_PMDParameterWidget->ActivateAllParameters(); } else if (selectedCamera=="MESA Swissranger 4000") { this->m_Controls->m_MESAParameterWidget->ActivateAllParameters(); } m_Controls->m_ConnectCameraButton->setText("Disconnect"); // send connect signal to the caller functionality emit ToFCameraConnected(); } else { 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_SelectCameraCombobox->setEnabled(true); this->OnSelectCamera(m_Controls->m_SelectCameraCombobox->currentText()); return; } m_Controls->m_ConnectCameraButton->setEnabled(true); } 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_SelectCameraCombobox->setEnabled(true); this->OnSelectCamera(m_Controls->m_SelectCameraCombobox->currentText()); - this->m_ToFImageGrabber = NULL; // send disconnect signal to the caller functionality emit ToFCameraDisconnected(); } } diff --git a/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.h b/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.h index ae46b113c1..b31fd101ed 100644 --- a/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.h +++ b/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.h @@ -1,111 +1,111 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile$ Language: C++ Date: $Date: 2009-05-20 13:35:09 +0200 (Mi, 20 Mai 2009) $ Version: $Revision: 17332 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _QMITKTOFCONNECTIONWIDGET_H_INCLUDED #define _QMITKTOFCONNECTIONWIDGET_H_INCLUDED #include "mitkTOFUIExports.h" #include "ui_QmitkToFConnectionWidgetControls.h" //QT headers #include //mitk headers #include "mitkToFImageGrabber.h" /** * @brief Widget allowing to connect to different ToF / range cameras (located in module ToFProcessing) * * The widget basically allows to connect/disconnect to different ToF cameras * * @ingroup ToFUI */ class mitkTOFUI_EXPORT QmitkToFConnectionWidget :public QWidget { //this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) Q_OBJECT public: static const std::string VIEW_ID; QmitkToFConnectionWidget(QWidget* p = 0, Qt::WindowFlags f1 = 0); virtual ~QmitkToFConnectionWidget(); /* @brief This method is part of the widget an needs not to be called seperately. */ virtual void CreateQtPartControl(QWidget *parent); /* @brief This method is part of the widget an needs not to be called seperately. (Creation of the connections of main and control widget.)*/ virtual void CreateConnections(); /*! - \brief returns the ToFImageGrabber which was provided by the ToFImageGrabberCreator after selecting a camera / player + \brief returns the ToFImageGrabber which was configured after selecting a camera / player \return ToFImageGrabber currently used by the widget */ mitk::ToFImageGrabber* GetToFImageGrabber(); signals: /*! \brief This signal is sent if the user has connected the TOF camera. * The ToFImageGrabber is now availiable if the method GetToFImageGrabber() is called. */ void ToFCameraConnected(); /*! \brief This signal is sent if the user has disconnect the TOF camera. */ void ToFCameraDisconnected(); /*! \brief signal that is emitted when a ToF camera is selected in the combo box */ void ToFCameraSelected(const QString selectedText); protected slots: /*! \brief slot called when the "Connect Camera" button was pressed - * According to the selection in the camera combo box, the ToFImageGrabberCreator provides + * According to the selection in the camera combo box, the widget provides * the desired instance of the ToFImageGrabber */ void OnConnectCamera(); /*! \brief slot updating the GUI elements after the selection of the camera combo box has changed */ void OnSelectCamera(const QString selectedText); protected: Ui::QmitkToFConnectionWidgetControls* m_Controls; ///< member holding the UI elements of this widget - mitk::ToFImageGrabber* m_ToFImageGrabber; ///< member holding the current ToFImageGrabber + mitk::ToFImageGrabber::Pointer m_ToFImageGrabber; ///< member holding the current ToFImageGrabber int m_IntegrationTime; ///< member for the current integration time of the ToF device int m_ModulationFrequency; ///< member for the current modulation frequency of the ToF device private: void ShowParameterWidget(); void ShowPMDParameterWidget(); void ShowMESAParameterWidget(); void ShowPlayerParameterWidget(); }; #endif // _QMITKTOFCONNECTIONWIDGET_H_INCLUDED diff --git a/Modules/ToFUI/Qmitk/QmitkToFMESAParameterWidget.cpp b/Modules/ToFUI/Qmitk/QmitkToFMESAParameterWidget.cpp index 2f21b1a895..4a5e21eefa 100644 --- a/Modules/ToFUI/Qmitk/QmitkToFMESAParameterWidget.cpp +++ b/Modules/ToFUI/Qmitk/QmitkToFMESAParameterWidget.cpp @@ -1,176 +1,173 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile$ Language: C++ Date: $Date: 2009-05-20 13:35:09 +0200 (Mi, 20 Mai 2009) $ Version: $Revision: 17332 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ //#define _USE_MATH_DEFINES #include //QT headers #include #include #include -//mitk headers -#include - //itk headers #include const std::string QmitkToFMESAParameterWidget::VIEW_ID = "org.mitk.views.qmitktofpmdparameterwidget"; QmitkToFMESAParameterWidget::QmitkToFMESAParameterWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f) { this->m_IntegrationTime = 0; this->m_ModulationFrequency = 0; this->m_ToFImageGrabber = NULL; m_Controls = NULL; CreateQtPartControl(this); } QmitkToFMESAParameterWidget::~QmitkToFMESAParameterWidget() { } void QmitkToFMESAParameterWidget::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkToFMESAParameterWidgetControls; m_Controls->setupUi(parent); this->CreateConnections(); } } void QmitkToFMESAParameterWidget::CreateConnections() { if ( m_Controls ) { connect( m_Controls->m_IntegrationTimeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnChangeIntegrationTimeSpinBox(int)) ); connect( m_Controls->m_ModulationFrequencyComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnChangeModulationFrequencyComboBox(int)) ); connect( m_Controls->m_FPNCB, SIGNAL(toggled(bool)), this, SLOT(OnChangeFPNCheckBox(bool)) ); connect( m_Controls->m_ConvGrayCB, SIGNAL(toggled(bool)), this, SLOT(OnChangeConvGrayCheckBox(bool)) ); connect( m_Controls->m_MedianCB, SIGNAL(toggled(bool)), this, SLOT(OnChangeMedianCheckBox(bool)) ); connect( m_Controls->m_ANFCB, SIGNAL(toggled(bool)), this, SLOT(OnChangeANFCheckBox(bool)) ); } } mitk::ToFImageGrabber* QmitkToFMESAParameterWidget::GetToFImageGrabber() { return this->m_ToFImageGrabber; } void QmitkToFMESAParameterWidget::SetToFImageGrabber(mitk::ToFImageGrabber* aToFImageGrabber) { this->m_ToFImageGrabber = aToFImageGrabber; } void QmitkToFMESAParameterWidget::ActivateAllParameters() { this->m_IntegrationTime = m_Controls->m_IntegrationTimeSpinBox->value(); this->m_IntegrationTime = this->m_ToFImageGrabber->SetIntegrationTime(this->m_IntegrationTime); switch(m_Controls->m_ModulationFrequencyComboBox->currentIndex()) { case 0: this->m_ModulationFrequency = 29; break; case 1: this->m_ModulationFrequency = 30; break; case 2: this->m_ModulationFrequency = 31; break; default: this->m_ModulationFrequency = 30; break; } this->m_ModulationFrequency = this->m_ToFImageGrabber->SetModulationFrequency(this->m_ModulationFrequency); //set the MESA acquire mode according to the check boxes bool boolValue = false; boolValue = m_Controls->m_FPNCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetFPN", boolValue); boolValue = m_Controls->m_ConvGrayCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetConvGray", boolValue); boolValue = m_Controls->m_MedianCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetMedian", boolValue); boolValue = m_Controls->m_ANFCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetANF", boolValue); //reset the GUI elements m_Controls->m_IntegrationTimeSpinBox->setValue(this->m_IntegrationTime); //m_Controls->m_ModulationFrequencyComboBox->setValue(this->m_ModulationFrequency); } void QmitkToFMESAParameterWidget::OnChangeFPNCheckBox(bool checked) { this->m_ToFImageGrabber->SetBoolProperty("SetFPN", checked); } void QmitkToFMESAParameterWidget::OnChangeConvGrayCheckBox(bool checked) { this->m_ToFImageGrabber->SetBoolProperty("SetConvGray", checked); } void QmitkToFMESAParameterWidget::OnChangeMedianCheckBox(bool checked) { this->m_ToFImageGrabber->SetBoolProperty("SetMedian", checked); } void QmitkToFMESAParameterWidget::OnChangeANFCheckBox(bool checked) { this->m_ToFImageGrabber->SetBoolProperty("SetANF", checked); } void QmitkToFMESAParameterWidget::OnChangeIntegrationTimeSpinBox(int value) { if (this->m_ToFImageGrabber != NULL) { // stop camera if active bool active = m_ToFImageGrabber->IsCameraActive(); if (active) { m_ToFImageGrabber->StopCamera(); } this->m_IntegrationTime = m_Controls->m_IntegrationTimeSpinBox->value(); this->m_IntegrationTime = this->m_ToFImageGrabber->SetIntegrationTime(this->m_IntegrationTime); if (active) { m_ToFImageGrabber->StartCamera(); } } } void QmitkToFMESAParameterWidget::OnChangeModulationFrequencyComboBox(int index) { if (this->m_ToFImageGrabber != NULL) { // stop camera if active bool active = m_ToFImageGrabber->IsCameraActive(); if (active) { m_ToFImageGrabber->StopCamera(); } switch(index) { case 0: this->m_ModulationFrequency = 29; break; case 1: this->m_ModulationFrequency = 30; break; case 2: this->m_ModulationFrequency = 31; break; default: this->m_ModulationFrequency = 30; break; } this->m_ModulationFrequency = this->m_ToFImageGrabber->SetModulationFrequency(this->m_ModulationFrequency); if (active) { m_ToFImageGrabber->StartCamera(); } } } diff --git a/Modules/ToFUI/Qmitk/QmitkToFMESAParameterWidget.h b/Modules/ToFUI/Qmitk/QmitkToFMESAParameterWidget.h index 0e392ce3b8..8ad027a5ff 100644 --- a/Modules/ToFUI/Qmitk/QmitkToFMESAParameterWidget.h +++ b/Modules/ToFUI/Qmitk/QmitkToFMESAParameterWidget.h @@ -1,128 +1,128 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile$ Language: C++ Date: $Date: 2009-05-20 13:35:09 +0200 (Mi, 20 Mai 2009) $ Version: $Revision: 17332 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _QMITKTOFMESAPARAMETERWIDGET_H_INCLUDED #define _QMITKTOFMESAPARAMETERWIDGET_H_INCLUDED #include "mitkTOFUIExports.h" #include "ui_QmitkToFMESAParameterWidgetControls.h" //QT headers #include //mitk headers #include "mitkToFImageGrabber.h" /** * @brief Widget allowing to connect to different ToF / range cameras (located in module ToFProcessing) * * The widget basically allows to connect/disconnect to different ToF cameras * * @ingroup ToFUI */ class mitkTOFUI_EXPORT QmitkToFMESAParameterWidget :public QWidget { //this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) Q_OBJECT public: static const std::string VIEW_ID; QmitkToFMESAParameterWidget(QWidget* p = 0, Qt::WindowFlags f1 = 0); virtual ~QmitkToFMESAParameterWidget(); /* @brief This method is part of the widget an needs not to be called seperately. */ virtual void CreateQtPartControl(QWidget *parent); /* @brief This method is part of the widget an needs not to be called seperately. (Creation of the connections of main and control widget.)*/ virtual void CreateConnections(); /*! - \brief returns the ToFImageGrabber which was provided by the ToFImageGrabberCreator after selecting a camera / player + \brief returns the ToFImageGrabber which was configured after selecting a camera / player \return ToFImageGrabber currently used by the widget */ mitk::ToFImageGrabber* GetToFImageGrabber(); /*! - \brief sets the ToFImageGrabber which was provided by the ToFImageGrabberCreator after selecting a camera / player + \brief sets the ToFImageGrabber which was configured after selecting a camera / player */ void SetToFImageGrabber(mitk::ToFImageGrabber* aToFImageGrabber); /*! \brief activate camera settings according to the parameters from GUI */ void ActivateAllParameters(); signals: /*! \brief This signal is sent if the user has connected the TOF camera. * The ToFImageGrabber is now availiable if the method GetToFImageGrabber() is called. */ void ToFCameraConnected(); /*! \brief This signal is sent if the user has disconnect the TOF camera. */ void ToFCameraDisconnected(); /*! \brief signal that is emitted when the ToF camera is started */ void ToFCameraStart(); /*! \brief signal that is emitted when the ToF camera is stopped */ void ToFCameraStop(); /*! \brief signal that is emitted when a ToF camera is selected in the combo box */ void ToFCameraSelected(int); protected slots: /*! \brief slot updating the member m_IntegrationTime and the parameter "integration time" of the current ToFImageGrabber */ void OnChangeIntegrationTimeSpinBox(int value); /*! \brief slot updating the member m_ModulationFrequency and the parameter "modulation frequency" of the current ToFImageGrabber */ void OnChangeModulationFrequencyComboBox(int index); void OnChangeFPNCheckBox(bool checked); void OnChangeConvGrayCheckBox(bool checked); void OnChangeMedianCheckBox(bool checked); void OnChangeANFCheckBox(bool checked); protected: Ui::QmitkToFMESAParameterWidgetControls* m_Controls; ///< member holding the UI elements of this widget mitk::ToFImageGrabber* m_ToFImageGrabber; ///< member holding the current ToFImageGrabber int m_IntegrationTime; ///< member for the current integration time of the ToF device int m_ModulationFrequency; ///< member for the current modulation frequency of the ToF device private: }; #endif // _QMITKTOFCONNECTIONWIDGET_H_INCLUDED diff --git a/Modules/ToFUI/Qmitk/QmitkToFPMDParameterWidget.cpp b/Modules/ToFUI/Qmitk/QmitkToFPMDParameterWidget.cpp index 223faacf41..37df9718f8 100644 --- a/Modules/ToFUI/Qmitk/QmitkToFPMDParameterWidget.cpp +++ b/Modules/ToFUI/Qmitk/QmitkToFPMDParameterWidget.cpp @@ -1,142 +1,139 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile$ Language: C++ Date: $Date: 2009-05-20 13:35:09 +0200 (Mi, 20 Mai 2009) $ Version: $Revision: 17332 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ //#define _USE_MATH_DEFINES #include //QT headers #include #include #include -//mitk headers -#include - //itk headers #include const std::string QmitkToFPMDParameterWidget::VIEW_ID = "org.mitk.views.qmitktofpmdparameterwidget"; QmitkToFPMDParameterWidget::QmitkToFPMDParameterWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f) { this->m_IntegrationTime = 0; this->m_ModulationFrequency = 0; this->m_ToFImageGrabber = NULL; m_Controls = NULL; CreateQtPartControl(this); } QmitkToFPMDParameterWidget::~QmitkToFPMDParameterWidget() { } void QmitkToFPMDParameterWidget::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkToFPMDParameterWidgetControls; m_Controls->setupUi(parent); this->CreateConnections(); } } void QmitkToFPMDParameterWidget::CreateConnections() { if ( m_Controls ) { connect( m_Controls->m_IntegrationTimeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnChangeIntegrationTimeSpinBox(int)) ); connect( m_Controls->m_ModulationFrequencySpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnChangeModulationFrequencySpinBox(int)) ); } } mitk::ToFImageGrabber* QmitkToFPMDParameterWidget::GetToFImageGrabber() { return this->m_ToFImageGrabber; } void QmitkToFPMDParameterWidget::SetToFImageGrabber(mitk::ToFImageGrabber* aToFImageGrabber) { this->m_ToFImageGrabber = aToFImageGrabber; } void QmitkToFPMDParameterWidget::ActivateAllParameters() { this->m_IntegrationTime = m_Controls->m_IntegrationTimeSpinBox->value(); this->m_IntegrationTime = this->m_ToFImageGrabber->SetIntegrationTime(this->m_IntegrationTime); this->m_ModulationFrequency = m_Controls->m_ModulationFrequencySpinBox->value(); this->m_ModulationFrequency = this->m_ToFImageGrabber->SetModulationFrequency(this->m_ModulationFrequency); //set the PMD calibration according to the check boxes bool boolValue = false; boolValue = m_Controls->m_FPNCalibCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetFPNCalibration", boolValue); boolValue = m_Controls->m_FPPNCalibCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetFPPNCalibration", boolValue); boolValue = m_Controls->m_LinearityCalibCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetLinearityCalibration", boolValue); boolValue = m_Controls->m_LensCorrection->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetLensCalibration", boolValue); boolValue = m_Controls->m_ExposureModeCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetExposureMode", boolValue); //reset the GUI elements m_Controls->m_IntegrationTimeSpinBox->setValue(this->m_IntegrationTime); m_Controls->m_ModulationFrequencySpinBox->setValue(this->m_ModulationFrequency); } void QmitkToFPMDParameterWidget::OnChangeIntegrationTimeSpinBox(int value) { if (this->m_ToFImageGrabber != NULL) { // stop camera if active bool active = m_ToFImageGrabber->IsCameraActive(); if (active) { m_ToFImageGrabber->StopCamera(); } this->m_IntegrationTime = m_Controls->m_IntegrationTimeSpinBox->value(); this->m_IntegrationTime = this->m_ToFImageGrabber->SetIntegrationTime(this->m_IntegrationTime); if (active) { m_ToFImageGrabber->StartCamera(); } } } void QmitkToFPMDParameterWidget::OnChangeModulationFrequencySpinBox(int value) { if (this->m_ToFImageGrabber != NULL) { // stop camera if active bool active = m_ToFImageGrabber->IsCameraActive(); if (active) { m_ToFImageGrabber->StopCamera(); } this->m_ModulationFrequency = m_Controls->m_ModulationFrequencySpinBox->value(); this->m_ModulationFrequency = this->m_ToFImageGrabber->SetModulationFrequency(this->m_ModulationFrequency); if (active) { m_ToFImageGrabber->StartCamera(); } } } diff --git a/Modules/ToFUI/Qmitk/QmitkToFPMDParameterWidget.h b/Modules/ToFUI/Qmitk/QmitkToFPMDParameterWidget.h index 9b24d80916..6f9ec700f1 100644 --- a/Modules/ToFUI/Qmitk/QmitkToFPMDParameterWidget.h +++ b/Modules/ToFUI/Qmitk/QmitkToFPMDParameterWidget.h @@ -1,120 +1,120 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile$ Language: C++ Date: $Date: 2009-05-20 13:35:09 +0200 (Mi, 20 Mai 2009) $ Version: $Revision: 17332 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _QMITKTOFPMDPARAMETERWIDGET_H_INCLUDED #define _QMITKTOFPMDPARAMETERWIDGET_H_INCLUDED #include "mitkTOFUIExports.h" #include "ui_QmitkToFPMDParameterWidgetControls.h" //QT headers #include //mitk headers #include "mitkToFImageGrabber.h" /** * @brief Widget allowing to connect to different ToF / range cameras (located in module ToFProcessing) * * The widget basically allows to connect/disconnect to different ToF cameras * * @ingroup ToFUI */ class mitkTOFUI_EXPORT QmitkToFPMDParameterWidget :public QWidget { //this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) Q_OBJECT public: static const std::string VIEW_ID; QmitkToFPMDParameterWidget(QWidget* p = 0, Qt::WindowFlags f1 = 0); virtual ~QmitkToFPMDParameterWidget(); /* @brief This method is part of the widget an needs not to be called seperately. */ virtual void CreateQtPartControl(QWidget *parent); /* @brief This method is part of the widget an needs not to be called seperately. (Creation of the connections of main and control widget.)*/ virtual void CreateConnections(); /*! - \brief returns the ToFImageGrabber which was provided by the ToFImageGrabberCreator after selecting a camera / player + \brief returns the ToFImageGrabber which was configured after selecting a camera / player \return ToFImageGrabber currently used by the widget */ mitk::ToFImageGrabber* GetToFImageGrabber(); /*! - \brief sets the ToFImageGrabber which was provided by the ToFImageGrabberCreator after selecting a camera / player + \brief sets the ToFImageGrabber which was configured after selecting a camera / player */ void SetToFImageGrabber(mitk::ToFImageGrabber* aToFImageGrabber); /*! \brief activate camera settings according to the parameters from GUI */ void ActivateAllParameters(); signals: /*! \brief This signal is sent if the user has connected the TOF camera. * The ToFImageGrabber is now availiable if the method GetToFImageGrabber() is called. */ void ToFCameraConnected(); /*! \brief This signal is sent if the user has disconnect the TOF camera. */ void ToFCameraDisconnected(); /*! \brief signal that is emitted when the ToF camera is started */ void ToFCameraStart(); /*! \brief signal that is emitted when the ToF camera is stopped */ void ToFCameraStop(); /*! \brief signal that is emitted when a ToF camera is selected in the combo box */ void ToFCameraSelected(int); protected slots: /*! \brief slot updating the member m_IntegrationTime and the parameter "integration time" of the current ToFImageGrabber */ void OnChangeIntegrationTimeSpinBox(int value); /*! \brief slot updating the member m_ModulationFrequency and the parameter "modulation frequency" of the current ToFImageGrabber */ void OnChangeModulationFrequencySpinBox(int value); protected: Ui::QmitkToFPMDParameterWidgetControls* m_Controls; ///< member holding the UI elements of this widget mitk::ToFImageGrabber* m_ToFImageGrabber; ///< member holding the current ToFImageGrabber int m_IntegrationTime; ///< member for the current integration time of the ToF device int m_ModulationFrequency; ///< member for the current modulation frequency of the ToF device private: }; #endif // _QMITKTOFCONNECTIONWIDGET_H_INCLUDED diff --git a/Plugins/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialView.cpp b/Plugins/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialView.cpp index 53003d3d27..bd980acdae 100644 --- a/Plugins/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialView.cpp +++ b/Plugins/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialView.cpp @@ -1,200 +1,196 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ // Blueberry #include #include // Qmitk #include "QmitkToFTutorialView.h" #include "QmitkStdMultiWidget.h" // Qt #include // mitk includes #include // class holding the intrinsic parameters of the according camera #include // MITK-ToF related includes +#include #include // configuration file holding e.g. plugin paths or path to test file directory #include // filter from module ToFProcessing that calculates a surface from the given range image -#include // creator class that provides pre-configured ToFCameraDevices #include // allows access to images provided by the ToF camera - - const std::string QmitkToFTutorialView::VIEW_ID = "org.mitk.views.toftutorial"; QmitkToFTutorialView::QmitkToFTutorialView() : QmitkFunctionality() , m_Controls( 0 ) , m_MultiWidget( NULL ) { } QmitkToFTutorialView::~QmitkToFTutorialView() { } - void QmitkToFTutorialView::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::QmitkToFTutorialViewControls; m_Controls->setupUi( parent ); connect( m_Controls->step1Button, SIGNAL(clicked()), this, SLOT(OnStep1()) ); connect( m_Controls->step2Button, SIGNAL(clicked()), this, SLOT(OnStep2()) ); } } void QmitkToFTutorialView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) { m_MultiWidget = &stdMultiWidget; } - void QmitkToFTutorialView::StdMultiWidgetNotAvailable() { m_MultiWidget = NULL; } - void QmitkToFTutorialView::OnStep1() { // clean up data storage RemoveAllNodesFromDataStorage(); - // use ToFImageGrabber to create instance of ToFImageGrabber that holds a ToFCameraMITKPlayerDevice for playing ToF data - mitk::ToFImageGrabber::Pointer tofImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetMITKPlayerImageGrabber(); + // Create an instance of ToFImageGrabber that holds a ToFCameraMITKPlayerDevice for playing ToF data + mitk::ToFImageGrabber::Pointer tofImageGrabber = mitk::ToFImageGrabber::New(); + tofImageGrabber->SetCameraDevice(mitk::ToFCameraMITKPlayerDevice::New()); // set paths to test data std::string distanceFileName = MITK_TOF_DATA_DIR; distanceFileName.append("/PMDCamCube2_MF0_IT0_20Images_DistanceImage.pic"); std::string amplitudeFileName = MITK_TOF_DATA_DIR; amplitudeFileName.append("/PMDCamCube2_MF0_IT0_20Images_AmplitudeImage.pic"); std::string intensityFileName = MITK_TOF_DATA_DIR; intensityFileName.append("/PMDCamCube2_MF0_IT0_20Images_IntensityImage.pic"); // set file name property in image grabber. This will be propagated to the corresponding device and controller class tofImageGrabber->SetProperty("DistanceImageFileName",mitk::StringProperty::New(distanceFileName)); tofImageGrabber->SetProperty("AmplitudeImageFileName",mitk::StringProperty::New(amplitudeFileName)); tofImageGrabber->SetProperty("IntensityImageFileName",mitk::StringProperty::New(intensityFileName)); // connect to device if (tofImageGrabber->ConnectCamera()) { //// start camera (internally starts thread that continuously grabs images from the camera) tofImageGrabber->StartCamera(); // update image grabber which itself represents the source of a MITK filter pipeline tofImageGrabber->Update(); // grab distance image mitk::Image::Pointer distanceImage = tofImageGrabber->GetOutput(0); // grab amplitude image mitk::Image::Pointer amplitudeImage = tofImageGrabber->GetOutput(1); // grab intensity image mitk::Image::Pointer intensityImage = tofImageGrabber->GetOutput(2); //add distance image to data storage mitk::DataNode::Pointer distanceNode = mitk::DataNode::New(); distanceNode->SetName("Distance Image"); distanceNode->SetData(distanceImage); this->GetDefaultDataStorage()->Add(distanceNode); //add amplitude image to data storage mitk::DataNode::Pointer amplitudeNode = mitk::DataNode::New(); amplitudeNode->SetName("Amplitude Image"); amplitudeNode->SetData(amplitudeImage); this->GetDefaultDataStorage()->Add(amplitudeNode); //add intensity image to data storage mitk::DataNode::Pointer intensityNode = mitk::DataNode::New(); intensityNode->SetName("Intensity Image"); intensityNode->SetData(intensityImage); this->GetDefaultDataStorage()->Add(intensityNode); // stop camera (terminate internally used thread) tofImageGrabber->StopCamera(); //// disconnect from camera tofImageGrabber->DisconnectCamera(); // adjust views to new data in DataStorage mitk::RenderingManager::GetInstance()->InitializeViews(distanceImage->GetGeometry()); } else { MITK_ERROR<<"Connection to ToF camera could not be established"; } } void QmitkToFTutorialView::OnStep2() { // Check if distance image is available mitk::DataNode::Pointer distanceNode = this->GetDefaultDataStorage()->GetNamedNode("Distance Image"); if (distanceNode.IsNotNull()) { // get distance image from node and check if node contains image mitk::Image::Pointer distanceImage = dynamic_cast(distanceNode->GetData()); if (distanceImage.IsNotNull()) { // create object of CameraIntrinsics that holds intrinsic parameters of the ToF camera mitk::CameraIntrinsics::Pointer cameraIntrinsics = mitk::CameraIntrinsics::New(); // set focal length in pixel cameraIntrinsics->SetFocalLength(295.8,296.1); // set principal point in pixel cameraIntrinsics->SetPrincipalPoint(113.2,97.1); // set up filter for surface calculation mitk::ToFDistanceImageToSurfaceFilter::Pointer surfaceFilter = mitk::ToFDistanceImageToSurfaceFilter::New(); // apply intrinsic parameters to filter surfaceFilter->SetCameraIntrinsics(cameraIntrinsics); // set distance between pixels on chip in mm (in this example squared pixel) mitk::ToFProcessingCommon::ToFPoint2D interPixelDistance; interPixelDistance[0] = 0.045; interPixelDistance[1] = 0.045; surfaceFilter->SetInterPixelDistance(interPixelDistance); // set distance image as input surfaceFilter->SetInput(distanceImage); // update the filter surfaceFilter->Update(); // get surface from filter mitk::Surface::Pointer surface = surfaceFilter->GetOutput(); // add surface to data storage mitk::DataNode::Pointer surfaceNode = mitk::DataNode::New(); surfaceNode->SetName("ToF surface"); surfaceNode->SetData(surface); this->GetDefaultDataStorage()->Add(surfaceNode); // adjust views to new data in DataStorage mitk::RenderingManager::GetInstance()->InitializeViews(surface->GetGeometry()); mitk::RenderingManager::GetInstance()->InitializeViews(surface->GetGeometry()); } else { QMessageBox::warning(NULL,"ToF Tutorial","Node 'Distance Image' contains no image"); } } else { QMessageBox::warning(NULL,"ToF Tutorial","Perform Step 1 first to acquire a distance image"); } } void QmitkToFTutorialView::RemoveAllNodesFromDataStorage() { mitk::DataStorage::SetOfObjects::ConstPointer allNodes = this->GetDefaultDataStorage()->GetAll(); this->GetDefaultDataStorage()->Remove(allNodes); }