Fawkes API  Fawkes Development Version
firevision::Bulb Class Reference

Bulb mirror lookup table. More...

#include <>>

Inheritance diagram for firevision::Bulb:

Classes

struct  bulb_file_header_t
 bulb file header. More...
 

Public Member Functions

 Bulb (const char *filename)
 Constructor. More...
 
 Bulb (const char *filename, const char *lut_id, bool destroy_on_delete=false)
 Constructor. More...
 
 Bulb (unsigned int width, unsigned int height)
 Constructor. More...
 
 Bulb (unsigned int width, unsigned int height, const char *lut_id, bool destroy_on_delete=false)
 Constructor. More...
 
 Bulb (const Bulb &bulb)
 Copy constructor. More...
 
virtual ~Bulb ()
 Destructor. More...
 
virtual void warp2unwarp (unsigned int warp_x, unsigned int warp_y, unsigned int *unwarp_x, unsigned int *unwarp_y)
 Transform warped to unwarped point. More...
 
virtual void unwarp2warp (unsigned int unwarp_x, unsigned int unwarp_y, unsigned int *warp_x, unsigned int *warp_y)
 Transform unwarped to warped point. More...
 
virtual const char * getName ()
 Get name of model. More...
 
virtual bool isValid ()
 Check if a valid LUT has been loaded. More...
 
virtual void setWorldPoint (unsigned int image_x, unsigned int image_y, float world_r, float world_phi)
 Set a world point mapping. More...
 
virtual fawkes::polar_coord_2d_t getWorldPointRelative (unsigned int image_x, unsigned int image_y) const
 Get relative coordinate based on image coordinates. More...
 
virtual fawkes::cart_coord_2d_t getWorldPointGlobal (unsigned int image_x, unsigned int image_y, float pose_x, float pose_y, float pose_ori) const
 Get global coordinate based on image coordinates. More...
 
virtual void reset ()
 Reset model. More...
 
virtual fawkes::upoint_t getCenter () const
 Get the image pixel that is the center of the omni-camera. More...
 
virtual void setCenter (unsigned int image_x, unsigned int image_y)
 Set center of omni-camera to given image pixel. More...
 
virtual void setOrientation (float angle)
 Set orientation of the omni-camera device. More...
 
virtual float getOrientation () const
 Get orientation of the omni-camera. More...
 
virtual bool isValidPoint (unsigned int image_x, unsigned int image_y) const
 Check if the given point is valid. More...
 
bool isNonZero (unsigned int image_x, unsigned int image_y) const
 Check if pixel maps to valid world point. More...
 
unsigned int numNonZero () const
 Get number of non-zero entries. More...
 
float getAngle (unsigned int image_x, unsigned int image_y) const
 Angle between direction to point and "to the right". More...
 
float getDistanceInImage (unsigned int image_p1_x, unsigned int image_p1_y, unsigned int image_p2_x, unsigned int image_p2_y)
 Euklidean distance between to image points. More...
 
float convertAngleI2W (float angle_in_image) const
 convertAngleI2W More...
 
void load (const char *filename)
 Load LUT from file. More...
 
void save (const char *filename)
 Save LUT from file. More...
 
const fawkes::polar_coord_2d_tget_lut () const
 Get the raw lookup table. More...
 
- Public Member Functions inherited from firevision::MirrorModel
virtual ~MirrorModel ()
 Virtual empty destructor. More...
 

Static Public Member Functions

static std::string composeFilename (const char *format)
 Compose a filename matching the given format. More...
 

Friends

class BulbGenerator
 

Detailed Description

Bulb mirror lookup table.

This mirror model is based on a LUT that will map image pixels to radial coordinates in relative radial coordinates.

Author
Tim Niemueller
Martin Heracles

Definition at line 38 of file bulb.h.

Constructor & Destructor Documentation

◆ Bulb() [1/5]

firevision::Bulb::Bulb ( const char *  filename)

Constructor.

Load bulb LUT from file.

Parameters
filenamefilename of bulb file to load.

Definition at line 62 of file bulb.cpp.

◆ Bulb() [2/5]

firevision::Bulb::Bulb ( const char *  filename,
const char *  lut_id,
bool  destroy_on_delete = false 
)

Constructor.

Load bulb LUT from file and expose LUT via shared memory.

Parameters
filenamefilename of bulb file to load.
lut_idLUT ID
destroy_on_deletedestroy LUT on delete
See also
SharedMemoryLookupTable

Definition at line 76 of file bulb.cpp.

◆ Bulb() [3/5]

firevision::Bulb::Bulb ( unsigned int  width,
unsigned int  height 
)

Constructor.

Create new empty bulb LUT.

Parameters
widthwidth of LUT
heightheight of LUT

