AURobotServers  4
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
UCalibrationMarkSet Class Reference

#include <ucalibrate.h>

Public Member Functions

void clear ()
 
bool evaluateChartPosRot (UPosition *initialChartPos, URotation *initialChartRot, double stopLimDist, double stopLimRot, UCamPar *camp, bool adjRadial, bool makeLogfile)
 
bool evaluateChartPosRot (UPosition *initialChartPos, URotation *initialChartRot, double stopLimDist, double stopLimRot, UCamPar *camp, bool adjRadial, FILE *f)
 
bool evaluatePosRot (const char *params, UCamPar *camp, UPosition *oldPos, URotation *oldRot, UPosition *chartP, bool makeLogfile)
 
double getErrDist ()
 
double getErrorInPixels (UCalibrationMark *thisMark, float *cx, float *cy, UCamPar *camp, bool radErrAdj)
 
double geterrorInPixels (UPosition *chartPos, URotation *chartRot, UPosition *camPos, URotation *camRot, int markDist, UCamPar *camp, double *variance, bool adjRadial)
 
double getErrPix ()
 
double getErrRot ()
 
double getStopLimitAngle ()
 
double getStopLimitDistance ()
 
bool info (int cam)
 
bool saveMarksToFile (const char filename[], bool radialErrorRemoved, UCamPar *cam, int imageNumber)
 
bool setFramePositions (int fw, float stride, char order[], char fwd[], float AX[], float AY[], float BX[], float BY[], float CX[], float CY[], float DX[], float DY[])
 
void setStopLimit (double distance, double angle)
 
void toLog (const char *info, int significance, UTime *timestamp=NULL)
 
 UCalibrationMarkSet ()
 

Public Attributes

unsigned long barcode
 
int barcodeSetNum
 
bool barcodeValid
 
bool calValid
 
bool implemented
 
UCalibrationMark mark [MAX_FRAME_POSITIONS]
 
int markCnt
 
float pixSize
 
UPosition posBarcode
 
UPosition posCal
 
URotation rotBarcode
 
URotation rotCal
 
bool valid
 

Private Member Functions

bool setBarcodePosRowSet (UMatrixBig *B, UMatrixBig *K, int r, UCamPar *camp, bool adjRadial, UPosition *chartPos0, URotation *chartRot0, UCalibrationMark *pkt)
 
bool setCameraPosRowSet (const char *params, UMatrixBig *B, UMatrixBig *K, int r, double hx, double hy, double c, UPosition *camPos0, URotation *camRot0, UCalibrationMark *pkt, UPosition *chartPos)
 

Private Attributes

double errDist
 
double errDistStopLimit
 
double errEpix
 
double errRot
 
double errRotStopLimit
 
int loops
 

Detailed Description

Class to hold positions of all frame corners in a barcode frame. These corners are used as calibration marks. Calibration marks are used to:

Constructor & Destructor Documentation

UCalibrationMarkSet::UCalibrationMarkSet ( )

Constructor

Member Function Documentation

void UCalibrationMarkSet::clear ( void  )

Set all data as invalid.

Referenced by UCalibrationMarkSets::getNewSet().

bool UCalibrationMarkSet::evaluateChartPosRot ( UPosition initialChartPos,
URotation initialChartRot,
double  stopLimDist,
double  stopLimRot,
UCamPar camp,
bool  adjRadial,
bool  makeLogfile 
)

Estimats a barcode position and rotation relative to the camera. If the initial position and rotation is known this is used as the initial vale. If no initial or expected position is given (set to NULL), then a serach will be performed in all 4 quadrants (+/- Phi and +/- Omega) to ensure that the real optimum is found. The stop limit in distance and rotation is the 3D change in position in last iteration, if both these are below the stop limits then the parameter estimation stops.
If 'adjRadial' then pixel positions is assumed distorted and is adjusted acccording to value of K1, K2 and head point found in camera parameters 'camp'.
The actual work is done in 'evaluateChartPosRot(-,-,-,-,logfile)'

References absd(), dataPath, UTime::GetHour(), UTime::GetJustSec(), UTime::GetMin(), UCamPar::getPixelSize(), URotation::Kappa, mind(), UTime::Now(), URotation::Omega, URotation::Phi, UCalibrationComponents::toLog(), UPosition::x, UPosition::y, and UPosition::z.

Referenced by UCalibrationMarkSets::doEstimateCameraParameters(), UCalibrationMarkSets::evaluatePixError(), and UCalibrate::findBarcodeChartPosition().

bool UCalibrationMarkSet::evaluateChartPosRot ( UPosition initialChartPos,
URotation initialChartRot,
double  stopLimDist,
double  stopLimRot,
UCamPar camp,
bool  adjRadial,
FILE *  f 
)
bool UCalibrationMarkSet::evaluatePosRot ( const char *  params,
UCamPar camp,
UPosition oldPos,
URotation oldRot,
UPosition chartP,
bool  makeLogfile 
)

