bulb.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
00033 }
00034 #endif
00035
00036 class SharedMemoryLookupTable;
00037
00038 class Bulb : public MirrorModel
00039 {
00040 friend class BulbGenerator;
00041 public:
00042
00043
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
00114 typedef struct {
00115 unsigned int width;
00116 unsigned int height;
00117 unsigned int center_x;
00118 unsigned int center_y;
00119 float orientation;
00120 float dist_min;
00121 float dist_max;
00122 } bulb_file_header_t;
00123
00124
00125 private:
00126 void create();
00127 void erase();
00128 void init();
00129
00130 private:
00131
00132
00133 unsigned int width;
00134 unsigned int height;
00135 unsigned int bytes_per_sample;
00136
00137
00138 unsigned int image_center_x;
00139 unsigned int image_center_y;
00140
00141
00142 float orientation;
00143
00144
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 }
00161
00162 #endif