core/vidl/vidl_iidc1394_params.h
Go to the documentation of this file.
00001 // This is core/vidl/vidl_iidc1394_params.h
00002 #ifndef vidl_iidc1394_params_h_
00003 #define vidl_iidc1394_params_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief A parameters struct for IIDC 1394 camera streams
00010 //
00011 // \author Matt Leotta
00012 // \date 10 Jan 2006
00013 //
00014 // These parameters are as described by the
00015 // IIDC 1394-base Digital Camera Specification
00016 // they should work for any istream that follows this
00017 // specification.
00018 
00019 #include <vcl_string.h>
00020 #include <vcl_vector.h>
00021 #include "vidl_pixel_format.h"
00022 
00023 //: A parameters struct for IIDC 1394 camera streams
00024 //
00025 // The setter functions are provided for convenience, so that the
00026 // parameters can be set through an anonymous object.
00027 // \code
00028 //   ostream.open( filename,
00029 //                 vidl_iidc1394_params()
00030 //                 .frame_rate( vidl_iidc1394_params::FRAMERATE_7_5 )
00031 //                 .video_mode( vidl_iidc1394_params::MODE_1024x768_YUV422 ) );
00032 // \endcode
00033 struct vidl_iidc1394_params
00034 {
00035   //: Available data transfer speeds
00036   enum speed_t { ISO_SPEED_100= 0,
00037                  ISO_SPEED_200,
00038                  ISO_SPEED_400,
00039                  ISO_SPEED_800,
00040                  ISO_SPEED_1600,
00041                  ISO_SPEED_3200 };
00042 
00043   //: Return the speed value for a speed setting
00044   static unsigned int speed_val(speed_t s);
00045 
00046   //: Available frame rates
00047   enum frame_rate_t { FRAMERATE_1_875= 32,
00048                       FRAMERATE_3_75,
00049                       FRAMERATE_7_5,
00050                       FRAMERATE_15,
00051                       FRAMERATE_30,
00052                       FRAMERATE_60,
00053                       FRAMERATE_120,
00054                       FRAMERATE_240 };
00055 
00056   //: Return the frame rate as a floating point value
00057   static float frame_rate_val(frame_rate_t r);
00058 
00059   //: Available video modes (format and mode combined)
00060   enum video_mode_t { MODE_160x120_YUV444= 64,
00061                       MODE_320x240_YUV422,
00062                       MODE_640x480_YUV411,
00063                       MODE_640x480_YUV422,
00064                       MODE_640x480_RGB8,
00065                       MODE_640x480_MONO8,
00066                       MODE_640x480_MONO16,
00067                       MODE_800x600_YUV422,
00068                       MODE_800x600_RGB8,
00069                       MODE_800x600_MONO8,
00070                       MODE_1024x768_YUV422,
00071                       MODE_1024x768_RGB8,
00072                       MODE_1024x768_MONO8,
00073                       MODE_800x600_MONO16,
00074                       MODE_1024x768_MONO16,
00075                       MODE_1280x960_YUV422,
00076                       MODE_1280x960_RGB8,
00077                       MODE_1280x960_MONO8,
00078                       MODE_1600x1200_YUV422,
00079                       MODE_1600x1200_RGB8,
00080                       MODE_1600x1200_MONO8,
00081                       MODE_1280x960_MONO16,
00082                       MODE_1600x1200_MONO16,
00083                       MODE_EXIF,
00084                       MODE_FORMAT7_0,
00085                       MODE_FORMAT7_1,
00086                       MODE_FORMAT7_2,
00087                       MODE_FORMAT7_3,
00088                       MODE_FORMAT7_4,
00089                       MODE_FORMAT7_5,
00090                       MODE_FORMAT7_6,
00091                       MODE_FORMAT7_7 };
00092 
00093   //: Available camera features
00094   enum feature_t{ FEATURE_BRIGHTNESS,
00095                   FEATURE_EXPOSURE,
00096                   FEATURE_SHARPNESS,
00097                   FEATURE_WHITE_BALANCE,
00098                   FEATURE_HUE,
00099                   FEATURE_SATURATION,
00100                   FEATURE_GAMMA,
00101                   FEATURE_SHUTTER,
00102                   FEATURE_GAIN,
00103                   FEATURE_IRIS,
00104                   FEATURE_FOCUS,
00105                   FEATURE_TEMPERATURE,
00106                   FEATURE_TRIGGER,
00107                   FEATURE_TRIGGER_DELAY,
00108                   FEATURE_WHITE_SHADING,
00109                   FEATURE_FRAME_RATE,
00110                   FEATURE_ZOOM,
00111                   FEATURE_PAN,
00112                   FEATURE_TILT,
00113                   FEATURE_OPTICAL_FILTER,
00114                   FEATURE_CAPTURE_SIZE,
00115                   FEATURE_CAPTURE_QUALITY};
00116 
00117   //: Available feature control modes
00118   enum feature_mode_t{ FEATURE_MODE_MANUAL,
00119                        FEATURE_MODE_AUTO,
00120                        FEATURE_MODE_ONE_PUSH_AUTO};
00121 
00122   //: Return string describing the mode
00123   static vcl_string video_mode_string(video_mode_t m);
00124 
00125   //: Return string describing the feature
00126   static vcl_string feature_string(feature_t f);
00127 
00128   //: Return string describing the feature mode
00129   static vcl_string feature_mode_string(feature_mode_t fm);
00130 
00131   //: Return the format number from the video mode enumeration
00132   static unsigned int video_format_val(video_mode_t m);
00133   //: Return the mode number from the video mode enumeration
00134   static unsigned int video_mode_val(video_mode_t m);
00135 
00136   //: Return the pixel format of the video mode
00137   // \note Only works for predefined modes (not Format 7 or Exif)
00138   static vidl_pixel_format pixel_format(video_mode_t m);
00139 
00140   //: Return the image resolution of the video mode
00141   // \note Only works for predefined modes (not Format 7 or Exif)
00142   static bool resolution(video_mode_t m, unsigned& ni, unsigned& nj);
00143 
00144   //: Return the video mode enumeration for a format and mode
00145   static video_mode_t video_mode(unsigned int format, unsigned int mode);
00146 
00147   //: Describes the valid options for the parameters
00148   struct valid_options;
00149 
00150   //: Describes a feature and its set of options
00151   struct feature_options;
00152 
00153   //-------------------------------------------------------
00154 
00155   //: The global unique identifier of the camera (default 0)
00156   vxl_uint_64 guid_;
00157 
00158   //: The data transfer speed (default ISO_SPEED_400)
00159   speed_t speed_;
00160 
00161   //: Operate the camera in 1394b mode
00162   bool b_mode_;
00163 
00164   //: The frame rate (default FRAMERATE_15)
00165   frame_rate_t frame_rate_;
00166 
00167   //: The video format and mode (default MODE_640x480_RGB8)
00168   video_mode_t video_mode_;
00169 
00170   //: The settings of camera features
00171   vcl_vector<feature_options> features_;
00172 
00173   //-------------------------------------------------------
00174 
00175   //: Construct to default values
00176   vidl_iidc1394_params();
00177 
00178   //: Set the guid
00179   vidl_iidc1394_params& guid( vxl_uint_64 the_guid )
00180   { guid_ = the_guid; return *this; }
00181 
00182   //: Set the speed
00183   vidl_iidc1394_params& speed( speed_t s )
00184   { speed_ = s; return *this; }
00185 
00186   //: Set b mode
00187   vidl_iidc1394_params& b_mode( bool b )
00188   { b_mode_ = b; return *this; }
00189 
00190   //: Set the frame rate
00191   vidl_iidc1394_params& frame_rate( frame_rate_t r )
00192   { frame_rate_ = r; return *this; }
00193 
00194   //: Set the video mode
00195   vidl_iidc1394_params& video_mode(video_mode_t m)
00196   { video_mode_ = m; return *this; }
00197 };
00198 
00199 
00200 //=============================================================================
00201 
00202 //: Describes a feature and its set of options
00203 struct vidl_iidc1394_params::feature_options
00204 {
00205   feature_t       id;
00206   bool            available;
00207   bool            absolute_capable;
00208   bool            readout_capable;
00209   bool            on_off_capable;
00210   bool            polarity_capable;
00211   bool            is_on;
00212   feature_mode_t  active_mode;
00213 
00214   vcl_vector<feature_mode_t>  available_modes;
00215 
00216 // FIXME - add trigger options
00217 #if 0
00218   trigger_modes_t    trigger_modes;
00219   trigger_mode_t     trigger_mode;
00220   trigger_polarity_t trigger_polarity;
00221   trigger_sources_t  trigger_sources;
00222   trigger_source_t   trigger_source;
00223 #endif
00224 
00225   unsigned int       min;
00226   unsigned int       max;
00227   unsigned int       value;
00228   unsigned int       BU_value;
00229   unsigned int       RV_value;
00230   unsigned int       B_value;
00231   unsigned int       R_value;
00232   unsigned int       G_value;
00233   unsigned int       target_value;
00234 
00235   bool               abs_control;
00236   float              abs_value;
00237   float              abs_max;
00238   float              abs_min;
00239 };
00240 
00241 //=============================================================================
00242 
00243 //: This structure holds the set of valid options for parameters
00244 // The istream class should be able to produce this object by
00245 // probing cameras on the 1394 bus
00246 struct vidl_iidc1394_params::valid_options
00247 {
00248   //: A valid mode and its valid frame rates
00249   struct valid_mode
00250   {
00251     video_mode_t mode;
00252     vcl_vector<frame_rate_t> frame_rates;
00253   };
00254 
00255   //: A valid camera and its options
00256   struct camera
00257   {
00258     vxl_uint_64 guid; // global unique identifier
00259     vcl_string vendor;
00260     vcl_string model;
00261     speed_t speed;
00262     bool b_mode;
00263     vcl_vector<valid_mode> modes;
00264     vcl_vector<vidl_iidc1394_params::feature_options> features;
00265     video_mode_t curr_mode;
00266     frame_rate_t curr_frame_rate;
00267   };
00268 
00269   //: A vector of the valid cameras
00270   // one object for each camera detected on the bus
00271   vcl_vector<camera> cameras;
00272 };
00273 
00274 #endif // vidl_iidc1394_params_h_