Classes | Public Member Functions | Private Member Functions | Private Attributes
calibTree Class Reference

This class manages the calibration points and generates structures for parsing them. More...

#include <calibTree.h>

List of all members.

Classes

struct  calib

Public Member Functions

 calibTree ()
void createTree ()
void freeTree ()
int getCalibPointCamera (int index)
int getCalibPointColor (int index, int paramIndex)
int getCalibPointsSize ()
int getCalibPointType (int index)
void newCalibPoint (uint8_t red, uint8_t green, uint8_t blue, int camera, int calibType)
void orderCalibsByRed ()
int parseCalibTree (int R, int G, int B, int camera, int calibAccuracy)
void printTree ()
void removeCalibPoint (int index)
bool removeLastNodeFromTree (int cameraShown)
 ~calibTree ()

Private Member Functions

void addToTree (int calibNode)
void createTreeNode (int vectorIndex, calib *nodePtr, calib *parentPtr)
void createTreeRecursion (int start, int end)
void freeTreeRecursion (calib *treeHead)
int parseCalibTreeRecursion (calib *treeNode, int R, int G, int B, int camera, int calibAccuracy)
void printTreeRecursion (calib *node, int level)
bool removeLastNodeFromTreeRecursion (calib *nodePtr, int r, int g, int b, int id)

Private Attributes

vector< calibcalibPoints
int idCount
struct calibtreeHead

Detailed Description

This class manages the calibration points and generates structures for parsing them.

This class is used by both image_calibration and create_calibs. It contains the calibPoints structure, a vector of calibs. A calib is a structure which contains all the information about a calibration point. If a pixel is close enough to the rgb values of a calib structure, it belongs to same calibration type than the calib struct, as defined by the calibType field.

The class also manages a tree of calibs created to allow quicker parsing of the calibs to find matches between pixel and calib rbg values. The tree is generated using the createTree() function, which uses the calibPoints vector to generate a tree. It is parsed using the parseCalibTree() function. The head of the tree is stored in treeHead.

Definition at line 30 of file calibTree.h.


Constructor & Destructor Documentation

CalibTree Constructor. Initializes the calibPoint vector, and sets the head of the tree to null.

Author:
: Frederik Clinckemaillie
Date:
: 07/06/2012

Definition at line 10 of file calibTree.cpp.

CalibTree Destructor

Definition at line 17 of file calibTree.cpp.


Member Function Documentation

void calibTree::addToTree ( int  calibNode) [private]

Function adds the given node to tree, which is ordered on the red color value. The tree is created based on the red color values of the calibration files. This tree allows for quicker search of calibration colors that are applicable to a pixel color

Parameters:
calibNode,theposition of the calib node in the point vector

Definition at line 321 of file calibTree.cpp.

This function creates a binary tree of calibration objects stored in the calibPoints vector, organized on the value of the red color value. This tree allows for faster searches of calibrations that may be applicable to pixels in the image.

Definition at line 70 of file calibTree.cpp.

void calibTree::createTreeNode ( int  vectorIndex,
calib nodePtr,
calib parentPtr 
) [private]

Creates tree nodes in red tree at position nodePtr, with values acquired from the calibration node stored at the vectorIndex position in the calibration vector.

Helper function for addTreeNodes()

Parameters:
vectorIndex,:the position of the node in the calibration vector containing all calibration points whose information is copied.
nodePtr,:node position in the tree.
parentPtr,:pointer to the position of the parent node of the node being created

Definition at line 378 of file calibTree.cpp.

void calibTree::createTreeRecursion ( int  start,
int  end 
) [private]

Private function performing the task described in createTree recursively Creates the (sub)tree of calibrations keyed on their red color value. Only considers calib objects in between the start and end indexes in the calibPoints vector.

Parameters:
start,:The start index of the calibration objects being used to create the tree
end,:The end index of the calibration objects being used to create the tree

Definition at line 77 of file calibTree.cpp.

Frees all the memory in the tree. Used in createCalib when a new tree has to be created because a node has been added by mouse press.

Definition at line 302 of file calibTree.cpp.

void calibTree::freeTreeRecursion ( calib treeHead) [private]

Recursive function called by freeTree to free the tree.

Parameters:
node,:the node at the top of the (sub)tree being deleted.

Definition at line 310 of file calibTree.cpp.

int calibTree::getCalibPointCamera ( int  index)

Getter for the camera a calibration point is meant to be applied to .

Parameters:
index,:the position of the calibration object in the calibPoints vector
Returns:
int: 1 for NORTH_CAMERA, 2 for SOUTH_CAMERA, 3 for BOTH_CAMERAS

Definition at line 52 of file calibTree.cpp.

int calibTree::getCalibPointColor ( int  index,
int  paramIndex 
)

Getter for the a specific calibPoint Color value

Parameters:
index,:the index value of the point in the vector
colorIndex,:color being queried 0- RED 1- GREEN 2- BLUE
Returns:
int: the value of colorIndex at the index position in calibPoints

Definition at line 42 of file calibTree.cpp.

Getter function for the size of the calibPoints vector

