Fawkes API Fawkes Development Version
bulb.h
1
2/***************************************************************************
3 * bulb.h - class defining a light bulb as mirror
4 *
5 * Created: Thu Jul 21 14:25:00 2005
6 * Copyright 2005-2012 Tim Niemueller [www.niemueller.de]
7 * 2005 Martin Heracles
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#ifndef _FIREVISION_MODELS_MIRROR_BULB_H_
25#define _FIREVISION_MODELS_MIRROR_BULB_H_
26
27#include <fvmodels/mirror/mirrormodel.h>
28
29#include <string>
30
31namespace firevision {
32
33class SharedMemoryLookupTable;
34class BulbGenerator;
35
36class Bulb : public MirrorModel
37{
38 friend BulbGenerator;
39
40public:
41 // This constructor loads an existing bulb model (lut) from file "filename".
42 Bulb(const char *filename);
43 Bulb(const char *filename, const char *lut_id, bool destroy_on_delete = false);
44
45 Bulb(unsigned int width, unsigned int height);
46 Bulb(unsigned int width, unsigned int height, const char *lut_id, bool destroy_on_delete = false);
47
48 Bulb(const Bulb &bulb);
49
50 virtual ~Bulb();
51
52 Bulb &operator=(const Bulb &bulb);
53
54 virtual void warp2unwarp(unsigned int warp_x,
55 unsigned int warp_y,
56 unsigned int *unwarp_x,
57 unsigned int *unwarp_y);
58 virtual void unwarp2warp(unsigned int unwarp_x,
59 unsigned int unwarp_y,
60 unsigned int *warp_x,
61 unsigned int *warp_y);
62
63 virtual const char *getName();
64
65 virtual bool isValid();
66
67 virtual void
68 setWorldPoint(unsigned int image_x, unsigned int image_y, float world_r, float world_phi);
69
70 virtual fawkes::polar_coord_2d_t getWorldPointRelative(unsigned int image_x,
71 unsigned int image_y) const;
72
73 virtual fawkes::cart_coord_2d_t getWorldPointGlobal(unsigned int image_x,
74 unsigned int image_y,
75 float pose_x,
76 float pose_y,
77 float pose_ori) const;
78
79 virtual void reset();
80
81 virtual fawkes::upoint_t getCenter() const;
82 virtual void setCenter(unsigned int image_x, unsigned int image_y);
83 virtual void setOrientation(float angle);
84 virtual float getOrientation() const;
85
86 virtual bool isValidPoint(unsigned int image_x, unsigned int image_y) const;
87
88 bool isNonZero(unsigned int image_x, unsigned int image_y) const;
89
90 unsigned int numNonZero() const;
91
92 float getAngle(unsigned int image_x, unsigned int image_y) const;
93
94 float getDistanceInImage(unsigned int image_p1_x,
95 unsigned int image_p1_y,
96 unsigned int image_p2_x,
97 unsigned int image_p2_y);
98
99 float convertAngleI2W(float angle_in_image) const;
100
101 void load(const char *filename);
102 void save(const char *filename);
103
104 static std::string composeFilename(const char *format);
105
106 const fawkes::polar_coord_2d_t *get_lut() const;
107
108protected:
109 /** bulb file header. */
110 typedef struct
111 {
112 unsigned int width; /**< width of LUT */
113 unsigned int height; /**< height of LUT */
114 unsigned int center_x; /**< x coordinate of mirror center in image */
115 unsigned int center_y; /**< y coordinate of mirror center in image */
116 float orientation; /**< orientation of camera in image */
117 float dist_min; /**< minimum distance from mirror center */
118 float dist_max; /**< maximum distance from mirror center */
120
121private:
122 void create();
123 void erase();
124 void init();
125
126private:
127 // dimension of lut (and image)
128 unsigned int width;
129 unsigned int height;
130 unsigned int bytes_per_sample;
131
132 // center of omni camera device
133 unsigned int image_center_x;
134 unsigned int image_center_y;
135
136 // orientation of omni camera device
137 float orientation;
138
139 // distance of closest and of farthest sample point
140 float distance_min;
141 float distance_max;
142
143 bool valid;
144
145 char * lut_id;
147 unsigned int lut_bytes;
148 bool destroy_on_delete;
149
151};
152
153} // end namespace firevision
154
155#endif
Bulb mirror lookup table.
Definition: bulb.h:37
Bulb & operator=(const Bulb &bulb)
Assignment operator.
Definition: bulb.cpp:156
virtual fawkes::cart_coord_2d_t getWorldPointGlobal(unsigned int image_x, unsigned int image_y, float pose_x, float pose_y, float pose_ori) const
Get global coordinate based on image coordinates.
Definition: bulb.cpp:389
virtual bool isValidPoint(unsigned int image_x, unsigned int image_y) const
Check if the given point is valid.
Definition: bulb.cpp:525
virtual float getOrientation() const
Get orientation of the omni-camera.
Definition: bulb.cpp:519
static std::string composeFilename(const char *format)
Compose a filename matching the given format.
Definition: bulb.cpp:653
unsigned int numNonZero() const
Get number of non-zero entries.
Definition: bulb.cpp:552
float getDistanceInImage(unsigned int image_p1_x, unsigned int image_p1_y, unsigned int image_p2_x, unsigned int image_p2_y)
Euklidean distance between to image points.
Definition: bulb.cpp:587
void load(const char *filename)
Load LUT from file.
Definition: bulb.cpp:262
virtual fawkes::polar_coord_2d_t getWorldPointRelative(unsigned int image_x, unsigned int image_y) const
Get relative coordinate based on image coordinates.
Definition: bulb.cpp:373
virtual void setWorldPoint(unsigned int image_x, unsigned int image_y, float world_r, float world_phi)
Set a world point mapping.
Definition: bulb.cpp:447
Bulb(const char *filename)
Constructor.
Definition: bulb.cpp:56
float getAngle(unsigned int image_x, unsigned int image_y) const
Angle between direction to point and "to the right".
Definition: bulb.cpp:574
virtual fawkes::upoint_t getCenter() const
Get the image pixel that is the center of the omni-camera.
Definition: bulb.cpp:480
virtual ~Bulb()
Destructor.
Definition: bulb.cpp:210
void save(const char *filename)
Save LUT from file.
Definition: bulb.cpp:297
virtual void setOrientation(float angle)
Set orientation of the omni-camera device.
Definition: bulb.cpp:507
float convertAngleI2W(float angle_in_image) const
convertAngleI2W
Definition: bulb.cpp:605
virtual void setCenter(unsigned int image_x, unsigned int image_y)
Set center of omni-camera to given image pixel.
Definition: bulb.cpp:491
const fawkes::polar_coord_2d_t * get_lut() const
Get the raw lookup table.
Definition: bulb.cpp:433
virtual void unwarp2warp(unsigned int unwarp_x, unsigned int unwarp_y, unsigned int *warp_x, unsigned int *warp_y)
Transform unwarped to warped point.
Definition: bulb.cpp:350
virtual void reset()
Reset model.
Definition: bulb.cpp:474
virtual void warp2unwarp(unsigned int warp_x, unsigned int warp_y, unsigned int *unwarp_x, unsigned int *unwarp_y)
Transform warped to unwarped point.
Definition: bulb.cpp:331
virtual const char * getName()
Get name of model.
Definition: bulb.cpp:358
bool isNonZero(unsigned int image_x, unsigned int image_y) const
Check if pixel maps to valid world point.
Definition: bulb.cpp:538
virtual bool isValid()
Check if a valid LUT has been loaded.
Definition: bulb.cpp:367
Mirror model interface.
Definition: mirrormodel.h:32
Shared memory lookup table.
Definition: shm_lut.h:113
Cartesian coordinates (2D).
Definition: types.h:65
Polar coordinates.
Definition: types.h:96
Point with cartesian coordinates as unsigned integers.
Definition: types.h:35
unsigned int height
height of LUT
Definition: bulb.h:113
float dist_max
maximum distance from mirror center
Definition: bulb.h:118
float dist_min
minimum distance from mirror center
Definition: bulb.h:117
unsigned int center_x
x coordinate of mirror center in image
Definition: bulb.h:114
unsigned int center_y
y coordinate of mirror center in image
Definition: bulb.h:115
float orientation
orientation of camera in image
Definition: bulb.h:116
unsigned int width
width of LUT
Definition: bulb.h:112