libcvd
timeddiskbuffer.h
1 #ifndef TIMEDDISKBUFFER_H
2 #define TIMEDDISKBUFFER_H
3 
4 #include <cvd/diskbuffer2.h>
5 
6 namespace CVD
7 {
8 
9 namespace Exceptions
10 {
13  namespace TimedDiskBuffer
14  {
18  {
19  using CVD::Exceptions::VideoBuffer::All::All;
20  };
23  struct IncompatibleListLengths : public All
24  {
26  };
27  }
28 }
29 
37 template <class T>
39 {
40  public:
46  TimedDiskBuffer(const std::vector<std::string>& names, const std::vector<double>& times, CVD::VideoBufferFlags::OnEndOfBuffer eob = CVD::VideoBufferFlags::RepeatLastFrame);
47 
48  virtual CVD::DiskBuffer2Frame<T>* get_frame();
49 
50  protected:
51  std::vector<double> file_times;
52 };
53 
54 template <class T>
55 inline TimedDiskBuffer<T>::TimedDiskBuffer(const std::vector<std::string>& names, const std::vector<double>& times, CVD::VideoBufferFlags::OnEndOfBuffer eob)
56  : CVD::DiskBuffer2<T>(names, 1, eob)
57 {
58  if(times.size() != names.size())
60  file_times = times;
61 }
62 
63 //
64 // GET FRAME
65 //
66 template <class T>
68 {
69  int current_frame = this->next_frame;
70  if(current_frame < 0)
71  current_frame = 0;
72  // get a frame from the super class
74  vf->timestamp(file_times[current_frame]);
75  return vf;
76 }
77 }
78 
79 #endif
OnEndOfBuffer
If it is a finite buffer (a video file, for example), what should happen when the end of the buffer i...
Definition: videobufferflags.h:14
All classes and functions are within the CVD namespace.
Definition: argb.h:6
virtual CVD::DiskBuffer2Frame< T > * get_frame()
Returns the next frame from the buffer. This function blocks until a frame is ready.
Definition: timeddiskbuffer.h:67
Play a series of image files as a video stream and use a list of provided timestamps.
Definition: timeddiskbuffer.h:38
void timestamp(double time)
set the time stamp, required for TimedDiskBuffer2
Definition: diskbuffer2_frame.h:29
Continue to return the final frame when get_frame() is called (with the same timestamp) ...
Definition: videobufferflags.h:16
Play a series of image files as a video stream.
Definition: diskbuffer2.h:86
list lengths for name and time lists do not agree
Definition: timeddiskbuffer.h:23
Base class for all VideoBuffer exceptions.
Definition: videobuffer.h:153
A frame from a DiskBuffer2.
Definition: diskbuffer2_frame.h:19
Base class for all DiskBuffer2 exceptions.
Definition: timeddiskbuffer.h:17
virtual DiskBuffer2Frame< T > * get_frame()
Returns the next frame from the buffer. This function blocks until a frame is ready.
Definition: diskbuffer2.h:173
TimedDiskBuffer(const std::vector< std::string > &names, const std::vector< double > &times, CVD::VideoBufferFlags::OnEndOfBuffer eob=CVD::VideoBufferFlags::RepeatLastFrame)
Construct a TimedDiskBuffer2 from a vector of filenames and timestamps.
Definition: timeddiskbuffer.h:55