libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] libcvd cvd/colourspacebuffer.h cvd/deinterlaceb...


From: Edward Rosten
Subject: [libcvd-members] libcvd cvd/colourspacebuffer.h cvd/deinterlaceb...
Date: Tue, 02 Dec 2008 17:30:42 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Changes by:     Edward Rosten <edrosten>        08/12/02 17:30:41

Modified files:
        cvd            : colourspacebuffer.h deinterlacebuffer.h 
                         diskbuffer2.h localvideobuffer.h 
                         readaheadvideobuffer.h serverpushjpegbuffer.h 
                         videobuffer.h videofilebuffer.h 
        cvd/Linux      : dvbuffer.h dvbuffer3.h v4l1buffer.h 
                         v4l2buffer.h v4lbuffer.h 
        cvd_src/Linux  : dvbuffer3_dc1394v2.cc 
        progs          : calibrate.cxx 

Log message:
        Fixed frame_pending() for VideoBuffer.
        
        VideoBuffers can have one of three types: NotLive, Live and Flushable.
        
        For NotLive, the semantics are the same. frame_pending() may be unset 
when the
        last frame arrives (eg from DiskBuffer), and subsequent get_frame()s 
throw.
        
        For Live, the video is from a live source (or behaves that way): frames 
arrive
        at a fixed rate. However, frame_pending() always returns true.
        
        Flushable buffers are live, but frame_pending() is useful.
        
        This allows you to test if a buffer is flushable before attempting to 
flush it.
        Alternatively, it allows you to determine if a buffer may have an end, 
before
        testing if it has ended. VideoBuffer now has a flush method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/colourspacebuffer.h?cvsroot=libcvd&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/deinterlacebuffer.h?cvsroot=libcvd&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/diskbuffer2.h?cvsroot=libcvd&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/localvideobuffer.h?cvsroot=libcvd&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/readaheadvideobuffer.h?cvsroot=libcvd&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/serverpushjpegbuffer.h?cvsroot=libcvd&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/videobuffer.h?cvsroot=libcvd&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/videofilebuffer.h?cvsroot=libcvd&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/Linux/dvbuffer.h?cvsroot=libcvd&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/Linux/dvbuffer3.h?cvsroot=libcvd&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/Linux/v4l1buffer.h?cvsroot=libcvd&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/Linux/v4l2buffer.h?cvsroot=libcvd&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/Linux/v4lbuffer.h?cvsroot=libcvd&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/Linux/dvbuffer3_dc1394v2.cc?cvsroot=libcvd&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/libcvd/progs/calibrate.cxx?cvsroot=libcvd&r1=1.12&r2=1.13

Patches:
Index: cvd/colourspacebuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/colourspacebuffer.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- cvd/colourspacebuffer.h     9 May 2005 11:54:56 -0000       1.5
+++ cvd/colourspacebuffer.h     2 Dec 2008 17:30:39 -0000       1.6
@@ -55,7 +55,7 @@
                /// Construct a ColourspaceBuffer by wrapping it around another 
VideoBuffer
                /// @param buf The buffer that will provide the raw frames
                ColourspaceBuffer(CVD::VideoBuffer<From>& buf)
-               :m_vidbuf(buf),m_size(buf.size())
+               
:LocalVideoBuffer<T>(buf.type()),m_vidbuf(buf),m_size(buf.size())
                {
                }
  

Index: cvd/deinterlacebuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/deinterlacebuffer.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- cvd/deinterlacebuffer.h     9 May 2005 11:54:56 -0000       1.8
+++ cvd/deinterlacebuffer.h     2 Dec 2008 17:30:39 -0000       1.9
@@ -130,6 +130,7 @@
 //
 template <typename T>
 DeinterlaceBuffer<T>::DeinterlaceBuffer(CVD::VideoBuffer<T>& vidbuf, Fields 
fields) :
+       VideoBuffer<T>(vidbuf.type()),
        m_vidbuf(vidbuf),
        m_fields(fields),
        m_loadnewframe(true)

