#include <OkanReg.h>
Public Member Functions | |
double | norCrosCorr (int x0, int y0, int x1, int y1, int n, double mean0, double std0, double mean1, double std1) |
void | findHomography (int *ids, CvMat *h) |
int | checkHomographyQuality (CvMat *h, float errTol, float &mse) |
OkanReg () | |
~OkanReg () | |
void | clearReg () |
void | destroyImage (int id) |
void | setImage (IplImage *im, int id) |
void | setImage (string im, int id) |
IplImage * | getImage (int id) |
void | setImageROI (int id, int x1, int y1, int x2, int y2) |
CvRect | getImageROI (int id) |
void | removeImageROI (int id) |
int | getCornerSize (int id) |
CvPoint2D32f * | getCorner (int id) |
void | clearMatches () |
void | addMatch (CvPoint2D32f p1, CvPoint2D32f p2) |
void | eraseMatch (int id) |
vector< CvPoint2D32f > & | getMatches (int id) |
CvMat * | getBestMat (int id) |
int | getBestPoint () |
float | getBestMse () |
double | findHarris (int id, int n, double thresh, double minDistance, int blockSize=3, int apertureSize=3, double k=0.04) |
int | findPutMatch (int n, int d=0, double thresh=-2) |
bool | findRANSACHomography (int iter, float errTol) |
Public Attributes | |
IplImage * | image [2] |
IplImage * | gray [2] |
CvPoint2D32f * | corner [2] |
int | cornerSize [2] |
vector< CvPoint2D32f > | matches [2] |
CvMat * | bestMat [2] |
int | bestPoint |
float | bestMse |
OkanReg::OkanReg | ( | ) |
Constructor of OkanReg class. It simply makes all values 0 and all pointers NULL.
OkanReg::~OkanReg | ( | ) |
Destructor of OkanReg class. It releases all data it has. Be carefull about that, it does not releases image field of the class.
double OkanReg::norCrosCorr | ( | int | x0, | |
int | y0, | |||
int | x1, | |||
int | y1, | |||
int | n, | |||
double | mean0, | |||
double | std0, | |||
double | mean1, | |||
double | std1 | |||
) |
Private member function to calculate normalized cross correlation of two points.
x0 | x coordinate of first point | |
y0 | y coordinate of first point | |
x1 | x coordinate of second point | |
y1 | y coordinate of second point | |
n | window size for calculating mean and standard deviation of a corner | |
mean0 | mean of first point | |
std0 | standard deviation of first point | |
mean1 | mean of second point | |
std1 | standard deviation of second point |
void OkanReg::findHomography | ( | int * | ids, | |
CvMat * | h | |||
) |
Finds homography matrix for one subset of putative matches.
ids | It contains 4 integer which are indexes of putative matches | |
h | A CvMat pointer to be filled by this function. It is used as return value. |
int OkanReg::checkHomographyQuality | ( | CvMat * | h, | |
float | errTol, | |||
float & | mse | |||
) |
A private function to calculate quality of a homography matrix
h | the homography matrix | |
errTol | error tolerance while calculating quality of a homography matrix | |
mse | mean square error of homography matrix. It is used as a return value |
void OkanReg::clearReg | ( | ) |
It does same work of a destructor.
void OkanReg::destroyImage | ( | int | id | ) |
It releases all data of the image which has the id. It is used for destructor and clearReg also.
id | id of image |
~clearReg()
void OkanReg::setImage | ( | IplImage * | im, | |
int | id | |||
) |
It sets im as a new image for registration process. It does not copy all image. It only copy the pointer. It releases all data for previous image named id. It calls destroyImage() for this process.
im | pointer of new image | |
id | the of image to be setted. It should 0 or 1 |
void OkanReg::setImage | ( | string | im, | |
int | id | |||
) |
IplImage * OkanReg::getImage | ( | int | id | ) |
Get method of image field
id | the id of the image which will be returned |
void OkanReg::setImageROI | ( | int | id, | |
int | x1, | |||
int | y1, | |||
int | x2, | |||
int | y2 | |||
) |
sets region of interest for the image. Give a coordination of rectangle. Be carefull about that it affects every computation.
id | image id | |
x1 | x coordinate of top-left of rectangle | |
y1 | y coordinate of top-left of rectangle | |
x2 | width of rectangle | |
y2 | heigth of rectangle |
CvRect OkanReg::getImageROI | ( | int | id | ) |
Get method for region of interest of image
id | image id |
void OkanReg::removeImageROI | ( | int | id | ) |
Removes region of interest from image.
id | image id |
int OkanReg::getCornerSize | ( | int | id | ) |
Returns size of corners
id | image id |
CvPoint2D32f * OkanReg::getCorner | ( | int | id | ) |
Get method of corner field.
id | image id |
void OkanReg::clearMatches | ( | ) |
Clears putative matches of two images. Because they are related with each other two of them will be removed at once.
void OkanReg::addMatch | ( | CvPoint2D32f | p1, | |
CvPoint2D32f | p2 | |||
) |
Adds a putative match to matches field.
p1 | point for first image | |
p2 | point for second image |
void OkanReg::eraseMatch | ( | int | id | ) |
Removes the putative match from matches field.
id | index of the putative match |
vector< CvPoint2D32f > & OkanReg::getMatches | ( | int | id | ) |
Get method of images
id | image id |
CvMat * OkanReg::getBestMat | ( | int | id | ) |
Get method of best homography matrix
id | image id |
int OkanReg::getBestPoint | ( | ) |
Returns the number of putative matches which correspond to best homography matrix
float OkanReg::getBestMse | ( | ) |
Returns mean square error of best homography matrix
double OkanReg::findHarris | ( | int | id, | |
int | n, | |||
double | thresh, | |||
double | minDistance, | |||
int | blockSize = 3 , |
|||
int | apertureSize = 3 , |
|||
double | k = 0.04 | |||
) |
Finds corners of the given image and pushes them into the corner field and sets cornerSize. ROI is effective at this.
id | image id | |
n | how many points should be found. If n is equal to 0, then thresh is ignored. | |
thresh | quality level for determining weak corener points. | |
minDistance | minimum distance between two corner points. According to this weaker ones will be eliminated from result. | |
blockSize | block size of image. Default value is 3. | |
apertureSize | aperture size for process. Default value is 3. | |
k | a parameter for the corner detection algorithm. Default value is 0.04 |
int OkanReg::findPutMatch | ( | int | n, | |
int | d = 0 , |
|||
double | thresh = -2 | |||
) |
Finds putative matches of two images and pushes them into the matches field. If cornerSize is 0 it throws an exception. ROI is not effective
n | window size for calculating mean and standard deviation of a corner. | |
d | maximum distance between two corners to be a putative match. | |
thresh | thresh value for eliminating weak putative matches. |
bool OkanReg::findRANSACHomography | ( | int | iter, | |
float | errTol | |||
) |
Finds best homography matrix according to RANSAC algorithm. If size of 4-combinations is less than iter it tries every possible one. Otherwise it applies RANSAC algorithm
iter | maximum number of iterations for RANSAC algorithm | |
errTol | error tolerance for homography matrix. It is used in determining quality of homography matrix. If the difference between matches is smaller than this errTol variable, homography matrix's quality increases 1 point |
IplImage* OkanReg::image[2] |
Private IPLImage* array which keeps registered images.
IplImage* OkanReg::gray[2] |
Private IPLImage* array which keeps gray level of registered images.
CvPoint2D32f* OkanReg::corner[2] |
Private CVPoint2D32f* array which keeps corner points of two images.
int OkanReg::cornerSize[2] |
Private int array which keeps size of corner points of two images.
vector< CvPoint2D32f > OkanReg::matches[2] |
Private CvPoint2D32f vector which is used for putative matches of two images.
CvMat* OkanReg::bestMat[2] |
Private CVMat* array which keeps best homography matrix of two images. bestMat[0] means image[0] * bestMat[0] => image[1]
Private int which is used for estimating value of bestMat homography matrix. It means that how many of putative matches corresponds to best homography matrix.
float OkanReg::bestMse |
Private float which is used for mean square error of best homography matrix