Follow this link to skip to the main content

camera_image.h

Go to the documentation of this file.
00001 // -*-c++-*- 
00002 //---------------------------< /-/ CLARAty /-/ >------------------------------
00003 /** 
00004  * @file  camera_image.h
00005  *
00006  * Extension of the Image class to include camera image properties
00007  *
00008  * <br>@b Designer(s):  Issa A.D. Nesnas
00009  *                      Max Bajracharya
00010  * <br>@b Author(s):    Issa A.D. Nesnas
00011  * <br>@b Date:         January 17, 2002
00012  *
00013  * <b>Software License:</b><br>
00014  * <code>  http://claraty.jpl.nasa.gov/license/open_src.html  or
00015  *         file: ../share/license.txt  </code>
00016  *
00017  * &copy; 2007, Jet Propulsion Laboratory, California Institute of Technology<br>
00018  *
00019  * $Revision: 1.6 $
00020  */ 
00021 //-----------------------------------------------------------------------------
00022 
00023 #ifndef  CAMERA_IMAGE_H
00024 #define  CAMERA_IMAGE_H
00025 
00026 #include "claraty/share.h"
00027 #include "claraty/fdm.h"
00028 #include <iostream>
00029 
00030 namespace claraty {
00031 
00032 template < typename Pixel_Type > class Image;
00033 class Camera_Model;
00034 
00035 //-----------------------------------------------------------------------------
00036 
00037 /**
00038  * @ingroup Camera
00039  * Used for capturing camera properties that are associated with an image
00040  */  
00041 struct Camera_Image_Properties {
00042    
00043   struct Property 
00044   {  
00045     float value; 
00046     float min_value;
00047     float max_value;
00048     enum Mode {INVALID, AUTO, MANUAL} mode;
00049     Property(float value=0.0, float min_val=0.0, float max_val=100.0, 
00050              Mode  mode = INVALID);
00051     bool io(FDM_Map map);
00052   };
00053 
00054   Property brightness;  /**< Percent black level of the picture (or gain) */
00055   Property contrast;    /**< Percent separation of bimodal histogram */
00056   Property exposure;    /**< Integration time (seconds) CCD is exposed */
00057   Property iris;        /**< F/stop number for the lens */
00058   Property focus;       /**< Lens focal length (meters) */
00059   float    temperature; /**< Temperature inside camera in deg C */
00060   int      frame_num;   /**< Frame number of images in a video stream */
00061   std::string camera_name;  /**< Name of camera that acquired the image */
00062   std::string filter_color; /**< color of the optical filter */
00063   
00064   Camera_Image_Properties();
00065   // Serialization and unserialization
00066   bool io(FDM_Map map);
00067 };
00068 
00069 std::ostream & operator << (std::ostream & os, 
00070                             const Camera_Image_Properties & p);
00071 
00072 //----------------------------------------------------------------------------
00073 /**
00074  * Extends the Image class to include a camera model, timestamp, 
00075  * a frame number (for video reconstruction), and camera image
00076  * properties (e.g. exposure time, shutter speed, etc) for that image.
00077  * A Camera_Image is simply an Image which was produced from a
00078  * camera.  
00079  *
00080  * The Camera_Image own a copy of the Camera_Model and hence does
00081  * not tie the lifetime of its objects to those of the camera 
00082  * that generated the Camera_Image.
00083  *
00084  * @ingroup Vision
00085  */
00086 template<typename Pixel_Type>
00087 class Camera_Image : public Image<Pixel_Type> {
00088   
00089   friend class Camera;
00090   
00091 public:
00092   
00093   // @{ @name Constructors/destructor
00094   Camera_Image(const Camera_Model * model = NULL, 
00095                Time timestamp = Time(), 
00096                Camera_Image_Properties * properties = NULL);
00097   
00098   Camera_Image(int nrows, int ncols, 
00099                const Camera_Model * model = NULL,
00100                Time timestamp = Time());
00101   
00102   Camera_Image(const Image<Pixel_Type> & src_image,
00103                const Camera_Model * model = NULL,
00104                Time timestamp=Time(), 
00105                Camera_Image_Properties * properties = NULL);
00106   
00107   Camera_Image(const Camera_Image<Pixel_Type> & src_image);
00108   
00109   virtual ~Camera_Image();
00110   
00111   Camera_Image & operator=(const Camera_Image& rhs); 
00112   // @}
00113   
00114   // @{ @name Observers
00115   const Camera_Model &   get_camera_model() const { return *_model;     }
00116   Time                   get_timestamp()    const { return  _timestamp; }
00117   const Camera_Image_Properties & get_properties() const {return _properties;}
00118   // @}
00119   
00120   // @{ @name Mutators
00121   void set_camera_model(const Camera_Model & model);
00122   void set_timestamp   (Time timestamp)     { _timestamp = timestamp; }
00123   void set_properties (Camera_Image_Properties & p)  { _properties = p;}
00124   // @}
00125 
00126   // This is not virtual because we still don't want it automatically
00127   // instantiated for every pixel type (some of which might not yet have io
00128   // routines) -- you must be careful, therefore, when calling it to know the
00129   // underlying data type that you're trying to io.
00130   bool io(FDM_Map m);
00131 
00132 private:
00133   
00134   Time                      _timestamp;
00135   Camera_Model            * _model;
00136   Camera_Image_Properties * _properties;
00137 };
00138 
00139 template < typename Pixel_Type >
00140 Camera_Image<Pixel_Type> rectify(const Camera_Image<Pixel_Type> & image);
00141 
00142 //-------------------------------------------------------------------------
00143 
00144 } // namespace claraty
00145 
00146 #include "claraty/camera_image.ipp"
00147 
00148 #endif  // CAMERA_IMAGE_H
00149