Commit 31b3511d authored by David Gobbi's avatar David Gobbi

NEW: vtkWin32VideoSource for Video for Windows support

FIX: the SetPlaying() method was breaking regression testing: it
     has been removed
parent e38eb8a6
This diff is collapsed.
......@@ -53,6 +53,7 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "vtkVideoSource.h"
// digitizer hardware
#define VTK_MIL_DEFAULT 0
#define VTK_MIL_METEOR 1
#define VTK_MIL_METEOR_II 2
......@@ -61,6 +62,21 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#define VTK_MIL_PULSAR 5
#define VTK_MIL_GENESIS 6
// video inputs:
#define VTK_MIL_MONO 0
#define VTK_MIL_COMPOSITE 1
#define VTK_MIL_YC 2
#define VTK_MIL_RGB 3
#define VTK_MIL_DIGITAL 4
// video formats:
#define VTK_MIL_RS170 0
#define VTK_MIL_NTSC 1
#define VTK_MIL_CCIR 2
#define VTK_MIL_PAL 3
#define VTK_MIL_SECAM 4
#define VTK_MIL_NONSTANDARD 5
class VTK_EXPORT vtkMILVideoSource : public vtkVideoSource
{
public:
......@@ -71,16 +87,53 @@ public:
// Description:
// See vtkVideoSource
void Initialize();
void ReleaseSystemResources();
void Grab(int n);
void Grab() { this->Grab(1); };
void Play();
void Stop();
void SetFrameSize(int x, int y, int z);
void SetOutputFormat(int format);
void SetVideoChannel(int channel);
void SetVideoFormat(int format);
void SetVideoInput(int input);
// Description:
// Set/Get the video channel
virtual void SetVideoChannel(int channel);
vtkGetMacro(VideoChannel, int);
// Description:
// Set/Get the video format
virtual void SetVideoFormat(int format);
void SetVideoFormatToNTSC() { this->SetVideoFormat(VTK_MIL_NTSC); };
void SetVideoFormatToPAL() { this->SetVideoFormat(VTK_MIL_PAL); };
void SetVideoFormatToSECAM() { this->SetVideoFormat(VTK_MIL_SECAM); };
void SetVideoFormatToRS170() { this->SetVideoFormat(VTK_MIL_RS170); };
void SetVideoFormatToCCIR() { this->SetVideoFormat(VTK_MIL_CCIR); };
void SetVideoFormatToNonStandard() {
this->SetVideoFormat(VTK_MIL_NONSTANDARD); };
vtkGetMacro(VideoFormat,int);
// Description:
// Set/Get the video input
virtual void SetVideoInput(int input);
void SetVideoInputToMono() { this->SetVideoInput(VTK_MIL_MONO); };
void SetVideoInputToComposite() {this->SetVideoInput(VTK_MIL_COMPOSITE);};
void SetVideoInputToYC() { this->SetVideoInput(VTK_MIL_YC); };
void SetVideoInputToRGB() { this->SetVideoInput(VTK_MIL_RGB); };
void SetVideoInputToDigital() { this->SetVideoInput(VTK_MIL_DIGITAL); };
vtkGetMacro(VideoInput,int);
// Description:
// Set/Get the video levels: the valid range is [0.0,2.0]
virtual void SetContrastLevel(float contrast);
vtkGetMacro(ContrastLevel,float);
virtual void SetBrightnessLevel(float brightness);
vtkGetMacro(BrightnessLevel,float);
virtual void SetHueLevel(float hue);
vtkGetMacro(HueLevel,float);
virtual void SetSaturationLevel(float saturation);
vtkGetMacro(SaturationLevel,float);
// Description:
// Set the system which you want use. If you don't specify a system,
......@@ -110,7 +163,7 @@ public:
vtkGetMacro(MILDigitizerNumber,int);
// Description:
// Set whether to display MIL error messages (default off)
// Set whether to display MIL error messages (default on)
virtual void SetMILErrorMessages(int yesno);
vtkBooleanMacro(MILErrorMessages,int);
vtkGetMacro(MILErrorMessages,int);
......@@ -141,6 +194,21 @@ protected:
virtual void AllocateMILDigitizer();
virtual void AllocateMILBuffer();
virtual void *MILInterpreterForSystem(int system);
char *MILInterpreterDLL;
int VideoChannel;
int VideoInput;
int VideoInputForColor;
int VideoFormat;
float ContrastLevel;
float BrightnessLevel;
float HueLevel;
float SaturationLevel;
int FrameMaxSize[2];
long MILAppID;
long MILSysID;
long MILDigID;
......@@ -158,6 +226,8 @@ protected:
int MILAppInternallyAllocated;
int MILSysInternallyAllocated;
int FatalMILError;
};
#endif
This diff is collapsed.
......@@ -57,15 +57,6 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "vtkImageSource.h"
#include "vtkScalarsToColors.h"
// video inputs: which are available depends on the driver
enum { VTK_VIDEO_MONO, VTK_VIDEO_COMPOSITE, VTK_VIDEO_YC, VTK_VIDEO_RGB,
VTK_VIDEO_DIGITAL };
// video formats: which are available depends on the driver
enum { VTK_VIDEO_RS170, VTK_VIDEO_NTSC,
VTK_VIDEO_CCIR, VTK_VIDEO_PAL, VTK_VIDEO_SECAM,
VTK_VIDEO_NONSTANDARD };
class VTK_EXPORT vtkVideoSource : public vtkImageSource
{
public:
......@@ -74,10 +65,15 @@ public:
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Initialize the hardware (this will be called automatically
// Initialize the hardware. This is called automatically
// on the first Update or Grab)
virtual void Initialize();
// Description:
// Release the video driver. This is called automatically
// when the vtkVideoSource is destroyed.
virtual void ReleaseSystemResources();
// Description:
// Grab a single frame or multiple frames
virtual void Grab(int n);
......@@ -93,22 +89,12 @@ public:
// Description:
// Are we in continuous grab mode?
void SetPlaying(int playing) {
if (playing)
{
this->Play();
}
else
{
this->Stop();
}
};
vtkGetMacro(Playing,int);
// Description:
// Set the frame rate for 'Play' mode. The default is zero, which forces
// one synchronous grab per Update
virtual void SetFrameRate(float rate);
vtkSetMacro(FrameRate,float);
vtkGetMacro(FrameRate,float);
// Description:
......@@ -153,16 +139,15 @@ public:
// Description:
// Advance the buffer by one frame
void Advance(int n) {
if (!this->Playing) { this->AdvanceFrameBuffer(n); this->Modified(); } };
void Advance() { this->Advance(-1); };
virtual void Advance(int n);
virtual void Advance() { this->Advance(-1); };
// Description:
// Circulate the buffer to bring the previous image to the top.
// If n is negative, then this circulates the buffer in the opposite
// direction.
void Rewind(int n) { this->Advance(-n); };
void Rewind() { this->Advance(-1); };
virtual void Rewind(int n) { this->Advance(-n); };
virtual void Rewind() { this->Advance(-1); };
// Description:
// Set the clip rectangle for the frames. The video will be clipped
......@@ -196,33 +181,6 @@ public:
vtkSetVector3Macro(DataOrigin,float);
vtkGetVector3Macro(DataOrigin,float);
// Description:
// Set/Get the video channel (only supported on some hardware)
vtkSetMacro(VideoChannel, int);
vtkGetMacro(VideoChannel,int);
// Description:
// Set/Get the video format (only supported on some hardware)
vtkSetMacro(VideoFormat, int);
void SetVideoFormatToNTSC() { this->SetVideoFormat(VTK_VIDEO_NTSC); };
void SetVideoFormatToPAL() { this->SetVideoFormat(VTK_VIDEO_PAL); };
void SetVideoFormatToSECAM() { this->SetVideoFormat(VTK_VIDEO_SECAM); };
void SetVideoFormatToRS170() { this->SetVideoFormat(VTK_VIDEO_RS170); };
void SetVideoFormatToCCIR() { this->SetVideoFormat(VTK_VIDEO_CCIR); };
void SetVideoFormatToNonStandard() {
this->SetVideoFormat(VTK_VIDEO_NONSTANDARD); };
vtkGetMacro(VideoFormat,int);
// Description:
// Set/Get the video input (only supported on some hardware)
vtkSetMacro(VideoInput,int);
void SetVideoInputToMono() { this->SetVideoInput(VTK_VIDEO_MONO); };
void SetVideoInputToComposite() {this->SetVideoInput(VTK_VIDEO_COMPOSITE);};
void SetVideoInputToYC() { this->SetVideoInput(VTK_VIDEO_YC); };
void SetVideoInputToRGB() { this->SetVideoInput(VTK_VIDEO_RGB); };
void SetVideoInputToDigital() { this->SetVideoInput(VTK_VIDEO_DIGITAL); };
vtkGetMacro(VideoInput,int);
// Description:
// For RGBA output only (4 scalar components), set the opacity. You will
// not see the effect until the next Grab.
......@@ -238,15 +196,12 @@ public:
// Description:
// Get a time stamp in seconds (resolution of milliseconds) for
// a video frame. Time began on Jan 1, 1970.
double GetFrameTimeStamp() {
return this->FrameBufferTimeStamps[this->FrameBufferIndex]; };
double GetFrameTimeStamp(int frame) {
return this->FrameBufferTimeStamps[(this->FrameBufferIndex + frame) \
% this->FrameBufferSize]; };
virtual double GetFrameTimeStamp(int frame);
virtual double GetFrameTimeStamp() { return this->GetFrameTimeStamp(0); };
// Description:
// Set this flag to automatically do a grab on each Update
vtkSetMacro(GrabOnUpdate,int);
virtual void SetGrabOnUpdate(int yesno);
vtkBooleanMacro(GrabOnUpdate,int);
vtkGetMacro(GrabOnUpdate,int);
......@@ -291,11 +246,6 @@ protected:
int AutoAdvance;
int NumberOfOutputFrames;
int VideoChannel;
int VideoInput;
int VideoInputForColor;
int VideoFormat;
float Opacity;
int Preview;
......
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkWin32VideoSource.h
Language: C++
Date: $Date$
Version: $Revision$
Thanks: Thanks to David G. Gobbi who developed this class.
Copyright (c) 1993-1999 Ken Martin, Will Schroeder, Bill Lorensen.
This software is copyrighted by Ken Martin, Will Schroeder and Bill Lorensen.
The following terms apply to all files associated with the software unless
explicitly disclaimed in individual files. This copyright specifically does
not apply to the related textbook "The Visualization Toolkit" ISBN
013199837-4 published by Prentice Hall which is covered by its own copyright.
The authors hereby grant permission to use, copy, and distribute this
software and its documentation for any purpose, provided that existing
copyright notices are retained in all copies and that this notice is included
verbatim in any distributions. Additionally, the authors grant permission to
modify this software and its documentation for any purpose, provided that
such modifications are not distributed without the explicit consent of the
authors and that existing copyright notices are retained in all copies. Some
of the algorithms implemented by this software are patented, observe all
applicable patent law.
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
"AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
=========================================================================*/
// .NAME vtkWin32VideoSource - Video-for-Windows video digitizer
// .SECTION Description
// vtkWin32VideoSource grabs frames or streaming video from a
// Video for Windows compatible device on the Win32 platform.
// .SECTION See Also
// vtkVideoSource vtkMILVideoSource
#ifndef __vtkWin32VideoSource_h
#define __vtkWin32VideoSource_h
#include "vtkVideoSource.h"
#include <windows.h>
#include <winuser.h>
#include <vfw.h>
class VTK_EXPORT vtkWin32VideoSource : public vtkVideoSource
{
public:
static vtkWin32VideoSource *New();
const char *GetClassName() {return "vtkWin32VideoSource";};
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// See vtkVideoSource
void Initialize();
void ReleaseSystemResources();
void Grab(int n);
void Grab() { this->Grab(1); };
void Play();
void Stop();
void SetFrameSize(int x, int y, int z);
void SetFrameRate(float rate);
void SetOutputFormat(int format);
// Description:
// bring up a modal dialog box for video format selection
void VideoFormatDialog();
// Description:
// bring up a modal dialog box for video input selection
void VideoSourceDialog();
// Description:
// For internal use only
void InternalGrab(LPVIDEOHDR VideoHdrPtr);
protected:
vtkWin32VideoSource();
~vtkWin32VideoSource();
vtkWin32VideoSource(const vtkWin32VideoSource&) {};
void operator=(const vtkWin32VideoSource&) {};
char WndClassName[16];
HWND CapWnd;
HWND ParentWnd;
CAPSTATUS CapStatus;
CAPDRIVERCAPS CapDriverCaps;
CAPTUREPARMS CaptureParms;
LPBITMAPINFO BitMapPtr;
int BitMapSize;
int FatalVFWError;
void CheckBuffer();
void UnpackRasterLine(char *outptr, char *inptr,
int start, int count);
void DoVFWFormatSetup();
void DoVFWFormatCheck();
};
#endif
Markdown is supported
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