Fawkes API  Fawkes Development Version
field_drawer.h
1 /***************************************************************************
2  * field_drawer.h - Encapsulates a soccer field
3  *
4  * Created: Tue Sep 23 00:00:00 2009
5  * Copyright 2008 Christof Rath <christof.rath@gmail.com>
6  *
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #ifndef _FVUTILS_DRAWER_FIELD_DRAWER_H__
23 #define _FVUTILS_DRAWER_FIELD_DRAWER_H__
24 
25 #include <fvutils/color/yuv.h>
26 #include <fvutils/draw/field.h>
27 #include <utils/math/types.h>
28 
29 namespace firevision {
30 
31 class SharedMemoryImageBuffer;
32 
33 class FieldDrawer
34 {
35 public:
36  FieldDrawer(const FieldLines &lines);
37  virtual ~FieldDrawer();
38 
39  void set_head_yaw(float head_yaw);
40  void set_own_pos(fawkes::field_pos_t own_position);
41  void set_own_pos_est(fawkes::field_pos_t own_position_estimate);
42 
43  void set_line_points(const fld_line_points_t *points);
44  void set_line_points_est(const fld_line_points_t *points_est);
45 
46  void set_color_background(YUV_t color);
47  void set_color_field(YUV_t color);
48  void set_color_lines(YUV_t color);
49  void set_color_line_points(YUV_t color);
50  void set_color_line_points_est(YUV_t color);
51  void set_color_own_pos(YUV_t color);
52  void set_color_own_pos_est(YUV_t color);
53 
54  virtual void draw_field(unsigned char *yuv422_planar,
55  unsigned int img_width,
56  unsigned int img_height,
57  bool draw_background = true,
58  bool draw_landscape = true);
59 
60 protected:
61  inline void clear_own_pos();
62  inline float
63  get_scale(unsigned int img_width, unsigned int img_height, bool draw_landscape = true) const;
64  virtual void draw_line_points(bool draw_landscape = true, float scale = 0) const;
65  virtual void draw_lines(YUV_t color, bool draw_landscape = true, float scale = 0) const;
66 
67  unsigned char *_img_buffer;
68  unsigned int _img_width;
69  unsigned int _img_height;
70 
71 private: //Members
72  const FieldLines & lines_;
73  fawkes::field_pos_t own_position_, own_pos_est_;
74  float head_yaw_;
75 
76  const fld_line_points_t *points_;
77  const fld_line_points_t *points_est_;
78 
79  YUV_t c_background_;
80  YUV_t c_field_;
81  YUV_t c_lines_;
82  YUV_t c_line_points_;
83  YUV_t c_line_points_est_;
84  YUV_t c_own_pos_;
85  YUV_t c_own_pos_est_;
86 };
87 
88 } // end namespace firevision
89 
90 #endif
firevision::FieldDrawer::get_scale
float get_scale(unsigned int img_width, unsigned int img_height, bool draw_landscape=true) const
Calculates the conversion factor between field size and image size.
Definition: field_drawer.cpp:161
firevision::FieldDrawer::set_head_yaw
void set_head_yaw(float head_yaw)
Sets the angular offset between body and head (along the body axis)
Definition: field_drawer.cpp:85
firevision::FieldDrawer::set_line_points_est
void set_line_points_est(const fld_line_points_t *points_est)
Setter for detected line points.
Definition: field_drawer.cpp:147
firevision::FieldDrawer::set_color_line_points
void set_color_line_points(YUV_t color)
Sets the line points color.
Definition: field_drawer.cpp:203
firevision::FieldDrawer::set_color_line_points_est
void set_color_line_points_est(YUV_t color)
Sets the line points color.
Definition: field_drawer.cpp:213
fawkes::field_pos_t
Position on the field.
Definition: types.h:123
firevision::FieldDrawer::_img_width
unsigned int _img_width
Definition: field_drawer.h:72
firevision::FieldDrawer::FieldDrawer
FieldDrawer(const FieldLines &lines)
Created a new field object.
Definition: field_drawer.cpp:55
firevision::YUV_t_struct
YUV pixel.
Definition: yuv.h:62
firevision::FieldDrawer::_img_height
unsigned int _img_height
Definition: field_drawer.h:73
firevision::FieldDrawer::~FieldDrawer
virtual ~FieldDrawer()
Destructor.
Definition: field_drawer.cpp:76
firevision::FieldDrawer::set_own_pos_est
void set_own_pos_est(fawkes::field_pos_t own_position_estimate)
Own position estimate setter.
Definition: field_drawer.cpp:107
firevision::FieldDrawer::draw_line_points
virtual void draw_line_points(bool draw_landscape=true, float scale=0) const
Draws the line points.
Definition: field_drawer.cpp:409
firevision::FieldDrawer::draw_field
virtual void draw_field(unsigned char *yuv422_planar, unsigned int img_width, unsigned int img_height, bool draw_background=true, bool draw_landscape=true)
Draws the field (including the own position [est]).
Definition: field_drawer.cpp:249
firevision::FieldDrawer::set_own_pos
void set_own_pos(fawkes::field_pos_t own_position)
Own position setter.
Definition: field_drawer.cpp:96
firevision::FieldLines
Definition: field_lines.h:38
firevision::FieldDrawer::draw_lines
virtual void draw_lines(YUV_t color, bool draw_landscape=true, float scale=0) const
Draws the field lines to a SharedMemoryImageBuffer.
Definition: field_drawer.cpp:463
firevision::FieldDrawer::set_color_own_pos
void set_color_own_pos(YUV_t color)
Sets the own position color.
Definition: field_drawer.cpp:223
firevision::FieldDrawer::_img_buffer
unsigned char * _img_buffer
Definition: field_drawer.h:71
firevision::FieldDrawer::set_line_points
void set_line_points(const fld_line_points_t *points)
Setter for detected line points.
Definition: field_drawer.cpp:136
firevision::FieldDrawer::set_color_lines
void set_color_lines(YUV_t color)
Sets the lines color.
Definition: field_drawer.cpp:193
firevision::FieldDrawer::clear_own_pos
void clear_own_pos()
Clears the own position.
Definition: field_drawer.cpp:117
firevision::FieldDrawer::set_color_field
void set_color_field(YUV_t color)
Sets the field color.
Definition: field_drawer.cpp:183
firevision::FieldDrawer::set_color_background
void set_color_background(YUV_t color)
Sets the background color (outside the field)
Definition: field_drawer.cpp:173
firevision::FieldDrawer::set_color_own_pos_est
void set_color_own_pos_est(YUV_t color)
Sets the own position estimates color.
Definition: field_drawer.cpp:233