Fawkes API  Fawkes Development Version
firevision::FieldDrawer Class Reference

This class is used to draw a soccer field. More...

#include <>>

Public Member Functions

 FieldDrawer (const FieldLines &lines)
 Created a new field object. More...
 
virtual ~FieldDrawer ()
 Destructor. More...
 
void set_head_yaw (float head_yaw)
 Sets the angular offset between body and head (along the body axis) More...
 
void set_own_pos (fawkes::field_pos_t own_position)
 Own position setter. More...
 
void set_own_pos_est (fawkes::field_pos_t own_position_estimate)
 Own position estimate setter. More...
 
void set_line_points (const fld_line_points_t *points)
 Setter for detected line points. More...
 
void set_line_points_est (const fld_line_points_t *points_est)
 Setter for detected line points. More...
 
void set_color_background (YUV_t color)
 Sets the background color (outside the field) More...
 
void set_color_field (YUV_t color)
 Sets the field color. More...
 
void set_color_lines (YUV_t color)
 Sets the lines color. More...
 
void set_color_line_points (YUV_t color)
 Sets the line points color. More...
 
void set_color_line_points_est (YUV_t color)
 Sets the line points color. More...
 
void set_color_own_pos (YUV_t color)
 Sets the own position color. More...
 
void set_color_own_pos_est (YUV_t color)
 Sets the own position estimates color. More...
 
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]). More...
 

Protected Member Functions

void clear_own_pos ()
 Clears the own position. More...
 
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. More...
 
virtual void draw_line_points (bool draw_landscape=true, float scale=0) const
 Draws the line points. More...
 
virtual void draw_lines (YUV_t color, bool draw_landscape=true, float scale=0) const
 Draws the field lines to a SharedMemoryImageBuffer. More...
 

Protected Attributes

unsigned char * _img_buffer
 The pointer to the target image buffer. More...
 
unsigned int _img_width
 The width of the target image buffer. More...
 
unsigned int _img_height
 The height of the target image buffer. More...
 

Detailed Description

This class is used to draw a soccer field.

Author
Christof Rath

Definition at line 38 of file field_drawer.h.

Constructor & Destructor Documentation

◆ FieldDrawer()

◆ ~FieldDrawer()

firevision::FieldDrawer::~FieldDrawer ( )
virtual

Destructor.

Definition at line 82 of file field_drawer.cpp.

Member Function Documentation

◆ clear_own_pos()

void firevision::FieldDrawer::clear_own_pos ( )
inlineprotected

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().

◆ draw_field()

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

Parameters
yuv422_planarthe image buffer
img_widththe image width
img_heightthe image height
draw_backgroundtrue if the background (field and border) should be drawn
draw_landscapetrue 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::cart_coord_2d_struct::x, fawkes::field_pos_t::x, firevision::YUV_t_struct::Y, fawkes::cart_coord_2d_struct::y, and fawkes::field_pos_t::y.

◆ draw_line_points()

void firevision::FieldDrawer::draw_line_points ( bool  draw_landscape = true,
float  scale = 0 
) const
protectedvirtual

Draws the line points.

Parameters
draw_landscapetrue if the field should be drawn landscape
scalethe 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(), and firevision::Drawer::set_color().

Referenced by draw_field().

◆ draw_lines()

void firevision::FieldDrawer::draw_lines ( YUV_t  color,
bool  draw_landscape = true,
float  scale = 0 
) const
protectedvirtual

Draws the field lines to a SharedMemoryImageBuffer.

Parameters
colorof the lines
draw_landscapeif true (default) the field is supposed to be landscape
scalethe 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(), and firevision::Drawer::set_color().

Referenced by draw_field().

◆ get_scale()

float firevision::FieldDrawer::get_scale ( unsigned int  img_width,
unsigned int  img_height,
bool  draw_landscape = true 
) const
inlineprotected

Calculates the conversion factor between field size and image size.

Parameters
img_widthof the target image
img_heightof the target image
draw_landscapetrue if the image should be drawn landscape
Returns
the conversion factor

Definition at line 169 of file field_drawer.cpp.

References firevision::FieldLines::get_field_length(), and firevision::FieldLines::get_field_width().

◆ set_color_background()

void firevision::FieldDrawer::set_color_background ( YUV_t  color)

Sets the background color (outside the field)

Parameters
colorto be used

Definition at line 181 of file field_drawer.cpp.

Referenced by FieldDrawer().

◆ set_color_field()

void firevision::FieldDrawer::set_color_field ( YUV_t  color)

Sets the field color.

Parameters
colorto be used

Definition at line 191 of file field_drawer.cpp.

Referenced by FieldDrawer().

◆ set_color_line_points()

void firevision::FieldDrawer::set_color_line_points ( YUV_t  color)

Sets the line points color.

Parameters
colorto be used

Definition at line 211 of file field_drawer.cpp.

Referenced by FieldDrawer().

◆ set_color_line_points_est()

void firevision::FieldDrawer::set_color_line_points_est ( YUV_t  color)

Sets the line points color.

Parameters
colorto be used

Definition at line 221 of file field_drawer.cpp.

Referenced by FieldDrawer().

◆ set_color_lines()

void firevision::FieldDrawer::set_color_lines ( YUV_t  color)

Sets the lines color.

Parameters
colorto be used

Definition at line 201 of file field_drawer.cpp.

Referenced by FieldDrawer().

◆ set_color_own_pos()

void firevision::FieldDrawer::set_color_own_pos ( YUV_t  color)

Sets the own position color.

Parameters
colorto be used

Definition at line 231 of file field_drawer.cpp.

Referenced by FieldDrawer().

◆ set_color_own_pos_est()

void firevision::FieldDrawer::set_color_own_pos_est ( YUV_t  color)

Sets the own position estimates color.

Parameters
colorto be used

Definition at line 241 of file field_drawer.cpp.

Referenced by FieldDrawer().

◆ set_head_yaw()

void firevision::FieldDrawer::set_head_yaw ( float  head_yaw)

Sets the angular offset between body and head (along the body axis)

Parameters
head_yawangular offset

Definition at line 92 of file field_drawer.cpp.

◆ set_line_points()

void firevision::FieldDrawer::set_line_points ( const fld_line_points_t *  points)

Setter for detected line points.

Parameters
pointsa list of line points (relative to the center of the field!)

Definition at line 143 of file field_drawer.cpp.

◆ set_line_points_est()

void firevision::FieldDrawer::set_line_points_est ( const fld_line_points_t *  points_est)

Setter for detected line points.

Parameters
points_esta list of line points (relative to the center of the field!)

Definition at line 154 of file field_drawer.cpp.

◆ set_own_pos()

void firevision::FieldDrawer::set_own_pos ( fawkes::field_pos_t  own_position)

Own position setter.

Sets the (calculated) own position on the field

Parameters
own_positionas calculated by the localization

Definition at line 103 of file field_drawer.cpp.

◆ set_own_pos_est()

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, ...)

Parameters
own_position_estimateas estimated

Definition at line 114 of file field_drawer.cpp.

Member Data Documentation

◆ _img_buffer

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().

◆ _img_height

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().

◆ _img_width

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().


The documentation for this class was generated from the following files: