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
29namespace firevision {
30
31class SharedMemoryImageBuffer;
32
34{
35public:
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);
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
60protected:
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
71private: //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
This class is used to draw a soccer field.
Definition: field_drawer.h:34
void set_line_points(const fld_line_points_t *points)
Setter for detected line points.
void set_line_points_est(const fld_line_points_t *points_est)
Setter for detected line points.
void set_color_own_pos(YUV_t color)
Sets the own position color.
void set_own_pos(fawkes::field_pos_t own_position)
Own position setter.
void clear_own_pos()
Clears the own position.
void set_color_own_pos_est(YUV_t color)
Sets the own position estimates color.
void set_own_pos_est(fawkes::field_pos_t own_position_estimate)
Own position estimate setter.
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]).
void set_color_field(YUV_t color)
Sets the field color.
void set_color_line_points(YUV_t color)
Sets the line points color.
void set_color_lines(YUV_t color)
Sets the lines color.
void set_head_yaw(float head_yaw)
Sets the angular offset between body and head (along the body axis)
void set_color_line_points_est(YUV_t color)
Sets the line points color.
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.
unsigned int _img_width
The width of the target image buffer.
Definition: field_drawer.h:68
virtual ~FieldDrawer()
Destructor.
unsigned char * _img_buffer
The pointer to the target image buffer.
Definition: field_drawer.h:67
unsigned int _img_height
The height of the target image buffer.
Definition: field_drawer.h:69
virtual void draw_lines(YUV_t color, bool draw_landscape=true, float scale=0) const
Draws the field lines to a SharedMemoryImageBuffer.
void set_color_background(YUV_t color)
Sets the background color (outside the field)
FieldDrawer(const FieldLines &lines)
Created a new field object.
virtual void draw_line_points(bool draw_landscape=true, float scale=0) const
Draws the line points.
This class acts as a container for lines on a soccer field.
Definition: field_lines.h:35
Position on the field.
Definition: types.h:125
YUV pixel.
Definition: yuv.h:58