diff --git a/Modules/US/USHardwareEpiphan/CMakeLists.txt b/Modules/US/USHardwareEpiphan/CMakeLists.txt index f64e683000..e36f457ed1 100644 --- a/Modules/US/USHardwareEpiphan/CMakeLists.txt +++ b/Modules/US/USHardwareEpiphan/CMakeLists.txt @@ -1,31 +1,27 @@ option(MITK_USE_EPIPHAN_SDK "Enable support for Epiphan devices" OFF) if(MITK_USE_EPIPHAN_SDK) set(MITK_EPIPHAN_SDK_PATH CACHE PATH "") if(MITK_EPIPHAN_SDK_PATH) find_library(MITK_EPIPHAN_FRMGRAB_LIBRARY frmgrab ${MITK_EPIPHAN_SDK_PATH}/frmgrab/lib/win/x64/ "Path which contains the Epiphan frmgrab.lib library.") find_path(MITK_EPIPHAN_INCLUDE_DIR v2u_defs.h ${MITK_EPIPHAN_SDK_PATH}/include "Include directory of the Epiphan library.") find_path(MITK_EPIPHAN_FRMGRAB_INCLUDE_DIR frmgrab.h ${MITK_EPIPHAN_SDK_PATH}/frmgrab/include "Include directory of the Epiphan frmgrab library.") -#set(MITK_EPIPHAN_INCLUDE_DIR ${MITK_EPIPHAN_SDK_PATH}/include) -#set(MITK_EPIPHAN_FRMGRAB_INCLUDE_DIR ${MITK_EPIPHAN_SDK_PATH}/frmgrab/include) -#set(MITK_EPIPHAN_FRMGRAB_LIBRARY ${MITK_EPIPHAN_SDK_PATH}/frmgrab/lib/win/x64/frmgrab.lib) mitk_create_module( SUBPROJECTS DEPENDS MitkUS INCLUDE_DIRS PUBLIC ${MITK_EPIPHAN_INCLUDE_DIR} ${MITK_EPIPHAN_FRMGRAB_INCLUDE_DIR} ADDITIONAL_LIBS ${MITK_EPIPHAN_FRMGRAB_LIBRARY} - #AUTOLOAD_WITH MitkUS ) else() message(FATAL_ERROR "Please set the Epiphan SDK root path (MITK_EPIPHAN_SDK_PATH).") endif() endif() diff --git a/Modules/US/USHardwareEpiphan/mitkUSEpiphanImageSource.cpp b/Modules/US/USHardwareEpiphan/mitkUSEpiphanImageSource.cpp index 3ad271ac86..b42da119fd 100644 --- a/Modules/US/USHardwareEpiphan/mitkUSEpiphanImageSource.cpp +++ b/Modules/US/USHardwareEpiphan/mitkUSEpiphanImageSource.cpp @@ -1,44 +1,60 @@ /*=================================================================== 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 #include +mitk::USEpiphanImageSource::USEpiphanImageSource(): m_Frame(nullptr) +{ +} -mitk::USEpiphanImageSource::USEpiphanImageSource() {} - -mitk::USEpiphanImageSource::~USEpiphanImageSource() {} +mitk::USEpiphanImageSource::~USEpiphanImageSource() +{ +} -void mitk::USEpiphanImageSource::GetNextRawImage(std::vector &) +void mitk::USEpiphanImageSource::GetNextRawImage(std::vector &imageVector) { - FrmGrab_Open("local:"); + if (imageVector.empty()) + { + imageVector.push_back(mitk::Image::New()); + // create single component float pixel type + mitk::PixelType pixelType(MakePixelType, 3>(3)); + unsigned int dimensions[] = { + static_cast(m_Frame->crop.width), static_cast(m_Frame->crop.height), 1}; + imageVector.at(0)->Initialize(pixelType, 3, dimensions); + } + m_Frame = FrmGrab_Frame(m_FrameGrabber, V2U_GRABFRAME_FORMAT_RGB24, NULL); + imageVector.at(0)->SetSlice((unsigned char*)m_Frame->pixbuf, 0, 0, 0); } void mitk::USEpiphanImageSource::StartGrabbing() { m_FrameGrabber = FrmGrab_Open(0); V2U_BOOL isStarted; isStarted = FrmGrab_Start(m_FrameGrabber); std::cout << "FG open and grab started: " << isStarted << std::endl; + + m_Frame = FrmGrab_Frame(m_FrameGrabber, V2U_GRABFRAME_FORMAT_RGB24, NULL); } void mitk::USEpiphanImageSource::StopGrabbing() { - //FrmGrab_Stop(m_FrameGrabber); - //FrmGrab_Close(m_FrameGrabber); - // - //std::cout << "FG closed and grab stopped: " << std::endl; + FrmGrab_Stop(m_FrameGrabber); + FrmGrab_Close(m_FrameGrabber); + + std::cout << "FG closed and grab stopped: " << std::endl; } diff --git a/Modules/US/USHardwareEpiphan/mitkUSEpiphanImageSource.h b/Modules/US/USHardwareEpiphan/mitkUSEpiphanImageSource.h index baaea3399f..8c3c272808 100644 --- a/Modules/US/USHardwareEpiphan/mitkUSEpiphanImageSource.h +++ b/Modules/US/USHardwareEpiphan/mitkUSEpiphanImageSource.h @@ -1,48 +1,50 @@ /*=================================================================== 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 MITKUSEpiphanImageSource_H_HEADER_INCLUDED_ #define MITKUSEpiphanImageSource_H_HEADER_INCLUDED_ #include "frmgrab.h" #include "mitkUSImageSource.h" #include namespace mitk { /** * \brief Implementation of mitk::USImageSource for Epiphan API devices. */ class MITKUSHARDWAREEPIPHAN_EXPORT USEpiphanImageSource : public USImageSource { public: mitkClassMacro(USEpiphanImageSource, USImageSource) itkFactorylessNewMacro(Self) itkCloneMacro(Self) - void GetNextRawImage(std::vector &); + void GetNextRawImage(std::vector &); void StartGrabbing(); void StopGrabbing(); FrmGrabber *m_FrameGrabber; protected: USEpiphanImageSource(); virtual ~USEpiphanImageSource(); + + V2U_GrabFrame2 *m_Frame; }; } // namespace mitk #endif // MITKUSEpiphanImageSource_H