firewire.h

00001
00002 /***************************************************************************
00003  *  firewire.h - This header defines a Firewire 1394 cam
00004  *
00005  *  Generated: Tue Feb 22 10:36:39 2005
00006  *  Copyright  2005  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023
00024 #ifndef __FIREVISION_CAMS_FIREWIRE_H_
00025 #define __FIREVISION_CAMS_FIREWIRE_H_
00026 
00027 #include <cams/camera.h>
00028 #include <cams/control/focus.h>
00029
00030 #include <dc1394/dc1394.h>
00031
00032 #ifndef __STDC_LIMIT_MACROS
00033 #define __STDC_LIMIT_MACROS
00034 #endif
00035 #include <stdint.h>
00036
00037 class CameraArgumentParser;
00038
00039 class FirewireCamera
00040 : public Camera,
00041   public CameraControlFocus
00042 {
00043
00044  public:
00045
00046   FirewireCamera(dc1394framerate_t framerate = DC1394_FRAMERATE_30,
00047                  dc1394video_mode_t mode     = DC1394_VIDEO_MODE_640x480_YUV422,
00048                  dc1394speed_t speed         = DC1394_ISO_SPEED_400,
00049                  int num_buffers=8);
00050   FirewireCamera(const CameraArgumentParser *cap);
00051
00052   virtual ~FirewireCamera();
00053
00054   virtual void open();
00055   virtual void start();
00056   virtual void stop();
00057   virtual void close();
00058   virtual void flush();
00059   virtual void capture();
00060
00061   virtual void print_info();
00062   virtual bool ready();
00063
00064   virtual unsigned char* buffer();
00065   virtual unsigned int   buffer_size();
00066   virtual void           dispose_buffer();
00067
00068   virtual unsigned int   pixel_width();
00069   virtual unsigned int   pixel_height();
00070   virtual colorspace_t   colorspace();
00071
00072   virtual void           set_image_number(unsigned int n);
00073
00074   bool    iso_mode_enabled();
00075
00076   virtual bool           auto_focus();
00077   virtual void           set_auto_focus(bool enabled);
00078
00079   virtual unsigned int   focus();
00080   virtual void           set_focus(unsigned int focus);
00081   virtual unsigned int   focus_min();
00082   virtual unsigned int   focus_max();
00083
00084   virtual bool           auto_shutter();
00085   virtual void           set_auto_shutter(bool enabled);
00086
00087   virtual unsigned int   shutter();
00088   virtual void           set_shutter(unsigned int shutter);
00089
00090   virtual bool           auto_white_balance();
00091   virtual void           set_auto_white_balance(bool enabled);
00092
00093   virtual void           white_balance(unsigned int *ub, unsigned int *vr);
00094   virtual void           set_white_balance(unsigned int ub, unsigned int vr);
00095
00096   virtual void           set_gain(unsigned int gain);
00097
00098   virtual void           parse_set_focus(const char *focus);
00099   virtual void           parse_set_white_balance(const char *white_balance);
00100   virtual void           parse_set_shutter(const char *shutter);
00101
00102   virtual uint64_t       guid() const;
00103   virtual const char *   model() const;
00104
00105   static  void           print_available_fwcams();
00106
00107  protected:
00108   /** Number of DMA buffers. */
00109   int  _num_buffers;
00110   /** true if camera has been opened, false otherwise */
00111   bool _opened;
00112   /** true if camera has been started, false otherwise */
00113   bool _started;
00114   /** true if auto focus is enabled, false if disabled */
00115   bool _auto_focus;
00116   /** true if auto shutter is enabled, false if disabled */
00117   bool _auto_shutter;
00118   /** true if auto white balance is enabled, false if disabled */
00119   bool _auto_white_balance;
00120   /** true, if a valid frame has been received, false otherwise */
00121   bool _valid_frame_received;
00122   /** true if the shutter should actually be set, false otherwise */
00123   bool _do_set_shutter;
00124   /** true if the white balance should actually be set, false otherwise */
00125   bool _do_set_white_balance;
00126   /** true if the focus should actually be set, false otherwise */
00127   bool _do_set_focus;
00128 
00129   /** DC1394 main context */
00130   dc1394_t                      *_dc1394;
00131   /** DC1394 video mode */
00132   dc1394video_mode_t             _mode;
00133   /** Indicator of Format7 status. */
00134   bool                           _format7_mode_enabled;
00135   /** DC1394 speed */
00136   dc1394speed_t                  _speed;
00137   /** DC1394 framerate */
00138   dc1394framerate_t              _framerate;
00139   /** DC1394 camera handle */
00140   dc1394camera_t                *_camera;
00141   /** Last captured DC1394 video frame */
00142   dc1394video_frame_t           *_frame;
00143   /** Format7 color coding */
00144   dc1394color_coding_t           _format7_coding;
00145   /** Format7 bytes per packet */
00146   int                            _format7_bpp;
00147   /** Format7 width */
00148   int                            _format7_width;
00149   /** Format7 height */
00150   int                            _format7_height;
00151   /** Format7 ROI Start X coordinate */
00152   int                            _format7_startx;
00153   /** Format7 ROI Start Y coordinate */
00154   int                            _format7_starty;
00155 
00156   /** White balance U/B value */
00157   unsigned int                   _white_balance_ub;
00158   /** White balance V/R value */
00159   unsigned int                   _white_balance_vr;
00160 
00161   /** Shutter value */
00162   unsigned int                   _shutter;
00163 
00164   /** Focus value */
00165   unsigned int                   _focus;
00166 
00167   /** Gain value */
00168   unsigned int                   _gain;
00169   /** True, if gain is set automatically */
00170   bool                           _auto_gain;
00171 
00172   /** Camera model, used in open to identify the camera, if empty first found camera is used */
00173   char *_model;
00174
00175 };
00176
00177 #endif