AURobotServers
4
|
#include <ucalibrate.h>
Public Member Functions | |
bool | allocateBufferImages (UImagePool *imgPool) |
bool | findBarcodeChartPosition (UCamMounted *cam, UCalibrationMarkSet *dataset, UCalibrationMark *indexCorner, int gmkBlocks, float gmkBlockSize, UImage *img, float pixFactor, bool removeRadialError, bool debug) |
bool | findCameraPosition (UCamMounted *cam, UCalibrationMarkSet *dataset, bool findPosition, float chartCenterHeight, bool debug) |
bool | findGmk (UCamMounted *cam, UImage *img, int frameSizeBlocks, int codeBlockFactor, float sideStride, int maxCodesToLookFor, bool findCode, bool findPosition, bool findRotation, float chartCenterHeight, bool findChartPos, bool nearGMK, bool useVertFilt, bool useDiagFilt, bool extraImages) |
UBarcode * | getGmk (int index) |
int | getGmksCnt () |
bool | isBufferImagesAvailable () |
bool | MarkCornerDetections4 (UImage *fim, UImage *cim, int GuardBandH, int GuardBandD, int IntensDiffH, int IntensDiffD, bool assumeBlackIsZero) |
int | SaveCalibrationMarks () |
bool | saveCodeFrame (unsigned long codeValue, int codeNum, float strideStride) |
void | setCameraParameters (float hx, float hy, float k1, float k2, float f, float resFactor, char *name) |
void | setCameraParameters (UCamPar *camPar) |
bool | ShowStatus (int setNumber) |
void | toLog (const char *info, int significance, UTime *timestamp=NULL) |
UCalibrate () | |
~UCalibrate () | |
Public Attributes | |
UCalibrationMarkSets | calcamset |
UCalibrationComponents | cc |
UImage * | pCornerImage |
UImage * | pFiltImage |
UImage * | pGridImage |
UImage * | pRawImage |
Protected Attributes | |
UCalibrationMarkSet | frameSet |
UBarcode | gmks [MAX_CODES_IN_ONE_IMAGE] |
int | gmksCnt |
This class encapsulates functions and methods used for calibration purposes.
UCalibrate::UCalibrate | ( | ) |
Constructor
References logGmk, logLevelGmk, and verboseMessagesGmk.
UCalibrate::~UCalibrate | ( | ) |
Destructor
References logGmk.
bool UCalibrate::allocateBufferImages | ( | UImagePool * | imgPool | ) |
Create or assign buffer images for guidemark/calibration process
References UImagePool::getImage(), UCAM_IMS_CALIB_CORNER, UCAM_IMS_CALIB_FILTER, UCAM_IMS_CALIB_GRID, and UCAM_IMS_CALIB_RAW.
Referenced by UFunctionCamGmk::handleGmkGetCommand().
bool UCalibrate::findBarcodeChartPosition | ( | UCamMounted * | cam, |
UCalibrationMarkSet * | dataset, | ||
UCalibrationMark * | indexCorner, | ||
int | gmkBlocks, | ||
float | gmkBlockSize, | ||
UImage * | img, | ||
float | pixFactor, | ||
bool | removeRadialError, | ||
bool | debug | ||
) |
Find position of barcode chart in this dataset. The position (x,y,z) and the orientation of the chart (Omega, Pgi and Kappa) is estimated. The accuracy depends on the pixel position accuracy in the dataset. Returns true if found. The found position is returned in the dataset structure as posBarcode and rotBarcode, with the barcodeValid if the data is valid.
References UCalibrationMarkSet::barcode, UCalibrationMarkSet::barcodeValid, UCalibrationMarkSet::calValid, UImage::cvArr(), UCalibrationMarkSet::evaluateChartPosRot(), UCamRad::getCamPar(), UCalibrationMarkSet::getErrorInPixels(), UCamMounted::getPosCC(), UCamMounted::getRotCC(), UCalibrationMark::ix, UCalibrationMark::iy, URotation::Kappa, URotation::LimitToPi(), UCalibrationMarkSet::posCal, UCalibrationMarkSet::rotBarcode, UCalibrationMarkSet::rotCal, roundi(), UCalibrationMark::rx, UCalibrationMark::ry, UPosition::set(), and UImage::width().
bool UCalibrate::findCameraPosition | ( | UCamMounted * | cam, |
UCalibrationMarkSet * | dataset, | ||
bool | findPosition, | ||
float | chartCenterHeight, | ||
bool | debug | ||
) |
Find camera position assuming barcode chart is not rotated relative to camera orientation. if 'findChartPos' then estimate chart both rotation and position, defult is just rotation and z-distance (addition to expected chart position). Returns true if found succesfully. The result is returned in the dataset structure as posCal and rotCal, with the calValid if the data is valid. If 'debug' is true, then some extra logfiles will be produced in result or image path with filename based on image number.
References absd(), UCalibrationMarkSet::calValid, UCalibrationMarkSet::evaluatePosRot(), UCamRad::getCamPar(), UCamMounted::getPosCC(), UCamMounted::getRotCC(), UCalibrationMarkSet::posCal, UCalibrationMarkSet::setStopLimit(), UPosition::x, and UPosition::z.
bool UCalibrate::findGmk | ( | UCamMounted * | cam, |
UImage * | img, | ||
int | frameSizeBlocks, | ||
int | codeBlockFactor, | ||
float | sideStride, | ||
int | maxCodesToLookFor, | ||
bool | findCode, | ||
bool | findPosition, | ||
bool | findRotation, | ||
float | chartCenterHeight, | ||
bool | findChartPos, | ||
bool | nearGMK, | ||
bool | useVertFilt, | ||
bool | useDiagFilt, | ||
bool | extraImages | ||
) |
Clear data store for frame corner positions. Find barcodes in this image. Both horizontal and diagonal may be used simultaniously
useVertFilt | use filters for mostly vertical guidemarks |
useDiagFilt | use filters for mostly diagonal guidemarks true if at least one is found. |
References UCalibrationComponents::clear(), UImage::cvArr(), dataPath, UCamRad::getCamPar(), UCamBase::getDev(), UCamPar::getFocalLength(), UCamDevBase::getImageNumber(), UImage::getPix(), UTime::getTimePassed(), UImage::height(), UImage::imageNumber, imagePath, img, UImage::imgTime, MAX_BARCODE_LENGTH, MAX_CODES_IN_ONE_IMAGE, MAX_IMG_NAME_SIZE, UTime::Now(), UImage::radialErrorRemoved, roundi(), UPosition::set(), URotation::set(), UPixel::set(), UCamMounted::setPosOnRobotCC(), UCalibrationComponents::toLog(), UPixel::u, UPixel::v, UImage::valid, UImage::width(), and UPixel::y.
Referenced by UFunctionCamGmk::handleGmkGetCommand().
|
inline |
Get a specific guidemark. NB! no index range check
Referenced by UFunctionCamGmk::handleGmkGetCommand().
|
inline |
Get number of found guidemarks
Referenced by UFunctionCamGmk::handleGmkGetCommand().
bool UCalibrate::isBufferImagesAvailable | ( | ) |
Buffer space is allocated on heap. This function returns true if all went well.
Referenced by UFunctionCamGmk::handleGmkGetCommand().
bool UCalibrate::MarkCornerDetections4 | ( | UImage * | fim, |
UImage * | cim, | ||
int | GuardBandH, | ||
int | GuardBandD, | ||
int | IntensDiffH, | ||
int | IntensDiffD, | ||
bool | assumeBlackIsZero | ||
) |
Compares four pixels from the filtered source image (fim) around a center cell. If there is sufficient intensity difference in the four corners a corner is found, and the pixel is marked in the destination image (cim). No corner is black, red is a white upper left and cyan is black upper left. www—bbb —bbb— 'GuardBand' is pixels from center www—bbb —bbb— cell to corner cell www—bbb —bbb—
References UImage::clear(), UImage::copyMeta(), dataPath, UImage::getPixRef(), UImage::height(), UImage::imageNumber, UImage::imgBytes(), MAX_IMG_NAME_SIZE, UImage::maxBytes(), maxi(), mini(), UImage::name, roundi(), UImage::setColorType(), UImage::setPix(), UPixel::u, UImage::used, UPixel::v, UImage::valid, UImage::width(), and UPixel::y.
Referenced by ShowStatus().
int UCalibrate::SaveCalibrationMarks | ( | ) |
Save found information, stored in grid array as calibration set for camera.
bool UCalibrate::saveCodeFrame | ( | unsigned long | codeValue, |
int | codeNum, | ||
float | strideStride | ||
) |
Save the frame positions for this barcode frame. save under 'codeValue' number. If 'codeNum' is -1 then new entry is created else the entry with this 'codeNum' and same 'codeValue' will be overwritten. if it do not exist, a new entry is created. All calculated values gets invalid. Returns true if entry created. Camera positioen relative to robot is in 'camera' (used set) or in this set for a just evaluated value. The default chart position is in 'calcamset.chartPos'. Position of chart relative to robot (and in robot coordinates) is in this set. Rotation of chart is in this set.
|
inline |
Set camera parameters
|
inline |
Set camera parameters from copy
bool UCalibrate::ShowStatus | ( | int | setNumber | ) |
Find calibration points in this source image with 100 corners,and stores the result calibration marks in the cc structure if successfull. if name provided, then points are saved in textfile with this name in the default image path with a .txt and .m extension. Returns number of found points (100 if all calibration points were found). Show calibration status as info messages.
References UCalibrationMarkSet::info(), and MarkCornerDetections4().
|
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 img, and toLogGmk().
UCalibrationMarkSets UCalibrate::calcamset |
Calibrate information sets (calcamset) stores one set of points per camera device.
UCalibrationComponents UCalibrate::cc |
Calibration components as extracted from pCornetImage.
|
protected |
Working frameset, with latest information on frame
|
protected |
Found barcodes in last image
|
protected |
Valid number of barcodes
UImage* UCalibrate::pCornerImage |
Image with detected corners marked. Last image stage before corner pixels are combined to components in cc.
UImage* UCalibrate::pFiltImage |
Averaged image after low pass.
UImage* UCalibrate::pGridImage |
Image used both to lines to neighbor and to code-cell lines and histogram paint
UImage* UCalibrate::pRawImage |
Raw image to be used as basis for calibration. (copy from camera or saved image)