diff --git a/Modules/US/Testing/files.cmake b/Modules/US/Testing/files.cmake index 0a0987f2d8..a91f95d61d 100644 --- a/Modules/US/Testing/files.cmake +++ b/Modules/US/Testing/files.cmake @@ -1,15 +1,16 @@ SET(MODULE_TESTS mitkUSImageTest.cpp mitkUSImage2DTest.cpp mitkUSImageVideoSourceTest.cpp mitkUSProbeTest.cpp mitkUSDeviceTest.cpp + mitkUSPipelineTest.cpp # ----------------------------------------------------------------------- # ------------------ Deavtivated Tests ---------------------------------- # ----------------------------------------------------------------------- ) diff --git a/Modules/US/Testing/mitkUSImageVideoSourceTest.cpp b/Modules/US/Testing/mitkUSImageVideoSourceTest.cpp index 433c6eeaf6..e9f2630852 100644 --- a/Modules/US/Testing/mitkUSImageVideoSourceTest.cpp +++ b/Modules/US/Testing/mitkUSImageVideoSourceTest.cpp @@ -1,64 +1,65 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-02-25 17:27:17 +0100 (Mo, 25 Feb 2008) $ Version: $Revision: 7837 $ 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 "mitkUSImageVideoSource.h" #include "mitkTestingMacros.h" class mitkUSImageVideoSourceTestClass { public: static void TestInstantiation() { // let's create an object of our class mitk::USImageVideoSource::Pointer usSource = mitk::USImageVideoSource::New(); MITK_TEST_CONDITION_REQUIRED(usSource.IsNotNull(), "USImageVideoSource should not be null after instantiation"); } static void TestOpenVideoFile() { mitk::USImageVideoSource::Pointer usSource = mitk::USImageVideoSource::New(); // "C:\\Users\\maerz\\Videos\\Debut\\us.avi" usSource->SetVideoFileInput("C:\\Users\\maerz\\Videos\\Debut\\us.avi"); MITK_TEST_CONDITION_REQUIRED(usSource->GetIsVideoReady(), "USImageVideoSource should have isVideoReady flag set after opening a Video File"); } - +/** This TEst will fail if no device is attached. Since it basically covers the same non- Opencvfunctionality as TestOpenVideoFile, it is ommited static void TestOpenDevice() { mitk::USImageVideoSource::Pointer usSource = mitk::USImageVideoSource::New(); usSource->SetCameraInput(-1); MITK_TEST_CONDITION_REQUIRED(usSource->GetIsVideoReady(), "USImageVideoSource should have isVideoReady flag set after opening a Camera device"); } +*/ }; /** * This function is testing methods of the class USImageVideoSource. */ int mitkUSImageVideoSourceTest(int /* argc */, char* /*argv*/[]) { MITK_TEST_BEGIN("mitkUSImageVideoSourceTest"); mitkUSImageVideoSourceTestClass::TestInstantiation(); mitkUSImageVideoSourceTestClass::TestOpenVideoFile(); - mitkUSImageVideoSourceTestClass::TestOpenDevice(); + //mitkUSImageVideoSourceTestClass::TestOpenDevice(); MITK_TEST_END(); } \ No newline at end of file diff --git a/Modules/US/Testing/mitkUSPipelineTest.cpp b/Modules/US/Testing/mitkUSPipelineTest.cpp new file mode 100644 index 0000000000..ac70ecb116 --- /dev/null +++ b/Modules/US/Testing/mitkUSPipelineTest.cpp @@ -0,0 +1,57 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2008-02-25 17:27:17 +0100 (Mo, 25 Feb 2008) $ +Version: $Revision: 7837 $ + +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 "mitkUSVideoDevice.h" +#include "mitkTestingMacros.h" + + +class mitkUSPipelineTestClass +{ +public: + + // Anm: Implementierung der einzelnen Testmethoden + + static void TestInstantiation() + { + // 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"); + videoDevice->GenerateData(); + mitk::USImage::Pointer result = videoDevice->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"); + + } + + + + + +}; + +/** +* This function is setting up a pipeline and checks the output for validity. +*/ +int mitkUSPipelineTest(int /* argc */, char* /*argv*/[]) +{ + MITK_TEST_BEGIN("mitkUSPipelineTest"); + + mitkUSPipelineTestClass::TestInstantiation(); + + + MITK_TEST_END(); +} \ No newline at end of file diff --git a/Modules/US/USFilters/mitkUSDevice.cpp b/Modules/US/USFilters/mitkUSDevice.cpp index 3082968f9b..5cf4df78bb 100644 --- a/Modules/US/USFilters/mitkUSDevice.cpp +++ b/Modules/US/USFilters/mitkUSDevice.cpp @@ -1,89 +1,148 @@ /*========================================================================= 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. =========================================================================*/ #include "mitkUSDevice.h" #include "mitkUSImageMetadata.h" mitk::USDevice::USDevice(std::string manufacturer, std::string model, bool isVideoOnly) : mitk::ImageSource() { // Initialize Members m_Metadata = mitk::USImageMetadata::New(); m_Metadata->SetDeviceManufacturer(manufacturer); m_Metadata->SetDeviceModel(model); m_Metadata->SetDeviceIsVideoOnly(isVideoOnly); //set number of outputs this->SetNumberOfOutputs(1); //create a new output mitk::USImage::Pointer newOutput = mitk::USImage::New(); this->SetNthOutput(0,newOutput); } mitk::USDevice::~USDevice() { } void mitk::USDevice::AddProbe(mitk::USProbe::Pointer probe) { for(int i = 0; i < m_ConnectedProbes.size(); i++) { if (m_ConnectedProbes[i]->IsEqualToProbe(probe)) return; } this->m_ConnectedProbes.push_back(probe); } void mitk::USDevice::ActivateProbe(mitk::USProbe::Pointer probe){ // currently, we may just add the probe. This behaviour must be changed, should more complicated SDK applications emerge AddProbe(probe); int index = -1; for(int i = 0; i < m_ConnectedProbes.size(); i++) { if (m_ConnectedProbes[i]->IsEqualToProbe(probe)) index = i; } // index now contains the position of the original instance of this probe m_ActiveProbe = m_ConnectedProbes[index]; } void mitk::USDevice::DeactivateProbe(){ m_ActiveProbe = 0; } + +void mitk::USDevice::GenerateData() +{ + +} + + +mitk::USImage* mitk::USDevice::GetOutput() +{ + if (this->GetNumberOfOutputs() < 1) + return NULL; + + return static_cast(this->ProcessObject::GetOutput(0)); +} + + +mitk::USImage* mitk::USDevice::GetOutput(unsigned int idx) +{ + if (this->GetNumberOfOutputs() < 1) + return NULL; + return static_cast(this->ProcessObject::GetOutput(idx)); +} + + +void mitk::USDevice::GraftOutput(itk::DataObject *graft) +{ + this->GraftNthOutput(0, graft); +} + + +void mitk::USDevice::GraftNthOutput(unsigned int idx, itk::DataObject *graft) +{ + if ( idx >= this->GetNumberOfOutputs() ) + { + itkExceptionMacro(<<"Requested to graft output " << idx << + " but this filter only has " << this->GetNumberOfOutputs() << " Outputs."); + } + + if ( !graft ) + { + itkExceptionMacro(<<"Requested to graft output with a NULL pointer object" ); + } + + itk::DataObject* output = this->GetOutput(idx); + if ( !output ) + { + itkExceptionMacro(<<"Requested to graft output that is a NULL pointer" ); + } + // Call Graft on USImage to copy member data + output->Graft( graft ); +} + + +itk::ProcessObject::DataObjectPointer mitk::USDevice::MakeOutput( unsigned int /*idx */) +{ + mitk::USImage::Pointer p = mitk::USImage::New(); + return static_cast(p.GetPointer()); +} + //########### GETTER & SETTER ##################// std::string mitk::USDevice::GetDeviceManufacturer(){ return this->m_Metadata->GetDeviceManufacturer(); } std::string mitk::USDevice::GetDeviceModel(){ return this->m_Metadata->GetDeviceModel(); } std::string mitk::USDevice::GetDeviceComment(){ return this->m_Metadata->GetDeviceComment(); } bool mitk::USDevice::GetIsVideoOnly(){ return this->m_Metadata->GetDeviceIsVideoOnly(); } std::vector mitk::USDevice::GetConnectedProbes() { return m_ConnectedProbes; } diff --git a/Modules/US/USFilters/mitkUSDevice.h b/Modules/US/USFilters/mitkUSDevice.h index 5f3b00242c..0911af6a6e 100644 --- a/Modules/US/USFilters/mitkUSDevice.h +++ b/Modules/US/USFilters/mitkUSDevice.h @@ -1,104 +1,148 @@ /*========================================================================= 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. =========================================================================*/ #ifndef MITKUSDevice_H_HEADER_INCLUDED_ #define MITKUSDevice_H_HEADER_INCLUDED_ #include #include "mitkUSProbe.h" #include "mitkUSImageMetadata.h" #include "mitkUSImage.h" #include #include #include #include namespace mitk { /**Documentation * \brief A device holds information about it's model, make and the connected probes. It is the * common superclass for all Devices and acts as an image source for mitk Images as well as openCV Images. * if one of these functionalities is not supported by a subclass, it will throw an unsupported Operation Exception. * \ingroup US */ class MitkUS_EXPORT USDevice : public mitk::ImageSource { public: mitkClassMacro(USDevice, mitk::ImageSource); mitkNewMacro3Param(Self, std::string, std::string, bool); /** * \brief Add a probe to the device without connecting to it. * This should usually be done before connecting to the probe */ virtual void AddProbe(mitk::USProbe::Pointer probe); /** * \brief Connect to a probe and activate it. The probe should be added first. * Usually, a VideoDevice will just add a probe it want's to connect to, * but an SDK Device might require adding a probe first. */ virtual void ActivateProbe(mitk::USProbe::Pointer probe); /** * \brief Deactivates the currently active probe. */ virtual void DeactivateProbe(); /** * \brief Removes a probe from the ist of currently added probes. */ //virtual void removeProbe(mitk::USProbe::Pointer probe); std::vector GetConnectedProbes(); + /** + *\brief Grabs the next frame from the Video input + */ + void GenerateData(); + + /** + *\brief return the output (output with id 0) of the filter + */ + USImage* GetOutput(void); + + /** + *\brief return the output with id idx of the filter + */ + USImage* GetOutput(unsigned int idx); + + + /** + *\brief Graft the specified DataObject onto this ProcessObject's output. + * + * See itk::ImageSource::GraftNthOutput for details + */ + virtual void GraftNthOutput(unsigned int idx, itk::DataObject *graft); + + /** + * \brief Graft the specified DataObject onto this ProcessObject's output. + * + * See itk::ImageSource::Graft Output for details + */ + virtual void GraftOutput(itk::DataObject *graft); + + /** + * \brief Make a DataObject of the correct type to used as the specified output. + * + * This method is automatically called when DataObject::DisconnectPipeline() + * is called. DataObject::DisconnectPipeline, disconnects a data object + * from being an output of its current source. When the data object + * is disconnected, the ProcessObject needs to construct a replacement + * output data object so that the ProcessObject is in a valid state. + * Subclasses of USImageVideoSource that have outputs of different + * data types must overwrite this method so that proper output objects + * are created. + */ + virtual DataObjectPointer MakeOutput(unsigned int idx); + //########### GETTER & SETTER ##################// itkGetMacro(ActiveProbe, mitk::USProbe::Pointer); std::string GetDeviceManufacturer(); std::string GetDeviceModel(); std::string GetDeviceComment(); bool GetIsVideoOnly(); protected: mitk::USProbe::Pointer m_ActiveProbe; std::vector m_ConnectedProbes; /** * \brief This metadata set is privately used to imprint Images with Metadata later. * At instantiation time, it only contains Information about the Device, At scan time, it integrates this data with the probe information and imprints it on the produced images. This field is intentionally hidden from outside interference. */ mitk::USImageMetadata::Pointer m_Metadata; /** * \brief Enforces minimal Metadata to be set. The isVideoOnly flag indicates that this class * only handles a videostream and does not recieve Metadata from the physical device itself. */ USDevice(std::string manufacturer, std::string model, bool isVideoOnly); virtual ~USDevice(); }; } // namespace mitk #endif \ No newline at end of file diff --git a/Modules/US/USFilters/mitkUSImage.cpp b/Modules/US/USFilters/mitkUSImage.cpp index c888eba45b..200dde29d5 100644 --- a/Modules/US/USFilters/mitkUSImage.cpp +++ b/Modules/US/USFilters/mitkUSImage.cpp @@ -1,57 +1,63 @@ /*========================================================================= 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. =========================================================================*/ #include "mitkUSImage.h" #include #include mitk::USImage::USImage() : mitk::Image() { } +mitk::USImage::USImage(mitk::Image::Pointer image) : mitk::Image() +{ + this->Initialize(image); + this->SetVolume(image->GetData()); +} + 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())); } \ No newline at end of file diff --git a/Modules/US/USFilters/mitkUSImage.h b/Modules/US/USFilters/mitkUSImage.h index 332a37738d..23360b968e 100644 --- a/Modules/US/USFilters/mitkUSImage.h +++ b/Modules/US/USFilters/mitkUSImage.h @@ -1,57 +1,63 @@ /*========================================================================= 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. =========================================================================*/ #ifndef MITKUSIMAGE_H_HEADER_INCLUDED_ #define MITKUSIMAGE_H_HEADER_INCLUDED_ #include #include #include #include "mitkUSImageMetadata.h" namespace mitk { /**Documentation * \brief This specialization of mitk::Image only appends necessary Metadata to an MITK image. Otherwise it can safely be treated like it's mother class. * \ingroup US */ class MitkUS_EXPORT USImage : public mitk::Image { public: mitkClassMacro(USImage, mitk::Image); itkNewMacro(Self); + // Macro to create an mitkUSImage from an mitkImage + mitkNewMacro1Param(Self, mitk::Image::Pointer); /** * \brief reads out this image's Metadata set from the properties and returns a corresponding USImageMetadata object. */ mitk::USImageMetadata::Pointer GetMetadata(); /** * \brief writes the information of the metadata object into the image's properties. */ void SetMetadata(mitk::USImageMetadata::Pointer metadata); protected: USImage(); + /** + * \brief this constructor creates an US Image identical to the recieved mitkImage. The Metadata are set to default. + */ + USImage(mitk::Image::Pointer image); virtual ~USImage(); }; } // namespace mitk #endif \ No newline at end of file diff --git a/Modules/US/USFilters/mitkUSImageVideoSource.cpp b/Modules/US/USFilters/mitkUSImageVideoSource.cpp index f1142184c8..a5e1ef2326 100644 --- a/Modules/US/USFilters/mitkUSImageVideoSource.cpp +++ b/Modules/US/USFilters/mitkUSImageVideoSource.cpp @@ -1,118 +1,82 @@ /*========================================================================= 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. =========================================================================*/ #include "mitkUSImageVideoSource.h" +#include "mitkImage.h" +#include + mitk::USImageVideoSource::USImageVideoSource() -: itk::ProcessObject() +: 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){ m_OpenCVVideoSource->SetVideoCameraInput(deviceID); m_OpenCVVideoSource->StartCapturing(); m_OpenCVVideoSource->FetchFrame(); // Let's see if we have been successful m_IsVideoReady = m_OpenCVVideoSource->IsCapturingEnabled(); } -void mitk::USImageVideoSource::GenerateData() -{ - - -} - - -mitk::USImage* mitk::USImageVideoSource::GetOutput() -{ - if (this->GetNumberOfOutputs() < 1) - return NULL; - - return static_cast(this->ProcessObject::GetOutput(0)); -} - - -mitk::USImage* mitk::USImageVideoSource::GetOutput(unsigned int idx) -{ - if (this->GetNumberOfOutputs() < 1) - return NULL; - return static_cast(this->ProcessObject::GetOutput(idx)); -} - -void mitk::USImageVideoSource::GraftOutput(itk::DataObject *graft) -{ - this->GraftNthOutput(0, graft); -} +mitk::USImage::Pointer mitk::USImageVideoSource::GetNextImage(){ + mitk::USImage::Pointer result; + mitk::Image::Pointer normalImage; + IplImage* iplImage = cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,3); + m_OpenCVVideoSource->GetCurrentFrameAsOpenCVImage(iplImage); + + this->m_OpenCVToMitkFilter->SetOpenCVImage(iplImage); + this->m_OpenCVToMitkFilter->Update(); -void mitk::USImageVideoSource::GraftNthOutput(unsigned int idx, itk::DataObject *graft) -{ - if ( idx >= this->GetNumberOfOutputs() ) - { - itkExceptionMacro(<<"Requested to graft output " << idx << - " but this filter only has " << this->GetNumberOfOutputs() << " Outputs."); - } - - if ( !graft ) - { - itkExceptionMacro(<<"Requested to graft output with a NULL pointer object" ); - } - - itk::DataObject* output = this->GetOutput(idx); - if ( !output ) - { - itkExceptionMacro(<<"Requested to graft output that is a NULL pointer" ); - } - // Call Graft on USImage to copy member data - output->Graft( graft ); + normalImage = this->m_OpenCVToMitkFilter->GetOutput(0); + result = mitk::USImage::New(normalImage); + + + cvReleaseImage (&iplImage); + return result; } - - -itk::ProcessObject::DataObjectPointer mitk::USImageVideoSource::MakeOutput( unsigned int /*idx */) -{ - mitk::USImage::Pointer p = mitk::USImage::New(); - return static_cast(p.GetPointer()); -} \ No newline at end of file diff --git a/Modules/US/USFilters/mitkUSImageVideoSource.h b/Modules/US/USFilters/mitkUSImageVideoSource.h index 7e7f986e9b..056887ed6d 100644 --- a/Modules/US/USFilters/mitkUSImageVideoSource.h +++ b/Modules/US/USFilters/mitkUSImageVideoSource.h @@ -1,123 +1,84 @@ /*========================================================================= 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. =========================================================================*/ #ifndef MITKUSImageVideoSource_H_HEADER_INCLUDED_ #define MITKUSImageVideoSource_H_HEADER_INCLUDED_ #include #include "mitkUSImage.h" #include "mitkOpenCVVideoSource.h" +#include "mitkOpenCVToMitkImageFilter.h" namespace mitk { /**Documentation * \brief TODO * * \ingroup US */ - class MitkUS_EXPORT USImageVideoSource : public itk::ProcessObject + class MitkUS_EXPORT USImageVideoSource : public itk::Object { public: mitkClassMacro(USImageVideoSource, itk::ProcessObject); itkNewMacro(Self); /** *\brief Opens a video file for streaming. If nothing goes wrong, the * VideoSource is ready to deliver images after calling this function. */ void SetVideoFileInput(std::string path); /** *\brief Opens a video device for streaming. Takes the Device id. Try -1 for "grab the first you can get" * which works quite well if only one device is available. If nothing goes wrong, the * VideoSource is ready to deliver images after calling this function. */ void SetCameraInput(int deviceID); - /** - *\brief Grabs the next frame from the Video input - */ - void GenerateData(); - - /** - *\brief return the output (output with id 0) of the filter - */ - USImage* GetOutput(void); - - /** - *\brief return the output with id idx of the filter - */ - USImage* GetOutput(unsigned int idx); - - - /** - *\brief Graft the specified DataObject onto this ProcessObject's output. - * - * See itk::ImageSource::GraftNthOutput for details - */ - virtual void GraftNthOutput(unsigned int idx, itk::DataObject *graft); - - /** - * \brief Graft the specified DataObject onto this ProcessObject's output. - * - * See itk::ImageSource::Graft Output for details - */ - virtual void GraftOutput(itk::DataObject *graft); - - /** - * \brief Make a DataObject of the correct type to used as the specified output. - * - * This method is automatically called when DataObject::DisconnectPipeline() - * is called. DataObject::DisconnectPipeline, disconnects a data object - * from being an output of its current source. When the data object - * is disconnected, the ProcessObject needs to construct a replacement - * output data object so that the ProcessObject is in a valid state. - * Subclasses of USImageVideoSource that have outputs of different - * data types must overwrite this method so that proper output objects - * are created. - */ - virtual DataObjectPointer MakeOutput(unsigned int idx); - + mitk::USImage::Pointer GetNextImage(); + // Getter & Setter itkGetMacro(OpenCVVideoSource, mitk::OpenCVVideoSource::Pointer); itkSetMacro(OpenCVVideoSource, mitk::OpenCVVideoSource::Pointer); itkGetMacro(IsVideoReady, bool); itkGetMacro(IsMetadataReady, bool); itkGetMacro(IsGeometryReady, bool); + protected: USImageVideoSource(); virtual ~USImageVideoSource(); + /** * \brief The source of the video */ mitk::OpenCVVideoSource::Pointer m_OpenCVVideoSource; /** * \brief The Following flags are used internally, to assure that all necessary steps are taken before capturing */ bool m_IsVideoReady; bool m_IsMetadataReady; bool m_IsGeometryReady; - + mitk::OpenCVToMitkImageFilter::Pointer m_OpenCVToMitkFilter; }; } // namespace mitk #endif /* MITKUSImageVideoSource_H_HEADER_INCLUDED_ */ \ No newline at end of file diff --git a/Modules/US/USFilters/mitkUSVideoDevice.cpp b/Modules/US/USFilters/mitkUSVideoDevice.cpp index 38a7a44f8f..ef75b815d8 100644 --- a/Modules/US/USFilters/mitkUSVideoDevice.cpp +++ b/Modules/US/USFilters/mitkUSVideoDevice.cpp @@ -1,47 +1,52 @@ /*========================================================================= 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. =========================================================================*/ #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::USImage::Pointer result = mitk::USImage::New(); + mitk::USImage::Pointer result; + result = m_Source->GetNextImage(); + // Set Metadata result->SetMetadata(this->m_Metadata); - // 1) get Image from Source - - // 2) Process Image as necessary - - // 3) Set Output - + this->SetNthOutput(0, result); } diff --git a/Modules/US/USFilters/mitkUSVideoDevice.h b/Modules/US/USFilters/mitkUSVideoDevice.h index 1359e97abe..54f13a7558 100644 --- a/Modules/US/USFilters/mitkUSVideoDevice.h +++ b/Modules/US/USFilters/mitkUSVideoDevice.h @@ -1,58 +1,60 @@ /*========================================================================= 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. =========================================================================*/ #ifndef MITKUSVideoDevice_H_HEADER_INCLUDED_ #define MITKUSVideoDevice_H_HEADER_INCLUDED_ #include #include #include "mitkUSDevice.h" #include #include "mitkUSImageVideoSource.h" namespace mitk { /**Documentation * \brief TODO * \ingroup US */ class MitkUS_EXPORT USVideoDevice : public mitk::USDevice { public: mitkClassMacro(USVideoDevice, mitk::USDevice); mitkNewMacro3Param(Self, int, std::string, std::string); + mitkNewMacro3Param(Self, std::string, std::string, std::string); void GenerateData(); //## getter and setter ## // itkGetMacro(Name, std::string); // itkSetMacro(Name, std::string); protected: USVideoDevice(int videoDeviceNumber, std::string manufacturer, std::string model); + USVideoDevice(std::string videoFilePath, std::string manufacturer, std::string model); virtual ~USVideoDevice(); mitk::USImageVideoSource::Pointer m_Source; }; } // namespace mitk #endif \ No newline at end of file