Try use the calibration marks to calculate new position and rotation parameters.
Takes a parameter string of the form "xyzOPK" for all 6 parameters or a subset, e.g. "xy" to evaluate an estimate for x and y only. The 'chartP' must be the known position of the calibration chart. The chart must be vertical and facing the camera. the iteration continues for up to 50 loops or until distance error is less than 'errStopLimit'.
Returns 0 if seccessfull, and the new parameters in posCal and rotCal (and calValid will be true, and loops be the number of iterations to find solution).

References UPosition::copy(), dataPath, UPosition::dist(), UMatrix::get(), UCamPar::getFocalLength(), UCamPar::getHx(), UCamPar::getHy(), URotation::Kappa, URotation::Omega, URotation::Phi, URotation::set(), UMatrix::setSize(), UMatrix::solve(), UPosition::sprint(), URotation::sprint(), UPosition::subtract(), URotation::subtract(), UCalibrationComponents::toLog(), UPosition::x, UPosition::y, and UPosition::z.

Referenced by UCalibrate::findCameraPosition().

double UCalibrationMarkSet::getErrDist ( )
inline

Get finishing error distance change for x,y,z

double UCalibrationMarkSet::getErrorInPixels ( UCalibrationMark thisMark,
float *  cx,
float *  cy,
UCamPar camp,
bool  radErrAdj 
)

Get distance from expected pixel position to actual pixel position.
Guidemark corner is at (rx,ry)[meter] in this mark, and is converted to pixel coordinates using pos- and rotBarcode and camera info to get to pixel coordinates. From this difference is calculated.
NB! expects that pos- and rotBarcode is in camera coordinates.
Returns distance in pixels and calculated position in (cx,cy).

References UMatrix::err, UMatrix::expand(), UMatrix::get(), UCamPar::getItoP(), UCamPar::getRadialU2D(), UCalibrationMark::ix, UCalibrationMark::iy, UCalibrationMark::rx, UCalibrationMark::ry, and UMatrix::set().

Referenced by UCalibrate::findBarcodeChartPosition().

double UCalibrationMarkSet::geterrorInPixels ( UPosition chartPos,
URotation chartRot,
UPosition camPos,
URotation camRot,
int  markDist,
UCamPar camp,
double *  variance,
bool  adjRadial 
)

Calculate average pixel position error by transferring real chart position to image pixel position using the values in the markSet and the transformations in the following values, i.e.: Xpix = b * P * Pcam * Ocam * Kcam * Tcam * Tbar^-1 * Pbar' * Obar' * Kbar' * Xbar.
If 'markDist' is 1, then all points are used else only [0, markDist, ... n* markDist], for n = 1,2,3... until no more marks. b and P is taken from cam->mb and cam->mP as mItoP.
if 'adjRadial' then radial correction is applied to pixel coordinates.
Returns -1.0 if error.

References URotation::asMatrix4x4CtoW(), URotation::asMatrix4x4WtoC(), UMatrix::err, UMatrix::expand(), UMatrix::get(), UCamPar::getFocalLength(), UCamPar::getHx(), UCamPar::getHy(), UCamPar::getItoP(), UCamPar::getK1(), UCamPar::getK2(), UCamPar::getRadialU2D(), URotation::Kappa, URotation::Omega, URotation::Phi, UMatrix::set(), UMatrix::snprint(), sqr(), UPosition::x, UPosition::y, and UPosition::z.

Referenced by UCalibrationMarkSets::doEstimateCameraParameters(), and UCalibrationMarkSets::evaluatePixError().

double UCalibrationMarkSet::getErrPix ( )
inline

Get finishing error in pixels (absolute)

double UCalibrationMarkSet::getErrRot ( )
inline

Get finishing error angle change - combination of omega, phi and kappa

double UCalibrationMarkSet::getStopLimitAngle ( )
inline

Get current error angle that stops iteration (in connection with distance stop limit).

double UCalibrationMarkSet::getStopLimitDistance ( )
inline

Get current error distance that stops iteration (in connection with angle stop limit).

bool UCalibrationMarkSet::info ( int  cam)

Show calibration status as info.

References UCalibrationComponents::toLog().

Referenced by UCalibrate::ShowStatus().

bool UCalibrationMarkSet::saveMarksToFile ( const char  filename[],
bool  radialErrorRemoved,
UCamPar cam,
int  imageNumber 
)

Save mark positions to file If no filename is provided (is NULL) then a name is constructed 'image999calib.m' on data path with 999 beeing the provided image number.

References dataPath, UCamPar::getFocalLength(), UCamPar::getHx(), UCamPar::getHy(), UCamPar::getK1(), UCamPar::getK2(), UCamPar::getPixelSize(), imagePath, and UCalibrationComponents::toLog().

bool UCalibrationMarkSet::setBarcodePosRowSet ( UMatrixBig B,
UMatrixBig K,
int  r,
UCamPar camp,
bool  adjRadial,
UPosition chartPos0,
URotation chartRot0,
UCalibrationMark pkt 
)
private

