AURobotServers  4
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
UCamPar Class Reference

#include <ucampar.h>

Inheritance diagram for UCamPar:
Inheritance graph

Public Member Functions

UMatrix4 getCtoPRob ()
 
URPos getCtoPRob (UPosition pos3D)
 
float getFocalLength ()
 
float getHx ()
 
float getHy ()
 
UMatrix4getItoP ()
 
float getK1 ()
 
float getK2 ()
 
float getPixelSize ()
 
UPosition getPtoCRob (int x, int y, float distance)
 
UPosition getPtoCRob (float x, float y, float distance)
 
bool getRadialD2U (float xu, float yu, float *xd, float *yd)
 
bool getRadialU2D (float xu, float yu, float *xd, float *yd)
 
void invalidate ()
 
bool isValid ()
 
void print (const char *prestring)
 
bool savePar (Uconfig *ini, const char *key)
 
bool setCameraParameters (float hx, float hy, float k1, float k2, float focalLng, float pixSizeFactor)
 
bool setCameraParameters (UCamPar *source)
 
bool setCameraParameters (Uconfig *ini, const char *key)
 
bool setPixelSize (float pixSize)
 
int snprint (const char *preString, char *dest, const int maxLength)
 
 UCamPar ()
 
 ~UCamPar ()
 

Public Attributes

bool parValid
 

Protected Member Functions

bool setMatrices (void)
 

Protected Attributes

float focalLength
 
float headX
 
float headY
 
UMatrix4 mb
 
UMatrix4 mCtoPRob
 
UMatrix4 mItoP
 
UMatrix4 mP
 
float radialK1
 
float radialK2
 
float resFactor
 

Detailed Description

The class holds camera parameters and functions related to the inner orientation of a camera. This includes radial error and fical length. Further is matrices for projecting from 3D to image coordinates and conversion to image coordinates included.

Author
Christian Andersen

Constructor & Destructor Documentation

UCamPar::UCamPar ( )

Constructor

References focalLength, headX, headY, parValid, radialK1, radialK2, and resFactor.

UCamPar::~UCamPar ( )

Destructor

Member Function Documentation

UMatrix4 UCamPar::getCtoPRob ( )

Get conversion matrix from a 3d camera coordinate to image pixel position, where the camera coordinates are oriented as robot coordinates (z is up).

References mItoP, and UMatrix::setRow().

Referenced by UImgPolyProj::getFloorToPix(), UImgProj::getFloorToPix(), getItoP(), UCamMounted::getMtoPix(), setMatrices(), and testCamPar().

URPos UCamPar::getCtoPRob ( UPosition  pos3D)

Convert a 3D position to pixel position. 3D position is in camera coordinates using robot coordinate system (x forward, y left z up).

References absd(), focalLength, headX, headY, resFactor, URPos::x, UPosition::x, URPos::y, UPosition::y, and UPosition::z.

float UCamPar::getFocalLength ( )
inline
float UCamPar::getHx ( )
inline
float UCamPar::getHy ( )
inline
UMatrix4* UCamPar::getItoP ( )
inline
float UCamPar::getK1 ( )
inline
float UCamPar::getK2 ( )
inline
float UCamPar::getPixelSize ( )
inline

Get size of one pixel relative to max resolution. Max resolution is normally 640x480, so pixSize of 4 corresponds to 160x120 pixels.

References resFactor, and setPixelSize().

Referenced by UCalibrationMarkSets::doEstimateCameraParametersBinary(), UCalibrationMarkSet::evaluateChartPosRot(), UCamRad::removeRadialError(), UCalibrationMarkSet::saveMarksToFile(), UCamRad::saveRadialCorrectionMatrix(), setCameraParameters(), and UCamRad::setRadialErrorMatrix().

UPosition UCamPar::getPtoCRob ( int  x,
int  y,
float  distance 
)

Convert pixel position to 3D position with this distance (x) coordinate 3D position is in robot coordinates system (x forward, y left and z up), by oriented as camera.

References focalLength, headX, headY, resFactor, UPosition::x, UPosition::y, and UPosition::z.

Referenced by getItoP(), UImgPolyProj::getPixToRobFloor(), UImgProj::getPixToRobFloor(), UClientFuncLaserGui::getPixToRobFloor(), UNavPaint::paintCams(), and testCamPar().

UPosition UCamPar::getPtoCRob ( float  x,
float  y,
float  distance 
)

Convert pixel position to 3D position with this distance (x) coordinate 3D position is in robot coordinates system (x forward, y left and z up), by oriented as camera.

References focalLength, headX, headY, resFactor, UPosition::x, UPosition::y, and UPosition::z.

bool UCamPar::getRadialD2U ( float  xu,
float  yu,
float *  xd,
float *  yd 
)

From an image position in a distorted {xd,yd} image to a pixel position in the undistorted image {xu,yu} with these camera parameters. Res factor is size of pixels relative to resolution where camera parameters are valid.

  • typical 1, 2, 4 for (640x480, 320x240, 160x120)

References headX, headY, radialK1, radialK2, and resFactor.

Referenced by UImgPolyProj::doProjectPolygonToFloorReal(), UImgProj::doProjectPolygonToFloorReal(), getRadialU2D(), isValid(), and UCalibrationMarkSet::setBarcodePosRowSet().

bool UCamPar::getRadialU2D ( float  xu,
float  yu,
float *  xd,
float *  yd 
)