Index: cvd/diskbuffer2.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/diskbuffer2.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- cvd/diskbuffer2.h   12 Jun 2008 13:04:13 -0000      1.16
+++ cvd/diskbuffer2.h   2 Dec 2008 17:30:39 -0000       1.17
@@ -135,7 +135,7 @@
        //
        template<typename T>
        inline DiskBuffer2<T>::DiskBuffer2(const std::vector<std::string>& 
names, double fps, VideoBufferFlags::OnEndOfBuffer eob) 
-       :end_of_buffer_behaviour(eob)
+       
:LocalVideoBuffer<T>(VideoBufferType::NotLive),end_of_buffer_behaviour(eob)
        {
                frames_per_sec = fps;
 

Index: cvd/localvideobuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/localvideobuffer.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- cvd/localvideobuffer.h      9 May 2005 11:54:57 -0000       1.6
+++ cvd/localvideobuffer.h      2 Dec 2008 17:30:39 -0000       1.7
@@ -36,6 +36,10 @@
 class LocalVideoBuffer: public  CVD::VideoBuffer<T>
 {
        public:
+               LocalVideoBuffer(typename VideoBufferType::Type t)
+               :VideoBuffer<T>(t)
+               {}
+
                virtual ~LocalVideoBuffer(){}
 
                virtual ImageRef size()=0;

Index: cvd/readaheadvideobuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/readaheadvideobuffer.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- cvd/readaheadvideobuffer.h  1 Dec 2008 09:02:20 -0000       1.5
+++ cvd/readaheadvideobuffer.h  2 Dec 2008 17:30:40 -0000       1.6
@@ -77,15 +77,13 @@
        EventObject qevent;
        Thread thread;
 
-       typedef typename VideoBuffer<T>::Type Type;
        
-
-       static Type type_update(Type t)
+       static VideoBufferType::Type type_update(VideoBufferType::Type t)
        {
-               if(t== VideoBuffer<T>::NotLive)
+               if(t== VideoBufferType::NotLive)
                        return t; 
                else
-                       return VideoBuffer<T>::Flushable;
+                       return VideoBufferType::Flushable;
        }
 
     public:

Index: cvd/serverpushjpegbuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/serverpushjpegbuffer.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- cvd/serverpushjpegbuffer.h  28 Aug 2008 06:56:32 -0000      1.1
+++ cvd/serverpushjpegbuffer.h  2 Dec 2008 17:30:40 -0000       1.2
@@ -43,7 +43,7 @@
                ///@param warnings Whether to print warnings if mis-sized 
frames arrive. 
                ///@param eat_frames Number of frames to discard on 
initialization.
                ServerPushJpegBuffer<C>(std::istream& i, bool warnings_=0, int 
eat_frames=0)
-               :is(i),warnings(warnings_)
+               
:LocalVideoBuffer<C>(VideoBufferType::Live),is(i),warnings(warnings_)
                {
                        std::string tmp;
                        //Eat the first 10 frames because the camera sometimes 
takes a while to

Index: cvd/videobuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/videobuffer.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- cvd/videobuffer.h   1 Dec 2008 14:01:13 -0000       1.13
+++ cvd/videobuffer.h   2 Dec 2008 17:30:40 -0000       1.14
@@ -51,28 +51,35 @@
                }
 };
 
-/// Base class for objects which provide a video stream. A video 
-/// stream is a sequence of video frames (derived from VideoFrame).
-/// @param T The pixel type of the video frames
-/// @ingroup gVideoBuffer
-template <class T> 
-class VideoBuffer 
+///The semsntics of the videobuffer. See VideoFrame::type()
+class VideoBufferType
 {
-       public:
                enum Type
                {
+               ///The buffer does not have live semantics: frames
+               ///are not throttled by something external. 
+               ///VideoBuffer::frame_pending() is true until the last frame 
has 
+               ///been retrieved, after which is is set to false.
                        NotLive,
+               ///The buffer has live semantics: frames are throttled by
+               ///something externa, but VideoBuffer::frame_pending() always 
returns true.
                        Live,
+               ///The buffer is flushable: it is live and 
VideoBuffer::frame_pending() returns
+               ///an accurate result.
                        Flushable
                };
+};
                
-               ///Default to the most general semantics
-               VideoBuffer()
-               :m_type(NotLive)
-               {}
-               
+/// Base class for objects which provide a video stream. A video 
+/// stream is a sequence of video frames (derived from VideoFrame).
+/// @param T The pixel type of the video frames
+/// @ingroup gVideoBuffer
+template <class T> 
+class VideoBuffer 
+{
+       public:
                ///Construct the buffer with the known semantics
-               VideoBuffer(Type _type)
+               VideoBuffer(VideoBufferType::Type _type)
                :m_type(_type)
                {}
 
@@ -109,7 +116,7 @@
                ///
                /// Otherwise, streams have a type VideoBuffer::Type::NotLive, 
and
                /// frame_pending is always 1
-               Type type()
+               VideoBufferType::Type type()
                {
                        return m_type;
                }
@@ -120,7 +127,7 @@
                /// buffer, this does nothing.
                virtual void flush()
                {
-                       if(type() == Flushable)
+                       if(type() == VideoBufferType::Flushable)
                                while(frame_pending())
                                        put_frame(get_frame());
                }
@@ -139,7 +146,7 @@
                std::auto_ptr<VideoBufferData> extra_data;
 
        private:
-               Type m_type;
+               VideoBufferType::Type m_type;
 };
 
 namespace Exceptions

Index: cvd/videofilebuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/videofilebuffer.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- cvd/videofilebuffer.h       14 Aug 2008 16:12:28 -0000      1.15
+++ cvd/videofilebuffer.h       2 Dec 2008 17:30:40 -0000       1.16
@@ -214,7 +214,7 @@
                        /// Construct a VideoFileBuffer to play this file
                        /// @param file The path to the video file
                        VideoFileBuffer(const std::string& file)
-                       :vf(file, VFB::rgb<T>::p)
+                       :LocalVideoBuffer<T>(VideoBufferType::NotLive),vf(file, 
VFB::rgb<T>::p)
                        {
                        }
 

Index: cvd/Linux/dvbuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/Linux/dvbuffer.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- cvd/Linux/dvbuffer.h        28 Feb 2008 00:27:22 -0000      1.20
+++ cvd/Linux/dvbuffer.h        2 Dec 2008 17:30:40 -0000       1.21
@@ -251,8 +251,10 @@
                /// @param exposure The exposure correction (default = -1 = 
automatic)
                /// @param fps The number of frames per second (default = 30fps)
                DVBuffer2(int cam_no, int num_dma_buffers, int bright=-1, int 
exposure=-1, double fps=DC::cam_type<T>::fps)
-               :RawDCVideo(cam_no, num_dma_buffers, bright, exposure, 
DC::cam_type<T>::mode, fps)
+               :VideoBuffer<T>(VideoBufferType::Live),RawDCVideo(cam_no, 
num_dma_buffers, bright, exposure, DC::cam_type<T>::mode, fps)
                {
+                       //Apparently, DVBuffer isn't flushable.
+                       //This should probably be fixed.
                }
 
                virtual ~DVBuffer2()