Set values in B matrix and K vector before least square calculation for rows r and r+1 for the parameters mentioned in params from:
camera constants headpoint hx and hy and focus length c,
initial estimate of barchart position and rotation (chartPos0 and chartRot0),
one calibration mark with object and pixel position (pkt),
Returns true if focus length is > 0.

References UCamPar::getFocalLength(), UCamPar::getHx(), UCamPar::getHy(), UCamPar::getRadialD2U(), UCalibrationMark::ix, UCalibrationMark::iy, URotation::Kappa, UMatrix::maxSize(), URotation::Omega, URotation::Phi, UCalibrationMark::rx, UCalibrationMark::ry, UMatrix::setRC(), UPosition::x, UPosition::y, and UPosition::z.

bool UCalibrationMarkSet::setCameraPosRowSet ( const char *  params,
UMatrixBig B,
UMatrixBig K,
int  r,
double  hx,
double  hy,
double  c,
UPosition camPos0,
URotation camRot0,
UCalibrationMark pkt,
UPosition chartPos 
)
private

Set values in B matrix and K vector before least square calculation for rows r and r+1 for the parameters mentioned in params from:
camera constants headpoint hx and hy and focus length c,
initial estimate of camera position and rotation (camPos0 and camRot0),
one calibration mark with object and pixel position (pkt),
The base position of the chart, NB chart must be perpendicular to robot main Z axis e.g. parallel to world Y and X axis.
Returns true if focus length is > 0.

References UCalibrationMark::ix, UCalibrationMark::iy, URotation::Kappa, UMatrix::maxSize(), URotation::Omega, URotation::Phi, UCalibrationMark::rx, UCalibrationMark::ry, UMatrix::setRC(), UPosition::x, UPosition::y, and UPosition::z.

bool UCalibrationMarkSet::setFramePositions ( int  fw,
float  stride,
char  order[],
char  fwd[],
float  AX[],
float  AY[],
float  BX[],
float  BY[],
float  CX[],
float  CY[],
float  DX[],
float  DY[] 
)

Set position of each frame position in a fw x fw squared frame. The side size is 'stride' meter. and an array of X and Y positions are provided as parameter for side A, B, C, D. The side order is in 'order[]'. if the corresponding entry in 'fwd[]' is 't' (true) array element [0] is the first in clockwise direction; if false, then element [fw] is the first.

References MAX_FRAME_POSITIONS.

Referenced by UCalibrationComponents::doMakeCodeGrid().

void UCalibrationMarkSet::setStopLimit ( double  distance,
double  angle 
)
inline

Set evaluation stop limits in distance and angle. Iteration stops if error change between two iterations is below thise limits.

Referenced by UCalibrate::findCameraPosition().

void UCalibrationMarkSet::toLog ( const char *  info,
int  significance,
UTime timestamp = NULL 
)
inline

Save this message in logfile if significance is less than logLevel. Print also to console (debug feature) if verbose messages. Timestamp is optional, if not used, then Now() is used in logfile.

References toLogGmk().

Member Data Documentation

unsigned long UCalibrationMarkSet::barcode

Solve a set of equations by least square adjustment. B * R = K, where R is the unknown.
Returns true if solved barcode number or image number

Referenced by UCalibrate::findBarcodeChartPosition().

int UCalibrationMarkSet::barcodeSetNum

number of dataset for this barcode chart

bool UCalibrationMarkSet::barcodeValid

is barcode chart position valid

Referenced by UCalibrate::findBarcodeChartPosition(), and UCalibrationMarkSets::saveNewSet().

bool UCalibrationMarkSet::calValid
double UCalibrationMarkSet::errDist
private

end error in position (m)

double UCalibrationMarkSet::errDistStopLimit
private

Max error limit, when estimation position error. When estimation error is less, then stop iterations. (in meters)

double UCalibrationMarkSet::errEpix
private

remaining average error distance in pixels

double UCalibrationMarkSet::errRot
private

end error in rotation (radians)

double UCalibrationMarkSet::errRotStopLimit
private

Max error limit, when estimation rotation error. When estimation error is less, then stop iterations. (in radians)

bool UCalibrationMarkSet::implemented

is results implemented to camera

int UCalibrationMarkSet::loops
private

number of iteration loops

UCalibrationMark UCalibrationMarkSet::mark[MAX_FRAME_POSITIONS]
int UCalibrationMarkSet::markCnt
float UCalibrationMarkSet::pixSize
UPosition UCalibrationMarkSet::posBarcode
UPosition UCalibrationMarkSet::posCal

calibrated camera position

Referenced by UCalibrate::findBarcodeChartPosition(), and UCalibrate::findCameraPosition().

URotation UCalibrationMarkSet::rotBarcode
URotation UCalibrationMarkSet::rotCal

calibrated camera rotation

Referenced by UCalibrate::findBarcodeChartPosition().

bool UCalibrationMarkSet::valid

is marks valid

Referenced by UCalibrationMarkSets::saveNewSet().


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