Merge branch 'accuracy' of https://github.com/obilaniu/opencv into accuracy

Conflicts:
	modules/calib3d/src/rhorefc.cpp
This commit is contained in:
ASUS
2015-02-12 21:27:08 -05:00
14 changed files with 811 additions and 593 deletions

View File

@@ -303,8 +303,7 @@ static bool createAndRunRHORegistrator(double confidence,
* initialized, used, then finalized.
*/
RHO_HEST_REFC p;
rhoRefCInit(&p);
RHO_HEST_REFC* p = rhoRefCInit();
/**
* Optional. Ideally, the context would survive across calls to
@@ -312,7 +311,7 @@ static bool createAndRunRHORegistrator(double confidence,
* to pay is marginally more computational work than strictly needed.
*/
rhoRefCEnsureCapacity(&p, npoints, beta);
rhoRefCEnsureCapacity(p, npoints, beta);
/**
* The critical call. All parameters are heavily documented in rhorefc.h.
@@ -325,7 +324,7 @@ static bool createAndRunRHORegistrator(double confidence,
* this behaviour is too problematic.
*/
result = !!rhoRefC(&p,
result = !!rhoRefC(p,
(const float*)src.data,
(const float*)dst.data,
(char*) tempMask.data,
@@ -344,7 +343,7 @@ static bool createAndRunRHORegistrator(double confidence,
* Cleanup.
*/
rhoRefCFini(&p);
rhoRefCFini(p);
/* Convert float homography to double precision. */
tmpH.convertTo(_H, CV_64FC1);

File diff suppressed because it is too large Load Diff

View File

@@ -56,7 +56,6 @@
/* Defines */
#ifdef __cplusplus
/* C++ does not have the restrict keyword. */
#ifdef restrict
@@ -64,15 +63,6 @@
#endif
#define restrict
#else
/* C99 and over has the restrict keyword. */
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#define restrict
#endif
#endif
/* Flags */
#ifndef RHO_FLAG_NONE
@@ -90,101 +80,17 @@
/* Namespace cv */
namespace cv{
/* Data structures */
/**
* Homography Estimation context.
*/
typedef struct{
/**
* Virtual Arguments.
*
* Exactly the same as at function call, except:
* - minInl is enforced to be >= 4.
*/
struct{
const float* restrict src;
const float* restrict dst;
char* restrict inl;
unsigned N;
float maxD;
unsigned maxI;
unsigned rConvg;
double cfd;
unsigned minInl;
double beta;
unsigned flags;
const float* guessH;
float* finalH;
} arg;
/* PROSAC Control */
struct{
unsigned i; /* Iteration Number */
unsigned phNum; /* Phase Number */
unsigned phEndI; /* Phase End Iteration */
double phEndFpI; /* Phase floating-point End Iteration */
unsigned phMax; /* Termination phase number */
unsigned phNumInl; /* Number of inliers for termination phase */
unsigned numModels; /* Number of models tested */
unsigned* restrict smpl; /* Sample of match indexes */
} ctrl;
/* Current model being tested */
struct{
float* restrict pkdPts; /* Packed points */
float* restrict H; /* Homography */
char* restrict inl; /* Mask of inliers */
unsigned numInl; /* Number of inliers */
} curr;
/* Best model (so far) */
struct{
float* restrict H; /* Homography */
char* restrict inl; /* Mask of inliers */
unsigned numInl; /* Number of inliers */
} best;
/* Non-randomness criterion */
struct{
unsigned* restrict tbl; /* Non-Randomness: Table */
unsigned size; /* Non-Randomness: Size */
double beta; /* Non-Randomness: Beta */
} nr;
/* SPRT Evaluator */
struct{
double t_M; /* t_M */
double m_S; /* m_S */
double epsilon; /* Epsilon */
double delta; /* delta */
double A; /* SPRT Threshold */
unsigned Ntested; /* Number of points tested */
unsigned Ntestedtotal; /* Number of points tested in total */
int good; /* Good/bad flag */
double lambdaAccept; /* Accept multiplier */
double lambdaReject; /* Reject multiplier */
} eval;
/* Levenberg-Marquardt Refinement */
struct{
float* ws; /* Levenberg-Marqhard Workspace */
float (* restrict JtJ)[8]; /* JtJ matrix */
float (* restrict tmp1)[8]; /* Temporary 1 */
float* restrict Jte; /* Jte vector */
} lm;
} RHO_HEST_REFC;
/* Extern C */
#ifdef __cplusplus
namespace cv{
/* extern "C" { */
#endif
struct RHO_HEST_REFC;
typedef struct RHO_HEST_REFC RHO_HEST_REFC;
/* Functions */
@@ -193,11 +99,10 @@ namespace cv{
* Initialize the estimator context, by allocating the aligned buffers
* internally needed.
*
* @param [in/out] p The uninitialized estimator context to initialize.
* @return 0 if successful; non-zero if an error occured.
* @return A pointer to the context if successful; NULL if an error occured.
*/
int rhoRefCInit(RHO_HEST_REFC* p);
RHO_HEST_REFC* rhoRefCInit(void);
/**
@@ -355,11 +260,8 @@ unsigned rhoRefC(RHO_HEST_REFC* restrict p, /* Homography estimation conte
/* Extern C */
#ifdef __cplusplus
/* } *//* End extern "C" */
/* End Namespace cv */
}
#endif

View File

@@ -94,12 +94,12 @@ private:
void print_information_1(int j, int N, int method, const Mat& H);
void print_information_2(int j, int N, int method, const Mat& H, const Mat& H_res, int k, double diff);
void print_information_3(int j, int N, const Mat& mask);
void print_information_3(int method, int j, int N, const Mat& mask);
void print_information_4(int method, int j, int N, int k, int l, double diff);
void print_information_5(int method, int j, int N, int l, double diff);
void print_information_6(int j, int N, int k, double diff, bool value);
void print_information_7(int j, int N, int k, double diff, bool original_value, bool found_value);
void print_information_8(int j, int N, int k, int l, double diff);
void print_information_6(int method, int j, int N, int k, double diff, bool value);
void print_information_7(int method, int j, int N, int k, double diff, bool original_value, bool found_value);
void print_information_8(int method, int j, int N, int k, int l, double diff);
};
CV_HomographyTest::CV_HomographyTest() : max_diff(1e-2f), max_2diff(2e-2f)
@@ -166,13 +166,13 @@ void CV_HomographyTest::print_information_2(int j, int N, int _method, const Mat
cout << "Maximum allowed difference: " << max_diff << endl; cout << endl;
}
void CV_HomographyTest::print_information_3(int j, int N, const Mat& mask)
void CV_HomographyTest::print_information_3(int _method, int j, int N, const Mat& mask)
{
cout << endl; cout << "Checking for inliers/outliers mask..." << endl; cout << endl;
cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>";
cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl;
cout << "Count of points: " << N << endl; cout << endl;
cout << "Method: RANSAC" << endl;
cout << "Method: "; if (_method == RANSAC) cout << "RANSAC" << endl; else if (_method == cv::RHO) cout << "RHO" << endl; else cout << _method << endl;
cout << "Found mask:" << endl; cout << endl;
cout << mask << endl; cout << endl;
cout << "Number of rows: " << mask.rows << " Number of cols: " << mask.cols << endl; cout << endl;
@@ -205,10 +205,10 @@ void CV_HomographyTest::print_information_5(int _method, int j, int N, int l, do
cout << "Maxumum allowed difference: " << max_diff << endl; cout << endl;
}
void CV_HomographyTest::print_information_6(int j, int N, int k, double diff, bool value)
void CV_HomographyTest::print_information_6(int _method, int j, int N, int k, double diff, bool value)
{
cout << endl; cout << "Checking for inliers/outliers mask..." << endl; cout << endl;
cout << "Method: RANSAC" << endl;
cout << "Method: "; if (_method == RANSAC) cout << "RANSAC" << endl; else if (_method == cv::RHO) cout << "RHO" << endl; else cout << _method << endl;
cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>";
cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl;
cout << "Count of points: " << N << " " << endl;
@@ -218,10 +218,10 @@ void CV_HomographyTest::print_information_6(int j, int N, int k, double diff, bo
cout << "Value of found mask: "<< value << endl; cout << endl;
}
void CV_HomographyTest::print_information_7(int j, int N, int k, double diff, bool original_value, bool found_value)
void CV_HomographyTest::print_information_7(int _method, int j, int N, int k, double diff, bool original_value, bool found_value)
{
cout << endl; cout << "Checking for inliers/outliers mask..." << endl; cout << endl;
cout << "Method: RANSAC" << endl;
cout << "Method: "; if (_method == RANSAC) cout << "RANSAC" << endl; else if (_method == cv::RHO) cout << "RHO" << endl; else cout << _method << endl;
cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>";
cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl;
cout << "Count of points: " << N << " " << endl;
@@ -231,10 +231,10 @@ void CV_HomographyTest::print_information_7(int j, int N, int k, double diff, bo
cout << "Value of original mask: "<< original_value << " Value of found mask: " << found_value << endl; cout << endl;
}
void CV_HomographyTest::print_information_8(int j, int N, int k, int l, double diff)
void CV_HomographyTest::print_information_8(int _method, int j, int N, int k, int l, double diff)
{
cout << endl; cout << "Checking for reprojection error of inlier..." << endl; cout << endl;
cout << "Method: RANSAC" << endl;
cout << "Method: "; if (_method == RANSAC) cout << "RANSAC" << endl; else if (_method == cv::RHO) cout << "RHO" << endl; else cout << _method << endl;
cout << "Sigma of normal noise: " << sigma << endl;
cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>";
cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl;
@@ -371,7 +371,7 @@ void CV_HomographyTest::run(int)
if (code)
{
print_information_3(j, N, mask[j]);
print_information_3(method, j, N, mask[j]);
switch (code)
{
@@ -490,7 +490,7 @@ void CV_HomographyTest::run(int)
if (code)
{
print_information_3(j, N, mask_res[j]);
print_information_3(method, j, N, mask_res[j]);
switch (code)
{
@@ -522,14 +522,14 @@ void CV_HomographyTest::run(int)
if (mask_res[j].at<bool>(k, 0) != (diff <= reproj_threshold))
{
print_information_6(j, N, k, diff, mask_res[j].at<bool>(k, 0));
print_information_6(method, j, N, k, diff, mask_res[j].at<bool>(k, 0));
CV_Error(CALIB3D_HOMOGRAPHY_ERROR_RANSAC_MASK, MESSAGE_RANSAC_MASK_4);
return;
}
if (mask.at<bool>(k, 0) && !mask_res[j].at<bool>(k, 0))
{
print_information_7(j, N, k, diff, mask.at<bool>(k, 0), mask_res[j].at<bool>(k, 0));
print_information_7(method, j, N, k, diff, mask.at<bool>(k, 0), mask_res[j].at<bool>(k, 0));
CV_Error(CALIB3D_HOMOGRAPHY_ERROR_RANSAC_MASK, MESSAGE_RANSAC_MASK_5);
return;
}
@@ -549,7 +549,7 @@ void CV_HomographyTest::run(int)
if (diff - cv::norm(noise_2d, NORM_TYPE[l]) > max_2diff)
{
print_information_8(j, N, k, l, diff - cv::norm(noise_2d, NORM_TYPE[l]));
print_information_8(method, j, N, k, l, diff - cv::norm(noise_2d, NORM_TYPE[l]));
CV_Error(CALIB3D_HOMOGRAPHY_ERROR_RANSAC_DIFF, MESSAGE_RANSAC_DIFF);
return;
}