From an undistorted pixel position {xu,yu} to the cooresponding distorted the pixel value {xd, yd}. Res factor is size of pixels relative to resolution where camera parameters are valid.

  • typical 1, 2, 4 for (640x480, 320x240, 160x120)

References absf(), getRadialD2U(), headX, headY, and resFactor.

Referenced by UCalibrationMarkSet::getErrorInPixels(), UCalibrationMarkSet::geterrorInPixels(), UCamMounted::getMtoPix(), UCamRad::getRadialU2DOffset(), and isValid().

void UCamPar::invalidate ( )
inline

Invalidate information

References parValid.

Referenced by UImgPolyProj::UImgPolyProj(), and UImgProj::UImgProj().

bool UCamPar::isValid ( )
inline
void UCamPar::print ( const char *  prestring)

Print most of values to console (debug)

References bool2str(), focalLength, headX, headY, mb, mCtoPRob, mItoP, mP, parValid, UMatrix::print(), radialK1, radialK2, and resFactor.

Referenced by getItoP(), and testCamPar().

bool UCamPar::savePar ( Uconfig ini,
const char *  key 
)

Save camera parameters to this configuration file under this key name

References Uconfig::doublePut(), focalLength, headX, headY, radialK1, and radialK2.

Referenced by getItoP().

bool UCamPar::setCameraParameters ( float  hx,
float  hy,
float  k1,
float  k2,
float  focalLng,
float  pixSizeFactor 
)

Set all camera parameters in one call hx, hy, k1, k2, focal-length are all as found for a 640x480 image. pixelSize is for actual image releative to 640x480. ix 320x240 has pixel size 2. Returns true if set.

References focalLength, headX, headY, parValid, radialK1, radialK2, resFactor, and setMatrices().

Referenced by getItoP(), UClientFuncLaserGui::getPixToRobFloor(), isValid(), setCameraParameters(), UCamRad::setCameraParameters(), testCamPar(), and UCamRad::updateLensParams().

bool UCamPar::setCameraParameters ( UCamPar source)

Copy parameters from other set of parameters.

References getFocalLength(), getHx(), getHy(), getK1(), getK2(), getPixelSize(), and setCameraParameters().

bool UCamPar::setCameraParameters ( Uconfig ini,
const char *  key 
)

Set camera parameters from 'ini' configuration file under this 'key'.

References Uconfig::doubleGet(), focalLength, headX, headY, radialK1, radialK2, resFactor, and setCameraParameters().

bool UCamPar::setMatrices ( void  )
protected

Set conversion matrices after change in parameters.

References focalLength, getCtoPRob(), headX, headY, UMatrix::init(), mb, mCtoPRob, mItoP, mP, resFactor, and UMatrix::setRC().

Referenced by getItoP(), UClientCamData::handleCamGet(), setCameraParameters(), and setPixelSize().

bool UCamPar::setPixelSize ( float  pixSize)

Set size of one pixel relative to max resolution. Max resolution is normally 640x480, so pixSize of 4 corresponds to 160x120 pixels.

  • NB! depricatede - set to 1 always

References resFactor, and setMatrices().

Referenced by UFuncImgPoly::findAreaFromSeedRGB(), UFunctionCamPath::findPath(), getPixelSize(), UCamRad::imageSizeChanged(), UComCamSml::setCamDevice(), UCamRad::setRadialErrorMatrix(), and testCamPar().

int UCamPar::snprint ( const char *  preString,
char *  dest,
const int  maxLength 
)

Print camera parameters to the destination string with 'preString' in front of test. (format suited for console display). 'maxLength' is length of 'dest' buffer. Returns length of produced string.

References focalLength, headX, headY, radialK1, and radialK2.

Referenced by getItoP(), and UClientCamData::snprint().

Member Data Documentation

float UCamPar::focalLength
protected
float UCamPar::headX
protected
float UCamPar::headY
protected
UMatrix4 UCamPar::mb
protected

Image coordinate (2d y up, 0,0 in center) to pixel coordinate (2d y down, 0,0 top left)

Referenced by print(), and setMatrices().

UMatrix4 UCamPar::mCtoPRob
protected

Matrix to convert camera 3D oordinate to pixel position when the 3D position is in robot coordinates (x forward, y left and z up).

Referenced by print(), and setMatrices().

UMatrix4 UCamPar::mItoP
protected

Pixel to Image coordinate matrix Image 3d (z is back) coordinate to pixel (y down) matrix

Referenced by getCtoPRob(), getItoP(), print(), and setMatrices().

UMatrix4 UCamPar::mP
protected

3D (y back) to 2D (0,0 in center, y up)

Referenced by print(), and setMatrices().

bool UCamPar::parValid
float UCamPar::radialK1
protected

Radial error correction parameters. K1 is proportional to r^3 and K2 to r^5.

Referenced by UCamParEst::adjustParameters(), UCamParEst::adjustParameters35(), getK1(), getRadialD2U(), UClientCamData::handleCamGet(), print(), savePar(), setCameraParameters(), snprint(), and UCamPar().

float UCamPar::radialK2
protected
float UCamPar::resFactor
protected

Factor from actual coordinates to 640x480. i.e resFactor 2 corresponds to 320x240 image. resFactor is the same as pixelSize (relative to 640x480).

Referenced by getCtoPRob(), getFocalLength(), getHx(), getHy(), getPixelSize(), getPtoCRob(), getRadialD2U(), getRadialU2D(), UClientCamData::handleCamGet(), print(), setCameraParameters(), setMatrices(), setPixelSize(), and UCamPar().


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