DC1394Grabber2.H

Go to the documentation of this file.
00001 /*!@file Devices/DC1394Grabber2.H FireWire grabber class based on libdc1394 version 2.x */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00005 // by the University of Southern California (USC) and the iLab at USC.  //
00006 // See http://iLab.usc.edu for information about this project.          //
00007 // //////////////////////////////////////////////////////////////////// //
00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00010 // in Visual Environments, and Applications'' by Christof Koch and      //
00011 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00012 // pending; application number 09/912,225 filed July 23, 2001; see      //
00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00014 // //////////////////////////////////////////////////////////////////// //
00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00016 //                                                                      //
00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00018 // redistribute it and/or modify it under the terms of the GNU General  //
00019 // Public License as published by the Free Software Foundation; either  //
00020 // version 2 of the License, or (at your option) any later version.     //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00025 // PURPOSE.  See the GNU General Public License for more details.       //
00026 //                                                                      //
00027 // You should have received a copy of the GNU General Public License    //
00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00030 // Boston, MA 02111-1307 USA.                                           //
00031 // //////////////////////////////////////////////////////////////////// //
00032 //
00033 // Primary maintainer for this file: Rob Peters <rjpeters at usc dot edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Devices/DC1394Grabber2.H $
00035 // $Id: DC1394Grabber2.H 9255 2008-02-11 20:59:00Z rjpeters $
00036 //
00037 
00038 #ifndef DEVICES_DC1394GRABBER2_H_DEFINED
00039 #define DEVICES_DC1394GRABBER2_H_DEFINED
00040 
00041 #include "Component/ModelParam.H"
00042 #include "Image/Dims.H"
00043 #include "Transport/FrameIstream.H"
00044 #include "Util/Types.H"
00045 #include "Video/VideoFormat.H"
00046 
00047 #ifdef HAVE_DC1394V2
00048 #include <dc1394/control.h>
00049 #endif
00050 
00051 class VideoFrame;
00052 template <class T> class PixRGB;
00053 template <class T> class Image;
00054 
00055 //! Firewire bus speed to use
00056 #define IEEE1394GRABSPEED SPEED_400
00057 
00058 //! FireWire grabber class based on libdc1394 version 2.x
00059 class DC1394Grabber2 : public FrameIstream
00060 {
00061 public:
00062   //! Constructor
00063   DC1394Grabber2(OptionManager& mgr,
00064                  const std::string& descrName="DC1394 Frame Grabber Driver v2",
00065                  const std::string& tagName = "DC1394Grabber2");
00066 
00067   //! Destructor
00068   virtual ~DC1394Grabber2();
00069 
00070   //! Return the specifications of the next frame to be returned
00071   virtual GenericFrameSpec peekFrameSpec();
00072 
00073   //! Get the inter-frame time that matches our video mode
00074   virtual SimTime getNaturalFrameTime() const;
00075 
00076   //! Get the next frame from the frame-grabber
00077   /*! Returns grabbed frame. This call will block until a frame is
00078       ready and has been grabbed.
00079 
00080       Beware that the integrity of the GenericFrame object may not
00081       last "very long"; basically, try to be finished using the
00082       GenericFrame object before you attempt to grab the next frame in
00083       the stream. If you need it for longer than that, then you should
00084        use GenericFrame::deepCopyOf() to make a copy of the frame that
00085      can be safely held indefinitely. */
00086   virtual GenericFrame readFrame();
00087 
00088 protected:
00089   //! Grab raw data
00090   /*! Don't call this directly; use readFrame() instead. */
00091   VideoFrame grabRaw();
00092 
00093   //! get started
00094   virtual void start1();
00095 
00096   //! get stopped
00097   virtual void stop2();
00098 
00099 private:
00100   virtual void paramChanged(ModelParamBase* const param,
00101                             const bool valueChanged,
00102                             ParamClient::ChangeStatus* status);
00103 
00104   //! whether to print detailed info about our camera
00105   OModelParam<bool> itsShowInputDetails;
00106 
00107   //! device name of the /dev/ entry for the grabber device
00108   OModelParam<std::string> itsDevName;
00109 
00110   //! input channel to use
00111   OModelParam<int> itsChannel;
00112 
00113   //! input subchannel to use
00114   OModelParam<int> itsSubChan;
00115 
00116   //! width of grabbed frames
00117   OModelParam<Dims> itsDims;
00118 
00119   //! grab mode that the hardware should use
00120   /*! Grabbed frames will internally be converted to Image<
00121     PixRGB<byte> > whatever that mode is, but playing with it may
00122     influence image quality, maximum achievable framerate, and amounts
00123     of CPU doing those conversions to RGB. */
00124   OModelParam<VideoFormat> itsGrabMode;
00125 
00126   //! determines whether byte swapping is done during conversion to RGB
00127   OModelParam<bool> itsByteSwap;
00128 
00129   //! frames per second
00130   OModelParam<float> itsFPS;
00131 
00132   //! number of frame buffers kept internally
00133   OModelParam<int> itsNbuf;
00134 
00135   //! brightness - highly dependent on your driver
00136   OModelParam<int> itsBrightness;
00137 
00138   //! hue - highly dependent on your driver
00139   OModelParam<int> itsHue;
00140 
00141   //! saturation - highly dependent on your driver
00142   OModelParam<int> itsSaturation;
00143 
00144   //! exposure - highly dependent on your driver
00145   OModelParam<int> itsExposure;
00146 
00147   //! sharpness - highly dependent on your driver
00148   OModelParam<int> itsSharpness;
00149 
00150   //! white balance (B/U value) - highly dependent on your driver
00151   OModelParam<int> itsWhiteBalBU;
00152 
00153   //! white balance (R/V value) - highly dependent on your driver
00154   OModelParam<int> itsWhiteBalRV;
00155 
00156   //! gamma  - highly dependent on your driver
00157   OModelParam<int> itsGamma;
00158 
00159   //! shutter - highly dependent on your driver
00160   OModelParam<int> itsShutter;
00161 
00162   //! gain - highly dependent on your driver
00163   OModelParam<int> itsGain;
00164 
00165   // check whether the configure script found libdc1394 version 2.x;
00166   // if not, then just stub out the core of the DC1394Grabber2 class
00167   // and LFATAL() if somebody actually tries to use it
00168 #ifdef HAVE_DC1394V2
00169   dc1394_t* itsDC1394; // our link to libdc1394
00170   dc1394camera_t* itsCam; // our camera
00171 #endif
00172 };
00173 
00174 // ######################################################################
00175 /* So things look consistent in everyone's emacs... */
00176 /* Local Variables: */
00177 /* mode: c++ */
00178 /* indent-tabs-mode: nil */
00179 /* End: */
00180 
00181 #endif // DEVICES_DC1394GRABBER2_H_DEFINED
Generated on Sun May 8 08:40:37 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3