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/draw/field.h>
26 
27 #include <utils/math/types.h>
28 #include <fvutils/color/yuv.h>
29 
30 namespace firevision {
31 #if 0 /* just to make Emacs auto-indent happy */
32 }
33 #endif
34 
35 
36 class SharedMemoryImageBuffer;
37 
39 {
40 public:
41  FieldDrawer(const FieldLines &lines);
42  virtual ~FieldDrawer();
43 
44  void set_head_yaw(float head_yaw);
45  void set_own_pos(fawkes::field_pos_t own_position);
46  void set_own_pos_est(fawkes::field_pos_t own_position_estimate);
47 
48  void set_line_points(const fld_line_points_t *points);
49  void set_line_points_est(const fld_line_points_t *points_est);
50 
51  void set_color_background(YUV_t color);
52  void set_color_field(YUV_t color);
53  void set_color_lines(YUV_t color);
54  void set_color_line_points(YUV_t color);
55  void set_color_line_points_est(YUV_t color);
56  void set_color_own_pos(YUV_t color);
57  void set_color_own_pos_est(YUV_t color);
58 
59  virtual void draw_field(unsigned char *yuv422_planar, unsigned int img_width, unsigned int img_height,
60  bool draw_background = true, bool draw_landscape = true);
61 
62 protected:
63  inline void clear_own_pos();
64  inline float get_scale(unsigned int img_width, unsigned int img_height, bool draw_landscape = true) const;
65  virtual void draw_line_points(bool draw_landscape = true, float scale = 0) const;
66  virtual void draw_lines(YUV_t color, bool draw_landscape = true, float scale = 0) const;
67 
68  unsigned char *_img_buffer;
69  unsigned int _img_width;
70  unsigned int _img_height;
71 
72 private: //Members
73  const FieldLines &__lines;
74  fawkes::field_pos_t __own_position, __own_pos_est;
75  float __head_yaw;
76 
77  const fld_line_points_t *__points;
78  const fld_line_points_t *__points_est;
79 
80  YUV_t __c_background;
81  YUV_t __c_field;
82  YUV_t __c_lines;
83  YUV_t __c_line_points;
84  YUV_t __c_line_points_est;
85  YUV_t __c_own_pos;
86  YUV_t __c_own_pos_est;
87 };
88 
89 } // end namespace firevision
90 
91 #endif
void set_color_lines(YUV_t color)
Sets the lines color.
void set_color_own_pos_est(YUV_t color)
Sets the own position estimates color.
virtual void draw_lines(YUV_t color, bool draw_landscape=true, float scale=0) const
Draws the field lines to a SharedMemoryImageBuffer.
void clear_own_pos()
Clears the own position.
unsigned int _img_width
The width of the target image buffer.
Definition: field_drawer.h:69
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.
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]).
virtual ~FieldDrawer()
Destructor.
FieldDrawer(const FieldLines &lines)
Created a new field object.
This class is used to draw a soccer field.
Definition: field_drawer.h:38
void set_color_background(YUV_t color)
Sets the background color (outside the field)
void set_line_points(const fld_line_points_t *points)
Setter for detected line points.
Position on the field.
Definition: types.h:110
unsigned char * _img_buffer
The pointer to the target image buffer.
Definition: field_drawer.h:68
void set_color_line_points(YUV_t color)
Sets the line points color.
void set_head_yaw(float head_yaw)
Sets the angular offset between body and head (along the body axis)
void set_color_own_pos(YUV_t color)
Sets the own position color.
unsigned int _img_height
The height of the target image buffer.
Definition: field_drawer.h:70
This class acts as a container for lines on a soccer field.
Definition: field_lines.h:36
YUV pixel.
Definition: yuv.h:59
void set_own_pos(fawkes::field_pos_t own_position)
Own position setter.
void set_color_field(YUV_t color)
Sets the field color.
virtual void draw_line_points(bool draw_landscape=true, float scale=0) const
Draws the line points.
void set_color_line_points_est(YUV_t color)
Sets the line points color.
void set_own_pos_est(fawkes::field_pos_t own_position_estimate)
Own position estimate setter.
void set_line_points_est(const fld_line_points_t *points_est)
Setter for detected line points.