VTK  9.0.20201019
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]) { this->SetFrameSize(dim[0], dim[1], dim[2]); }
118  vtkGetVector3Macro(FrameSize, int);
120 
122 
125  virtual void SetFrameRate(float rate);
126  vtkGetMacro(FrameRate, float);
128 
130 
134  virtual void SetOutputFormat(int format);
135  void SetOutputFormatToLuminance() { this->SetOutputFormat(VTK_LUMINANCE); }
136  void SetOutputFormatToRGB() { this->SetOutputFormat(VTK_RGB); }
137  void SetOutputFormatToRGBA() { this->SetOutputFormat(VTK_RGBA); }
138  vtkGetMacro(OutputFormat, int);
140 
142 
146  virtual void SetFrameBufferSize(int FrameBufferSize);
147  vtkGetMacro(FrameBufferSize, int);
149 
151 
157  vtkSetMacro(NumberOfOutputFrames, int);
158  vtkGetMacro(NumberOfOutputFrames, int);
160 
162 
166  vtkBooleanMacro(AutoAdvance, vtkTypeBool);
167  vtkSetMacro(AutoAdvance, vtkTypeBool);
168  vtkGetMacro(AutoAdvance, vtkTypeBool);
170 
172 
178  virtual void SetClipRegion(int r[6]) { this->SetClipRegion(r[0], r[1], r[2], r[3], r[4], r[5]); }
179  virtual void SetClipRegion(int x0, int x1, int y0, int y1, int z0, int z1);
180  vtkGetVector6Macro(ClipRegion, int);
182 
184 
193  vtkSetVector6Macro(OutputWholeExtent, int);
194  vtkGetVector6Macro(OutputWholeExtent, int);
196 
198 
202  vtkSetVector3Macro(DataSpacing, double);
203  vtkGetVector3Macro(DataSpacing, double);
205 
207 
211  vtkSetVector3Macro(DataOrigin, double);
212  vtkGetVector3Macro(DataOrigin, double);
214 
216 
221  vtkSetMacro(Opacity, float);
222  vtkGetMacro(Opacity, float);
224 
226 
230  vtkGetMacro(FrameCount, int);
231  vtkSetMacro(FrameCount, int);
233 
235 
239  vtkGetMacro(FrameIndex, int);
241 
248  virtual double GetFrameTimeStamp(int frame);
249 
255  double GetFrameTimeStamp() { return this->FrameTimeStamp; }
256 
258 
262  virtual void Initialize();
263  virtual int GetInitialized() { return this->Initialized; }
265 
271  virtual void ReleaseSystemResources();
272 
278  virtual void InternalGrab();
279 
281 
285  void SetStartTimeStamp(double t) { this->StartTimeStamp = t; }
286  double GetStartTimeStamp() { return this->StartTimeStamp; }
288 
289 protected:
290  vtkVideoSource();
291  ~vtkVideoSource() override;
293 
295 
296  int FrameSize[3];
297  int ClipRegion[6];
298  int OutputWholeExtent[6];
299  double DataSpacing[3];
300  double DataOrigin[3];
302  // set according to the OutputFormat
304  // The FrameOutputExtent is the WholeExtent for a single output frame.
305  // It is initialized in ExecuteInformation.
306  int FrameOutputExtent[6];
307 
308  // save this information from the output so that we can see if the
309  // output scalars have changed
311  int LastOutputExtent[6];
312 
314  int Playing;
315  float FrameRate;
317 
320 
323 
324  float Opacity;
325 
326  // true if Execute() must apply a vertical flip to each frame
328 
329  // set if output needs to be cleared to be cleared before being written
331 
332  // An example of asynchrony
335 
336  // A mutex for the frame buffer: must be applied when any of the
337  // below data is modified.
339 
340  // set according to the needs of the hardware:
341  // number of bits per framebuffer pixel
343  // byte alignment of each row in the framebuffer
345  // FrameBufferExtent is the extent of frame after it has been clipped
346  // with ClipRegion. It is initialized in CheckBuffer().
347  int FrameBufferExtent[6];
348 
350 
351  // where the current frame is, note this decreases in time
352  // increasing values are older frames
354 
355  // number of frames from the beginning sort of,
356  // it does wrap, sometimes
358 
359  void** FrameBuffer;
361 
363 
366  virtual void UpdateFrameBuffer();
367  virtual void AdvanceFrameBuffer(int n);
369  // if some component conversion is required, it is done here:
370  virtual void UnpackRasterLine(char* outPtr, char* rowPtr, int start, int count);
372 
373 private:
374  vtkVideoSource(const vtkVideoSource&) = delete;
375  void operator=(const vtkVideoSource&) = delete;
376 };
377 
378 #endif
vtkVideoSource::StartTimeStamp
double StartTimeStamp
Definition: vtkVideoSource.h:318
vtkImageAlgorithm::RequestData
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called in response to a REQUEST_DATA request from the executive.
vtkVideoSource::Opacity
float Opacity
Definition: vtkVideoSource.h:324
vtkVideoSource::FrameCount
int FrameCount
Definition: vtkVideoSource.h:316
vtkVideoSource::FrameTimeStamp
double FrameTimeStamp
Definition: vtkVideoSource.h:319
vtkVideoSource::PlayerThreader
vtkMultiThreader * PlayerThreader
Definition: vtkVideoSource.h:333
vtkVideoSource::SetStartTimeStamp
void SetStartTimeStamp(double t)
And internal variable which marks the beginning of a Record session.
Definition: vtkVideoSource.h:285
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkImageAlgorithm.h
vtkVideoSource::GetStartTimeStamp
double GetStartTimeStamp()
Definition: vtkVideoSource.h:286
vtkVideoSource::FrameIndex
int FrameIndex
Definition: vtkVideoSource.h:357
vtkImageAlgorithm
Generic algorithm superclass for image algs.
Definition: vtkImageAlgorithm.h:37
VTK_LUMINANCE
#define VTK_LUMINANCE
Definition: vtkSystemIncludes.h:84
vtkVideoSource::FrameBufferIndex
int FrameBufferIndex
Definition: vtkVideoSource.h:353
vtkMultiThreader
A class for performing multithreaded execution.
Definition: vtkMultiThreader.h:76
vtkVideoSource::Initialized
int Initialized
Definition: vtkVideoSource.h:294
vtkVideoSource::FrameBufferSize
int FrameBufferSize
Definition: vtkVideoSource.h:349
vtkVideoSource::PlayerThreadId
int PlayerThreadId
Definition: vtkVideoSource.h:334
vtkImageAlgorithm::RequestInformation
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
vtkVideoSource::FrameBuffer
void ** FrameBuffer
Definition: vtkVideoSource.h:359
VTK_RGB
#define VTK_RGB
Definition: vtkSystemIncludes.h:86
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkVideoSource::Playing
int Playing
Definition: vtkVideoSource.h:314
vtkVideoSource::NumberOfScalarComponents
int NumberOfScalarComponents
Definition: vtkVideoSource.h:303
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:59
vtkVideoSource::GetFrameTimeStamp
double GetFrameTimeStamp()
Get a time stamp in seconds (resolution of milliseconds) for the Output.
Definition: vtkVideoSource.h:255
vtkVideoSource::AutoAdvance
vtkTypeBool AutoAdvance
Definition: vtkVideoSource.h:321
vtkVideoSource::NumberOfOutputFrames
int NumberOfOutputFrames
Definition: vtkVideoSource.h:322
vtkVideoSource::FrameBufferBitsPerPixel
int FrameBufferBitsPerPixel
Definition: vtkVideoSource.h:342
vtkVideoSource::SetOutputFormatToLuminance
void SetOutputFormatToLuminance()
Definition: vtkVideoSource.h:135
vtkVideoSource::SetOutputFormatToRGBA
void SetOutputFormatToRGBA()
Definition: vtkVideoSource.h:137
vtkVideoSource::OutputNeedsInitialization
int OutputNeedsInitialization
Definition: vtkVideoSource.h:330
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkImageAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAlgorithm::New
static vtkAlgorithm * New()
vtkVideoSource::OutputFormat
int OutputFormat
Definition: vtkVideoSource.h:301
vtkTimerLog
Timer support and logging.
Definition: vtkTimerLog.h:90
vtkVideoSource::FrameBufferMutex
vtkCriticalSection * FrameBufferMutex
Definition: vtkVideoSource.h:338
VTK_RGBA
#define VTK_RGBA
Definition: vtkSystemIncludes.h:87
vtkCriticalSection
Critical section locking class.
Definition: vtkCriticalSection.h:43
vtkVideoSource::GetInitialized
virtual int GetInitialized()
Definition: vtkVideoSource.h:263
vtkVideoSource::FrameBufferRowAlignment
int FrameBufferRowAlignment
Definition: vtkVideoSource.h:344
vtkVideoSource::FlipFrames
int FlipFrames
Definition: vtkVideoSource.h:327
vtkVideoSource::LastNumberOfScalarComponents
int LastNumberOfScalarComponents
Definition: vtkVideoSource.h:310
vtkVideoSource::FrameBufferTimeStamps
double * FrameBufferTimeStamps
Definition: vtkVideoSource.h:360
vtkVideoSource::SetFrameSize
virtual void SetFrameSize(int dim[3])
Definition: vtkVideoSource.h:117
vtkVideoSource::Recording
int Recording
Definition: vtkVideoSource.h:313
vtkVideoSource::FrameRate
float FrameRate
Definition: vtkVideoSource.h:315
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkVideoSource::SetClipRegion
virtual void SetClipRegion(int r[6])
Set the clip rectangle for the frames.
Definition: vtkVideoSource.h:178
vtkVideoSource::SetOutputFormatToRGB
void SetOutputFormatToRGB()
Definition: vtkVideoSource.h:136
vtkVideoSource
Superclass of video input devices for VTK.
Definition: vtkVideoSource.h:43