Fawkes API  Fawkes Development Version
star.h
1 
2 /***************************************************************************
3  * star.h - Starlike scanline model
4  *
5  * Created: Mon Nov 05 09:45:06 2007
6  * Copyright 2007 Daniel Beck
7  *
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_SCANLINES_STAR_H_
25 #define __FIREVISION_MODELS_SCANLINES_STAR_H_
26 
27 #include <fvmodels/scanlines/scanlinemodel.h>
28 #include <vector>
29 #include <map>
30 
31 namespace firevision {
32 #if 0 /* just to make Emacs auto-indent happy */
33 }
34 #endif
35 
37 {
38  public:
39  ScanlineStar(unsigned int image_width, unsigned int image_height,
40  unsigned int center_x, unsigned int center_y,
41  unsigned int num_rays, unsigned int radius_incr,
42  unsigned char* yuv_mask,
43  unsigned int dead_radius = 0, unsigned int max_radius = 0,
44  unsigned int margin = 0);
45 
46  virtual ~ScanlineStar();
47 
52 
53  void advance();
54  bool finished();
55  void reset();
56  const char* get_name();
57  unsigned int get_margin();
58  void set_robot_pose(float x, float y, float ori);
59  void set_pan_tilt(float pan, float tilt);
60  void skip_current_ray();
61  unsigned int num_rays() const;
62  unsigned int ray_index() const;
63  unsigned int current_radius() const;
64  float current_angle() const;
65  bool first_on_ray() const;
66 
67  private:
68  void generate_scan_points();
69 
70  unsigned int m_image_width;
71  unsigned int m_image_height;
72  fawkes::upoint_t m_center;
73  unsigned int m_num_rays;
74  unsigned int m_radius_incr;
75  unsigned int m_dead_radius;
76  unsigned int m_max_radius;
77  unsigned int m_margin;
78  float m_angle_incr;
79  unsigned char* m_mask;
80 
81  bool m_first_on_ray;
82  bool m_done;
83 
84  fawkes::upoint_t m_current_point;
85  fawkes::upoint_t m_tmp_point;
86  unsigned int m_ray_index;
87 
88  typedef std::map<unsigned int, fawkes::upoint_t> Ray;
89  std::map<float, Ray*> m_rays;
90  std::map<float, Ray*>::iterator m_ray_iter;
91  Ray::iterator m_point_iter;
92 
93  // std::vector<float> m_angles;
94  // std::vector<float>::iterator m_angle_iter;
95 
96  Ray* m_first_ray;
97  Ray* m_previous_ray;
98 };
99 
100 } // end namespace firevision
101 
102 #endif /* __FIREVISION_MODELS_SCANLINES_STAR_H_ */
void advance()
Calculates the next scanline point.
Definition: star.cpp:140
void set_robot_pose(float x, float y, float ori)
Set the robot&#39;s pose.
Definition: star.cpp:201
Scanline model interface.
Definition: scanlinemodel.h:55
fawkes::upoint_t * operator->()
Get pointer to current point.
Definition: star.cpp:114
const char * get_name()
Get name of scanline model.
Definition: star.cpp:187
ScanlineStar(unsigned int image_width, unsigned int image_height, unsigned int center_x, unsigned int center_y, unsigned int num_rays, unsigned int radius_incr, unsigned char *yuv_mask, unsigned int dead_radius=0, unsigned int max_radius=0, unsigned int margin=0)
Constructor.
Definition: star.cpp:58
void set_pan_tilt(float pan, float tilt)
Set camera&#39;s pan/tilt values.
Definition: star.cpp:208
unsigned int get_margin()
Get margin around points.
Definition: star.cpp:194
fawkes::upoint_t * operator++()
Postfix ++ operator.
Definition: star.cpp:121
void skip_current_ray()
Skips the current ray and continues with the first valid scanline point of the next ray...
Definition: star.cpp:217
Point with cartesian coordinates as unsigned integers.
Definition: types.h:34
Star-like arranged scanline points.
Definition: star.h:36
void reset()
Reset model.
Definition: star.cpp:174
fawkes::upoint_t operator*()
Get the current coordinate.
Definition: star.cpp:107
unsigned int ray_index() const
Return the index of the current ray.
Definition: star.cpp:250
virtual ~ScanlineStar()
Destructor.
Definition: star.cpp:97
bool finished()
Check if all desired points have been processed.
Definition: star.cpp:167
unsigned int num_rays() const
Returns the number of segments in the model.
Definition: star.cpp:240
unsigned int current_radius() const
Returns the radius of the current scanline point.
Definition: star.cpp:260
bool first_on_ray() const
Checks whether the current scanpoint is the first scanpoint on the current ray.
Definition: star.cpp:280
float current_angle() const
Returns the angle of the current scanline point.
Definition: star.cpp:270