Index: cvd/Linux/dvbuffer3.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/Linux/dvbuffer3.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- cvd/Linux/dvbuffer3.h       14 Jul 2008 00:03:55 -0000      1.1
+++ cvd/Linux/dvbuffer3.h       2 Dec 2008 17:30:40 -0000       1.2
@@ -130,7 +130,8 @@
     DVBuffer3(unsigned int nCamNumber=0, 
              ImageRef irSize = ImageRef(-1,-1), 
              float fFPS = -1.0)
-      : RawDVBuffer3(DV3::CSConvert<pixel_T>::space, nCamNumber, irSize, fFPS)
+      : VideoBuffer<pixel_T>(VideoBufferType::Live),
+           RawDVBuffer3(DV3::CSConvert<pixel_T>::space, nCamNumber, irSize, 
fFPS)
        {
        }
       

Index: cvd/Linux/v4l1buffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/Linux/v4l1buffer.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- cvd/Linux/v4l1buffer.h      28 Nov 2008 16:56:07 -0000      1.15
+++ cvd/Linux/v4l1buffer.h      2 Dec 2008 17:30:41 -0000       1.16
@@ -193,7 +193,7 @@
     /// Construct a video buffer
     /// @param dev file name of the device to use
     V4L1Buffer(const std::string & dev) 
-       :VideoBuffer<T>(VideoBuffer<T>::Flushable),
+       :VideoBuffer<T>(VideoBufferType::Flushable),
         RawV4L1( dev, V4L1::cam_type<T>::mode, ImageRef(0,0)) 
        {}
 
@@ -201,7 +201,7 @@
     /// @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) 
-       :VideoBuffer<T>(VideoBuffer<T>::Flushable),
+       :VideoBuffer<T>(VideoBufferType::Flushable),
         RawV4L1( dev, V4L1::cam_type<T>::mode,size ) 
        {}
 

Index: cvd/Linux/v4l2buffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/Linux/v4l2buffer.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- cvd/Linux/v4l2buffer.h      24 Apr 2008 23:30:38 -0000      1.14
+++ cvd/Linux/v4l2buffer.h      2 Dec 2008 17:30:41 -0000       1.15
@@ -149,7 +149,7 @@
 {
        public:
                V4L2BufferT(const char *devname, bool fields, 
V4L2BufferBlockMethod block, int input=1, int numbufs=V4L2BUFFERS)
-               :V4L2Buffer_Base(devname, fields, block, input, numbufs, 
V4L2_Traits<T>::pix_code)
+               
:VideoBuffer<T>(VideoBufferType::Flushable),V4L2Buffer_Base(devname, fields, 
block, input, numbufs, V4L2_Traits<T>::pix_code)
                {}
 
                virtual ImageRef size() 

Index: cvd/Linux/v4lbuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/Linux/v4lbuffer.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- cvd/Linux/v4lbuffer.h       28 Nov 2008 16:56:08 -0000      1.12
+++ cvd/Linux/v4lbuffer.h       2 Dec 2008 17:30:41 -0000       1.13
@@ -153,7 +153,7 @@
 {
 public:
  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), 
+ :VideoBuffer<T>(VideoBufferType::Flushable), 
   devname(dev)
     {
        int device = open(devname.c_str(), O_RDWR | O_NONBLOCK);

Index: cvd_src/Linux/dvbuffer3_dc1394v2.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/Linux/dvbuffer3_dc1394v2.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- cvd_src/Linux/dvbuffer3_dc1394v2.cc 17 Jul 2008 13:55:53 -0000      1.3
+++ cvd_src/Linux/dvbuffer3_dc1394v2.cc 2 Dec 2008 17:30:41 -0000       1.4
@@ -280,7 +280,7 @@
   
     bool RawDVBuffer3::frame_pending()
     {
-      return false;
+      return true;
     }
 
     VideoFrame<byte>* RawDVBuffer3::get_frame()

Index: progs/calibrate.cxx
===================================================================
RCS file: /cvsroot/libcvd/libcvd/progs/calibrate.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- progs/calibrate.cxx 28 Nov 2008 16:56:10 -0000      1.12
+++ progs/calibrate.cxx 2 Dec 2008 17:30:41 -0000       1.13
@@ -751,12 +751,10 @@
            }
        }
            
+       
+       videoBuffer->flush();
        VideoFrame<CAMERA_PIXEL>* vframe = videoBuffer->get_frame();
-       while(videoBuffer->type() == VideoBuffer<CAMERA_PIXEL>::Flushable && 
videoBuffer->frame_pending())
-       {
-           videoBuffer->put_frame(vframe);
-           vframe = videoBuffer->get_frame();
-       }
+       
        // leave this in, we cannot assume that vframe has a datatype that can 
be
        // directly used in the glTexImage call later on (e.g. its yuv422 on 
OSX)
        Image<byte> temp = convert_image(*vframe);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]