Definition at line 121 of file bulb.cpp.

◆ Bulb() [4/5]

firevision::Bulb::Bulb ( unsigned int  width,
unsigned int  height,
const char *  lut_id,
bool  destroy_on_delete = false 
)

Constructor.

Create new empty bulb LUT and expose LUT via shared memory.

Parameters
widthwidth of LUT
heightheight of LUT
lut_idLUT ID
destroy_on_deletedestroy LUT on delete
See also
SharedMemoryLookupTable

Definition at line 97 of file bulb.cpp.

◆ Bulb() [5/5]

firevision::Bulb::Bulb ( const Bulb bulb)

Copy constructor.

Parameters
bulbbulb LUT to copy

Definition at line 141 of file bulb.cpp.

◆ ~Bulb()

firevision::Bulb::~Bulb ( )
virtual

Destructor.

Erases LUT memory.

Definition at line 194 of file bulb.cpp.

Member Function Documentation

◆ composeFilename()

string firevision::Bulb::composeFilename ( const char *  format)
static

Compose a filename matching the given format.

In the format h is replaced by the hostname.

Parameters
formatformat of file name
Returns
filename based on the given format

Definition at line 678 of file bulb.cpp.

◆ convertAngleI2W()

float firevision::Bulb::convertAngleI2W ( float  angle_in_image) const

convertAngleI2W

Returns
If you have a (ball-) direction in the omni-image, at which direction is the ball in the world, relative to the robot?
Parameters
angle_in_imageangle to be converted

Definition at line 621 of file bulb.cpp.

◆ get_lut()

const fawkes::polar_coord_2d_t * firevision::Bulb::get_lut ( ) const

Get the raw lookup table.

Returns a pointer to the raw lookup table buffer ordered in row-major mappings from pixels to polar coordinates.

Returns
raw lookup table

Definition at line 432 of file bulb.cpp.

◆ getAngle()

float firevision::Bulb::getAngle ( unsigned int  image_x,
unsigned int  image_y 
) const

Angle between direction to point and "to the right".

Parameters
image_xx coordinate in image
image_yy coordinate in image
Returns
angle between direction "to point (px, py)" and direction "to the right", with respect to center point. (Angle is in radians; clockwise is positive, counter-clockwise is negative.)

Definition at line 587 of file bulb.cpp.

◆ getCenter()

upoint_t firevision::Bulb::getCenter ( ) const
virtual

Get the image pixel that is the center of the omni-camera.

Returns
pixel coordinates of mirror center in image.

Implements firevision::MirrorModel.

Definition at line 486 of file bulb.cpp.

References fawkes::upoint_t::x, and fawkes::upoint_t::y.

◆ getDistanceInImage()

float firevision::Bulb::getDistanceInImage ( unsigned int  image_p1_x,
unsigned int  image_p1_y,
unsigned int  image_p2_x,
unsigned int  image_p2_y 
)

Euklidean distance between to image points.

Returns
the (euklidian) distance between two image points
Parameters
image_p1_xx coordinate in image of point 1
image_p1_yy coordinate in image of point 1
image_p2_xx coordinate in image of point 2
image_p2_yy coordinate in image of point 2

Definition at line 603 of file bulb.cpp.

◆ getName()

const char * firevision::Bulb::getName ( )
virtual

Get name of model.

Returns
name of model

Implements firevision::MirrorModel.

Definition at line 348 of file bulb.cpp.

◆ getOrientation()

float firevision::Bulb::getOrientation ( ) const
virtual

Get orientation of the omni-camera.

Returns
angle to forward direction.

Implements firevision::MirrorModel.

Definition at line 530 of file bulb.cpp.

◆ getWorldPointGlobal()

cart_coord_2d_t firevision::Bulb::getWorldPointGlobal ( unsigned int  image_x,
unsigned int  image_y,
float  pose_x,
float  pose_y,
float  pose_ori 
) const
virtual

Get global coordinate based on image coordinates.

Parameters
image_xx coordinate in image in pixels
image_yy coordinate in image in pixels
pose_xrobot pose global x coordinate
pose_yrobot pose global y coordinate
pose_orirobot pose global orientation
Returns
cartesian coordinates relative to the base system in metric global system

Implements firevision::MirrorModel.

Definition at line 383 of file bulb.cpp.

References fawkes::polar_coord_2d_t::phi, fawkes::polar_coord_2d_t::r, fawkes::cart_coord_2d_struct::x, and fawkes::cart_coord_2d_struct::y.

◆ getWorldPointRelative()

polar_coord_2d_t firevision::Bulb::getWorldPointRelative ( unsigned int  image_x,
unsigned int  image_y 
) const
virtual

