This class is used to draw a soccer field. More...
#include <>>
Public Member Functions | |
FieldDrawer (const FieldLines &lines) | |
Created a new field object. | |
virtual | ~FieldDrawer () |
Destructor. | |
void | set_head_yaw (float head_yaw) |
Sets the angular offset between body and head (along the body axis). | |
void | set_own_pos (fawkes::field_pos_t own_position) |
Own position setter. | |
void | set_own_pos_est (fawkes::field_pos_t own_position_estimate) |
Own position estimate setter. | |
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_background (YUV_t color) |
Sets the background color (outside the field). | |
void | set_color_field (YUV_t color) |
Sets the field color. | |
void | set_color_lines (YUV_t color) |
Sets the lines color. | |
void | set_color_line_points (YUV_t color) |
Sets the line points color. | |
void | set_color_line_points_est (YUV_t color) |
Sets the line points color. | |
void | set_color_own_pos (YUV_t color) |
Sets the own position color. | |
void | set_color_own_pos_est (YUV_t color) |
Sets the own position estimates color. | |
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]). | |
Protected Member Functions | |
void | clear_own_pos () |
Clears the own position. | |
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_line_points (bool draw_landscape=true, float scale=0) const |
Draws the line points. | |
virtual void | draw_lines (YUV_t color, bool draw_landscape=true, float scale=0) const |
Draws the field lines to a SharedMemoryImageBuffer. | |
Protected Attributes | |
unsigned char * | _img_buffer |
The pointer to the target image buffer. | |
unsigned int | _img_width |
The width of the target image buffer. | |
unsigned int | _img_height |
The height of the target image buffer. |
This class is used to draw a soccer field.
Definition at line 38 of file field_drawer.h.
firevision::FieldDrawer::FieldDrawer | ( | const FieldLines & | lines | ) |
Created a new field object.
lines | the field lines container |
Definition at line 60 of file field_drawer.cpp.
References firevision::YUV_t_struct::black(), clear_own_pos(), firevision::YUV_t_struct::cyan(), firevision::YUV_t_struct::green(), set_color_background(), set_color_field(), set_color_line_points(), set_color_line_points_est(), set_color_lines(), set_color_own_pos(), set_color_own_pos_est(), firevision::YUV_t_struct::white(), and firevision::YUV_t_struct::yellow().
firevision::FieldDrawer::~FieldDrawer | ( | ) | [virtual] |
Destructor.
Definition at line 82 of file field_drawer.cpp.
void firevision::FieldDrawer::clear_own_pos | ( | ) | [inline, protected] |
Clears the own position.
Used (e.g.) if the own position couldn't be calculated
Definition at line 124 of file field_drawer.cpp.
References _img_buffer, _img_height, _img_width, and fawkes::field_pos_t::ori.
Referenced by draw_field(), and FieldDrawer().
void firevision::FieldDrawer::draw_field | ( | unsigned char * | yuv422_planar, | |
unsigned int | img_width, | |||
unsigned int | img_height, | |||
bool | draw_background = true , |
|||
bool | draw_landscape = true | |||
) | [virtual] |
Draws the field (including the own position [est]).
The position [est] and line points [est] gets reseted after drawing
yuv422_planar | the image buffer | |
img_width | the image width | |
img_height | the image height | |
draw_background | true if the background (field and border) should be drawn | |
draw_landscape | true if the field should be drawn landscape |
Definition at line 259 of file field_drawer.cpp.
References _img_buffer, _img_height, _img_width, clear_own_pos(), firevision::ROI::contains(), firevision::Drawer::draw_circle(), firevision::Drawer::draw_line(), draw_line_points(), draw_lines(), firevision::FieldLines::get_field_length(), firevision::FieldLines::get_field_offsets(), firevision::FieldLines::get_field_width(), fawkes::field_pos_t::ori, firevision::Drawer::set_buffer(), firevision::Drawer::set_color(), firevision::YUV_t_struct::U, firevision::YUV_t_struct::V, fawkes::field_pos_t::x, fawkes::cart_coord_2d_t::x, fawkes::field_pos_t::y, fawkes::cart_coord_2d_t::y, and firevision::YUV_t_struct::Y.
void firevision::FieldDrawer::draw_line_points | ( | bool | draw_landscape = true , |
|
float | scale = 0 | |||
) | const [protected, virtual] |
Draws the line points.
draw_landscape | true if the field should be drawn landscape | |
scale | the pre calculated scale (conversion factor between image size and field size - if 0 the value gets calculated) |
Definition at line 401 of file field_drawer.cpp.
References _img_buffer, _img_height, _img_width, firevision::Drawer::draw_cross(), firevision::FieldLines::get_field_length(), firevision::FieldLines::get_field_offsets(), firevision::FieldLines::get_field_width(), firevision::Drawer::set_buffer(), firevision::Drawer::set_color(), fawkes::cart_coord_2d_t::x, and fawkes::cart_coord_2d_t::y.
Referenced by draw_field().
void firevision::FieldDrawer::draw_lines | ( | YUV_t | color, | |
bool | draw_landscape = true , |
|||
float | scale = 0 | |||
) | const [protected, virtual] |
Draws the field lines to a SharedMemoryImageBuffer.
color | of the lines | |
draw_landscape | if true (default) the field is supposed to be landscape | |
scale | the conversation factor between [m] and [px] (if 0 this value gets calculated) |
Definition at line 445 of file field_drawer.cpp.
References _img_buffer, _img_height, _img_width, firevision::Drawer::draw_circle(), firevision::Drawer::draw_line(), firevision::FieldLines::get_circles(), firevision::FieldLines::get_field_length(), firevision::FieldLines::get_field_offsets(), firevision::FieldLines::get_field_width(), firevision::Drawer::set_buffer(), firevision::Drawer::set_color(), fawkes::cart_coord_2d_t::x, and fawkes::cart_coord_2d_t::y.
Referenced by draw_field().
float firevision::FieldDrawer::get_scale | ( | unsigned int | img_width, | |
unsigned int | img_height, | |||
bool | draw_landscape = true | |||
) | const [inline, protected] |
Calculates the conversion factor between field size and image size.
img_width | of the target image | |
img_height | of the target image | |
draw_landscape | true if the image should be drawn landscape |
Definition at line 169 of file field_drawer.cpp.
References firevision::FieldLines::get_field_length(), and firevision::FieldLines::get_field_width().
void firevision::FieldDrawer::set_color_background | ( | YUV_t | color | ) |
Sets the background color (outside the field).
color | to be used |
Definition at line 181 of file field_drawer.cpp.
Referenced by FieldDrawer().
void firevision::FieldDrawer::set_color_field | ( | YUV_t | color | ) |
Sets the field color.
color | to be used |
Definition at line 191 of file field_drawer.cpp.
Referenced by FieldDrawer().
void firevision::FieldDrawer::set_color_line_points | ( | YUV_t | color | ) |
Sets the line points color.
color | to be used |
Definition at line 211 of file field_drawer.cpp.
Referenced by FieldDrawer().
void firevision::FieldDrawer::set_color_line_points_est | ( | YUV_t | color | ) |
Sets the line points color.
color | to be used |
Definition at line 221 of file field_drawer.cpp.
Referenced by FieldDrawer().
void firevision::FieldDrawer::set_color_lines | ( | YUV_t | color | ) |
Sets the lines color.
color | to be used |
Definition at line 201 of file field_drawer.cpp.
Referenced by FieldDrawer().
void firevision::FieldDrawer::set_color_own_pos | ( | YUV_t | color | ) |
Sets the own position color.
color | to be used |
Definition at line 231 of file field_drawer.cpp.
Referenced by FieldDrawer().
void firevision::FieldDrawer::set_color_own_pos_est | ( | YUV_t | color | ) |
Sets the own position estimates color.
color | to be used |
Definition at line 241 of file field_drawer.cpp.
Referenced by FieldDrawer().
void firevision::FieldDrawer::set_head_yaw | ( | float | head_yaw | ) |
Sets the angular offset between body and head (along the body axis).
head_yaw | angular offset |
Definition at line 92 of file field_drawer.cpp.
void firevision::FieldDrawer::set_line_points | ( | const fld_line_points_t * | points | ) |
Setter for detected line points.
points | a list of line points (relative to the center of the field!) |
Definition at line 143 of file field_drawer.cpp.
void firevision::FieldDrawer::set_line_points_est | ( | const fld_line_points_t * | points_est | ) |
Setter for detected line points.
points_est | a list of line points (relative to the center of the field!) |
Definition at line 154 of file field_drawer.cpp.
void firevision::FieldDrawer::set_own_pos | ( | fawkes::field_pos_t | own_position | ) |
Own position setter.
Sets the (calculated) own position on the field
own_position | as calculated by the localization |
Definition at line 103 of file field_drawer.cpp.
void firevision::FieldDrawer::set_own_pos_est | ( | fawkes::field_pos_t | own_position_estimate | ) |
Own position estimate setter.
Sets the position estimate (e.g. by triangulation, odometry, ...)
own_position_estimate | as estimated |
Definition at line 114 of file field_drawer.cpp.
float firevision::FieldDrawer::_img_buffer [protected] |
The pointer to the target image buffer.
Definition at line 68 of file field_drawer.h.
Referenced by clear_own_pos(), draw_field(), draw_line_points(), and draw_lines().
float firevision::FieldDrawer::_img_height [protected] |
The height of the target image buffer.
Definition at line 70 of file field_drawer.h.
Referenced by clear_own_pos(), draw_field(), draw_line_points(), and draw_lines().
float firevision::FieldDrawer::_img_width [protected] |
The width of the target image buffer.
Definition at line 69 of file field_drawer.h.
Referenced by clear_own_pos(), draw_field(), draw_line_points(), and draw_lines().