This class manages the calibration points and generates structures for parsing them. More...
#include <calibTree.h>
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< calib > | calibPoints |
int | idCount |
struct calib * | treeHead |
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.
CalibTree Constructor. Initializes the calibPoint vector, and sets the head of the tree to null.
Definition at line 10 of file calibTree.cpp.
CalibTree Destructor
Definition at line 17 of file calibTree.cpp.
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
calibNode,the | position of the calib node in the point vector |
Definition at line 321 of file calibTree.cpp.
void calibTree::createTree | ( | ) |
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()
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.
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.
void calibTree::freeTree | ( | ) |
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.
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 .
index,: | the position of the calibration object in the calibPoints vector |
Definition at line 52 of file calibTree.cpp.
int calibTree::getCalibPointColor | ( | int | index, |
int | paramIndex | ||
) |
Getter for the a specific calibPoint Color value
index,: | the index value of the point in the vector |
colorIndex,: | color being queried 0- RED 1- GREEN 2- BLUE |
Definition at line 42 of file calibTree.cpp.
int calibTree::getCalibPointsSize | ( | ) |
Getter function for 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
index,: | position of the calib object whos calibType is being queried |
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.
red:the | red 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:The | camera 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.
void calibTree::orderCalibsByRed | ( | ) |
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".
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.
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 |
Definition at line 107 of file calibTree.cpp.
void calibTree::printTree | ( | ) |
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).
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
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)
cameraShown,: | the camera currently being shown when the commmand to delete a node was pressed |
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
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 |
Definition at line 221 of file calibTree.cpp.
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.