Get relative coordinate based on image coordinates.

Parameters
image_xx coordinate in image in pixels
image_yy coordinate in image in pixels
Returns
polar coordinates relative to the base system in metric local system

Implements firevision::MirrorModel.

Definition at line 364 of file bulb.cpp.

References fawkes::polar_coord_2d_t::phi, and fawkes::polar_coord_2d_t::r.

Referenced by firevision::MirrorCalibTool::eval().

◆ isNonZero()

bool firevision::Bulb::isNonZero ( unsigned int  image_x,
unsigned int  image_y 
) const

Check if pixel maps to valid world point.

Parameters
image_xx coordinate in image
image_yy coordinate in image
Returns
true, iff image pixel (imagePointX, imagePointY) is not zero (checks distances "r" only, not the angles "phi") i.e. if it maps to a real-world position

Definition at line 551 of file bulb.cpp.

◆ isValid()

bool firevision::Bulb::isValid ( )
virtual

Check if a valid LUT has been loaded.

Returns
true if a valid LUT has been loaded and can be used, false otherwise

Definition at line 357 of file bulb.cpp.

◆ isValidPoint()

bool firevision::Bulb::isValidPoint ( unsigned int  image_x,
unsigned int  image_y 
) const
virtual

Check if the given point is valid.

Parameters
image_xx coordinate of queried pixel in image
image_yy coordinate of queried pixel in image
Returns
true, if pixel is valid, false otherwise.

Implements firevision::MirrorModel.

Definition at line 537 of file bulb.cpp.

◆ load()

◆ numNonZero()

unsigned int firevision::Bulb::numNonZero ( ) const

Get number of non-zero entries.

Returns
number of non-zero entries.

Definition at line 565 of file bulb.cpp.

◆ reset()

void firevision::Bulb::reset ( )
virtual

Reset model.

This will reset mirror model.

Implements firevision::MirrorModel.

Definition at line 479 of file bulb.cpp.

◆ save()

◆ setCenter()

void firevision::Bulb::setCenter ( unsigned int  image_x,
unsigned int  image_y 
)
virtual

Set center of omni-camera to given image pixel.

Parameters
image_xx coordinate in image in pixels
image_yy coordinate in image in pixels

Implements firevision::MirrorModel.

Definition at line 498 of file bulb.cpp.

Referenced by firevision::MirrorCalibTool::next_step().

◆ setOrientation()

void firevision::Bulb::setOrientation ( float  angle)
virtual

Set orientation of the omni-camera device.

Parameters
angleangle to the forward direction.

Implements firevision::MirrorModel.

Definition at line 516 of file bulb.cpp.

Referenced by firevision::MirrorCalibTool::next_step().

◆ setWorldPoint()

void firevision::Bulb::setWorldPoint ( unsigned int  image_x,
unsigned int  image_y,
float  world_r,
float  world_phi 
)
virtual

Set a world point mapping.

This modifies the mapping in the LUT. An exception is thrown if the coordinates are out of range or the distance is zero.

Parameters
image_xx coordinate of point in image in pixels
image_yy coordinate of point in image in pixels
world_rdistance to real object from camera center in meters
world_phiangle to real object

Definition at line 447 of file bulb.cpp.

Referenced by firevision::MirrorCalibTool::next_step().

◆ unwarp2warp()

void firevision::Bulb::unwarp2warp ( unsigned int  unwarp_x,
unsigned int  unwarp_y,
unsigned int *  warp_x,
unsigned int *  warp_y 
)
virtual

Transform unwarped to warped point.

Given a point in the unwarped image it returns the coordinates of the corresponding pixel in the warped image Useful for: You want to generate the unwarped image and ask the model for every point of the unwarped image which warped pixel to copy

Parameters
unwarp_xunwarped x coordinate
unwarp_yunwarped y coordinate
warp_xcontains the warped x coordinate upon return
warp_ycontains the warped y coordinate upon return

Implements firevision::MirrorModel.

Definition at line 340 of file bulb.cpp.

◆ warp2unwarp()

void firevision::Bulb::warp2unwarp ( unsigned int  warp_x,
unsigned int  warp_y,
unsigned int *  unwarp_x,
unsigned int *  unwarp_y 
)
virtual

Transform warped to unwarped point.

Given a point in the warped image it returns the coordinates of the corresponding pixel in the unwarped image Useful for: You found the ball center in the image and want to get the position this pixel would have in an unwarped image

Parameters
warp_xwarped x coordinate
warp_ywarped y coordinate
unwarp_xcontains unwarped x coordinate upon return
unwarp_ycontains unwarped y coordinate upon return

Implements firevision::MirrorModel.

Definition at line 323 of file bulb.cpp.


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