[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd cvd/videobuffer.h cvd/Linux/v4l1buffer.h...
From: |
Edward Rosten |
Subject: |
[libcvd-members] libcvd cvd/videobuffer.h cvd/Linux/v4l1buffer.h... |
Date: |
Fri, 28 Nov 2008 16:56:12 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Changes by: Edward Rosten <edrosten> 08/11/28 16:56:12
Modified files:
cvd : videobuffer.h
cvd/Linux : v4l1buffer.h v4lbuffer.h
progs : calibrate.cxx
Log message:
Initial implementation of Live/Flushable/NotLive semantics for video
buffers.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/videobuffer.h?cvsroot=libcvd&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/Linux/v4l1buffer.h?cvsroot=libcvd&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/Linux/v4lbuffer.h?cvsroot=libcvd&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/libcvd/progs/calibrate.cxx?cvsroot=libcvd&r1=1.11&r2=1.12
Patches:
Index: cvd/videobuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/videobuffer.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- cvd/videobuffer.h 28 Aug 2008 06:56:32 -0000 1.11
+++ cvd/videobuffer.h 28 Nov 2008 16:56:04 -0000 1.12
@@ -59,7 +59,25 @@
class VideoBuffer
{
public:
- virtual ~VideoBuffer(){}
+ enum Type
+ {
+ NotLive,
+ Live,
+ Flushable
+ };
+
+ ///Default to the most general semantics
+ VideoBuffer()
+ :m_type(NotLive)
+ {}
+
+ ///Construct the buffer with the known semantics
+ VideoBuffer(Type _type)
+ :m_type(_type)
+ {}
+
+ virtual ~VideoBuffer()
+ {}
/// The size of the VideoFrames returned by this buffer
virtual ImageRef size()=0;
@@ -69,7 +87,33 @@
/// \param f The frame that you are finished with.
virtual void put_frame(VideoFrame<T>* f)=0;
/// Is there a frame waiting in the buffer? This function does
not block.
+ /// See is_live and is_flushable.
virtual bool frame_pending()=0;
+
+ /// Returns the type of the video stream
+ ///
+ /// A video with live semantics has frames fed at
+ /// some externally controlled rate, such as from a
+ /// video camera.
+ ///
+ /// A stream with live semantics also may be flushable, in
+ /// that all current frames can be removed from the stream
+ /// while frame_pending() is 1, and then the next get_frame()
+ /// will sleep until a frame arrives. This ensures that the
latency
+ /// is low by discarding any old frames. Buffers flushable in
this
+ /// manner have a type of VideoBuffer::Type::Flushable.
+ ///
+ /// Some live streams are not flushable because it is not
possible
+ /// to determine the state of frame_pending(). These have the
type
+ /// VideoBuffer::Type::Live, and frame_pending() is always 1.
+ ///
+ /// Otherwise, streams have a type VideoBuffer::Type::NotLive,
and
+ /// frame_pending is always 1
+ Type type()
+ {
+ return m_type;
+ }
+
/// What is the (expected) frame rate of this video buffer, in
frames per second?
virtual double frame_rate()=0;
/// Go to a particular point in the video buffer (only
implemented in buffers of recorded video)
@@ -82,6 +126,9 @@
/// with the same lifetime as the buffer. This is a tool to
allow management of
/// this data.
std::auto_ptr<VideoBufferData> extra_data;
+
+ private:
+ Type m_type;
};
namespace Exceptions
Index: cvd/Linux/v4l1buffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/Linux/v4l1buffer.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- cvd/Linux/v4l1buffer.h 29 Apr 2008 19:57:54 -0000 1.14
+++ cvd/Linux/v4l1buffer.h 28 Nov 2008 16:56:07 -0000 1.15
@@ -192,12 +192,18 @@
public:
/// Construct a video buffer
/// @param dev file name of the device to use
- V4L1Buffer(const std::string & dev) : RawV4L1( dev,
V4L1::cam_type<T>::mode, ImageRef(0,0)) {}
+ V4L1Buffer(const std::string & dev)
+ :VideoBuffer<T>(VideoBuffer<T>::Flushable),
+ RawV4L1( dev, V4L1::cam_type<T>::mode, ImageRef(0,0))
+ {}
/// Construct a video buffer
/// @param dev file name of the device to use
/// @param size Size of the video stream to grab
- V4L1Buffer(const std::string & dev, ImageRef size) : RawV4L1( dev,
V4L1::cam_type<T>::mode,size ) {}
+ V4L1Buffer(const std::string & dev, ImageRef size)
+ :VideoBuffer<T>(VideoBuffer<T>::Flushable),
+ RawV4L1( dev, V4L1::cam_type<T>::mode,size )
+ {}
virtual ImageRef size()
{
Index: cvd/Linux/v4lbuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/Linux/v4lbuffer.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- cvd/Linux/v4lbuffer.h 26 Nov 2008 22:15:43 -0000 1.11
+++ cvd/Linux/v4lbuffer.h 28 Nov 2008 16:56:08 -0000 1.12
@@ -152,7 +152,9 @@
template <class T> class V4LBuffer : public VideoBuffer<T>
{
public:
- V4LBuffer(const std::string & dev, ImageRef size, int input=-1, bool
fields=false, int frames_per_second=0, bool verbose=0) : devname(dev)
+ V4LBuffer(const std::string & dev, ImageRef size, int input=-1, bool
fields=false, int frames_per_second=0, bool verbose=0)
+ :VideoBuffer<T>(VideoBuffer<T>::Flushable),
+ devname(dev)
{
int device = open(devname.c_str(), O_RDWR | O_NONBLOCK);
if (device == -1)
Index: progs/calibrate.cxx
===================================================================
RCS file: /cvsroot/libcvd/libcvd/progs/calibrate.cxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- progs/calibrate.cxx 29 Aug 2008 20:27:33 -0000 1.11
+++ progs/calibrate.cxx 28 Nov 2008 16:56:10 -0000 1.12
@@ -752,7 +752,7 @@
}
VideoFrame<CAMERA_PIXEL>* vframe = videoBuffer->get_frame();
- while(videoBuffer->frame_pending())
+ while(videoBuffer->type() == VideoBuffer<CAMERA_PIXEL>::Flushable &&
videoBuffer->frame_pending())
{
videoBuffer->put_frame(vframe);
vframe = videoBuffer->get_frame();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libcvd-members] libcvd cvd/videobuffer.h cvd/Linux/v4l1buffer.h...,
Edward Rosten <=