AURobotServers
4
|
#include <ucampar.h>
Public Member Functions | |
UMatrix4 | getCtoPRob () |
URPos | getCtoPRob (UPosition pos3D) |
float | getFocalLength () |
float | getHx () |
float | getHy () |
UMatrix4 * | getItoP () |
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 |
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.
UCamPar::UCamPar | ( | ) |
UCamPar::~UCamPar | ( | ) |
Destructor
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().
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.
|
inline |
Get focus length in pixels in actual resolution
References focalLength, and resFactor.
Referenced by UFuncBallKL::calculateBallPosition(), UFuncBall::calculateBallPosition(), UFuncBall_improved::calculateBallPosition(), UCalibrationMarkSet::evaluatePosRot(), UCalibrate::findGmk(), UFuncCropRow::findPlants(), UFuncStraightLine::findWoldPoints(), UCalibrationMarkSet::geterrorInPixels(), UFuncKinect::GetXYZCoordinates(), UResCamIfCam::gotNewData(), UFuncCropRow::handleCommand(), UCamRad::lensParChanged(), UImageLog::logImage(), UFuncKinect::makeObj3Dcloud(), UFuncPiCam::run(), UCalibrationMarkSet::saveMarksToFile(), UCalibrationMarkSet::setBarcodePosRowSet(), UComCamSml::setCamDevice(), setCameraParameters(), UCamParEst::setEstMatrix(), UCamParEst::setEstMatrix35(), UComCamSml::setFromCam(), and UCamRad::updateLensParams().
|
inline |
Get image center point X in actual resolution
References headX, and resFactor.
Referenced by UFuncBallKL::calculateBallPosition(), UFuncBall::calculateBallPosition(), UFuncBall_improved::calculateBallPosition(), UCalibrationMarkSet::evaluatePosRot(), UFuncCropRow::findPlants(), UCalibrationMarkSet::geterrorInPixels(), UFuncCropRow::handleCommand(), UCamRad::lensParChanged(), UCamRad::removeRadialErrorOnePlane(), UCamRad::removeRadialErrorPixels(), UFuncPiCam::run(), UCalibrationMarkSet::saveMarksToFile(), UCamRad::saveRadialCorrectionMatrix(), UCalibrationMarkSet::setBarcodePosRowSet(), UComCamSml::setCamDevice(), setCameraParameters(), UCamParEst::setEstMatrix(), UCamParEst::setEstMatrix35(), UComCamSml::setFromCam(), UCamRad::setRadialErrorMatrix(), and UCamRad::updateLensParams().
|
inline |
Get image center point Y in actual resolution
References headY, and resFactor.
Referenced by UFuncBallKL::calculateBallPosition(), UFuncBall::calculateBallPosition(), UFuncBall_improved::calculateBallPosition(), UCalibrationMarkSet::evaluatePosRot(), UFuncCropRow::findPlants(), UCalibrationMarkSet::geterrorInPixels(), UFuncCropRow::handleCommand(), UCamRad::lensParChanged(), UCamRad::removeRadialErrorOnePlane(), UCamRad::removeRadialErrorPixels(), UFuncPiCam::run(), UCalibrationMarkSet::saveMarksToFile(), UCamRad::saveRadialCorrectionMatrix(), UCalibrationMarkSet::setBarcodePosRowSet(), UComCamSml::setCamDevice(), setCameraParameters(), UCamParEst::setEstMatrix(), UCamParEst::setEstMatrix35(), UComCamSml::setFromCam(), UCamRad::setRadialErrorMatrix(), and UCamRad::updateLensParams().
|
inline |
Get matrix for conversion from image to pixel coordinates.
References getCtoPRob(), getPtoCRob(), mItoP, print(), savePar(), setCameraParameters(), setMatrices(), and snprint().
Referenced by UCalibrationMarkSet::getErrorInPixels(), UCalibrationMarkSet::geterrorInPixels(), and UCalibrationComponents::PaintChartInImage().
|
inline |
Get radial distorsion value proportional to radius from center point in 3rd power. Value relates to max camera resolution.
References radialK1.
Referenced by UCalibrationMarkSet::geterrorInPixels(), UCamRad::lensParChanged(), UFuncPiCam::run(), UCalibrationMarkSet::saveMarksToFile(), UCamRad::saveRadialCorrectionMatrix(), UComCamSml::setCamDevice(), setCameraParameters(), UCamParEst::setEstMatrix(), UCamParEst::setEstMatrix35(), UComCamSml::setFromCam(), and UCamRad::updateLensParams().
|
inline |
Get radial distorsion value proportional to radius from center point in 5rd power. Value relates to max camera resolution.
References radialK2.
Referenced by UCalibrationMarkSet::geterrorInPixels(), UCamRad::lensParChanged(), UFuncPiCam::run(), UCalibrationMarkSet::saveMarksToFile(), UCamRad::saveRadialCorrectionMatrix(), UComCamSml::setCamDevice(), setCameraParameters(), UCamParEst::setEstMatrix(), UCamParEst::setEstMatrix35(), UComCamSml::setFromCam(), and UCamRad::updateLensParams().
|
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.
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.
References absf(), getRadialD2U(), headX, headY, and resFactor.
Referenced by UCalibrationMarkSet::getErrorInPixels(), UCalibrationMarkSet::geterrorInPixels(), UCamMounted::getMtoPix(), UCamRad::getRadialU2DOffset(), and isValid().
|
inline |
Invalidate information
References parValid.
Referenced by UImgPolyProj::UImgPolyProj(), and UImgProj::UImgProj().
|
inline |
Is parameters valid
References getRadialD2U(), getRadialU2D(), parValid, and setCameraParameters().
Referenced by UImgPolyProj::doProject(), UImgProj::doProject(), UCamRad::removeRadialError(), and UComCamSml::setFromCam().
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().
|
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.
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().
|
protected |
Focal length for focus at infinity.
Referenced by UCamParEst::adjustParameters(), UCamParEst::adjustParameters35(), getCtoPRob(), getFocalLength(), getPtoCRob(), UClientCamData::handleCamGet(), print(), savePar(), setCameraParameters(), setMatrices(), snprint(), UCamPar(), and UClientCamData::UClientCamData().
|
protected |
Center point (optical)
Referenced by UCamParEst::adjustParameters(), UCamParEst::adjustParameters35(), getCtoPRob(), getHx(), getPtoCRob(), getRadialD2U(), getRadialU2D(), UClientCamData::handleCamGet(), print(), savePar(), setCameraParameters(), setMatrices(), snprint(), and UCamPar().
|
protected |
|
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().
|
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().
|
protected |
Pixel to Image coordinate matrix Image 3d (z is back) coordinate to pixel (y down) matrix
Referenced by getCtoPRob(), getItoP(), print(), and setMatrices().
|
protected |
3D (y back) to 2D (0,0 in center, y up)
Referenced by print(), and setMatrices().
bool UCamPar::parValid |
Is camera parameters valid
Referenced by UClientCamData::handleCamGet(), invalidate(), isValid(), UNavPaint::paintCams(), print(), setCameraParameters(), and UCamPar().
|
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().
|
protected |
|
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().