Returns:
int: the size of the calibPoints vector

Definition at line 37 of file calibTree.cpp.

int calibTree::getCalibPointType ( int  index)

Getter for the calibType value of the calib object at index position in the calibPoints vector

Parameters:
index,:position of the calib object whos calibType is being queried
Returns:
int: the calibration type of the object: 0-ROBOT_LEFT_FRONT 1-ROBOT_RIGHT_FRONT 2-ROBOT_LEFT_BACK 3-ROBOT_RIGHT_BACK 4-FLOOR 5-NOT_SET

Definition at line 57 of file calibTree.cpp.

void calibTree::newCalibPoint ( uint8_t  red,
uint8_t  green,
uint8_t  blue,
int  camera,
int  calibType 
)

This function creates a new calib object and adds it to the calib points vector.

Parameters:
red:thered color value of the calibration point being added
green,:the green color value of the calibration point being added
blue,:the blue color value of the calibration point being added
camera:Thecamera applicable to the calibration point being added
calibType,:The calibration type of the calibration point being added

Definition at line 22 of file calibTree.cpp.

This function uses insertion sort to sort the calib objects in the calibPoints vector by their red color value. This is used to create a balanced tree of the calib objects when createTree() is called. Since the tree is only constructed once, but used once for every pixel of every image read from the overhead cameras, the overhead in sorting the calib objects and creating the tree is almost insignificant.

Definition at line 144 of file calibTree.cpp.

int calibTree::parseCalibTree ( int  R,
int  G,
int  B,
int  camera,
int  calibAccuracy 
)

Given the RBG values of a pixel in the image, this function parses the color tree to find a calibration object that is within a certain range of that pixel color, as defined by "calibAccuracy".

Parameters:
R,:Red color value of pixel
G,:Green color value of pixel
B,:Blue color value of pixel
camera,:The camera used to get the pixel currently being calibrated
calibAccuracy,:Marks how far from a pixel color value a calibration color can be to still be considered applicable to that pixel

Definition at line 102 of file calibTree.cpp.

int calibTree::parseCalibTreeRecursion ( calib treeNode,
int  R,
int  G,
int  B,
int  camera,
int  calibAccuracy 
) [private]

Performs the recursion for parseCalibTree.

Parameters:
treeNode,:node marking the head of the (sub)tree being parsed
R,:Red color value of pixel
G,:Green color value of pixel
B,:Blue color value of pixel
camera,:The camera used to get the pixel currently being calibrated
calibAccuracy,:Marks how far from a pixel color value a calibration color can be to still be considered applicable to that pixel
Returns:
the calibType of the applicable calib node if one was found. If none are found, NOT_SET (-1) is returned.

Definition at line 107 of file calibTree.cpp.

Prints the created calibration tree by calling the printTreeRecursion function.

Definition at line 401 of file calibTree.cpp.

void calibTree::printTreeRecursion ( calib node,
int  level 
) [private]

Recursive function called by print tree. Prints the rgb, camera, and calibType values of each node. Also prints the level of the node in the tree and the pointer values to that nodes children (to determine if the node has children).

Parameters:
node,:the node being printed
level,:the level of the node being printed in the overall tree

Definition at line 407 of file calibTree.cpp.

void calibTree::removeCalibPoint ( int  index)

Removes the object at position index in the calibPoints vector. Used by create_calibs to remove badly selected calibration points

Parameters:
index,:the position of the calibration object in the calibPoints vector

Definition at line 62 of file calibTree.cpp.

bool calibTree::removeLastNodeFromTree ( int  cameraShown)

This function is used to remove the node that was added last to the tree. It only considers tree nodes whos camera field match the camera shown parameter. This is used in the create_calib program when removing a node added by accident. Only nodes that are applicable to the current camera will be considered (camera = cameraShown || camera = BOTH_CAMERAS)

Parameters:
cameraShown,:the camera currently being shown when the commmand to delete a node was pressed
Returns:
bool: Whether the deletion was a success. Could be false if no applicable node was found.

Definition at line 191 of file calibTree.cpp.

bool calibTree::removeLastNodeFromTreeRecursion ( calib nodePtr,
int  r,
int  g,
int  b,
int  id 
) [private]

Recursive function for removeLastNodeFrom tree. Removes a node from the tree with the correct r,g,b and camera value

Parameters:
nodePtr,:the pointer to the head of the (sub)tree currently being examined for the node to delete
r,:red color value of the node to be deleted
g,:green color value of the node to be deleted
b,:blue color value of the node to be deleted
id,:the id of the node being deleted
Returns:
bool: Whether the deletion was a success. Could be false if no applicable node was found.

Definition at line 221 of file calibTree.cpp.


Member Data Documentation

vector<calib> calibTree::calibPoints [private]

Definition at line 161 of file calibTree.h.

int calibTree::idCount [private]

Definition at line 163 of file calibTree.h.

struct calib* calibTree::treeHead [private]

Definition at line 158 of file calibTree.h.


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


youbot_overhead_vision
Author(s): Fred Clinckemaillie, Maintained by David Kent
autogenerated on Thu Jan 2 2014 12:14:12