diff --git a/CMakeExternals/MITKData.cmake b/CMakeExternals/MITKData.cmake index 8648242a19..31f5eff67b 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 9cb5f967) + set(revision_tag 6572126b) #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 - URL_MD5 f0e1128618c59f7f69f9c79c9673b51b + URL_MD5 ad2a35e2902572d6ba99a5e8e129b05e 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/US/Testing/CMakeLists.txt b/Modules/US/Testing/CMakeLists.txt index 836377a743..2b3bee20a5 100644 --- a/Modules/US/Testing/CMakeLists.txt +++ b/Modules/US/Testing/CMakeLists.txt @@ -1,7 +1,10 @@ MITK_CREATE_MODULE_TESTS() -#if(BUILD_TESTING AND MODULE_IS_ENABLED) -#mitkAddCustomModuleTest(mitkUSImageVideoSourceTest mitkUSImageVideoSourceTest -# ${MITK_DATA_DIR}/CommonTestData/bunny_640x480.avi -#) -# -#endif() \ No newline at end of file +if(BUILD_TESTING AND MODULE_IS_ENABLED) +mitkAddCustomModuleTest(mitkUSImageVideoSourceTest mitkUSImageVideoSourceTest + ${MITK_DATA_DIR}/CommonTestData/bunny_640x480.avi +) +mitkAddCustomModuleTest(mitkUSPipelineTest mitkUSPipelineTest + ${MITK_DATA_DIR}/CommonTestData/bunny_640x480.avi +) + +endif() \ No newline at end of file diff --git a/Modules/US/Testing/files.cmake b/Modules/US/Testing/files.cmake index b6cef51f25..5171e190d7 100644 --- a/Modules/US/Testing/files.cmake +++ b/Modules/US/Testing/files.cmake @@ -1,19 +1,18 @@ SET(MODULE_TESTS + mitkUSDeviceTest.cpp mitkUSImageTest.cpp - #mitkUSImageVideoSourceTest.cpp // deactivated until updated to current openCV mitkUSProbeTest.cpp - mitkUSDeviceTest.cpp - #mitkUSPipelineTest.cpp //deactivated until bugfix for mitkImage cloning available # ----------------------------------------------------------------------- # ------------------ Deavtivated Tests ---------------------------------- # ----------------------------------------------------------------------- ) -#SET(MODULE_CUSTOM_TESTS -#mitkUSImageVideoSourceTest.cpp //deactivated until updated to current openCV -#) +SET(MODULE_CUSTOM_TESTS + mitkUSImageVideoSourceTest.cpp + mitkUSPipelineTest.cpp +) diff --git a/Modules/US/Testing/mitkUSPipelineTest.cpp b/Modules/US/Testing/mitkUSPipelineTest.cpp index 22a3bc8e65..de5ca46e03 100644 --- a/Modules/US/Testing/mitkUSPipelineTest.cpp +++ b/Modules/US/Testing/mitkUSPipelineTest.cpp @@ -1,125 +1,102 @@ /*=================================================================== 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 "mitkUSVideoDevice.h" #include "mitkTestingMacros.h" #include "mitkUSImageToUSImageFilter.h" #include "mitkPadImageFilter.h" +// START TESTFILER +// This is an specialization of the USImageToUSImageFIlter -class mitkUSPipelineTestClass -{ - - -public: - // Internal specialisation of USImageToUSImageFilter to build a test-pipeline - class TestFilter : public mitk::USImageToUSImageFilter - { - public : mitkUSPipelineTestClass::TestFilter() : mitk::USImageToUSImageFilter() + class TestUSFilter : public mitk::USImageToUSImageFilter { - this->SetNumberOfInputs(1); - this->SetNumberOfOutputs(1); + protected: + TestUSFilter() : mitk::USImageToUSImageFilter(){}; + virtual ~TestUSFilter(){}; - } + public: + mitkClassMacro(TestUSFilter, mitk::USImageToUSImageFilter); + itkNewMacro(Self); - /* - \brief Method generating the output information of this filter (e.g. image dimension, image type, etc.). - The interface ImageToImageFilter requires this implementation. Everything is taken from the input image. - */ virtual void GenerateOutputInformation() - { - MITK_INFO << "GenerateOutputInformation called in Testfilter!"; - mitk::Image::Pointer inputImage = (mitk::Image*) this->GetInput(); - mitk::Image::Pointer output = this->GetOutput(0); - itkDebugMacro(<<"GenerateOutputInformation()"); + { + mitk::Image::Pointer inputImage = (mitk::Image*) this->GetInput(0); + mitk::Image::Pointer output = (mitk::Image*) this->GetOutput(0); if(inputImage.IsNull()) return; - } + }; - void GenerateData(){ + void GenerateData() + { MITK_INFO << "GenerateData called in Testfilter!"; - mitk::Image::Pointer ni = const_cast(this->GetInput(0)); + //mitk::Image::Pointer ni = const_cast(this->GetInput(0)); + mitk::USImage::Pointer ni = this->GetInput(0); mitk::USImage::Pointer result = mitk::USImage::New(); result->Initialize(ni); result->SetImportVolume(ni->GetData()); - mitk::USImageMetadata::Pointer meta = result->GetMetadata(); + + mitk::USImageMetadata::Pointer meta = ni->GetMetadata(); meta->SetDeviceComment("Test"); result->SetMetadata(meta); SetNthOutput(0, result); MITK_INFO << "GenerateData completed in Testfilter!"; - } - }; // Inner class end + }; + }; + +// END TESTFILTER - static void TestPipelineUS() - { - +class mitkUSPipelineTestClass +{ + +public: + + static void TestPipelineUS(std::string videoFilePath) + { // Set up a pipeline mitk::USVideoDevice::Pointer videoDevice = mitk::USVideoDevice::New("C:\\Users\\maerz\\Videos\\Debut\\us.avi", "Manufacturer", "Model"); - TestFilter::Pointer filter = TestFilter::New(); + TestUSFilter::Pointer filter = TestUSFilter::New(); + videoDevice->Update(); filter->SetInput(videoDevice->GetOutput()); - - MITK_TEST_CONDITION_REQUIRED(videoDevice.IsNotNull(), "videoDevice should not be null after instantiation"); filter->Update(); - mitk::USImage::Pointer result = dynamic_cast (filter->GetOutput(0)); - MITK_TEST_CONDITION_REQUIRED(result.IsNotNull(), "resulting images should not be null"); - MITK_TEST_CONDITION_REQUIRED(result->GetMetadata()->GetDeviceModel().compare("Model") == 0 , "Resulting images should have their metadata set correctly"); - - } - - static void TestPipelinePlain() - { - - // Set up a pipeline - mitk::USVideoDevice::Pointer videoDevice = mitk::USVideoDevice::New("C:\\Users\\maerz\\Videos\\Debut\\us.avi", "Manufacturer", "Model"); MITK_TEST_CONDITION_REQUIRED(videoDevice.IsNotNull(), "videoDevice should not be null after instantiation"); + - mitk::PadImageFilter::Pointer padFilter = mitk::PadImageFilter::New(); - // This shouldn't really change anything - padFilter->SetInput(0, videoDevice->GetOutput()); - padFilter->SetInput(1, videoDevice->GetOutput()); - - // padFilter->GetOutput()->Update(); - padFilter->GetOutput(0)->Update(); - mitk::Image::Pointer result = padFilter->GetOutput(0); - mitk::USImage::Pointer newres = mitk::USImage::New(result); - MITK_TEST_CONDITION_REQUIRED(newres.IsNotNull(), "resulting images should not be null"); - MITK_TEST_CONDITION_REQUIRED(newres->GetMetadata()->GetDeviceModel().compare("Model") == 0 , "resulting images should have their metadata set correctly"); - + //mitk::USImage::Pointer result = dynamic_cast (filter->GetOutput(0)); + mitk::USImage::Pointer result = filter->GetOutput(0); + MITK_TEST_CONDITION_REQUIRED(result.IsNotNull(), "resulting images should not be null"); + std::string model = result->GetMetadata()->GetDeviceModel(); + MITK_TEST_CONDITION_REQUIRED(model.compare("Model") == 0 , "Resulting images should have their metadata set correctly"); + } - - - - }; /** * This function is setting up a pipeline and checks the output for validity. */ -int mitkUSPipelineTest(int /* argc */, char* /*argv*/[]) +int mitkUSPipelineTest(int argc , char* argv[]) { MITK_TEST_BEGIN("mitkUSPipelineTest"); - // Tests are commented out until master merge - they fail because of an old big in mitk image - - // mitkUSPipelineTestClass::TestPipelineUS(); - // mitkUSPipelineTestClass::TestPipelinePlain(); + mitkUSPipelineTestClass::TestPipelineUS(argv[1]); + MITK_TEST_END(); } \ No newline at end of file diff --git a/Modules/US/USFilters/mitkUSImage.cpp b/Modules/US/USFilters/mitkUSImage.cpp index f67de973c2..214acd2cdf 100644 --- a/Modules/US/USFilters/mitkUSImage.cpp +++ b/Modules/US/USFilters/mitkUSImage.cpp @@ -1,63 +1,63 @@ /*=================================================================== 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 "mitkUSImage.h" #include #include mitk::USImage::USImage() : mitk::Image() { this->SetMetadata(mitk::USImageMetadata::New()); } mitk::USImage::USImage(mitk::Image::Pointer image) : mitk::Image() { this->Initialize(image); this->SetVolume(image->GetData()); - this->SetMetadata(mitk::USImageMetadata::New()); + //this->SetMetadata(mitk::USImageMetadata::New()); } mitk::USImage::~USImage() { } mitk::USImageMetadata::Pointer mitk::USImage::GetMetadata(){ mitk::USImageMetadata::Pointer result = mitk::USImageMetadata::New(); result->SetDeviceManufacturer(this->GetProperty(mitk::USImageMetadata::PROP_DEV_MANUFACTURER)->GetValueAsString()); result->SetDeviceModel( this->GetProperty(mitk::USImageMetadata::PROP_DEV_MODEL)->GetValueAsString()); result->SetDeviceComment( this->GetProperty(mitk::USImageMetadata::PROP_DEV_COMMENT)->GetValueAsString()); result->SetDeviceIsVideoOnly( this->GetProperty(mitk::USImageMetadata::PROP_DEV_ISVIDEOONLY)); result->SetProbeName( this->GetProperty(mitk::USImageMetadata::PROP_PROBE_NAME)->GetValueAsString()); result->SetProbeFrequency( this->GetProperty(mitk::USImageMetadata::PROP_PROBE_FREQUENCY)->GetValueAsString()); result->SetZoom( this->GetProperty(mitk::USImageMetadata::PROP_ZOOM)->GetValueAsString()); return result; } void mitk::USImage::SetMetadata(mitk::USImageMetadata::Pointer metadata){ this->SetProperty(mitk::USImageMetadata::PROP_DEV_MANUFACTURER, mitk::StringProperty::New(metadata->GetDeviceManufacturer())); this->SetProperty(mitk::USImageMetadata::PROP_DEV_MODEL, mitk::StringProperty::New(metadata->GetDeviceModel())); this->SetProperty(mitk::USImageMetadata::PROP_DEV_COMMENT, mitk::StringProperty::New(metadata->GetDeviceComment())); this->SetProperty(mitk::USImageMetadata::PROP_DEV_ISVIDEOONLY, mitk::BoolProperty::New(metadata->GetDeviceIsVideoOnly())); this->SetProperty(mitk::USImageMetadata::PROP_PROBE_NAME, mitk::StringProperty::New(metadata->GetProbeName())); this->SetProperty(mitk::USImageMetadata::PROP_PROBE_FREQUENCY, mitk::StringProperty::New(metadata->GetProbeFrequency())); this->SetProperty(mitk::USImageMetadata::PROP_ZOOM, mitk::StringProperty::New(metadata->GetZoom())); } diff --git a/Modules/US/USFilters/mitkUSImageToUSImageFilter.cpp b/Modules/US/USFilters/mitkUSImageToUSImageFilter.cpp index 48a07be27b..ae0bed302d 100644 --- a/Modules/US/USFilters/mitkUSImageToUSImageFilter.cpp +++ b/Modules/US/USFilters/mitkUSImageToUSImageFilter.cpp @@ -1,47 +1,54 @@ /*=================================================================== 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 "mitkUSImageToUSImageFilter.h" #include mitk::USImageToUSImageFilter::USImageToUSImageFilter() : mitk::ImageToImageFilter() { } mitk::USImageToUSImageFilter::~USImageToUSImageFilter() { } -/* + // ---- OVERRIDDEN INHERITED METHODS ---- // void mitk::USImageToUSImageFilter::SetInput (const mitk::USImage * image){ mitk::ImageToImageFilter::SetInput(image); } void mitk::USImageToUSImageFilter::SetInput (unsigned int index, const mitk::USImage * image){ mitk::ImageToImageFilter::SetInput(index, image); } mitk::USImage::Pointer mitk::USImageToUSImageFilter::GetOutput(unsigned int idx){ if (this->GetNumberOfOutputs() < 1) return NULL; return static_cast(this->ProcessObject::GetOutput(idx)); } -*/ +mitk::USImage::Pointer mitk::USImageToUSImageFilter::GetInput(unsigned int idx){ + if (this->GetNumberOfInputs() < 1) + return NULL; + mitk::USImage::Pointer result = static_cast(this->ProcessObject::GetInput(idx)); + return result; +} + + diff --git a/Modules/US/USFilters/mitkUSImageToUSImageFilter.h b/Modules/US/USFilters/mitkUSImageToUSImageFilter.h index 2c55b2006c..86ff1e89c0 100644 --- a/Modules/US/USFilters/mitkUSImageToUSImageFilter.h +++ b/Modules/US/USFilters/mitkUSImageToUSImageFilter.h @@ -1,53 +1,53 @@ /*=================================================================== 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 MITKUSImageToUSImageFilter_H_HEADER_INCLUDED_ #define MITKUSImageToUSImageFilter_H_HEADER_INCLUDED_ #include #include #include #include "mitkUSImage.h" namespace mitk { /**Documentation * \brief Todo * \ingroup US */ class MitkUS_EXPORT USImageToUSImageFilter : public mitk::ImageToImageFilter { public: - mitkClassMacro(USImageToUSImageFilter,itk::Object); + mitkClassMacro(USImageToUSImageFilter, mitk::ImageToImageFilter); itkNewMacro(Self); -/* + // ---- OVERRIDDEN INHERITED METHODS ---- // virtual void SetInput (const mitk::USImage *image); virtual void SetInput (unsigned int index, const mitk::USImage *image); virtual mitk::USImage::Pointer GetOutput(unsigned int idx); - */ + virtual mitk::USImage::Pointer GetInput (unsigned int idx); protected: USImageToUSImageFilter(); virtual ~USImageToUSImageFilter(); }; } // namespace mitk #endif \ No newline at end of file diff --git a/Modules/US/USFilters/mitkUSImageVideoSource.cpp b/Modules/US/USFilters/mitkUSImageVideoSource.cpp index 693090adf1..4bc5abc0af 100644 --- a/Modules/US/USFilters/mitkUSImageVideoSource.cpp +++ b/Modules/US/USFilters/mitkUSImageVideoSource.cpp @@ -1,84 +1,83 @@ /*=================================================================== 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 "mitkUSImageVideoSource.h" #include "mitkImage.h" #include mitk::USImageVideoSource::USImageVideoSource() : itk::Object() { m_IsVideoReady = false; m_IsMetadataReady = false; m_IsGeometryReady = false; this->m_OpenCVToMitkFilter = mitk::OpenCVToMitkImageFilter::New(); } mitk::USImageVideoSource::~USImageVideoSource() { } void mitk::USImageVideoSource::SetVideoFileInput(std::string path) { m_OpenCVVideoSource = mitk::OpenCVVideoSource::New(); // Example: "C:\\Users\\maerz\\Videos\\Debut\\us.avi" m_OpenCVVideoSource->SetVideoFileInput(path.c_str(),true,false); m_OpenCVVideoSource->StartCapturing(); m_OpenCVVideoSource->FetchFrame(); // Let's see if we have been successful m_IsVideoReady = m_OpenCVVideoSource->IsCapturingEnabled(); } -void mitk::USImageVideoSource::SetCameraInput(int deviceID){ +void mitk::USImageVideoSource::SetCameraInput(int deviceID) +{ m_OpenCVVideoSource->SetVideoCameraInput(deviceID); m_OpenCVVideoSource->StartCapturing(); m_OpenCVVideoSource->FetchFrame(); // Let's see if we have been successful m_IsVideoReady = m_OpenCVVideoSource->IsCapturingEnabled(); } -mitk::USImage::Pointer mitk::USImageVideoSource::GetNextImage(){ - // MITK_INFO << "GetNextImage called in USVideoSource!"; - mitk::USImage::Pointer result; - mitk::Image::Pointer normalImage; - +mitk::USImage::Pointer mitk::USImageVideoSource::GetNextImage() +{ m_OpenCVVideoSource->FetchFrame(); + // This is a bit of a workaround: We only need to initialize an OpenCV Image. Actual + // Initialization happens inside the OpenCVVideoSource IplImage* iplImage = cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,3); m_OpenCVVideoSource->GetCurrentFrameAsOpenCVImage(iplImage); this->m_OpenCVToMitkFilter->SetOpenCVImage(iplImage); this->m_OpenCVToMitkFilter->Update(); - normalImage = this->m_OpenCVToMitkFilter->GetOutput(0); - result = mitk::USImage::New(normalImage); - + // OpenCVToMitkImageFilter returns a standard mit::image. We then transform it into an USImage + mitk::USImage::Pointer result = mitk::USImage::New(this->m_OpenCVToMitkFilter->GetOutput(0)); cvReleaseImage (&iplImage); - // MITK_INFO << "GetNextImage completed in USVideoSource!"; + return result; } diff --git a/Modules/US/USFilters/mitkUSVideoDevice.cpp b/Modules/US/USFilters/mitkUSVideoDevice.cpp index 5ae12f4af2..b37f8f8dfb 100644 --- a/Modules/US/USFilters/mitkUSVideoDevice.cpp +++ b/Modules/US/USFilters/mitkUSVideoDevice.cpp @@ -1,53 +1,51 @@ /*=================================================================== 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 "mitkUSVideoDevice.h" #include mitk::USVideoDevice::USVideoDevice(int videoDeviceNumber, std::string manufacturer, std::string model) : mitk::USDevice(manufacturer, model, true) { this->SetNumberOfInputs(1); this->SetNumberOfOutputs(1); m_Source = mitk::USImageVideoSource::New(); m_Source->SetCameraInput(videoDeviceNumber); } mitk::USVideoDevice::USVideoDevice(std::string videoFilePath, std::string manufacturer, std::string model) : mitk::USDevice(manufacturer, model, true) { this->SetNumberOfInputs(1); this->SetNumberOfOutputs(1); m_Source = mitk::USImageVideoSource::New(); m_Source->SetVideoFileInput(videoFilePath); } mitk::USVideoDevice::~USVideoDevice() { } void mitk::USVideoDevice::GenerateData() { - // MITK_INFO << "Generate called in USVideoDevice!"; mitk::USImage::Pointer result; result = m_Source->GetNextImage(); // Set Metadata result->SetMetadata(this->m_Metadata); - + // Set Output this->SetNthOutput(0, result); - // MITK_INFO << "Successfully generated Image in USVideoDevice!"; }