bulb.h

00001 /***************************************************************************
00002  *  bulb.h - class defining a light bulb as mirror
00003  *
00004  *  Created: Thu Jul 21 14:25:00 2005
00005  *  Copyright 2005-2006 Tim Niemueller [www.niemueller.de]
00006  *            2005      Martin Heracles
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_MODELS_MIRROR_BULB_H_
00025 #define __FIREVISION_MODELS_MIRROR_BULB_H_
00026 
00027 #include <models/mirror/mirrormodel.h>
00028 
00029 #include <string>
00030 
00031 namespace firevision {
00032 #if 0 /* just to make Emacs auto-indent happy */
00033 }
00034 #endif
00035 
00036 class SharedMemoryLookupTable;
00037 
00038 class Bulb : public MirrorModel
00039 {
00040   friend class BulbGenerator;
00041  public:
00042 
00043   // This constructor loads an existing bulb model (lut) from file "filename".
00044   Bulb(const char *filename);
00045   Bulb(const char *filename,
00046        const char *lut_id, bool destroy_on_delete = false);
00047 
00048   Bulb(unsigned int width, unsigned int height);
00049   Bulb(unsigned int width, unsigned int height,
00050        const char *lut_id, bool destroy_on_delete = false);
00051 
00052   Bulb(const Bulb &bulb);
00053 
00054   virtual ~Bulb();
00055 
00056   virtual void warp2unwarp(unsigned int warp_x, unsigned int warp_y,
00057                            unsigned int *unwarp_x, unsigned int *unwarp_y);
00058   virtual void unwarp2warp(unsigned int unwarp_x, unsigned int unwarp_y,
00059                            unsigned int *warp_x, unsigned int *warp_y    );
00060 
00061   virtual const char * getName();
00062 
00063   virtual bool isValid();
00064 
00065 
00066   virtual void setWorldPoint(unsigned int image_x,
00067                              unsigned int image_y,
00068                              float        world_r,
00069                              float        world_phi);
00070 
00071 
00072   virtual fawkes::polar_coord_2d_t getWorldPointRelative(unsigned int image_x,
00073                                                          unsigned int image_y  ) const;
00074 
00075   virtual fawkes::cart_coord_2d_t getWorldPointGlobal(unsigned int image_x,
00076                                                       unsigned int image_y,
00077                                                       float pose_x, float pose_y,
00078                                                       float pose_ori ) const;
00079 
00080   virtual void reset();
00081 
00082   virtual fawkes::point_t getCenter() const;
00083   virtual void setCenter(unsigned int image_x, 
00084                          unsigned int image_y  );
00085   virtual void setOrientation(float angle);
00086   virtual float getOrientation() const;
00087 
00088   virtual bool isValidPoint( unsigned int image_x, unsigned int image_y ) const;
00089 
00090 
00091   bool isNonZero(unsigned int image_x,
00092                  unsigned int image_y  ) const;
00093 
00094   unsigned int numNonZero() const;
00095 
00096 
00097   float getAngle(unsigned int image_x, 
00098                  unsigned int image_y  ) const;
00099 
00100   float getDistanceInImage(unsigned int image_p1_x, unsigned int image_p1_y,
00101                            unsigned int image_p2_x, unsigned int image_p2_y  );
00102 
00103   float convertAngleI2W (float angle_in_image) const;
00104 
00105 
00106   void load(const char * filename);
00107   void save(const char * filename);
00108   
00109   static std::string composeFilename(const char * format);
00110 
00111  protected:
00112 
00113   /** bulb file header. */
00114   typedef struct {
00115     unsigned int width;         /**< width of LUT */
00116     unsigned int height;        /**< height of LUT */
00117     unsigned int center_x;      /**< x coordinate of mirror center in image */
00118     unsigned int center_y;      /**< y coordinate of mirror center in image */
00119     float        orientation;   /**< orientation of camera in image */
00120     float        dist_min;      /**< minimum distance from mirror center */
00121     float        dist_max;      /**< maximum distance from mirror center */
00122   } bulb_file_header_t;
00123 
00124 
00125  private:
00126   void create();
00127   void erase();
00128   void init();
00129 
00130  private:
00131 
00132   // dimension of lut (and image)
00133   unsigned int width;
00134   unsigned int height;
00135   unsigned int bytes_per_sample;
00136 
00137   // center of omni camera device
00138   unsigned int image_center_x;
00139   unsigned int image_center_y;
00140 
00141   // orientation of omni camera device
00142   float orientation;
00143 
00144   // distance of closest and of farthest sample point
00145   float distance_min;
00146   float distance_max;
00147 
00148   bool valid;
00149 
00150   char          *lut_id;
00151   fawkes::polar_coord_2d_t *lut;
00152   unsigned int   lut_bytes;
00153   bool destroy_on_delete;
00154 
00155   SharedMemoryLookupTable *shm_lut;
00156 
00157 
00158 };
00159 
00160 } // end namespace firevision
00161 
00162 #endif

Generated on Tue Feb 22 13:31:17 2011 for Fawkes API by  doxygen 1.4.7