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 
29 #include <map>
30 #include <vector>
31 
32 namespace firevision {
33 
34 class ScanlineStar : public ScanlineModel
35 {
36 public:
37  ScanlineStar(unsigned int image_width,
38  unsigned int image_height,
39  unsigned int center_x,
40  unsigned int center_y,
41  unsigned int num_rays,
42  unsigned int radius_incr,
43  unsigned char *yuv_mask,
44  unsigned int dead_radius = 0,
45  unsigned int max_radius = 0,
46  unsigned int margin = 0);
47 
48  virtual ~ScanlineStar();
49 
54 
55  void advance();
56  bool finished();
57  void reset();
58  const char * get_name();
59  unsigned int get_margin();
60  void set_robot_pose(float x, float y, float ori);
61  void set_pan_tilt(float pan, float tilt);
62  void skip_current_ray();
63  unsigned int num_rays() const;
64  unsigned int ray_index() const;
65  unsigned int current_radius() const;
66  float current_angle() const;
67  bool first_on_ray() const;
68 
69 private:
70  void generate_scan_points();
71 
72  unsigned int m_image_width;
73  unsigned int m_image_height;
74  fawkes::upoint_t m_center;
75  unsigned int m_num_rays;
76  unsigned int m_radius_incr;
77  unsigned int m_dead_radius;
78  unsigned int m_max_radius;
79  unsigned int m_margin;
80  float m_angle_incr;
81  unsigned char * m_mask;
82 
83  bool m_first_on_ray;
84  bool m_done;
85 
86  fawkes::upoint_t m_current_point;
87  fawkes::upoint_t m_tmp_point;
88  unsigned int m_ray_index;
89 
90  typedef std::map<unsigned int, fawkes::upoint_t> Ray;
91  std::map<float, Ray *> m_rays;
92  std::map<float, Ray *>::iterator m_ray_iter;
93  Ray::iterator m_point_iter;
94 
95  // std::vector<float> m_angles;
96  // std::vector<float>::iterator m_angle_iter;
97 
98  Ray *m_first_ray;
99  Ray *m_previous_ray;
100 };
101 
102 } // end namespace firevision
103 
104 #endif /* FIREVISION_MODELS_SCANLINES_STAR_H__ */
firevision::ScanlineStar::get_margin
unsigned int get_margin()
Get margin around points.
Definition: star.cpp:182
firevision::ScanlineStar::current_angle
float current_angle() const
Returns the angle of the current scanline point.
Definition: star.cpp:252
firevision::ScanlineStar::ScanlineStar
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:55
firevision::ScanlineStar::set_pan_tilt
void set_pan_tilt(float pan, float tilt)
Set camera's pan/tilt values.
Definition: star.cpp:194
fawkes::upoint_t
Point with cartesian coordinates as unsigned integers.
Definition: types.h:34
firevision::ScanlineStar::operator->
fawkes::upoint_t * operator->()
Get pointer to current point.
Definition: star.cpp:109
firevision::ScanlineStar::operator++
fawkes::upoint_t * operator++()
Postfix ++ operator.
Definition: star.cpp:115
firevision::ScanlineStar::reset
void reset()
Reset model.
Definition: star.cpp:164
firevision::ScanlineStar::first_on_ray
bool first_on_ray() const
Checks whether the current scanpoint is the first scanpoint on the current ray.
Definition: star.cpp:262
firevision::ScanlineStar::skip_current_ray
void skip_current_ray()
Skips the current ray and continues with the first valid scanline point of the next ray.
Definition: star.cpp:202
firevision::ScanlineStar::finished
bool finished()
Check if all desired points have been processed.
Definition: star.cpp:158
firevision::ScanlineStar::~ScanlineStar
virtual ~ScanlineStar()
Destructor.
Definition: star.cpp:96
firevision::ScanlineStar::current_radius
unsigned int current_radius() const
Returns the radius of the current scanline point.
Definition: star.cpp:243
firevision::ScanlineStar::get_name
const char * get_name()
Get name of scanline model.
Definition: star.cpp:176
firevision::ScanlineStar::set_robot_pose
void set_robot_pose(float x, float y, float ori)
Set the robot's pose.
Definition: star.cpp:188
firevision::ScanlineStar::ray_index
unsigned int ray_index() const
Return the index of the current ray.
Definition: star.cpp:234
firevision::ScanlineStar::operator*
fawkes::upoint_t operator*()
Get the current coordinate.
Definition: star.cpp:104
firevision::ScanlineStar::num_rays
unsigned int num_rays() const
Returns the number of segments in the model.
Definition: star.cpp:225
firevision::ScanlineStar::advance
void advance()
Calculates the next scanline point.
Definition: star.cpp:132