libcvd
colourspacebuffer.h
1 // PAS 17/6/04 (revised 16/2/05)
2 
3 #ifndef CVD_INCLUDE_COLOURSPACEBUFFER_H
4 #define CVD_INCLUDE_COLOURSPACEBUFFER_H
5 
6 #include <cvd/colourspace_convert.h>
7 #include <cvd/colourspace_frame.h>
8 #include <cvd/convert_image.h>
9 #include <cvd/localvideobuffer.h>
10 
11 namespace CVD
12 {
32 template <class T, class From>
34 {
35  public:
39  : LocalVideoBuffer<T>(buf.type())
40  , m_vidbuf(buf)
41  , m_size(buf.size())
42  {
43  }
44 
46  {
47  return &m_vidbuf;
48  }
49 
52  {
53  return m_size;
54  }
55 
56  virtual bool frame_pending()
57  {
58  return m_vidbuf.frame_pending();
59  }
60 
61  virtual void seek_to(double t)
62  {
63  m_vidbuf.seek_to(t);
64  }
65 
66  virtual double frame_rate()
67  {
68  return m_vidbuf.frame_rate();
69  }
70 
72  {
73  VideoFrame<From>* fr = m_vidbuf.get_frame();
74  Image<T> cv = convert_image<T>(*fr);
75  ColourspaceFrame<T>* ret = new ColourspaceFrame<T>(fr->timestamp(), std::move(cv));
76  m_vidbuf.put_frame(fr);
77  return ret;
78  }
79 
80  virtual void put_frame(CVD::VideoFrame<T>* f)
81  {
82  //Check that the type is correct...
83  ColourspaceFrame<T>* csf = dynamic_cast<ColourspaceFrame<T>*>(f);
84 
85  if(csf == NULL)
87  else
88  delete csf;
89  }
90 
91  private:
92  CVD::VideoBuffer<From>& m_vidbuf;
93  ImageRef m_size;
94 };
95 
97 template <class T, class From>
99 {
100  public:
104  : ColourspaceBuffer<T, From>(*buf)
105  , vb(buf)
106  {
107  }
108 
110  {
111  delete vb;
112  }
113 
114  private:
115  VideoBuffer<From>* vb;
116 };
117 
118 }
119 #endif
virtual bool frame_pending()
Is there a frame waiting in the buffer? This function does not block.
Definition: colourspacebuffer.h:56
A frame from a ColourspaceBuffer. Can be treated as a VideoFrame.
Definition: colourspace_frame.h:13
virtual double frame_rate()
What is the (expected) frame rate of this video buffer, in frames per second?
Definition: colourspacebuffer.h:66
virtual void seek_to(double t)
Go to a particular point in the video buffer (only implemented in buffers of recorded video) ...
Definition: colourspacebuffer.h:61
Base class which provides untyped access to video grabber objects.
Definition: videobuffer.h:39
All classes and functions are within the CVD namespace.
Definition: argb.h:6
virtual void put_frame(VideoFrame< T > *f)=0
Tell the buffer that you are finished with this frame.
virtual bool frame_pending()=0
Is there a frame waiting in the buffer? This function does not block.
ColourspaceBuffer(CVD::VideoBuffer< From > &buf)
Construct a ColourspaceBuffer by wrapping it around another VideoBuffer.
Definition: colourspacebuffer.h:38
ImageRef size()
The size of the VideoFrames returns by this buffer.
Definition: colourspacebuffer.h:51
VideoBufferType::Type type()
Returns the type of the video stream.
Definition: videobuffer.h:136
virtual void seek_to(double)
Go to a particular point in the video buffer (only implemented in buffers of recorded video) ...
Definition: videobuffer.h:72
virtual double frame_rate()=0
What is the (expected) frame rate of this video buffer, in frames per second?
virtual CVD::ColourspaceFrame< T > * get_frame()
Returns the next frame from the buffer. This function blocks until a frame is ready.
Definition: colourspacebuffer.h:71
A decorator class which wraps a VideoBuffer to perfrom colourspace conversion on the incoming data...
Definition: colourspacebuffer.h:33
virtual void put_frame(CVD::VideoFrame< T > *f)
Tell the buffer that you are finished with this frame.
Definition: colourspacebuffer.h:80
ColourspaceBuffer_managed(CVD::VideoBuffer< From > *buf)
Construct a ColourspaceBuffer by wrapping it around another VideoBuffer.
Definition: colourspacebuffer.h:103
Base class for a VideoBuffer which manages its own memory for each VideoFrame that it provides...
Definition: localvideobuffer.h:17
Definition: image_ref.h:29
This is just like ColourspaceBuffer, except it deleted the videobuffer on destruction.
Definition: colourspacebuffer.h:98
The VideoBuffer was unable to successfully complete a VideoBuffer::put_frame() operation.
Definition: videobuffer.h:160
virtual VideoFrame< T > * get_frame()=0
Returns the next frame from the buffer. This function blocks until a frame is ready.
A frame from a VideoBuffer.
Definition: videoframe.h:35
A full image which manages its own data.
Definition: image.h:623
virtual RawVideoBuffer * source_buffer()
Which video grabber provides the source images for this video grabber.
Definition: colourspacebuffer.h:45