AURobotServers
4
|
#include <ucamrad.h>
Public Member Functions | |
virtual void | createVars () |
UCamPar * | getCamPar () |
int | getDefaultColFormat () |
bool | getDefaultRemRadErr () |
bool | getImageSnapshot (UImage *image) |
bool | removeRadialError (UImage *source, UImage *destination) |
void | saveRadialCorrectionMatrix (char *filename) |
bool | setCameraParameters (float hx, float hy, float k1, float k2, float focalLng) |
void | setDefaultRemRadErr (bool value) |
bool | setRadialErrorMatrix () |
UCamRad (UCamDevBase *device) | |
void | updateLensParams (const int height, const int width) |
virtual | ~UCamRad () |
Public Member Functions inherited from UCamPanTiltDevice | |
int | getPanMaxRange () |
int | getPanMinRange () |
int | getPanPos () |
int | getTiltMaxRange () |
int | getTiltMinRange () |
int | getTiltPos () |
bool | isPantiltSupported () |
bool | isPantiltValid () |
bool | pantiltSetPosition (bool relative, int pan, int tilt) |
bool | pantiltToHomePosition () |
bool | pantiltUpdatePosition () |
bool | setPantiltStatus () |
UCamPanTiltDevice (UCamDevBase *device) | |
Public Member Functions inherited from UCamBase | |
const char * | getCamName () |
UCamDevBase * | getDev () |
int | getDevNum () |
virtual void | gotNewImage (UImage *) |
virtual void | imgUpdated () |
virtual bool | needNewPushData () |
void | setTypeName (const char *newName) |
void | setVarPool (UVarPool *vpd) |
UCamBase (UCamDevBase *device) | |
virtual | ~UCamBase () |
Public Attributes | |
UVarPool * | varBaseStruct |
Protected Member Functions | |
bool | getRadialU2DOffset (float xu, float yu, float *dxd, float *dyd) |
UXYoffset | getRadialU2DOffsetInt (int x, int y) |
virtual void | imageSizeChanged (double iResFactor) |
bool | lensParChanged () |
virtual bool | logImage (UImage *) |
bool | removeRadialErrorOnePlane (unsigned char ps[], unsigned char pd[], unsigned int height, unsigned int width, float pixSize, bool halfRes) |
bool | removeRadialErrorPixels (UPixel ps[], UPixel pd[], unsigned int height, unsigned int width, float pixSize) |
Protected Member Functions inherited from UCamPanTiltDevice | |
bool | protPantiltGetPosition () |
bool | protPantiltGetRange () |
bool | protPantiltReset (bool resetPan, bool resetTilt) |
Private Attributes | |
int | defaultColFormat |
bool | defaultRemRadErr |
IplImage * | mapx |
IplImage * | mapy |
UCamPar | par |
UXYoffset | radialOffset [MAX_IMAGE_HEIGHT_RAD_SQUARE][MAX_IMAGE_WIDTH_RAD_SQUARE] |
bool | radialOffsetValid |
UVariable * | varDistortion |
pointer to lens distortion parameters radial (k1, k2, k3) and tangential - ccd-chip not parallel to lens (p1, p2)) More... | |
UVariable * | varIntrinsic |
pointer to intrinsic camera parameters (focal-length and head-point) More... | |
Additional Inherited Members | |
Protected Attributes inherited from UCamBase | |
UCamDevBase * | dev |
UVarPool * | vars |
Class that includes camera functtions to remove radial error in the raw images. The calss is based on both the camera device 'UCamDevice' and camera parameters 'UCamPar'.
UCamRad::UCamRad | ( | UCamDevBase * | device | ) |
Constructor
References defaultColFormat, defaultRemRadErr, mapx, mapy, PIX_PLANES_YUV, radialOffsetValid, varDistortion, and varIntrinsic.
|
virtual |
Create locally maintained variables - if any
Reimplemented from UCamBase.
Reimplemented in UCamMounted, and UCamPush.
References UVarPool::addVarA(), UCamBase::createVars(), varDistortion, varIntrinsic, and UCamBase::vars.
Referenced by UCamMounted::createVars(), and setCameraParameters().
|
inline |
Get pointer to camera parameters
Referenced by UFuncBallKL::calculateBallPosition(), UFuncBall::calculateBallPosition(), UFuncBall_improved::calculateBallPosition(), UFuncImgPoly::findAreaFromSeedRGB(), UCalibrate::findBarcodeChartPosition(), UCalibrate::findCameraPosition(), UCalibrate::findGmk(), UFunctionCamPath::findPath(), UFuncCropRow::findPlants(), UFuncStraightLine::findWoldPoints(), UCamMounted::getMtoPix(), UFuncKinect::GetXYZCoordinates(), UFuncCropRow::handleCommand(), UFuncLinefinder::houghTest(), UImageLog::logImage(), UFuncKinect::makeObj3Dcloud(), UFuncPiCam::run(), UComCamSml::setCamDevice(), UImgProj::setCamPar(), UImgPolyProj::setCamPar(), and UComCamSml::setFromCam().
|
inline |
Default color format if auto repeat is turned on. is set only when capturing an HDR image set.
|
inline |
Should radial error be removed by default when auto repeat is turned on. Is set when capturing an image
bool UCamRad::getImageSnapshot | ( | UImage * | image | ) |
Overwrite get Image Snapshot to allow removal of radial error if such removal is possible and set as default. returns true if image were captured and radial error status were removed or not as requetsed. Result is always in URawImage YUV42 or Bayer RGGB format. If 'image' == NULL then an image is captured, and discarded.
References UCamBase::dev, UCamDevBase::getImageSnapshot(), UCamDevBase::isCameraOpen(), logImage(), and UCamDevBase::openDeviceDefault().
Referenced by UFuncCog::centerOfGravity(), UFuncFocus::doFocus(), UFunctionCam::handleCamPushCommand(), testCameraHDR(), testCameraSettings(), testMatrixVecBig(), testRadErr(), testVideo2(), and testVideo3().
|
protected |
Same as above, but makes float calculations and return change in coordinates to dx, dy. to get the corresponding position in the raw image.
References UCamPar::getRadialU2D(), and par.
Referenced by getRadialU2DOffsetInt().
|
protected |
Calculate where to fetch a pixel in the distorted image (raw) to this corrected image position relative to this {x,y} position (+ is right and down). The returned result {X,Y} position is in 16 bit accuracy with fixed decimal point, i.e. multiplied with 'resultDecimalFactor' (probably 10). The decimal part should be used to interpolate between pixels in the raw image.
References UXYoffset::dx, UXYoffset::dy, getRadialU2DOffset(), resultDecimalFactor, and roundi().
Referenced by setRadialErrorMatrix().
|
protectedvirtual |
Set the parameters derived from resolution, i.e. conversion matrix, radial error valeues etc.
Reimplemented from UCamBase.
References par, radialOffsetValid, UCamPar::setPixelSize(), setRadialErrorMatrix(), and updateLensParams().
|
protected |
Has focal length, headpoint or lens parameters changed - i.e. must rectification matrix be re-calculated.
References UVariable::getDouble(), UCamPar::getFocalLength(), UCamPar::getHx(), UCamPar::getHy(), UCamPar::getK1(), UCamPar::getK2(), UVariable::getValued(), par, varDistortion, and varIntrinsic.
Referenced by removeRadialError().
|
inlineprotectedvirtual |
A call to see if anyone need the image logged.
image | is the newly captured image. |
Reimplemented in UCamMounted.
Referenced by getImageSnapshot().
Remove radial error from this image. uses openCV cvRemap(..) function to remove error. Resolution of destination will be as source. Uses pre-calculated correction matrix, if image size or rectification parameters has changed, then the rectification matrix is recalculated.
source | is source image |
destination | is destination image - both must exist at call. |
References UImage::copyMeta(), UImage::cvArr(), UImage::getColorType(), UCamBase::getDev(), UImage::getHeight(), UCamPar::getPixelSize(), UImage::getUline(), UImage::getVline(), UImage::getWidth(), UImage::getYline(), UCamPar::isValid(), lensParChanged(), mapx, mapy, par, PIX_PLANES_BGGR, PIX_PLANES_GBRG, PIX_PLANES_GRBG, PIX_PLANES_RGGB, PIX_PLANES_YUV420, UImage::radialErrorRemoved, removeRadialErrorOnePlane(), UImage::toBGR(), UImage::updated(), and updateLensParams().
Referenced by UFunctionCamBase::getCamAndRawImage(), and UFuncRectify::handleCommand().
|
protected |
Remove radial error for one pixel plane - either Y, U or V. A source pointer to the top-left pixel must be provided for source and destination, and the size of the images. The decimal factor is the factor in the radial error matrix that desides the decimal point. At full resolution this will normally be 10, at half resolution 20 and so on. For YUV the U and V the height, width and pixel size must be given in half resolution and further 'halfRes' must be true
References absi(), UXYoffset::dx, UXYoffset::dy, UCamPar::getHx(), UCamPar::getHy(), par, radialOffset, resultDecimalFactor, and roundi().
Referenced by removeRadialError().
|
protected |
Removes radial error based on offset array in full resolution as produced by 'setRadialErrorMatrix()'. Image pointers must be buffers of 'UPixel' ordered one row at a time, so that the next row follows imidiately after the first. A source pointer to the top-left pixel must be provided for source and destination, and the size of the images. The decimal factor is the factor in the radial error matrix that desides the decimal point. A pixel size must be provide for correct scaling of offset matrix values.
References absi(), UXYoffset::dx, UXYoffset::dy, UCamPar::getHx(), UCamPar::getHy(), par, radialOffset, resultDecimalFactor, roundi(), UPixel::u, UPixel::v, and UPixel::y.
void UCamRad::saveRadialCorrectionMatrix | ( | char * | filename | ) |
Make textfile with radial correction values. Saves pixel offset values for the last used resolution.
References UCamBase::dev, UXYoffset::dx, UXYoffset::dy, UCamPar::getHx(), UCamPar::getHy(), UCamPar::getK1(), UCamPar::getK2(), UCamPar::getPixelSize(), UCamDevBase::MAX_IMAGE_WIDTH, par, radialOffset, radialOffsetValid, and resultDecimalFactor.
bool UCamRad::setCameraParameters | ( | float | hx, |
float | hy, | ||
float | k1, | ||
float | k2, | ||
float | focalLng | ||
) |
Set camera internal parameters and redo the matrix for radial error removal and for conversion in camera coordinates (pixel to 3D and reverse). Parameters are expected to be in scale 1, i.e. 640x480 image size focal length, hx, hy (headpoint) are all in pixels and pixSizeFactor is pixel size relative to 640x480, i.e. 320x240 gives a pixSizeFactor of 2.0. Returns true if successful.
References createVars(), UCamBase::dev, UCamDevBase::getPixelSize(), par, UCamPar::setCameraParameters(), UVariable::setDouble(), setRadialErrorMatrix(), updateLensParams(), varDistortion, and varIntrinsic.
Referenced by UFuncPiCam::run(), UComCamSml::setCamDevice(), and testRadErr().
|
inline |
Should radial error be removed by default when auto repeat is turned on. Is set when capturing an image
bool UCamRad::setRadialErrorMatrix | ( | ) |
Removal of radial error is done in according to calibration information in the referenced camera. Removal follows the guidelines in Image Analysis, Vision and Computer Graphics DTU/IMM publication by Jens Michael Carstensen Lyngby 2001, page 75.
focus length, Head-point (hx and hy) and correction factors (k1 and k2) are always in 640x480 resolution.
References UXYoffset::dx, UCamPar::getHx(), UCamPar::getHy(), UCamPar::getPixelSize(), getRadialU2DOffsetInt(), MAX_IMAGE_HEIGHT_RAD_SQUARE, MAX_IMAGE_WIDTH_RAD_SQUARE, par, radialOffset, radialOffsetValid, and UCamPar::setPixelSize().
Referenced by imageSizeChanged(), and setCameraParameters().
void UCamRad::updateLensParams | ( | const int | height, |
const int | width | ||
) |
Update lens parameters and setup distortion correction matrix - as used by openCV. and as used by the old correction scheme - in the UCamPar structure. Parameters are assumed to be loaded into the corresponding clobal variables
height | is the actual image height in pixels. |
width | is the actual width of image in pixels. |
References UMatrix::cvMat(), UCamBase::getDev(), UVariable::getDouble(), UCamPar::getFocalLength(), UCamPar::getHx(), UCamPar::getHy(), UCamPar::getK1(), UCamPar::getK2(), UCamDevBase::getPixelSize(), UVariable::getValued(), UVariable::getValuesd(), mapx, mapy, par, UCamPar::setCameraParameters(), UMatrix::setMat(), varDistortion, and varIntrinsic.
Referenced by imageSizeChanged(), removeRadialError(), and setCameraParameters().
|
private |
Default color format if auto repeat is turned on.
Referenced by UCamRad().
|
private |
Should radial error be removed by default when auto repeat is turned on.
Referenced by UCamRad().
|
private |
Referenced by removeRadialError(), UCamRad(), updateLensParams(), and ~UCamRad().
|
private |
Referenced by removeRadialError(), UCamRad(), updateLensParams(), and ~UCamRad().
|
private |
Camera parameters as local object, as it is used during estimation etc.
Referenced by getRadialU2DOffset(), imageSizeChanged(), lensParChanged(), removeRadialError(), removeRadialErrorOnePlane(), removeRadialErrorPixels(), saveRadialCorrectionMatrix(), setCameraParameters(), setRadialErrorMatrix(), and updateLensParams().
|
private |
Radial error removal table
Referenced by removeRadialErrorOnePlane(), removeRadialErrorPixels(), saveRadialCorrectionMatrix(), and setRadialErrorMatrix().
|
private |
Is the radial error table calculated
Referenced by imageSizeChanged(), saveRadialCorrectionMatrix(), setRadialErrorMatrix(), and UCamRad().
UVarPool* UCamRad::varBaseStruct |
structure for variables for this camera
|
private |
pointer to lens distortion parameters radial (k1, k2, k3) and tangential - ccd-chip not parallel to lens (p1, p2))
Referenced by createVars(), lensParChanged(), setCameraParameters(), UCamRad(), and updateLensParams().
|
private |
pointer to intrinsic camera parameters (focal-length and head-point)
Referenced by createVars(), lensParChanged(), setCameraParameters(), UCamRad(), and updateLensParams().