VTK  9.3.1
vtkVideoSource.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
20 #ifndef vtkVideoSource_h
21 #define vtkVideoSource_h
22 
23 #include "vtkIOVideoModule.h" // For export macro
24 #include "vtkImageAlgorithm.h"
25 
26 #include <mutex> // for std::mutex
27 
28 VTK_ABI_NAMESPACE_BEGIN
29 class vtkTimerLog;
30 class vtkMultiThreader;
31 class vtkScalarsToColors;
32 
33 class VTKIOVIDEO_EXPORT vtkVideoSource : public vtkImageAlgorithm
34 {
35 public:
36  static vtkVideoSource* New();
38  void PrintSelf(ostream& os, vtkIndent indent) override;
39 
44  virtual void Record();
45 
50  virtual void Play();
51 
55  virtual void Stop();
56 
62  virtual void Rewind();
63 
68  virtual void FastForward();
69 
74  virtual void Seek(int n);
75 
79  virtual void Grab();
80 
82 
86  vtkGetMacro(Recording, int);
88 
90 
94  vtkGetMacro(Playing, int);
96 
98 
106  virtual void SetFrameSize(int x, int y, int z);
107  virtual void SetFrameSize(int dim[3]) { this->SetFrameSize(dim[0], dim[1], dim[2]); }
108  vtkGetVector3Macro(FrameSize, int);
110 
112 
115  virtual void SetFrameRate(float rate);
116  vtkGetMacro(FrameRate, float);
118 
120 
124  virtual void SetOutputFormat(int format);
125  void SetOutputFormatToLuminance() { this->SetOutputFormat(VTK_LUMINANCE); }
126  void SetOutputFormatToRGB() { this->SetOutputFormat(VTK_RGB); }
127  void SetOutputFormatToRGBA() { this->SetOutputFormat(VTK_RGBA); }
128  vtkGetMacro(OutputFormat, int);
130 
132 
136  virtual void SetFrameBufferSize(int FrameBufferSize);
137  vtkGetMacro(FrameBufferSize, int);
139 
141 
147  vtkSetMacro(NumberOfOutputFrames, int);
148  vtkGetMacro(NumberOfOutputFrames, int);
150 
152 
156  vtkBooleanMacro(AutoAdvance, vtkTypeBool);
157  vtkSetMacro(AutoAdvance, vtkTypeBool);
158  vtkGetMacro(AutoAdvance, vtkTypeBool);
160 
162 
168  virtual void SetClipRegion(int r[6]) { this->SetClipRegion(r[0], r[1], r[2], r[3], r[4], r[5]); }
169  virtual void SetClipRegion(int x0, int x1, int y0, int y1, int z0, int z1);
170  vtkGetVector6Macro(ClipRegion, int);
172 
174 
183  vtkSetVector6Macro(OutputWholeExtent, int);
184  vtkGetVector6Macro(OutputWholeExtent, int);
186 
188 
192  vtkSetVector3Macro(DataSpacing, double);
193  vtkGetVector3Macro(DataSpacing, double);
195 
197 
201  vtkSetVector3Macro(DataOrigin, double);
202  vtkGetVector3Macro(DataOrigin, double);
204 
206 
211  vtkSetMacro(Opacity, float);
212  vtkGetMacro(Opacity, float);
214 
216 
220  vtkGetMacro(FrameCount, int);
221  vtkSetMacro(FrameCount, int);
223 
225 
229  vtkGetMacro(FrameIndex, int);
231 
238  virtual double GetFrameTimeStamp(int frame);
239 
245  double GetFrameTimeStamp() { return this->FrameTimeStamp; }
246 
248 
252  virtual void Initialize();
253  virtual int GetInitialized() { return this->Initialized; }
255 
261  virtual void ReleaseSystemResources();
262 
268  virtual void InternalGrab();
269 
271 
275  void SetStartTimeStamp(double t) { this->StartTimeStamp = t; }
276  double GetStartTimeStamp() { return this->StartTimeStamp; }
278 
279 protected:
280  vtkVideoSource();
281  ~vtkVideoSource() override;
283 
285 
286  int FrameSize[3];
287  int ClipRegion[6];
288  int OutputWholeExtent[6];
289  double DataSpacing[3];
290  double DataOrigin[3];
292  // set according to the OutputFormat
294  // The FrameOutputExtent is the WholeExtent for a single output frame.
295  // It is initialized in ExecuteInformation.
296  int FrameOutputExtent[6];
297 
298  // save this information from the output so that we can see if the
299  // output scalars have changed
301  int LastOutputExtent[6];
302 
304  int Playing;
305  float FrameRate;
307 
310 
313 
314  float Opacity;
315 
316  // true if Execute() must apply a vertical flip to each frame
318 
319  // set if output needs to be cleared to be cleared before being written
321 
322  // An example of asynchrony
325 
326  // A mutex for the frame buffer: must be applied when any of the
327  // below data is modified.
328  std::mutex FrameBufferMutex;
329 
330  // set according to the needs of the hardware:
331  // number of bits per framebuffer pixel
333  // byte alignment of each row in the framebuffer
335  // FrameBufferExtent is the extent of frame after it has been clipped
336  // with ClipRegion. It is initialized in CheckBuffer().
337  int FrameBufferExtent[6];
338 
340 
341  // where the current frame is, note this decreases in time
342  // increasing values are older frames
344 
345  // number of frames from the beginning sort of,
346  // it does wrap, sometimes
348 
349  void** FrameBuffer;
351 
353 
356  virtual void UpdateFrameBuffer();
357  virtual void AdvanceFrameBuffer(int n);
359  // if some component conversion is required, it is done here:
360  virtual void UnpackRasterLine(char* outPtr, char* rowPtr, int start, int count);
362 
363 private:
364  vtkVideoSource(const vtkVideoSource&) = delete;
365  void operator=(const vtkVideoSource&) = delete;
366 };
367 
368 VTK_ABI_NAMESPACE_END
369 #endif
virtual int GetInitialized()
Initialize the hardware.
Store vtkAlgorithm input/output information.
virtual void SetClipRegion(int r[6])
Set the clip rectangle for the frames.
void SetOutputFormatToRGB()
Set the output format.
A class for performing multithreaded execution.
int NumberOfScalarComponents
double * FrameBufferTimeStamps
Superclass of video input devices for VTK.
virtual void SetFrameSize(int dim[3])
Set the full-frame size.
void SetOutputFormatToRGBA()
Set the output format.
#define VTK_LUMINANCE
int vtkTypeBool
Definition: vtkABI.h:64
Timer support and logging.
Definition: vtkTimerLog.h:84
Superclass for mapping scalar values to colors.
vtkTypeBool AutoAdvance
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
double GetStartTimeStamp()
And internal variable which marks the beginning of a Record session.
vtkMultiThreader * PlayerThreader
double GetFrameTimeStamp()
Get a time stamp in seconds (resolution of milliseconds) for the Output.
void SetOutputFormatToLuminance()
Set the output format.
#define VTK_RGBA
#define VTK_RGB
int OutputNeedsInitialization
std::mutex FrameBufferMutex
Generic algorithm superclass for image algs.
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetStartTimeStamp(double t)
And internal variable which marks the beginning of a Record session.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called in response to a REQUEST_DATA request from the executive.
int LastNumberOfScalarComponents