Converted to C++ style, + bugfixes.
The code has been refactored in response to feedback on Pull Request Also, outputZeroH() now also zeroes the inlier set, much like outputModel().
This commit is contained in:
parent
87c2b8197a
commit
adac8c04bb
@ -303,8 +303,7 @@ static bool createAndRunRHORegistrator(double confidence,
|
|||||||
* initialized, used, then finalized.
|
* initialized, used, then finalized.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RHO_HEST_REFC p;
|
RHO_HEST_REFC* p = rhoRefCInit();
|
||||||
rhoRefCInit(&p);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional. Ideally, the context would survive across calls to
|
* 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.
|
* 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.
|
* 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.
|
* this behaviour is too problematic.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
result = !!rhoRefC(&p,
|
result = !!rhoRefC(p,
|
||||||
(const float*)src.data,
|
(const float*)src.data,
|
||||||
(const float*)dst.data,
|
(const float*)dst.data,
|
||||||
(char*) tempMask.data,
|
(char*) tempMask.data,
|
||||||
@ -344,7 +343,7 @@ static bool createAndRunRHORegistrator(double confidence,
|
|||||||
* Cleanup.
|
* Cleanup.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rhoRefCFini(&p);
|
rhoRefCFini(p);
|
||||||
|
|
||||||
/* Convert float homography to double precision. */
|
/* Convert float homography to double precision. */
|
||||||
tmpH.convertTo(_H, CV_64FC1);
|
tmpH.convertTo(_H, CV_64FC1);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -56,7 +56,6 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Defines */
|
/* Defines */
|
||||||
#ifdef __cplusplus
|
|
||||||
|
|
||||||
/* C++ does not have the restrict keyword. */
|
/* C++ does not have the restrict keyword. */
|
||||||
#ifdef restrict
|
#ifdef restrict
|
||||||
@ -64,15 +63,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#define restrict
|
#define restrict
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* C99 and over has the restrict keyword. */
|
|
||||||
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
|
|
||||||
#define restrict
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Flags */
|
/* Flags */
|
||||||
#ifndef RHO_FLAG_NONE
|
#ifndef RHO_FLAG_NONE
|
||||||
@ -90,101 +80,17 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Namespace cv */
|
||||||
|
namespace cv{
|
||||||
|
|
||||||
/* Data structures */
|
/* Data structures */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Homography Estimation context.
|
* Homography Estimation context.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct{
|
struct RHO_HEST_REFC;
|
||||||
/**
|
typedef struct RHO_HEST_REFC RHO_HEST_REFC;
|
||||||
* 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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
@ -193,11 +99,10 @@ namespace cv{
|
|||||||
* Initialize the estimator context, by allocating the aligned buffers
|
* Initialize the estimator context, by allocating the aligned buffers
|
||||||
* internally needed.
|
* internally needed.
|
||||||
*
|
*
|
||||||
* @param [in/out] p The uninitialized estimator context to initialize.
|
* @return A pointer to the context if successful; NULL if an error occured.
|
||||||
* @return 0 if successful; non-zero 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 */
|
/* End Namespace cv */
|
||||||
#ifdef __cplusplus
|
|
||||||
/* } *//* End extern "C" */
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user