VTK
vtkVideoSource.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkVideoSource.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
32 #ifndef vtkVideoSource_h
33 #define vtkVideoSource_h
34 
35 #include "vtkIOVideoModule.h" // For export macro
36 #include "vtkImageAlgorithm.h"
37 
38 class vtkTimerLog;
39 class vtkCriticalSection;
40 class vtkMultiThreader;
41 class vtkScalarsToColors;
42 
43 class VTKIOVIDEO_EXPORT vtkVideoSource : public vtkImageAlgorithm
44 {
45 public:
46  static vtkVideoSource *New();
48  void PrintSelf(ostream& os, vtkIndent indent) override;
49 
54  virtual void Record();
55 
60  virtual void Play();
61 
65  virtual void Stop();
66 
72  virtual void Rewind();
73 
78  virtual void FastForward();
79 
84  virtual void Seek(int n);
85 
89  virtual void Grab();
90 
92 
96  vtkGetMacro(Recording,int);
98 
100 
104  vtkGetMacro(Playing,int);
106 
108 
116  virtual void SetFrameSize(int x, int y, int z);
117  virtual void SetFrameSize(int dim[3]) {
118  this->SetFrameSize(dim[0], dim[1], dim[2]); };
119  vtkGetVector3Macro(FrameSize,int);
121 
123 
126  virtual void SetFrameRate(float rate);
127  vtkGetMacro(FrameRate,float);
129 
131 
135  virtual void SetOutputFormat(int format);
136  void SetOutputFormatToLuminance() { this->SetOutputFormat(VTK_LUMINANCE); };
137  void SetOutputFormatToRGB() { this->SetOutputFormat(VTK_RGB); };
138  void SetOutputFormatToRGBA() { this->SetOutputFormat(VTK_RGBA); };
139  vtkGetMacro(OutputFormat,int);
141 
143 
147  virtual void SetFrameBufferSize(int FrameBufferSize);
148  vtkGetMacro(FrameBufferSize,int);
150 
152 
158  vtkSetMacro(NumberOfOutputFrames,int);
159  vtkGetMacro(NumberOfOutputFrames,int);
161 
163 
167  vtkBooleanMacro(AutoAdvance,vtkTypeBool);
168  vtkSetMacro(AutoAdvance,vtkTypeBool)
169  vtkGetMacro(AutoAdvance,vtkTypeBool);
171 
173 
179  virtual void SetClipRegion(int r[6]) {
180  this->SetClipRegion(r[0],r[1],r[2],r[3],r[4],r[5]); };
181  virtual void SetClipRegion(int x0, int x1, int y0, int y1, int z0, int z1);
182  vtkGetVector6Macro(ClipRegion,int);
184 
186 
195  vtkSetVector6Macro(OutputWholeExtent,int);
196  vtkGetVector6Macro(OutputWholeExtent,int);
198 
200 
204  vtkSetVector3Macro(DataSpacing,double);
205  vtkGetVector3Macro(DataSpacing,double);
207 
209 
213  vtkSetVector3Macro(DataOrigin,double);
214  vtkGetVector3Macro(DataOrigin,double);
216 
218 
223  vtkSetMacro(Opacity,float);
224  vtkGetMacro(Opacity,float);
226 
228 
232  vtkGetMacro(FrameCount, int);
233  vtkSetMacro(FrameCount, int);
235 
237 
241  vtkGetMacro(FrameIndex, int);
243 
250  virtual double GetFrameTimeStamp(int frame);
251 
257  double GetFrameTimeStamp() { return this->FrameTimeStamp; };
258 
260 
264  virtual void Initialize();
265  virtual int GetInitialized() { return this->Initialized; };
267 
273  virtual void ReleaseSystemResources();
274 
280  virtual void InternalGrab();
281 
283 
287  void SetStartTimeStamp(double t) { this->StartTimeStamp = t; };
288  double GetStartTimeStamp() { return this->StartTimeStamp; };
290 
291 protected:
293  ~vtkVideoSource() override;
295 
297 
298  int FrameSize[3];
299  int ClipRegion[6];
300  int OutputWholeExtent[6];
301  double DataSpacing[3];
302  double DataOrigin[3];
304  // set according to the OutputFormat
306  // The FrameOutputExtent is the WholeExtent for a single output frame.
307  // It is initialized in ExecuteInformation.
308  int FrameOutputExtent[6];
309 
310  // save this information from the output so that we can see if the
311  // output scalars have changed
313  int LastOutputExtent[6];
314 
316  int Playing;
317  float FrameRate;
319 
322 
325 
326  float Opacity;
327 
328  // true if Execute() must apply a vertical flip to each frame
330 
331  // set if output needs to be cleared to be cleared before being written
333 
334  // An example of asynchrony
337 
338  // A mutex for the frame buffer: must be applied when any of the
339  // below data is modified.
341 
342  // set according to the needs of the hardware:
343  // number of bits per framebuffer pixel
345  // byte alignment of each row in the framebuffer
347  // FrameBufferExtent is the extent of frame after it has been clipped
348  // with ClipRegion. It is initialized in CheckBuffer().
349  int FrameBufferExtent[6];
350 
352 
353  // where the current frame is, note this decreases in time
354  // increasing values are older frames
356 
357  // number of frames from the beginning sort of,
358  // it does wrap, sometimes
360 
361 
362  void **FrameBuffer;
364 
366 
369  virtual void UpdateFrameBuffer();
370  virtual void AdvanceFrameBuffer(int n);
372  // if some component conversion is required, it is done here:
373  virtual void UnpackRasterLine(char *outPtr, char *rowPtr,
374  int start, int count);
376 
377 private:
378  vtkVideoSource(const vtkVideoSource&) = delete;
379  void operator=(const vtkVideoSource&) = delete;
380 };
381 
382 #endif
383 
384 
385 
386 
387 
vtkVideoSource::StartTimeStamp
double StartTimeStamp
Definition: vtkVideoSource.h:320
vtkVideoSource::Play
virtual void Play()
Play through the 'tape' sequentially at the specified frame rate.
vtkVideoSource::Opacity
float Opacity
Definition: vtkVideoSource.h:326
vtkVideoSource::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called in response to a REQUEST_DATA request from the executive.
vtkVideoSource::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkVideoSource::FrameCount
int FrameCount
Definition: vtkVideoSource.h:318
vtkVideoSource::FrameTimeStamp
double FrameTimeStamp
Definition: vtkVideoSource.h:321
vtkVideoSource::PlayerThreader
vtkMultiThreader * PlayerThreader
Definition: vtkVideoSource.h:335
vtkVideoSource::SetStartTimeStamp
void SetStartTimeStamp(double t)
And internal variable which marks the beginning of a Record session.
Definition: vtkVideoSource.h:287
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:42
vtkVideoSource::Rewind
virtual void Rewind()
Rewind to the frame with the earliest timestamp.
vtkVideoSource::InternalGrab
virtual void InternalGrab()
The internal function which actually does the grab.
vtkImageAlgorithm.h
vtkVideoSource::GetStartTimeStamp
double GetStartTimeStamp()
Definition: vtkVideoSource.h:288
vtkVideoSource::FrameIndex
int FrameIndex
Definition: vtkVideoSource.h:359
vtkImageAlgorithm
Generic algorithm superclass for image algs.
Definition: vtkImageAlgorithm.h:41
vtkVideoSource::UnpackRasterLine
virtual void UnpackRasterLine(char *outPtr, char *rowPtr, int start, int count)
vtkVideoSource::Stop
virtual void Stop()
Stop recording or playing.
VTK_LUMINANCE
#define VTK_LUMINANCE
Definition: vtkSystemIncludes.h:97
vtkVideoSource::FrameBufferIndex
int FrameBufferIndex
Definition: vtkVideoSource.h:355
vtkMultiThreader
A class for performing multithreaded execution.
Definition: vtkMultiThreader.h:84
vtkVideoSource::Initialized
int Initialized
Definition: vtkVideoSource.h:296
vtkVideoSource::SetFrameBufferSize
virtual void SetFrameBufferSize(int FrameBufferSize)
Set size of the frame buffer, i.e.
vtkVideoSource::FrameBufferSize
int FrameBufferSize
Definition: vtkVideoSource.h:351
vtkVideoSource::PlayerThreadId
int PlayerThreadId
Definition: vtkVideoSource.h:336
vtkVideoSource::FrameBuffer
void ** FrameBuffer
Definition: vtkVideoSource.h:362
VTK_RGB
#define VTK_RGB
Definition: vtkSystemIncludes.h:99
vtkVideoSource::ReleaseSystemResources
virtual void ReleaseSystemResources()
Release the video driver.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkVideoSource::RequestInformation
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
vtkVideoSource::Playing
int Playing
Definition: vtkVideoSource.h:316
vtkVideoSource::New
static vtkVideoSource * New()
vtkVideoSource::SetOutputFormat
virtual void SetOutputFormat(int format)
Set the output format.
vtkVideoSource::NumberOfScalarComponents
int NumberOfScalarComponents
Definition: vtkVideoSource.h:305
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:67
vtkVideoSource::Grab
virtual void Grab()
Grab a single video frame.
vtkVideoSource::GetFrameTimeStamp
double GetFrameTimeStamp()
Get a time stamp in seconds (resolution of milliseconds) for the Output.
Definition: vtkVideoSource.h:257
vtkVideoSource::AutoAdvance
vtkTypeBool AutoAdvance
Definition: vtkVideoSource.h:323
vtkVideoSource::NumberOfOutputFrames
int NumberOfOutputFrames
Definition: vtkVideoSource.h:324
vtkVideoSource::FrameBufferBitsPerPixel
int FrameBufferBitsPerPixel
Definition: vtkVideoSource.h:344
vtkVideoSource::SetOutputFormatToLuminance
void SetOutputFormatToLuminance()
Definition: vtkVideoSource.h:136
vtkVideoSource::AdvanceFrameBuffer
virtual void AdvanceFrameBuffer(int n)
vtkVideoSource::SetOutputFormatToRGBA
void SetOutputFormatToRGBA()
Definition: vtkVideoSource.h:138
vtkVideoSource::OutputNeedsInitialization
int OutputNeedsInitialization
Definition: vtkVideoSource.h:332
vtkVideoSource::Seek
virtual void Seek(int n)
Seek forwards or backwards by the specified number of frames (positive is forward,...
vtkVideoSource::SetClipRegion
virtual void SetClipRegion(int x0, int x1, int y0, int y1, int z0, int z1)
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:87
vtkVideoSource::OutputFormat
int OutputFormat
Definition: vtkVideoSource.h:303
vtkTimerLog
Timer support and logging.
Definition: vtkTimerLog.h:92
vtkVideoSource::FastForward
virtual void FastForward()
FastForward to the last frame that was recorded (i.e.
vtkVideoSource::FrameBufferMutex
vtkCriticalSection * FrameBufferMutex
Definition: vtkVideoSource.h:340
vtkVideoSource::SetFrameRate
virtual void SetFrameRate(float rate)
Request a particular frame rate (default 30 frames per second).
vtkVideoSource::vtkVideoSource
vtkVideoSource()
vtkVideoSource::SetFrameSize
virtual void SetFrameSize(int x, int y, int z)
Set the full-frame size.
vtkVideoSource::Record
virtual void Record()
Record incoming video at the specified FrameRate.
VTK_RGBA
#define VTK_RGBA
Definition: vtkSystemIncludes.h:100
vtkCriticalSection
Critical section locking class.
Definition: vtkCriticalSection.h:44
vtkVideoSource::GetInitialized
virtual int GetInitialized()
Definition: vtkVideoSource.h:265
vtkVideoSource::FrameBufferRowAlignment
int FrameBufferRowAlignment
Definition: vtkVideoSource.h:346
vtkVideoSource::FlipFrames
int FlipFrames
Definition: vtkVideoSource.h:329
vtkVideoSource::LastNumberOfScalarComponents
int LastNumberOfScalarComponents
Definition: vtkVideoSource.h:312
vtkVideoSource::FrameBufferTimeStamps
double * FrameBufferTimeStamps
Definition: vtkVideoSource.h:363
vtkVideoSource::~vtkVideoSource
~vtkVideoSource() override
vtkVideoSource::SetFrameSize
virtual void SetFrameSize(int dim[3])
Definition: vtkVideoSource.h:117
vtkVideoSource::GetFrameTimeStamp
virtual double GetFrameTimeStamp(int frame)
Get a time stamp in seconds (resolution of milliseconds) for a video frame.
vtkVideoSource::Recording
int Recording
Definition: vtkVideoSource.h:315
vtkVideoSource::Initialize
virtual void Initialize()
Initialize the hardware.
vtkVideoSource::FrameRate
float FrameRate
Definition: vtkVideoSource.h:317
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkVideoSource::UpdateFrameBuffer
virtual void UpdateFrameBuffer()
These methods can be overridden in subclasses.
vtkVideoSource::SetOutputFormatToRGB
void SetOutputFormatToRGB()
Definition: vtkVideoSource.h:137
vtkVideoSource
Superclass of video input devices for VTK.
Definition: vtkVideoSource.h:44