Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * bulb.h - class defining a light bulb as mirror 00004 * 00005 * Created: Thu Jul 21 14:25:00 2005 00006 * Copyright 2005-2012 Tim Niemueller [www.niemueller.de] 00007 * 2005 Martin Heracles 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 <fvmodels/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 const fawkes::polar_coord_2d_t * get_lut() const; 00112 00113 protected: 00114 00115 /** bulb file header. */ 00116 typedef struct { 00117 unsigned int width; /**< width of LUT */ 00118 unsigned int height; /**< height of LUT */ 00119 unsigned int center_x; /**< x coordinate of mirror center in image */ 00120 unsigned int center_y; /**< y coordinate of mirror center in image */ 00121 float orientation; /**< orientation of camera in image */ 00122 float dist_min; /**< minimum distance from mirror center */ 00123 float dist_max; /**< maximum distance from mirror center */ 00124 } bulb_file_header_t; 00125 00126 00127 private: 00128 void create(); 00129 void erase(); 00130 void init(); 00131 00132 private: 00133 00134 // dimension of lut (and image) 00135 unsigned int width; 00136 unsigned int height; 00137 unsigned int bytes_per_sample; 00138 00139 // center of omni camera device 00140 unsigned int image_center_x; 00141 unsigned int image_center_y; 00142 00143 // orientation of omni camera device 00144 float orientation; 00145 00146 // distance of closest and of farthest sample point 00147 float distance_min; 00148 float distance_max; 00149 00150 bool valid; 00151 00152 char *lut_id; 00153 fawkes::polar_coord_2d_t *lut; 00154 unsigned int lut_bytes; 00155 bool destroy_on_delete; 00156 00157 SharedMemoryLookupTable *shm_lut; 00158 00159 00160 }; 00161 00162 } // end namespace firevision 00163 00164 #endif