From 4b93e03825eaf1e55abcccab6531ae8746357db5 Mon Sep 17 00:00:00 2001 From: James Butler Date: Tue, 22 Nov 2022 17:22:23 -0500 Subject: [PATCH] COMP: Remove support for Video For Windows This device has been marked as deprecated since 2014 in https://github.com/PlusToolkit/PlusLib/commit/92c5c70460801aee551b14fb20e7f78af4e6b975. The MmfVideoDevice should be used instead. --- .../UserManual/DeviceVideoForWindows.dox | 38 - src/PlusConfigure.h.in | 1 - src/PlusDataCollection/CMakeLists.txt | 43 +- src/PlusDataCollection/Testing/CMakeLists.txt | 43 +- .../vtkPlusWin32VideoSource2.cxx | 825 ------------------ .../vtkPlusWin32VideoSource2.h | 130 --- .../vtkPlusDeviceFactory.cxx | 7 - src/UsePlusLib.cmake.in | 1 - 8 files changed, 24 insertions(+), 1064 deletions(-) delete mode 100644 src/Documentation/UserManual/DeviceVideoForWindows.dox delete mode 100644 src/PlusDataCollection/VideoForWindows/vtkPlusWin32VideoSource2.cxx delete mode 100644 src/PlusDataCollection/VideoForWindows/vtkPlusWin32VideoSource2.h diff --git a/src/Documentation/UserManual/DeviceVideoForWindows.dox b/src/Documentation/UserManual/DeviceVideoForWindows.dox deleted file mode 100644 index 76d9dd7ea..000000000 --- a/src/Documentation/UserManual/DeviceVideoForWindows.dox +++ /dev/null @@ -1,38 +0,0 @@ -/*! -\page DeviceVideoForWindows Video for Windows compatible imaging device - -\section VideoForWindowsSupportedHwDevices Supported hardware devices - -This device is deprecated, use MmfVideo device instead. - -Compatible frame grabbers and webcams through Video for Windows interface. - -Limitations: currently only certain color modes are supported, minor additional conversion routines may be needed for some devices. - -\section VideoForWindowsSupportedPlatforms Supported platforms -- \ref PackageWin32 -- \ref PackageWin64 -- \ref PackageWin32XPe - -\section VideoForWindowsInstallation Installation - -\section VideoForWindowsConfigSettings Device configuration settings - -- \xmlAtt \ref DeviceType "Type" = \c "VFWVideo" \RequiredAtt -- \xmlAtt \ref DeviceAcquisitionRate "AcquisitionRate" \OptionalAtt{30} -- \xmlAtt \ref LocalTimeOffsetSec \OptionalAtt{0} - -- \xmlElem \ref DataSources Exactly one \c DataSource child element is required \RequiredAtt - - \xmlElem \ref DataSource \RequiredAtt - - \xmlAtt \ref PortUsImageOrientation \RequiredAtt - - \xmlAtt \ref ImageType \OptionalAtt{BRIGHTNESS} - - \xmlAtt \ref BufferSize \OptionalAtt{150} - - \xmlAtt \ref AveragedItemsForFiltering \OptionalAtt{20} - - \xmlAtt \ref ClipRectangleOrigin \OptionalAtt{0 0 0} - - \xmlAtt \ref ClipRectangleSize \OptionalAtt{0 0 0} - -\section VideoForWindowsExampleConfigFile Example configuration file PlusDeviceSet_Server_VfwVideoCapture.xml - -\include "ConfigFiles/PlusDeviceSet_Server_VfwVideoCapture.xml" - -*/ \ No newline at end of file diff --git a/src/PlusConfigure.h.in b/src/PlusConfigure.h.in index ec5fd121f..7a6903249 100644 --- a/src/PlusConfigure.h.in +++ b/src/PlusConfigure.h.in @@ -88,7 +88,6 @@ #cmakedefine PLUS_USE_PHIDGET_SPATIAL_TRACKER #cmakedefine PLUS_USE_NDI #cmakedefine PLUS_USE_ULTRASONIX_VIDEO -#cmakedefine PLUS_USE_VFW_VIDEO #cmakedefine PLUS_USE_STEALTHLINK #cmakedefine PLUS_USE_IntuitiveDaVinci #cmakedefine PLUS_USE_PHILIPS_3D_ULTRASOUND diff --git a/src/PlusDataCollection/CMakeLists.txt b/src/PlusDataCollection/CMakeLists.txt index 3accaf42d..8c4146ab3 100644 --- a/src/PlusDataCollection/CMakeLists.txt +++ b/src/PlusDataCollection/CMakeLists.txt @@ -35,7 +35,6 @@ OPTION(PLUS_USE_ULTRASONIX_VIDEO "Provide support for Ultrasonix ultrasound scan OPTION(PLUS_USE_BKPROFOCUS_VIDEO "Provide support for BK ProFocus ultrasound scanners through the OEM (TCP/IP) interface" OFF) OPTION(PLUS_USE_BKPROFOCUS_CAMERALINK "Provide support for BK ProFocus ultrasound scanners through CameraLink interface" OFF) OPTION(PLUS_USE_ICCAPTURING_VIDEO "Provide support for the IC framegrabber device" OFF) -OPTION(PLUS_USE_VFW_VIDEO "Provide support for the Video-for-Windows video digitizer" OFF) OPTION(PLUS_USE_EPIPHAN "Provide support for the Epiphan" OFF) OPTION(PLUS_USE_CAPISTRANO_VIDEO "Provide support Capistrano Labs USB ultrasound probes" OFF) OPTION(PLUS_USE_WINPROBE_VIDEO "Provide support WinProbe ultrasound systems" OFF) @@ -801,7 +800,7 @@ IF(PLUS_USE_PICOSCOPE) ${CMAKE_CURRENT_SOURCE_DIR}/PicoScope ${PicoScopeSDK_INCLUDE_DIR} ) - + IF(WIN32) LIST(APPEND ${PROJECT_NAME}_LIBS ${PicoScopeSDK_LIBRARY_DIR}/ps2000${CMAKE_STATIC_LIBRARY_SUFFIX} @@ -815,7 +814,7 @@ IF(PLUS_USE_PICOSCOPE) LIST(APPEND External_Libraries_Install ${PicoScopeSDK_BINARY_DIR}/ps2000${CMAKE_SHARED_LIBRARY_SUFFIX} ) - + ENDIF() #-------------------------------------------------------------------------- @@ -935,7 +934,7 @@ IF(PLUS_USE_CLARIUS_OEM) LIST(APPEND ${PROJECT_NAME}_PRIVATE_LIBS ClariusOEM ) - + LIST(APPEND External_Libraries_Install ${ClariusOEM_BINARY_PATH} ) @@ -1489,35 +1488,6 @@ IF(PLUS_USE_IntuitiveDaVinci) ) ENDIF() -# -------------------------------------------------------------------------- -# Video-for-Windows video digitizer support -IF(PLUS_USE_VFW_VIDEO) - SET(Vfw_SRCS - VideoForWindows/vtkPlusWin32VideoSource2.cxx - ) - SET(Vfw_HDRS - VideoForWindows/vtkPlusWin32VideoSource2.h - ) - - LIST(APPEND ${PROJECT_NAME}_HDRS - ${Vfw_HDRS} - ) - - LIST(APPEND ${PROJECT_NAME}_SRCS - ${Vfw_SRCS} - ) - - LIST(APPEND ${PROJECT_NAME}_LIBS - ws2_32 - ) - LIST(APPEND ${PROJECT_NAME}_INCLUDE_DIRS - ${CMAKE_CURRENT_SOURCE_DIR}/VideoForWindows - ) - LIST(APPEND ${PROJECT_NAME}_LIBS - Vfw32.lib - ) -ENDIF() - # -------------------------------------------------------------------------- # Microsoft Media Foundation video digitizer support IF(PLUS_USE_MMF_VIDEO) @@ -2346,7 +2316,7 @@ IF(PLUS_USE_ANDOR_CAMERA) SET(Andor_HDRS Andor/vtkPlusAndorVideoSource.h ) - + LIST(APPEND ${PROJECT_NAME}_HDRS ${Andor_HDRS} ) @@ -2354,8 +2324,8 @@ IF(PLUS_USE_ANDOR_CAMERA) LIST(APPEND ${PROJECT_NAME}_SRCS ${Andor_SRCS} ) - - LIST(APPEND ${PROJECT_NAME}_LIBS + + LIST(APPEND ${PROJECT_NAME}_LIBS ${ANDOR_LIBRARY_DIR}/${ANDOR_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX} ) LIST(APPEND ${PROJECT_NAME}_INCLUDE_DIRS @@ -2634,7 +2604,6 @@ source_group("Capistrano" FILES ${Capistrano_HDRS} ${Capistrano_SRCS}) source_group("WinProbe" FILES ${WinProbe_HDRS} ${WinProbe_SRCS}) source_group("Epiphan" FILES ${Epiphan_HDRS} ${Epiphan_SRCS}) source_group("MicrosoftMediaFoundation" FILES ${Mmf_HDRS} ${Mmf_SRCS}) -source_group("VideoForWindows" FILES ${Vfw_HDRS} ${Vfw_SRCS}) source_group("daVinci" FILES ${daVinci_HDRS} ${daVinci_SRCS}) source_group("StealthLink" FILES ${StealthLink_HDRS} ${StealthLink_SRCS}) source_group("ICCapturing" FILES ${ICCapturing_HDRS} ${ICCapturing_SRCS}) diff --git a/src/PlusDataCollection/Testing/CMakeLists.txt b/src/PlusDataCollection/Testing/CMakeLists.txt index df48f59e8..66b2a73d1 100644 --- a/src/PlusDataCollection/Testing/CMakeLists.txt +++ b/src/PlusDataCollection/Testing/CMakeLists.txt @@ -192,9 +192,9 @@ IF(PLUS_USE_INTERSONSDKCXX_VIDEO AND PLUS_RENDERING_ENABLED) ADD_EXECUTABLE(vtkIntersonSDKCxxVideoSourceTest vtkintersonSDKCxxVideoSourceTest.cxx) SET_TARGET_PROPERTIES(vtkIntersonSDKCxxVideoSourceTest PROPERTIES FOLDER Tests) TARGET_LINK_LIBRARIES(vtkIntersonSDKCxxVideoSourceTest vtkPlusDataCollection vtkPlusCommon ${PLUSLIB_VTK_PREFIX}InteractionImage) - ADD_TEST(NAME vtkIntersonSDKCxxVideoSourceTest + ADD_TEST(NAME vtkIntersonSDKCxxVideoSourceTest COMMAND $ - --rendering-off + --rendering-off --config-file=${ConfigFilesDir}/Testing/PlusDeviceSet_IntersonSDKCxxVideoSourceTest.xml ) ADD_TEST(NAME vtkIntersonSDKCxxVideoSourceScanConvertTest @@ -295,7 +295,7 @@ IF(PLUS_USE_ICCAPTURING_VIDEO AND PLUS_RENDERING_ENABLED) ADD_EXECUTABLE(vtkICCapturingSourceTest1 vtkICCapturingSourceTest1.cxx ) SET_TARGET_PROPERTIES(vtkICCapturingSourceTest1 PROPERTIES FOLDER Tests) TARGET_LINK_LIBRARIES(vtkICCapturingSourceTest1 vtkPlusDataCollection ${PLUSLIB_VTK_PREFIX}InteractionImage) - # ADD_TEST(vtkICCapturingSourceTest1 + # ADD_TEST(vtkICCapturingSourceTest1 # ${PLUS_EXECUTABLE_OUTPUT_PATH}/vtkICCapturingSourceTest1 # --rendering-off # ) @@ -334,8 +334,8 @@ ENDIF() IF(PLUS_USE_CAPISTRANO_VIDEO AND PLUS_RENDERING_ENABLED) ADD_EXECUTABLE(vtkCapistranoVideoSourceTest vtkCapistranoVideoSourceTest.cxx ) SET_TARGET_PROPERTIES(vtkCapistranoVideoSourceTest PROPERTIES FOLDER Tests) - TARGET_LINK_LIBRARIES(vtkCapistranoVideoSourceTest vtkPlusDataCollection ${PLUSLIB_VTK_PREFIX}InteractionImage) - ADD_TEST(NAME vtkCapistranoVideoSourceTest + TARGET_LINK_LIBRARIES(vtkCapistranoVideoSourceTest vtkPlusDataCollection ${PLUSLIB_VTK_PREFIX}InteractionImage) + ADD_TEST(NAME vtkCapistranoVideoSourceTest COMMAND $ --rendering-off --config-file=${ConfigFilesDir}/Testing/PlusDeviceSet_CapistranoVideoSourceTest.xml @@ -346,8 +346,8 @@ ENDIF() IF(PLUS_USE_WINPROBE_VIDEO AND PLUS_RENDERING_ENABLED) ADD_EXECUTABLE(vtkWinProbeVideoSourceTest vtkWinProbeVideoSourceTest.cxx ) SET_TARGET_PROPERTIES(vtkWinProbeVideoSourceTest PROPERTIES FOLDER Tests) - TARGET_LINK_LIBRARIES(vtkWinProbeVideoSourceTest vtkPlusDataCollection ${PLUSLIB_VTK_PREFIX}InteractionImage) - ADD_TEST(NAME vtkWinProbeVideoSourceTest + TARGET_LINK_LIBRARIES(vtkWinProbeVideoSourceTest vtkPlusDataCollection ${PLUSLIB_VTK_PREFIX}InteractionImage) + ADD_TEST(NAME vtkWinProbeVideoSourceTest COMMAND $ --rendering-off --output-seq-file=${TEST_OUTPUT_PATH}/WinProbeTest.igs.nrrd @@ -361,7 +361,7 @@ ENDIF() IF(PLUS_USE_INTERSON_VIDEO AND PLUS_RENDERING_ENABLED) ADD_EXECUTABLE(vtkIntersonVideoSourceTest vtkIntersonVideoSourceTest.cxx ) SET_TARGET_PROPERTIES(vtkIntersonVideoSourceTest PROPERTIES FOLDER Tests) - TARGET_LINK_LIBRARIES(vtkIntersonVideoSourceTest vtkPlusDataCollection ${PLUSLIB_VTK_PREFIX}InteractionImage) + TARGET_LINK_LIBRARIES(vtkIntersonVideoSourceTest vtkPlusDataCollection ${PLUSLIB_VTK_PREFIX}InteractionImage) ENDIF() #*************************** vtkTelemedVideoSourceTest.cxx *************************** @@ -396,7 +396,7 @@ IF(PLUS_USE_ULTRASONIX_VIDEO AND PLUS_RENDERING_ENABLED) ADD_EXECUTABLE(vtkSonixPortaVideoSourceTest vtkSonixPortaVideoSourceTest.cxx ) SET_TARGET_PROPERTIES(vtkSonixPortaVideoSourceTest PROPERTIES FOLDER Tests) TARGET_LINK_LIBRARIES(vtkSonixPortaVideoSourceTest vtkPlusDataCollection vtkPlusCommon ${PLUSLIB_VTK_PREFIX}InteractionImage) - # ADD_TEST(vtkSonixPortaVideoSourceTest + # ADD_TEST(vtkSonixPortaVideoSourceTest # ${PLUS_EXECUTABLE_OUTPUT_PATH}/vtkSonixPortaVideoSourceTest # To be added if the 3D probe is attached to the machine # --setting-path=${ULTRASONIX_SDK_DIR}/porta/dat/ @@ -416,13 +416,6 @@ IF(PLUS_USE_ULTRASONIX_VIDEO AND PLUS_RENDERING_ENABLED) ENDIF() #Test is to be added. -#*************************** vtkWin32VideoSourceTest.cxx *************************** -IF(PLUS_USE_VFW_VIDEO AND PLUS_RENDERING_ENABLED) - ADD_EXECUTABLE(vtkWin32VideoSourceTest vtkWin32VideoSourceTest.cxx) - SET_TARGET_PROPERTIES(vtkWin32VideoSourceTest PROPERTIES FOLDER Tests) - TARGET_LINK_LIBRARIES(vtkWin32VideoSourceTest vtkPlusDataCollection ${PLUSLIB_VTK_PREFIX}InteractionImage) -ENDIF() - #*************************** vtkMmfVideoSourceTest.cxx *************************** IF(PLUS_USE_MMF_VIDEO AND PLUS_RENDERING_ENABLED) ADD_EXECUTABLE(vtkMmfVideoSourceTest vtkMmfVideoSourceTest.cxx ) @@ -430,7 +423,7 @@ IF(PLUS_USE_MMF_VIDEO AND PLUS_RENDERING_ENABLED) TARGET_LINK_LIBRARIES(vtkMmfVideoSourceTest vtkPlusDataCollection ${PLUSLIB_VTK_PREFIX}InteractionImage) IF(PLUS_TEST_MMF_VIDEO) - ADD_TEST(MmfVideoSourceTest + ADD_TEST(MmfVideoSourceTest ${PLUS_EXECUTABLE_OUTPUT_PATH}/vtkMmfVideoSourceTest --rendering-off --frame-size 640 480 @@ -449,8 +442,8 @@ ENDIF() IF(PLUS_USE_MICRONTRACKER AND PLUS_RENDERING_ENABLED) ADD_EXECUTABLE(vtkMicronTrackerTest vtkMicronTrackerTest.cxx) SET_TARGET_PROPERTIES(vtkMicronTrackerTest PROPERTIES FOLDER Tests) - TARGET_LINK_LIBRARIES(vtkMicronTrackerTest vtkPlusDataCollection vtkPlusCommon ${PLUSLIB_VTK_PREFIX}InteractionImage) -ENDIF() + TARGET_LINK_LIBRARIES(vtkMicronTrackerTest vtkPlusDataCollection vtkPlusCommon ${PLUSLIB_VTK_PREFIX}InteractionImage) +ENDIF() #*************************** IntelRealSenseTrackerTest *************************** IF(PLUS_USE_INTELREALSENSE AND PLUS_RENDERING_ENABLED) @@ -582,10 +575,10 @@ ENDIF() IF(PLUS_USE_ANDOR_CAMERA) ADD_EXECUTABLE(vtkAndorVideoSourceTest vtkAndorVideoSourceTest.cxx ) SET_TARGET_PROPERTIES(vtkAndorVideoSourceTest PROPERTIES FOLDER Tests) - TARGET_LINK_LIBRARIES(vtkAndorVideoSourceTest vtkPlusDataCollection vtkInteractionImage) - ADD_TEST(NAME vtkAndorVideoSourceTest + TARGET_LINK_LIBRARIES(vtkAndorVideoSourceTest vtkPlusDataCollection vtkInteractionImage) + ADD_TEST(NAME vtkAndorVideoSourceTest COMMAND $ - --rendering-off + --rendering-off --config-file=${ConfigFilesDir}/Testing/PlusDeviceSet_AndorVideoSourceTest.xml --flat-correction-image=${TestDataDir}/AndorTestFlat.png --bias-correction-image=${TestDataDir}/AndorTestBias.png @@ -613,7 +606,7 @@ IF(PLUS_USE_GENERIC_SENSOR_TRACKER) SET_TARGET_PROPERTIES(GenericSensorTrackerTest1 PROPERTIES FOLDER Tests) TARGET_LINK_LIBRARIES(GenericSensorTrackerTest1 vtkPlusDataCollection) - ADD_TEST(GenericSensorTrackerTest1 + ADD_TEST(GenericSensorTrackerTest1 ${PLUS_EXECUTABLE_OUTPUT_PATH}/GenericSensorTrackerTest1 --config-file=${ConfigFilesDir}/Testing/PlusDeviceSet_DataCollectionOnly_GenericSensor.xml ) @@ -627,10 +620,10 @@ IF(PLUS_USE_AZUREKINECT) SET_TARGET_PROPERTIES(AzureKinectTest1 PROPERTIES FOLDER Tests) TARGET_LINK_LIBRARIES(AzureKinectTest1 vtkPlusDataCollection) # add any other dependencies to the test executable - ADD_TEST(AzureKinectTest1 + ADD_TEST(AzureKinectTest1 ${PLUS_EXECUTABLE_OUTPUT_PATH}/AzureKinectTest1 --rendering-off - --config-file=${ConfigFilesDir}/Testing/PlusDeviceSet_DataCollectionOnly_AzureKinect.xml + --config-file=${ConfigFilesDir}/Testing/PlusDeviceSet_DataCollectionOnly_AzureKinect.xml ) SET_TESTS_PROPERTIES(AzureKinectTest1 PROPERTIES FAIL_REGULAR_EXPRESSION "ERROR") ENDIF() diff --git a/src/PlusDataCollection/VideoForWindows/vtkPlusWin32VideoSource2.cxx b/src/PlusDataCollection/VideoForWindows/vtkPlusWin32VideoSource2.cxx deleted file mode 100644 index 7c24905eb..000000000 --- a/src/PlusDataCollection/VideoForWindows/vtkPlusWin32VideoSource2.cxx +++ /dev/null @@ -1,825 +0,0 @@ -/*=Plus=header=begin====================================================== -Program: Plus -Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved. -See License.txt for details. -=========================================================Plus=header=end*/ - -/*========================================================================= -The following copyright notice is applicable to parts of this file: -Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -All rights reserved. -See Copyright.txt or http://www.kitware.com/Copyright.htm for details. -Authors include: Danielle Pace -=========================================================================*/ - -#include "PixelCodec.h" -#include "PlusConfigure.h" -#include "vtkObjectFactory.h" -#include "vtkPlusChannel.h" -#include "vtkPlusDataSource.h" -#include "vtkUnsignedCharArray.h" -#include "vtkPlusWin32VideoSource2.h" - -#include - -// because of warnings in windows header push and pop the warning level -#ifdef _MSC_VER - #pragma warning (push, 3) -#endif - -#include "vtkWindows.h" -#include -#include - -#ifdef _MSC_VER - #pragma warning (pop) -#endif - -class vtkPlusWin32VideoSource2Internal -{ -public: - //---------------------------------------------------------------------------- - vtkPlusWin32VideoSource2Internal() - { - CapWnd = NULL; - ParentWnd = NULL; - BitMapInfoSize = 0; - BitMapInfoPtr = NULL; - } - //---------------------------------------------------------------------------- - virtual ~vtkPlusWin32VideoSource2Internal() - { - delete [](char*)(BitMapInfoPtr); - BitMapInfoPtr = NULL; - BitMapInfoSize = 0; - } - //---------------------------------------------------------------------------- - PlusStatus GetBitmapInfoFromCaptureDevice() - { - if (CapWnd == NULL) - { - LOG_ERROR("Cannot get bitmap info, capture window has not been created yet"); - return PLUS_FAIL; - } - int formatSize = capGetVideoFormatSize(CapWnd); - if (formatSize > this->BitMapInfoSize) - { - delete []((char*)BitMapInfoPtr); - BitMapInfoPtr = (LPBITMAPINFO) new char[formatSize]; - BitMapInfoSize = formatSize; - } - if (!capGetVideoFormat(CapWnd, BitMapInfoPtr, formatSize)) - { - LOG_ERROR("Cannot get bitmap info from capture window"); - return PLUS_FAIL; - } - return PLUS_SUCCESS; - } - //---------------------------------------------------------------------------- - PlusStatus SetBitmapInfoInCaptureDevice() - { - if (!capSetVideoFormat(CapWnd, BitMapInfoPtr, BitMapInfoSize)) - { - LOG_ERROR("Cannot set bitmap video format for capture window"); - return PLUS_FAIL; - } - return PLUS_SUCCESS; - } - - HWND CapWnd; - HWND ParentWnd; - CAPSTATUS CapStatus; - CAPDRIVERCAPS CapDriverCaps; - CAPTUREPARMS CaptureParms; - LPBITMAPINFO BitMapInfoPtr; - int BitMapInfoSize; -}; - -vtkStandardNewMacro(vtkPlusWin32VideoSource2); - -#if ( _MSC_VER >= 1300 ) // Visual studio .NET - #pragma warning ( disable : 4311 ) - #pragma warning ( disable : 4312 ) - #define vtkGetWindowLong GetWindowLongPtr - #define vtkSetWindowLong SetWindowLongPtr - #define vtkGWL_USERDATA GWLP_USERDATA -#else // regular Visual studio - #define vtkGetWindowLong GetWindowLong - #define vtkSetWindowLong SetWindowLong - #define vtkGWL_USERDATA GWL_USERDATA -#endif // - -//---------------------------------------------------------------------------- -vtkPlusWin32VideoSource2::vtkPlusWin32VideoSource2() - : Internal(new vtkPlusWin32VideoSource2Internal) - , WndClassName(NULL) - , Preview(0) - , FrameIndex(0) -{ - this->RequireImageOrientationInConfiguration = true; - - // No need for StartThreadForInternalUpdates, as we are notified about each new frame through a callback function -} - -//---------------------------------------------------------------------------- -vtkPlusWin32VideoSource2::~vtkPlusWin32VideoSource2() -{ - this->vtkPlusWin32VideoSource2::ReleaseSystemResources(); - - delete this->Internal; - this->Internal = NULL; -} - -//---------------------------------------------------------------------------- -void vtkPlusWin32VideoSource2::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - - os << indent << "Preview: " << (this->Preview ? "On\n" : "Off\n"); -} - -//---------------------------------------------------------------------------- -LONG FAR PASCAL vtkPlusWin32VideoSource2WinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - vtkPlusWin32VideoSource2* self = (vtkPlusWin32VideoSource2*)(vtkGetWindowLong(hwnd, vtkGWL_USERDATA)); - switch (message) - { - case WM_MOVE: - LOG_TRACE("WM_MOVE"); - break; - case WM_SIZE: - LOG_TRACE("WM_SIZE"); - break; - case WM_DESTROY: - LOG_TRACE("WM_DESTROY"); - self->OnParentWndDestroy(); - break; - case WM_CLOSE: - LOG_TRACE("WM_CLOSE"); - self->PreviewOff(); - return 0; - } - return DefWindowProc(hwnd, message, wParam, lParam); -} - -//---------------------------------------------------------------------------- -LRESULT PASCAL vtkPlusWin32VideoSource2CapControlProc(HWND hwndC, int nState) -{ - vtkPlusWin32VideoSource2* self = (vtkPlusWin32VideoSource2*)(capGetUserData(hwndC)); - if (nState == CONTROLCALLBACK_PREROLL) - { - LOG_TRACE("controlcallback preroll"); - } - else if (nState == CONTROLCALLBACK_CAPTURING) - { - LOG_TRACE("controlcallback capturing"); - } - return TRUE; -} - -//---------------------------------------------------------------------------- -LRESULT PASCAL vtkPlusWin32VideoSource2CallbackProc(HWND hwndC, LPVIDEOHDR lpVideoHeader) -{ - vtkPlusWin32VideoSource2* self = (vtkPlusWin32VideoSource2*)(capGetUserData(hwndC)); - self->AddFrameToBuffer(lpVideoHeader); - return 0; -} - -//---------------------------------------------------------------------------- -// this callback is left in for debug purposes -LRESULT PASCAL vtkPlusWin32VideoSource2StatusCallbackProc(HWND vtkNotUsed(hwndC), int nID, LPCSTR vtkNotUsed(lpsz)) -{ - //vtkPlusWin32VideoSource2 *self = (vtkPlusWin32VideoSource2 *)(capGetUserData(hwndC)); - if (nID == IDS_CAP_BEGIN) - { - LOG_TRACE("start of capture"); - } - if (nID == IDS_CAP_END) - { - LOG_TRACE("end of capture"); - } - return 1; -} - -//---------------------------------------------------------------------------- -LRESULT PASCAL vtkPlusWin32VideoSource2ErrorCallbackProc(HWND hwndC, int ErrID, LPSTR lpErrorText) -{ - if (ErrID) - { - LOG_ERROR("Video for Windows error: #" << ErrID); - } - return 1; -} - -//---------------------------------------------------------------------------- -PlusStatus vtkPlusWin32VideoSource2::InternalConnect() -{ - if (this->GetConnected()) - { - // already connected - return PLUS_SUCCESS; - } - - // get necessary process info - HINSTANCE hinstance = GetModuleHandle(NULL); - - // set up a class for the main window - WNDCLASS wc; - wc.lpszClassName = this->WndClassName; - wc.hInstance = hinstance; - wc.lpfnWndProc = reinterpret_cast(&vtkPlusWin32VideoSource2WinProc); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hIcon = NULL; - wc.lpszMenuName = NULL; - wc.hbrBackground = NULL; - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.cbClsExtra = sizeof(void*); - wc.cbWndExtra = 0; - - std::string windowNameStr; - bool registrationSuccessful = false; - const int MAX_WINDOW_CLASS_REGISTRATION_ATTEMPTS = 32; - for (int i = 1; i <= MAX_WINDOW_CLASS_REGISTRATION_ATTEMPTS; i++) - { - if (RegisterClass(&wc)) - { - SetWndClassName(wc.lpszClassName); - registrationSuccessful = true; - break; - } - // try with a slightly different name at each registration attempt - std::ostringstream windowName; - windowName << "VTKVideo " << i << std::ends; - windowNameStr = windowName.str(); - wc.lpszClassName = windowNameStr.c_str(); - } - if (!registrationSuccessful) - { - LOG_ERROR("Initialize: failed to register VTKVideo class (" << GetLastError() << ")"); - return PLUS_FAIL; - } - - DWORD style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; - - if (this->Preview) - { - style |= WS_VISIBLE; - } - - // set up the parent window, but don't show it - vtkPlusDataSource* aSource(NULL); - if (this->GetFirstVideoSource(aSource) != PLUS_SUCCESS) - { - LOG_ERROR("Unable to retrieve the video source in the Win32Video device."); - return PLUS_FAIL; - } - FrameSizeType frameSize = aSource->GetInputFrameSize(); - - this->Internal->ParentWnd = CreateWindow(this->WndClassName, "Plus video capture window", style, 0, 0, - frameSize[0] + 2 * GetSystemMetrics(SM_CXFIXEDFRAME), - frameSize[1] + 2 * GetSystemMetrics(SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYBORDER) + GetSystemMetrics(SM_CYSIZE), - NULL, NULL, hinstance, NULL); - - if (!this->Internal->ParentWnd) - { - LOG_ERROR("Initialize: failed to create window (" << GetLastError() << ")"); - return PLUS_FAIL; - } - - // set the user data to 'this' - vtkSetWindowLong(this->Internal->ParentWnd, vtkGWL_USERDATA, (LONG_PTR)this); - - // Create the capture window - this->Internal->CapWnd = capCreateCaptureWindow("Capture", WS_CHILD | WS_VISIBLE, 0, 0, - frameSize[0], frameSize[1], this->Internal->ParentWnd, 1); - - if (!this->Internal->CapWnd) - { - LOG_ERROR("Initialize: failed to create capture window (" << GetLastError() << ")"); - this->ReleaseSystemResources(); - return PLUS_FAIL; - } - - // connect to the driver - if (!capDriverConnect(this->Internal->CapWnd, 0)) - { - LOG_ERROR("Initialize: couldn't connect to driver (" << GetLastError() << ")"); - this->ReleaseSystemResources(); - return PLUS_FAIL; - } - - capDriverGetCaps(this->Internal->CapWnd, &this->Internal->CapDriverCaps, sizeof(CAPDRIVERCAPS)); - - // set up the video capture format - this->Internal->GetBitmapInfoFromCaptureDevice(); - //this->Internal->BitMapInfoPtr->bmiHeader.biWidth = frameSize[0]; - //this->Internal->BitMapInfoPtr->bmiHeader.biHeight = frameSize[1]; - if (this->Internal->SetBitmapInfoInCaptureDevice() != PLUS_SUCCESS) - { - LOG_ERROR("Failed to set requested frame size in the capture device"); - this->ReleaseSystemResources(); - return PLUS_FAIL; - } - - int width = this->Internal->BitMapInfoPtr->bmiHeader.biWidth; - int height = this->Internal->BitMapInfoPtr->bmiHeader.biHeight; - this->ReleaseSystemResources(); - this->Internal->ParentWnd = CreateWindow(this->WndClassName, "Plus video capture window", style, 0, 0, - width + 2 * GetSystemMetrics(SM_CXFIXEDFRAME), - height + 2 * GetSystemMetrics(SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYBORDER) + GetSystemMetrics(SM_CYSIZE), - NULL, NULL, hinstance, NULL); - - if (!this->Internal->ParentWnd) - { - LOG_ERROR("Initialize: failed to create window (" << GetLastError() << ")"); - return PLUS_FAIL; - } - - // set the user data to 'this' - vtkSetWindowLong(this->Internal->ParentWnd, vtkGWL_USERDATA, (LONG_PTR)this); - - // Create the capture window - this->Internal->CapWnd = capCreateCaptureWindow("Capture", WS_CHILD | WS_VISIBLE, 0, 0, - frameSize[0], frameSize[1], this->Internal->ParentWnd, 1); - - if (!this->Internal->CapWnd) - { - LOG_ERROR("Initialize: failed to create capture window (" << GetLastError() << ")"); - this->ReleaseSystemResources(); - return PLUS_FAIL; - } - - // connect to the driver - if (!capDriverConnect(this->Internal->CapWnd, 0)) - { - LOG_ERROR("Initialize: couldn't connect to driver (" << GetLastError() << ")"); - this->ReleaseSystemResources(); - return PLUS_FAIL; - } - - capDriverGetCaps(this->Internal->CapWnd, &this->Internal->CapDriverCaps, sizeof(CAPDRIVERCAPS)); - - // set the capture parameters - capCaptureGetSetup(this->Internal->CapWnd, &this->Internal->CaptureParms, sizeof(CAPTUREPARMS)); - - if (this->AcquisitionRate > 0) - { - this->Internal->CaptureParms.dwRequestMicroSecPerFrame = int(1000000 / this->AcquisitionRate); - } - else - { - this->Internal->CaptureParms.dwRequestMicroSecPerFrame = 0; - } - - this->Internal->CaptureParms.fMakeUserHitOKToCapture = FALSE; - this->Internal->CaptureParms.fYield = 1; - this->Internal->CaptureParms.fCaptureAudio = FALSE; - this->Internal->CaptureParms.vKeyAbort = 0x00; - this->Internal->CaptureParms.fAbortLeftMouse = FALSE; - this->Internal->CaptureParms.fAbortRightMouse = FALSE; - this->Internal->CaptureParms.fLimitEnabled = FALSE; - this->Internal->CaptureParms.wNumAudioRequested = 0; - this->Internal->CaptureParms.wPercentDropForError = 100; - this->Internal->CaptureParms.dwAudioBufferSize = 0; - this->Internal->CaptureParms.AVStreamMaster = AVSTREAMMASTER_NONE; - - if (!capCaptureSetSetup(this->Internal->CapWnd, &this->Internal->CaptureParms, sizeof(CAPTUREPARMS))) - { - LOG_ERROR("Initialize: setup of capture parameters failed (" << GetLastError() << ")"); - this->ReleaseSystemResources(); - return PLUS_FAIL; - } - - // set user data for callbacks - if (!capSetUserData(this->Internal->CapWnd, (LONG_PTR)this)) - { - LOG_ERROR("Initialize: couldn't set user data for callback (" << GetLastError() << ")"); - this->ReleaseSystemResources(); - return PLUS_FAIL; - } - - // install the callback to precisely time beginning of grab - if (!capSetCallbackOnCapControl(this->Internal->CapWnd, &vtkPlusWin32VideoSource2CapControlProc)) - { - LOG_ERROR("Initialize: couldn't set control callback (" << GetLastError() << ")"); - this->ReleaseSystemResources(); - return PLUS_FAIL; - } - - // install the callback to copy frames into the buffer on sync grabs - if (!capSetCallbackOnFrame(this->Internal->CapWnd, &vtkPlusWin32VideoSource2CallbackProc)) - { - LOG_ERROR("Initialize: couldn't set frame callback (" << GetLastError() << ")"); - this->ReleaseSystemResources(); - return PLUS_FAIL; - } - // install the callback to copy frames into the buffer on stream grabs - if (!capSetCallbackOnVideoStream(this->Internal->CapWnd, &vtkPlusWin32VideoSource2CallbackProc)) - { - LOG_ERROR("Initialize: couldn't set stream callback (" << GetLastError() << ")"); - this->ReleaseSystemResources(); - return PLUS_FAIL; - } - // install the callback to get info on start/end of streaming - if (!capSetCallbackOnStatus(this->Internal->CapWnd, &vtkPlusWin32VideoSource2StatusCallbackProc)) - { - LOG_ERROR("Initialize: couldn't set status callback (" << GetLastError() << ")"); - this->ReleaseSystemResources(); - return PLUS_FAIL; - } - // install the callback to send messages to user - if (!capSetCallbackOnError(this->Internal->CapWnd, &vtkPlusWin32VideoSource2ErrorCallbackProc)) - { - LOG_ERROR("Initialize: couldn't set error callback (" << GetLastError() << ")"); - this->ReleaseSystemResources(); - return PLUS_FAIL; - } - - capOverlay(this->Internal->CapWnd, TRUE); - - // update framebuffer again to reflect any changes which - // might have occurred - this->UpdateFrameBuffer(); - - return PLUS_SUCCESS; -} - -PlusStatus vtkPlusWin32VideoSource2::InternalDisconnect() -{ - if (this->Internal->CapWnd) - { - LOG_DEBUG("capDriverDisconnect(this->Internal->CapWnd)"); - capDriverDisconnect(this->Internal->CapWnd); - LOG_DEBUG("DestroyWindow(this->Internal->CapWnd)"); - DestroyWindow(this->Internal->CapWnd); - this->Internal->CapWnd = NULL; - } - if (this->WndClassName != NULL && this->WndClassName[0] != '\0') - { - // window class name is valid - UnregisterClass(this->WndClassName, GetModuleHandle(NULL)); - SetWndClassName(""); - } - - return PLUS_SUCCESS; -} - -//---------------------------------------------------------------------------- -void vtkPlusWin32VideoSource2::SetPreview(int showPreview) -{ - if (this->Preview == showPreview) - { - return; - } - - this->Preview = showPreview; - - if (GetConnected()) - { - if (this->Internal->CapWnd == NULL || this->Internal->ParentWnd == NULL) - { - LOG_ERROR("Capture windows have not been intialized"); - return; - } - if (this->Preview) - { - ShowWindow(this->Internal->ParentWnd, SW_SHOWNORMAL); - } - else - { - ShowWindow(this->Internal->ParentWnd, SW_HIDE); - } - } - this->Modified(); -} - -//---------------------------------------------------------------------------- -void vtkPlusWin32VideoSource2::ReleaseSystemResources() -{ - // destruction of ParentWnd causes OnParentWndDestroy to be called - if (this->Internal->ParentWnd) - { - DestroyWindow(this->Internal->ParentWnd); - } -} - -//---------------------------------------------------------------------------- -void vtkPlusWin32VideoSource2::OnParentWndDestroy() -{ - Disconnect(); - this->Internal->ParentWnd = NULL; -} - -//---------------------------------------------------------------------------- -PlusStatus vtkPlusWin32VideoSource2::AddFrameToBuffer(void* lpVideoHeader) -{ - int inputCompression = this->Internal->BitMapInfoPtr->bmiHeader.biCompression; - if (!PixelCodec::IsConvertToGraySupported(inputCompression)) - { - LOG_ERROR("AddFrameToBuffer: video compression mode " << PixelCodec::GetCompressionModeAsString(inputCompression) << ": can't grab"); - return PLUS_FAIL; - } - - LOG_TRACE("Grabbed"); - - LPVIDEOHDR lpVHdr = static_cast(lpVideoHeader); - - // the VIDEOHDR has the following contents, for quick ref: - // - // lpData pointer to locked data buffer - // dwBufferLength Length of data buffer - // dwBytesUsed Bytes actually used - // dwTimeCaptured Milliseconds from start of stream - // dwUser for client's use - // dwFlags assorted flags (see VFW.H) - // dwReserved[4] reserved for driver - - unsigned char* inputPixelsPtr = lpVHdr->lpData; - - FrameSizeType outputFrameSize; - if (this->UncompressedVideoFrame.GetFrameSize(outputFrameSize) != PLUS_SUCCESS) - { - LOG_ERROR("Unable to retrieve frame size."); - return PLUS_FAIL; - } - - if (PixelCodec::ConvertToGray(inputCompression, outputFrameSize[0], outputFrameSize[1], inputPixelsPtr, (unsigned char*)this->UncompressedVideoFrame.GetScalarPointer()) != PLUS_SUCCESS) - { - LOG_ERROR("Error while decoding the grabbed image"); - return PLUS_FAIL; - } - - this->FrameIndex++; - vtkPlusDataSource* aSource(NULL); - if (this->GetFirstVideoSource(aSource) != PLUS_SUCCESS) - { - LOG_ERROR("Unable to retrieve the video source in the Win32Video device."); - return PLUS_FAIL; - } - double indexTime = aSource->GetStartTime() + 0.001 * lpVHdr->dwTimeCaptured; - this->UncompressedVideoFrame.SetImageOrientation(aSource->GetInputImageOrientation()); - PlusStatus status = aSource->AddItem(&this->UncompressedVideoFrame, this->FrameIndex, indexTime, indexTime); - - this->Modified(); - return status; -} - -//---------------------------------------------------------------------------- -PlusStatus vtkPlusWin32VideoSource2::InternalUpdate() -{ - // just request the grab, the callback does the rest - if (!capGrabFrameNoStop(this->Internal->CapWnd)) - { - LOG_ERROR("Initialize: failed to request a single frame grab (" << GetLastError() << ")"); - return PLUS_FAIL; - } - return PLUS_SUCCESS; -} - -//---------------------------------------------------------------------------- -PlusStatus vtkPlusWin32VideoSource2::InternalStartRecording() -{ - if (!capCaptureSequenceNoFile(this->Internal->CapWnd)) - { - LOG_ERROR("Initialize: failed to request continuous frame grabbing (" << GetLastError() << ")"); - return PLUS_FAIL; - } - this->FrameIndex = 0; - //double startTime = vtkIGSIOAccurateTimer::GetSystemTime(); - //this->Buffer->SetStartTime(startTime); - return PLUS_SUCCESS; -} - -//---------------------------------------------------------------------------- -PlusStatus vtkPlusWin32VideoSource2::InternalStopRecording() -{ - if (!capCaptureStop(this->Internal->CapWnd)) - { - LOG_ERROR("Initialize: failed to request continuous frame grabbing (" << GetLastError() << ")"); - return PLUS_FAIL; - } - return PLUS_SUCCESS; -} - -//---------------------------------------------------------------------------- -PlusStatus vtkPlusWin32VideoSource2::VideoFormatDialog() -{ - if (!GetConnected()) - { - LOG_ERROR("vtkPlusWin32VideoSource2::VideoFormatDialog failed, need to connect to the device first"); - return PLUS_FAIL; - } - - //if (!this->Internal->CapDriverCaps.fHasDlgVideoFormat) - // { - // LOG_ERROR("vtkPlusWin32VideoSource2::VideoFormatDialog failed, the video device has no Format dialog."); - // return PLUS_FAIL; - // } - - capGetStatus(this->Internal->CapWnd, &this->Internal->CapStatus, sizeof(CAPSTATUS)); - if (this->Internal->CapStatus.fCapturingNow) - { - LOG_ERROR("vtkPlusWin32VideoSource2::VideoFormatDialog failed, can't alter video format while grabbing"); - return PLUS_FAIL; - } - - int success = capDlgVideoFormat(this->Internal->CapWnd); - if (!success) - { - LOG_ERROR("vtkPlusWin32VideoSource2::VideoFormatDialog failed (" << GetLastError() << ")"); - return PLUS_FAIL; - } - this->UpdateFrameBuffer(); - return PLUS_SUCCESS; -} - -//---------------------------------------------------------------------------- -PlusStatus vtkPlusWin32VideoSource2::VideoSourceDialog() -{ - if (!GetConnected()) - { - LOG_ERROR("vtkPlusWin32VideoSource2::VideoSourceDialog failed, need to connect to the device first"); - return PLUS_FAIL; - } - - //if (!this->Internal->CapDriverCaps.fHasDlgVideoSource) - // { - // LOG_ERROR("vtkPlusWin32VideoSource2::VideoFormatDialog failed, the video device has no Source dialog."); - // return PLUS_FAIL; - // } - - capGetStatus(this->Internal->CapWnd, &this->Internal->CapStatus, sizeof(CAPSTATUS)); - if (this->Internal->CapStatus.fCapturingNow) - { - LOG_ERROR("vtkPlusWin32VideoSource2::VideoFormatDialog failed, can't alter video source while grabbing"); - return PLUS_FAIL; - } - - int success = capDlgVideoSource(this->Internal->CapWnd); - if (!success) - { - LOG_ERROR("vtkPlusWin32VideoSource2::VideoSourceDialog failed (" << GetLastError() << ")"); - return PLUS_FAIL; - } - return this->UpdateFrameBuffer(); -} - -//---------------------------------------------------------------------------- -PlusStatus vtkPlusWin32VideoSource2::SetFrameSize(const FrameSizeType& frameSize) -{ - vtkPlusDataSource* aSource(NULL); - if (this->GetFirstVideoSource(aSource) != PLUS_SUCCESS) - { - LOG_ERROR(this->GetDeviceId() << ": Unable to retrieve video source."); - return PLUS_FAIL; - } - if (this->Superclass::SetInputFrameSize(*aSource, frameSize[0], frameSize[1], 1) != PLUS_SUCCESS) - { - return PLUS_FAIL; - } - if (this->GetConnected()) - { - // set up the video capture format - this->Internal->GetBitmapInfoFromCaptureDevice(); - this->Internal->BitMapInfoPtr->bmiHeader.biWidth = frameSize[0]; - this->Internal->BitMapInfoPtr->bmiHeader.biHeight = frameSize[1]; - if (this->Internal->SetBitmapInfoInCaptureDevice() != PLUS_SUCCESS) - { - LOG_ERROR("Failed to set requested frame size in the capture device"); - return PLUS_FAIL; - } - } - return PLUS_SUCCESS; -} - -//---------------------------------------------------------------------------- -PlusStatus vtkPlusWin32VideoSource2::SetAcquisitionRate(double rate) -{ - if (rate == this->AcquisitionRate) - { - // no change - return PLUS_SUCCESS; - } - - this->AcquisitionRate = rate; - - if (GetConnected()) - { - capCaptureGetSetup(this->Internal->CapWnd, &this->Internal->CaptureParms, sizeof(CAPTUREPARMS)); - if (this->AcquisitionRate > 0) - { - this->Internal->CaptureParms.dwRequestMicroSecPerFrame = int(1000000 / this->AcquisitionRate); - } - else - { - this->Internal->CaptureParms.dwRequestMicroSecPerFrame = 0; - } - capCaptureSetSetup(this->Internal->CapWnd, &this->Internal->CaptureParms, sizeof(CAPTUREPARMS)); - } - - this->Modified(); - return PLUS_SUCCESS; -} - -//---------------------------------------------------------------------------- -PlusStatus vtkPlusWin32VideoSource2::SetOutputFormat(int format) -{ - // convert color format to number of scalar components - unsigned int numberOfScalarComponents = 0; - switch (format) - { - case VTK_RGBA: - numberOfScalarComponents = 4; - break; - case VTK_RGB: - numberOfScalarComponents = 3; - break; - case VTK_LUMINANCE: - numberOfScalarComponents = 1; - break; - default: - numberOfScalarComponents = 0; - LOG_ERROR("SetOutputFormat: Unrecognized color format."); - return PLUS_FAIL; - } - - if (numberOfScalarComponents != 1) - { - LOG_ERROR("Currently only 1 component image output is supported. Requested " << numberOfScalarComponents << " components"); - return PLUS_FAIL; - } - - vtkPlusDataSource* aSource(NULL); - for (ChannelContainerIterator it = this->OutputChannels.begin(); it != this->OutputChannels.end(); ++it) - { - if ((*it)->GetVideoSource(aSource) != PLUS_SUCCESS) - { - LOG_ERROR("Unable to retrieve the video source in the win32video device on channel " << (*it)->GetChannelId()); - return PLUS_FAIL; - } - else - { - aSource->SetPixelType(VTK_UNSIGNED_CHAR); - } - } - - if (this->GetConnected()) - { - // set up the video capture format - this->Internal->GetBitmapInfoFromCaptureDevice(); - // TODO: update this->Internal->BitMapInfoPtr->bmiHeader - if (this->Internal->SetBitmapInfoInCaptureDevice() != PLUS_SUCCESS) - { - LOG_ERROR("Failed to set requested frame size in the capture device"); - return PLUS_FAIL; - } - } - return PLUS_SUCCESS; -} - -//---------------------------------------------------------------------------- -PlusStatus vtkPlusWin32VideoSource2::UpdateFrameBuffer() -{ - // get the real video format - this->Internal->GetBitmapInfoFromCaptureDevice(); - - unsigned int width(this->Internal->BitMapInfoPtr->bmiHeader.biWidth); - unsigned int height(this->Internal->BitMapInfoPtr->bmiHeader.biHeight); - igsioCommon::VTKScalarPixelType pixelType(VTK_UNSIGNED_CHAR); // always convert output to 8-bit grayscale - unsigned int numberOfScalarComponents = 1; - - vtkPlusDataSource* aSource(NULL); - if (this->GetFirstVideoSource(aSource) != PLUS_SUCCESS) - { - LOG_ERROR("Unable to access video source in vtkPlusWin32VideoSource2. Critical failure."); - return PLUS_FAIL; - } - aSource->SetInputFrameSize(width, height, 1); - aSource->SetPixelType(pixelType); - aSource->SetNumberOfScalarComponents(numberOfScalarComponents); - - FrameSizeType frameSize = {width, height, 1}; - this->UncompressedVideoFrame.AllocateFrame(frameSize, pixelType, numberOfScalarComponents); - - return PLUS_SUCCESS; -} - -//---------------------------------------------------------------------------- - -PlusStatus vtkPlusWin32VideoSource2::NotifyConfigured() -{ - if (this->OutputChannels.size() > 1) - { - LOG_WARNING("Win32VideoSource is expecting one output channel and there are " << this->OutputChannels.size() << " channels. First output channel will be used."); - return PLUS_FAIL; - } - - if (this->OutputChannels.size() == 0) - { - LOG_ERROR("No output channels defined for win32 video source. Cannot proceed."); - this->CorrectlyConfigured = false; - return PLUS_FAIL; - } - - return PLUS_SUCCESS; -} \ No newline at end of file diff --git a/src/PlusDataCollection/VideoForWindows/vtkPlusWin32VideoSource2.h b/src/PlusDataCollection/VideoForWindows/vtkPlusWin32VideoSource2.h deleted file mode 100644 index e23b28d21..000000000 --- a/src/PlusDataCollection/VideoForWindows/vtkPlusWin32VideoSource2.h +++ /dev/null @@ -1,130 +0,0 @@ -/*=Plus=header=begin====================================================== - Program: Plus - Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved. - See License.txt for details. -=========================================================Plus=header=end*/ - -/*========================================================================= -The following copyright notice is applicable to parts of this file: -Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -All rights reserved. -See Copyright.txt or http://www.kitware.com/Copyright.htm for details. -Authors include: Danielle Pace -(Robarts Research Institute and The University of Western Ontario) -=========================================================================*/ - -#ifndef __vtkPlusWin32VideoSource2_h -#define __vtkPlusWin32VideoSource2_h - -#include "vtkPlusDataCollectionExport.h" - -#include "vtkPlusDevice.h" - -class vtkPlusWin32VideoSource2Internal; - -/*! - \class vtkPlusWin32VideoSource2 - \brief Video-for-Windows video digitizer - - vtkPlusWin32VideoSource2 grabs frames or streaming video from a - Video for Windows compatible device on the Win32 platform. - vtkPlusWin32VideoSource2 is an updated version of vtkWin32VideoSource and uses - vtkPlusDevice instead of vtkVideoSource. - - Caveats: - With some capture cards, if this class is leaked and ReleaseSystemResources - is not called, you may have to reboot before you can capture again. - vtkPlusDevice used to keep a global list and delete the video sources - if your program leaked, due to exit crashes that was removed. - - \sa vtkPlusDevice vtkMILVideoSource2 vtkWin32VideoSource - \ingroup PlusLibDataCollection -*/ -class vtkPlusDataCollectionExport vtkPlusWin32VideoSource2 : public vtkPlusDevice -{ -public: - static vtkPlusWin32VideoSource2* New(); - vtkTypeMacro(vtkPlusWin32VideoSource2, vtkPlusDevice); - virtual void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; - - /*! Request a particular frame size */ - virtual PlusStatus SetFrameSize(const FrameSizeType& frameSize); - - /*! Request a particular frame rate (default 30 frames per second). */ - virtual PlusStatus SetAcquisitionRate(double rate); - - /*! Request a particular output format (default: VTK_RGB). */ - virtual PlusStatus SetOutputFormat(int format); - - /*! Turn on/off the preview (overlay) window. */ - void SetPreview(int showPreview); - vtkBooleanMacro(Preview, int); - /*! Get state of preview (overlay) window */ - vtkGetMacro(Preview, int); - - /*! Bring up a modal dialog box for video format selection. */ - PlusStatus VideoFormatDialog(); - - /*! Bring up a modal dialog box for video input selection. */ - PlusStatus VideoSourceDialog(); - - /*! Callback function called on parent window destroyed. Public to allow calling from static function. */ - void OnParentWndDestroy(); - - /*! Adds a frame to the frame buffer. Called whenever the driver notified a new frame acquisition. Public to allow calling from static function. */ - PlusStatus AddFrameToBuffer(void* lpVideoHeader); - - /*! Verify the device is correctly configured */ - virtual PlusStatus NotifyConfigured(); - - virtual bool IsTracker() const { return false; } - -protected: - - /*! Constructor */ - vtkPlusWin32VideoSource2(); - /*! Destructor */ - ~vtkPlusWin32VideoSource2(); - - /*! Device-specific connect */ - virtual PlusStatus InternalConnect(); - - /*! Device-specific disconnect */ - virtual PlusStatus InternalDisconnect(); - - /*! Device-specific recording start */ - virtual PlusStatus InternalStartRecording(); - - /*! Device-specific recording stop */ - virtual PlusStatus InternalStopRecording(); - - /*! - The internal function which actually grabs one frame. - It just requests a single frame from the hardware and the object - will be notified when it is ready. - */ - virtual PlusStatus InternalUpdate(); - - /*! Set the capture window class name */ - vtkSetStringMacro(WndClassName); - - char* WndClassName; - int Preview; - - int FrameIndex; - - vtkPlusWin32VideoSource2Internal* Internal; - - /*! Update the buffer format to match the capture settings */ - PlusStatus UpdateFrameBuffer(); - - void ReleaseSystemResources(); - - igsioVideoFrame UncompressedVideoFrame; - -private: - vtkPlusWin32VideoSource2(const vtkPlusWin32VideoSource2&); // Not implemented. - void operator=(const vtkPlusWin32VideoSource2&); // Not implemented. -}; - -#endif \ No newline at end of file diff --git a/src/PlusDataCollection/vtkPlusDeviceFactory.cxx b/src/PlusDataCollection/vtkPlusDeviceFactory.cxx index 75375ac27..13c437236 100644 --- a/src/PlusDataCollection/vtkPlusDeviceFactory.cxx +++ b/src/PlusDataCollection/vtkPlusDeviceFactory.cxx @@ -102,10 +102,6 @@ See License.txt for details. #include "vtkPlusSavedDataSource.h" #include "vtkPlusUsSimulatorVideoSource.h" -#ifdef PLUS_USE_VFW_VIDEO -#include "vtkPlusWin32VideoSource2.h" -#endif - #ifdef PLUS_USE_MMF_VIDEO #include "vtkPlusMmfVideoSource.h" #endif @@ -327,9 +323,6 @@ vtkPlusDeviceFactory::vtkPlusDeviceFactory() RegisterDevice("BkProFocus", "vtkPlusBkProFocusCameraLinkVideoSource", (PointerToDevice)&vtkPlusBkProFocusCameraLinkVideoSource::New); #endif #endif -#ifdef PLUS_USE_VFW_VIDEO - RegisterDevice("VFWVideo", "vtkPlusWin32VideoSource2", (PointerToDevice)&vtkPlusWin32VideoSource2::New); -#endif #ifdef PLUS_USE_MMF_VIDEO RegisterDevice("MmfVideo", "vtkPlusMmfVideoSource", (PointerToDevice)&vtkPlusMmfVideoSource::New); #endif diff --git a/src/UsePlusLib.cmake.in b/src/UsePlusLib.cmake.in index 266f5f8b3..48293ad2a 100644 --- a/src/UsePlusLib.cmake.in +++ b/src/UsePlusLib.cmake.in @@ -165,7 +165,6 @@ IF(NOT PLUSLIB_USE_FILE_INCLUDED) SET(PLUS_USE_THORLABS_VIDEO @PLUS_USE_THORLABS_VIDEO@) SET(PLUS_USE_ULTRASONIX_VIDEO @PLUS_USE_ULTRASONIX_VIDEO@) SET(PLUS_USE_USDIGITALENCODERS_TRACKER @PLUS_USE_USDIGITALENCODERS_TRACKER@) - SET(PLUS_USE_VFW_VIDEO @PLUS_USE_VFW_VIDEO@) SET(PLUS_USE_OpenCV_VIDEO @PLUS_USE_OpenCV_VIDEO@) SET(PLUS_USE_OPENHAPTICS @PLUS_USE_OPENHAPTICS@) SET(PLUS_USE_BLACKMAGIC_DECKLINK @PLUS_USE_BLACKMAGIC_DECKLINK@)