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 class SharedMemoryLookupTable;
00032
00033 class Bulb : public MirrorModel {
00034
00035 friend class BulbGenerator;
00036
00037 public:
00038
00039
00040 Bulb(const char *filename);
00041 Bulb(const char *filename,
00042 const char *lut_id, bool destroy_on_delete = false);
00043
00044 Bulb(unsigned int width, unsigned int height);
00045 Bulb(unsigned int width, unsigned int height,
00046 const char *lut_id, bool destroy_on_delete = false);
00047
00048 Bulb(const Bulb &bulb);
00049
00050 virtual ~Bulb();
00051
00052 virtual void warp2unwarp(unsigned int warp_x, unsigned int warp_y,
00053 unsigned int *unwarp_x, unsigned int *unwarp_y);
00054 virtual void unwarp2warp(unsigned int unwarp_x, unsigned int unwarp_y,
00055 unsigned int *warp_x, unsigned int *warp_y );
00056
00057 virtual const char * getName();
00058
00059 virtual bool isValid();
00060
00061
00062 virtual void setWorldPoint(unsigned int image_x,
00063 unsigned int image_y,
00064 float world_r,
00065 float world_phi);
00066
00067
00068 virtual fawkes::polar_coord_2d_t getWorldPointRelative(unsigned int image_x,
00069 unsigned int image_y ) const;
00070
00071 virtual fawkes::cart_coord_2d_t getWorldPointGlobal(unsigned int image_x,
00072 unsigned int image_y,
00073 float pose_x, float pose_y,
00074 float pose_ori ) const;
00075
00076 virtual void reset();
00077
00078 virtual fawkes::point_t getCenter() const;
00079 virtual void setCenter(unsigned int image_x,
00080 unsigned int image_y );
00081 virtual void setOrientation(float angle);
00082 virtual float getOrientation() const;
00083
00084 virtual bool isValidPoint( unsigned int image_x, unsigned int image_y ) const;
00085
00086
00087 bool isNonZero(unsigned int image_x,
00088 unsigned int image_y ) const;
00089
00090 unsigned int numNonZero() const;
00091
00092
00093 float getAngle(unsigned int image_x,
00094 unsigned int image_y ) const;
00095
00096 float getDistanceInImage(unsigned int image_p1_x, unsigned int image_p1_y,
00097 unsigned int image_p2_x, unsigned int image_p2_y );
00098
00099 float convertAngleI2W (float angle_in_image) const;
00100
00101
00102 void load(const char * filename);
00103 void save(const char * filename);
00104
00105 static std::string composeFilename(const char * format);
00106
00107 protected:
00108
00109
00110 typedef struct {
00111 unsigned int width;
00112 unsigned int height;
00113 unsigned int center_x;
00114 unsigned int center_y;
00115 float orientation;
00116 float dist_min;
00117 float dist_max;
00118 } bulb_file_header_t;
00119
00120
00121 private:
00122 void create();
00123 void erase();
00124 void init();
00125
00126 private:
00127
00128
00129 unsigned int width;
00130 unsigned int height;
00131 unsigned int bytes_per_sample;
00132
00133
00134 unsigned int image_center_x;
00135 unsigned int image_center_y;
00136
00137
00138 float orientation;
00139
00140
00141 float distance_min;
00142 float distance_max;
00143
00144 bool valid;
00145
00146 char *lut_id;
00147 fawkes::polar_coord_2d_t *lut;
00148 unsigned int lut_bytes;
00149 bool destroy_on_delete;
00150
00151 SharedMemoryLookupTable *shm_lut;
00152
00153
00154 };
00155
00156 #endif