Commit 3d0618c8 authored by David Cole's avatar David Cole
Browse files

ENH: Automatically set default value for VTK_USE_VIDEO_FOR_WINDOWS based on...

ENH: Automatically set default value for VTK_USE_VIDEO_FOR_WINDOWS based on the result of a TRY_COMPILE if it has never been set in the cache. Add new internal only VTK_VFW_SUPPORTS_CAPTURE flag; if the video capture routines of vfw32 are supported, vtkWin32VideoSource is included. If VTK_USE_VIDEO_FOR_WINDOWS is OFF, vfw32 is not linked in, and neither the vtkAVIWriter nor the vtkWin32VideoSource class is available. Activate/add tests for recently added MPEG2Writer and AVIWriter classes. (Cross fingers for those other platforms...)
parent 3162a2ce
#include "windows.h"
#include "vfw.h"
// Can vtkWin32VideoSource.cxx be compiled?
// Test by using some of the structs in a class and
// calling some of the functions Win32VideoSource
// uses...
class vtkWin32VideoSourceInternal
{
public:
vtkWin32VideoSourceInternal() {}
HWND CapWnd;
HWND ParentWnd;
CAPSTATUS CapStatus;
CAPDRIVERCAPS CapDriverCaps;
CAPTUREPARMS CaptureParms;
LPBITMAPINFO BitMapPtr;
};
int main()
{
vtkWin32VideoSourceInternal internal;
internal.CapWnd = capCreateCaptureWindow(
"Capture", WS_CHILD|WS_VISIBLE, 0, 0, 100, 100, NULL, 1);
// capDriverConnect
// capDriverGetCaps
// capCaptureGetSetup
// capCaptureSetSetup
capSetUserData(internal.CapWnd, &internal);
// capSetCallbackOnCapControl
// capSetCallbackOnFrame
// capSetCallbackOnVideoStream
// capSetCallbackOnStatus
// capSetCallbackOnError
(void) capOverlay(internal.CapWnd, TRUE);
(void) capGetUserData(internal.CapWnd);
return 0;
}
......@@ -737,6 +737,63 @@ IF(VTK_SIZEOF_LONG_LONG)
ENDIF("VTK_ISTREAM_SUPPORTS_LONG_LONG" MATCHES "^VTK_ISTREAM_SUPPORTS_LONG_LONG$")
ENDIF(VTK_SIZEOF_LONG_LONG)
IF(VTK_USE_RENDERING AND WIN32)
# Check for vfw32 support
IF("VTK_USE_VIDEO_FOR_WINDOWS" MATCHES "^VTK_USE_VIDEO_FOR_WINDOWS$")
MESSAGE(STATUS "Checking if vfw32 is available")
TRY_COMPILE(VTK_USE_VIDEO_FOR_WINDOWS_DEFAULT
${VTK_BINARY_DIR}/CMakeTmp
${VTK_SOURCE_DIR}/CMake/vtkTestvfw32.cxx
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=vfw32"
OUTPUT_VARIABLE OUTPUT)
IF(VTK_USE_VIDEO_FOR_WINDOWS_DEFAULT)
MESSAGE(STATUS "Checking if vfw32 is available -- yes")
OPTION(VTK_USE_VIDEO_FOR_WINDOWS "Enable using Video for Windows (vfw32) for video input and output." ON)
WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log
"Checking if vfw32 is available "
"passed with the following output:\n"
"${OUTPUT}\n" APPEND)
ELSE(VTK_USE_VIDEO_FOR_WINDOWS_DEFAULT)
MESSAGE(STATUS "Checking if vfw32 is available -- no")
OPTION(VTK_USE_VIDEO_FOR_WINDOWS "Enable using Video for Windows (vfw32) for video input and output." OFF)
WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log
"Checking if vfw32 is available "
"failed with the following output:\n"
"${OUTPUT}\n" APPEND)
ENDIF(VTK_USE_VIDEO_FOR_WINDOWS_DEFAULT)
MARK_AS_ADVANCED(VTK_USE_VIDEO_FOR_WINDOWS)
ENDIF("VTK_USE_VIDEO_FOR_WINDOWS" MATCHES "^VTK_USE_VIDEO_FOR_WINDOWS$")
# Check if vfw32 supports the video capture functions
IF(VTK_USE_VIDEO_FOR_WINDOWS)
IF("VTK_VFW_SUPPORTS_CAPTURE" MATCHES "^VTK_VFW_SUPPORTS_CAPTURE$")
MESSAGE(STATUS "Checking if vfw32 supports video capture")
TRY_COMPILE(VTK_VFW_SUPPORTS_CAPTURE
${VTK_BINARY_DIR}/CMakeTmp
${VTK_SOURCE_DIR}/CMake/vtkTestvfw32Capture.cxx
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=vfw32"
OUTPUT_VARIABLE OUTPUT)
IF(VTK_VFW_SUPPORTS_CAPTURE)
MESSAGE(STATUS "Checking if vfw32 supports video capture -- yes")
SET(VTK_VFW_SUPPORTS_CAPTURE 1 CACHE INTERNAL "Enable using Video for Windows (vfw32) for video capture.")
WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log
"Checking if vfw32 supports video capture "
"passed with the following output:\n"
"${OUTPUT}\n" APPEND)
ELSE(VTK_VFW_SUPPORTS_CAPTURE)
MESSAGE(STATUS "Checking if vfw32 supports video capture -- no")
SET(VTK_VFW_SUPPORTS_CAPTURE 0 CACHE INTERNAL "Enable using Video for Windows (vfw32) for video capture.")
WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log
"Checking if vfw32 supports video capture "
"failed with the following output:\n"
"${OUTPUT}\n" APPEND)
ENDIF(VTK_VFW_SUPPORTS_CAPTURE)
ENDIF("VTK_VFW_SUPPORTS_CAPTURE" MATCHES "^VTK_VFW_SUPPORTS_CAPTURE$")
ELSE(VTK_USE_VIDEO_FOR_WINDOWS)
SET(VTK_VFW_SUPPORTS_CAPTURE 0)
ENDIF(VTK_USE_VIDEO_FOR_WINDOWS)
ENDIF(VTK_USE_RENDERING AND WIN32)
#-----------------------------------------------------------------------------
# Configure KWSys to be named "vtksys".
SET(KWSYS_NAMESPACE vtksys)
......@@ -877,9 +934,6 @@ VTK_DEPENDENT_OPTION(VTK_USE_MPI
VTK_DEPENDENT_OPTION(VTK_USE_MATROX_IMAGING
"Use Matrox Imaging Library for video input." OFF
"VTK_USE_RENDERING;WIN32" OFF)
VTK_DEPENDENT_OPTION(VTK_USE_VIDEO_FOR_WINDOWS
"Use Video for Windows for video input." OFF
"VTK_USE_RENDERING;WIN32" OFF)
VTK_DEPENDENT_OPTION(VTK_USE_GL2PS "Build VTK with gl2ps support." OFF
"VTK_USE_RENDERING" ON)
......@@ -900,8 +954,7 @@ MARK_AS_ADVANCED(VTK_OPENGL_HAS_OSMESA
VTK_USE_GL2PS
VTK_USE_MANGLED_MESA
VTK_USE_MATROX_IMAGING
VTK_USE_MPI
VTK_USE_VIDEO_FOR_WINDOWS)
VTK_USE_MPI)
#-----------------------------------------------------------------------------
# Provide options to use system versions of third-party libraries.
......
......@@ -10,7 +10,7 @@ IF(VTK_HAS_EXODUS)
ENDIF(VTK_HAS_EXODUS)
IF (WIN32)
IF (VTK_USE_VIDEO_FOR_WINDOWS)
IF (VTK_VFW_SUPPORTS_CAPTURE)
IF(BORLAND)
INCLUDE ("${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake")
CHECK_LIBRARY_EXISTS("vfw32" "printf" "" HAVE_VFW32)
......@@ -19,7 +19,7 @@ IF (WIN32)
ENDIF(NOT HAVE_VFW32)
ENDIF(BORLAND)
SET(KIT_LIBS ${KIT_LIBS} vfw32)
ENDIF (VTK_USE_VIDEO_FOR_WINDOWS)
ENDIF (VTK_VFW_SUPPORTS_CAPTURE)
IF (VTK_USE_MATROX_IMAGING)
SET(KIT_LIBS ${KIT_LIBS} ${MIL_LIBRARY})
ENDIF (VTK_USE_MATROX_IMAGING)
......@@ -70,9 +70,9 @@ IF(VTK_HAS_EXODUS)
ENDIF(VTK_HAS_EXODUS)
IF (WIN32)
IF (VTK_USE_VIDEO_FOR_WINDOWS)
IF (VTK_VFW_SUPPORTS_CAPTURE)
SET (Kit_SRCS ${Kit_SRCS} vtkWin32VideoSource.cxx)
ENDIF (VTK_USE_VIDEO_FOR_WINDOWS)
ENDIF (VTK_VFW_SUPPORTS_CAPTURE)
IF (VTK_USE_MATROX_IMAGING)
SET (Kit_SRCS ${Kit_SRCS} vtkMILVideoSource.cxx)
......
SET(KIT IO)
#
# Create a test lists
SET(ConditionalTests)
IF(VTK_USE_VIDEO_FOR_WINDOWS)
SET(ConditionalTests TestAVIWriter.cxx)
ENDIF(VTK_USE_VIDEO_FOR_WINDOWS)
CREATE_TEST_SOURCELIST(Tests ${KIT}CxxTests.cxx
TestXML.cxx
TestCompress.cxx
TestMovieWriter.cxx
${ConditionalTests}
EXTRA_INCLUDE vtkTestDriver.h
)
# Currently, only the _WIN32 branch of TestMovieWriter.cxx is
# working. Once a valid MovieWriter derived class is compiled
# and linked in on other platforms, get rid of this IF:
IF(WIN32)
# SET(Tests ${Tests} TestMovieWriter.cxx)
ENDIF(WIN32)
ADD_EXECUTABLE(${KIT}CxxTests ${Tests})
TARGET_LINK_LIBRARIES(${KIT}CxxTests vtkIO)
TARGET_LINK_LIBRARIES(${KIT}CxxTests vtkIO vtkImaging vtksys)
IF (VTK_DATA_ROOT)
ADD_TEST(TestXML ${CXX_TEST_PATH}/${KIT}CxxTests TestXML ${VTK_DATA_ROOT}/Data/sample.xml)
ADD_TEST(TestCompress ${CXX_TEST_PATH}/${KIT}CxxTests TestCompress ${VTK_DATA_ROOT}/Data/sample.xml)
ENDIF (VTK_DATA_ROOT)
ADD_TEST(TestMovieWriter ${CXX_TEST_PATH}/${KIT}CxxTests TestMovieWriter)
IF(ConditionalTests)
ADD_TEST(TestAVIWriter ${CXX_TEST_PATH}/${KIT}CxxTests TestAVIWriter)
ENDIF(ConditionalTests)
/*=========================================================================
Program: Visualization Toolkit
Module: TestAVIWriter.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm 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 notice for more information.
=========================================================================*/
// .NAME Test of vtkAVIWriter
// .SECTION Description
//
#include "vtkAVIWriter.h"
#include "vtkImageCast.h"
#include "vtkImageData.h"
#include "vtkImageMandelbrotSource.h"
#include "vtkImageMapToColors.h"
#include "vtkLookupTable.h"
#include "vtksys/SystemTools.hxx"
int TestAVIWriter(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
{
int err = 0;
int cc = 0;
int exists = 0;
unsigned long length = 0;
vtkImageMandelbrotSource* Fractal0 = vtkImageMandelbrotSource::New();
Fractal0->SetWholeExtent( 0, 247, 0, 247, 0, 0 );
Fractal0->SetProjectionAxes( 0, 1, 2 );
Fractal0->SetOriginCX( -1.75, -1.25, 0, 0 );
Fractal0->SetSizeCX( 2.5, 2.5, 2, 1.5 );
Fractal0->SetMaximumNumberOfIterations( 100);
vtkImageCast* cast = vtkImageCast::New();
cast->SetInput(Fractal0->GetOutput());
cast->SetOutputScalarTypeToUnsignedChar();
vtkLookupTable* table = vtkLookupTable::New();
table->SetTableRange(0, 100);
table->SetNumberOfColors(100);
table->Build();
table->SetTableValue(99, 0, 0, 0);
vtkImageMapToColors* colorize = vtkImageMapToColors::New();
colorize->SetOutputFormatToRGB();
colorize->SetLookupTable(table);
colorize->SetInput(cast->GetOutput());
vtkAVIWriter *w = vtkAVIWriter::New();
w->SetInput(colorize->GetOutput());
w->SetFileName("TestAVIWriter.avi");
cout << "Writing file TestAVIWriter.avi..." << endl;
w->Start();
for ( cc = 2; cc < 99; cc ++ )
{
cout << ".";
Fractal0->SetMaximumNumberOfIterations(cc);
table->SetTableRange(0, cc);
table->SetNumberOfColors(cc);
table->ForceBuild();
table->SetTableValue(cc-1, 0, 0, 0);
w->Write();
}
w->End();
cout << endl;
cout << "Done writing file TestAVIWriter.avi..." << endl;
w->Delete();
exists = (int) vtksys::SystemTools::FileExists("TestAVIWriter.avi");
length = vtksys::SystemTools::FileLength("TestAVIWriter.avi");
cout << "TestAVIWriter.avi file exists: " << exists << endl;
cout << "TestAVIWriter.avi file length: " << length << endl;
if (!exists)
{
err = 3;
cerr << "ERROR: 3 - Test failing because TestAVIWriter.avi file doesn't exist..." << endl;
}
if (0==length)
{
err = 4;
cerr << "ERROR: 4 - Test failing because TestAVIWriter.avi file has zero length..." << endl;
}
cast->Delete();
Fractal0->Delete();
// err == 0 means test passes...
//
return err;
}
#include "vtkGenericMovieWriter.h"
#include "vtkImageMandelbrotSource.h"
/*=========================================================================
Program: Visualization Toolkit
Module: TestMovieWriter.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm 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 notice for more information.
=========================================================================*/
// .NAME Test of vtkMPEG2Writer
// .SECTION Description
//
#include "vtkImageCast.h"
#include "vtkImageData.h"
#include "vtkImageMandelbrotSource.h"
#include "vtkImageMapToColors.h"
#include "vtkLookupTable.h"
#include "vtkImageData.h"
#include "vtkMPEG2Writer.h"
#include "vtksys/SystemTools.hxx"
#ifdef _WIN32
# include "vtkAVIWriter.h"
# define WRITER vtkAVIWriter
# define EXT "avi"
#else
# include "vtkMPEG2Writer.h"
# define WRITER vtkMPEG2Writer
# define EXT "mpg"
#endif
int main(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
int TestMovieWriter(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
{
int cc;
int err = 0;
int cc = 0;
int exists = 0;
unsigned long length = 0;
vtkImageMandelbrotSource* Fractal0 = vtkImageMandelbrotSource::New();
Fractal0->SetWholeExtent( 0, 250, 0, 250, 0, 0 );
Fractal0->SetWholeExtent( 0, 247, 0, 247, 0, 0 );
Fractal0->SetProjectionAxes( 0, 1, 2 );
Fractal0->SetOriginCX( -1.75, -1.25, 0, 0 );
Fractal0->SetSizeCX( 2.5, 2.5, 2, 1.5 );
......@@ -40,14 +52,14 @@ int main(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
colorize->SetLookupTable(table);
colorize->SetInput(cast->GetOutput());
vtkGenericMovieWriter *w = WRITER::New();
vtkMPEG2Writer *w = vtkMPEG2Writer::New();
w->SetInput(colorize->GetOutput());
w->SetFileName("movie." EXT);
w->SetFileName("TestMovieWriter.mpg");
cout << "Writing file TestMovieWriter.mpg..." << endl;
w->Start();
int cnt = 0;
for ( cc = 2; cc < 99; cc ++ )
{
cout << "Processing image: " << cnt++ << endl;
cout << ".";
Fractal0->SetMaximumNumberOfIterations(cc);
table->SetTableRange(0, cc);
table->SetNumberOfColors(cc);
......@@ -56,28 +68,29 @@ int main(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
w->Write();
}
w->End();
cout << endl;
cout << "Done writing file TestMovieWriter.mpg..." << endl;
w->Delete();
cnt = 0;
w = WRITER::New();
w->SetInput(colorize->GetOutput());
w->SetFileName("movie1." EXT);
w->Start();
for ( cc = 2; cc < 99; cc ++ )
exists = (int) vtksys::SystemTools::FileExists("TestMovieWriter.mpg");
length = vtksys::SystemTools::FileLength("TestMovieWriter.mpg");
cout << "TestMovieWriter.mpg file exists: " << exists << endl;
cout << "TestMovieWriter.mpg file length: " << length << endl;
if (!exists)
{
cout << "Processing image: " << cnt++ << endl;
Fractal0->SetMaximumNumberOfIterations(cc);
table->SetTableRange(0, cc);
table->SetNumberOfColors(cc);
table->ForceBuild();
table->SetTableValue(cc-1, 0, 0, 0);
w->Write();
err = 1;
cerr << "ERROR: 1 - Test failing because TestMovieWriter.mpg file doesn't exist..." << endl;
}
if (0==length)
{
err = 2;
cerr << "ERROR: 2 - Test failing because TestMovieWriter.mpg file has zero length..." << endl;
}
w->End();
w->Delete();
cast->Delete();
Fractal0->Delete();
return 0;
// err == 0 means test passes...
//
return err;
}
......@@ -73,6 +73,10 @@
#cmakedefine VTK_USE_SYSTEM_EXPAT
#cmakedefine VTK_USE_SYSTEM_FREETYPE
/* Whether VTK is using vfw32 and if it supports video capture */
#cmakedefine VTK_USE_VIDEO_FOR_WINDOWS
#cmakedefine VTK_VFW_SUPPORTS_CAPTURE
/* Whether the real python debug library has been provided. */
#cmakedefine VTK_WINDOWS_PYTHON_DEBUGGABLE
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment