cvd/Linux/dvbuffer3.h

00001 /*                       
00002     This file is part of the CVD Library.
00003 
00004     Copyright (C) 2005 The Authors
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Lesser General Public
00008     License as published by the Free Software Foundation; either
00009     version 2.1 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Lesser General Public License for more details.
00015 
00016     You should have received a copy of the GNU Lesser General Public
00017     License along with this library; if not, write to the Free Software
00018     Foundation, Inc., 
00019     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 */
00021 // -*- c++ -*-
00022 
00023 #ifndef __DVBUFFER_3_H
00024 #define __DVBUFFER_3_H
00025 #include <cvd/videobuffer.h>
00026 #include <cvd/byte.h>
00027 #include <cvd/rgb.h>
00028 #include <cvd/colourspaces.h>
00029 
00030 namespace CVD
00031 {
00032   namespace Exceptions
00033   {
00034     namespace DVBuffer3
00035     {
00038       struct All : public CVD::Exceptions::VideoBuffer::All 
00039       {
00040     All(std::string sWhat)
00041       {
00042         what = "DVBuffer3: " + sWhat;
00043       }
00044       };
00045     }
00046   }
00047 
00049   namespace DV3
00050   {
00053     enum DV3Feature { BRIGHTNESS,  EXPOSURE,  SHARPNESS,
00054               WHITE_BALANCE,  HUE,  SATURATION,
00055               GAMMA,  SHUTTER,  GAIN,  IRIS,
00056               FOCUS, ZOOM,   PAN,  TILT};
00057     
00060     enum DV3ColourSpace { MONO8,  MONO16,  MONO16S,
00061               RGB8,   RGB16,   RGB16S,
00062               YUV411, YUV422,  YUV444,
00063               RAW8,   RAW16};
00064     
00065 #ifndef DOXYGEN_IGNORE_INTERNAL
00066     // Translation helper classes to go from CVD-types to the above
00067     template<class C>  
00068       struct CSConvert
00069       { static const DV3ColourSpace space = C::Error__type_not_valid_for_camera; };
00070     template<> struct CSConvert<byte>
00071       { static const DV3ColourSpace space = MONO8;};
00072     template<> struct CSConvert<short unsigned int>
00073       { static const DV3ColourSpace space = MONO16;};
00074     template<> struct CSConvert<yuv411>
00075       { static const DV3ColourSpace space = YUV411;};
00076     template<> struct CSConvert<yuv422>
00077       { static const DV3ColourSpace space = YUV422;};
00078     template<> struct CSConvert<Rgb<byte> > 
00079       { static const DV3ColourSpace space = RGB8;};
00080     
00081     struct LibDCParams;
00082 #endif
00083     
00088     class RawDVBuffer3
00089     {
00090     public:
00096       RawDVBuffer3(DV3ColourSpace colourspace,
00097            unsigned int nCamNumber=0, 
00098            ImageRef irSize = ImageRef(-1,-1),
00099            float fFrameRate=-1.0);
00100       
00101       ~RawDVBuffer3();
00102       inline ImageRef size() {return mirSize;}
00103       inline double frame_rate() {return mdFramerate;}
00104       VideoFrame<byte>* get_frame();
00105       void put_frame(VideoFrame<byte>* f);
00106       bool frame_pending();
00107 
00108       void set_feature_value(DV3Feature nFeature, unsigned int nValue);
00109       unsigned int get_feature_value(DV3Feature nFeature);
00110       std::pair<unsigned int, unsigned int> get_feature_min_max(DV3Feature nFeature);
00111       void auto_on_off(DV3Feature nFeature, bool bValue);
00112       
00113     private:
00114       ImageRef mirSize;
00115       double mdFramerate;
00117       LibDCParams *mpLDCP;
00118     };
00119     
00120   }
00121 
00126   template <class pixel_T> 
00127     class DVBuffer3 : public VideoBuffer<pixel_T>, public DV3::RawDVBuffer3
00128     {
00129     public:
00130     DVBuffer3(unsigned int nCamNumber=0, 
00131           ImageRef irSize = ImageRef(-1,-1), 
00132           float fFPS = -1.0)
00133       : VideoBuffer<pixel_T>(VideoBufferType::Live),
00134         RawDVBuffer3(DV3::CSConvert<pixel_T>::space, nCamNumber, irSize, fFPS)
00135     {
00136     }
00137       
00138       virtual ~DVBuffer3()   {}
00139       double frame_rate()    {return RawDVBuffer3::frame_rate();  }
00140       ImageRef size()        {return RawDVBuffer3::size(); }
00141       virtual VideoFrame<pixel_T>* get_frame()
00142       {
00143     return reinterpret_cast<VideoFrame<pixel_T>*>(RawDVBuffer3::get_frame());
00144       }
00145       virtual void put_frame(VideoFrame<pixel_T>* f)
00146       {
00147     RawDVBuffer3::put_frame(reinterpret_cast<VideoFrame<byte>*>(f));
00148       }
00149       virtual bool frame_pending() {return RawDVBuffer3::frame_pending();}
00150       virtual void seek_to(double){}
00151     };
00152   
00153 }
00154 
00155 #endif
00156 
00157 
00158 
00159 
00160 
00161 

Generated on Wed Feb 18 10:23:01 2009 for CVD by  doxygen 1.5.3