mirror of
https://github.com/opencv/opencv.git
synced 2025-06-08 01:53:19 +08:00
Merge pull request #23900 from kai-waang:fixing-typo
Fixing typos in usac #23900 Just read and correct some typos in `usac` ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
parent
64be9c8bf6
commit
0661aff4a5
@ -112,7 +112,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Checks if points are not collinear
|
// Checks if points are not collinear
|
||||||
// If area of triangle constructed with 3 points is less then threshold then points are collinear:
|
// If area of triangle constructed with 3 points is less than threshold then points are collinear:
|
||||||
// |x1 y1 1| |x1 y1 1|
|
// |x1 y1 1| |x1 y1 1|
|
||||||
// (1/2) det |x2 y2 1| = (1/2) det |x2-x1 y2-y1 0| = det |x2-x1 y2-y1| < 2 * threshold
|
// (1/2) det |x2 y2 1| = (1/2) det |x2-x1 y2-y1 0| = det |x2-x1 y2-y1| < 2 * threshold
|
||||||
// |x3 y3 1| |x3-x1 y3-y1 0| |x3-x1 y3-y1|
|
// |x3 y3 1| |x3-x1 y3-y1 0| |x3-x1 y3-y1|
|
||||||
|
@ -142,7 +142,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<double> c(11), rs;
|
std::vector<double> c(11), rs;
|
||||||
// filling coefficients of 10-degree polynomial satysfying zero-determinant constraint of essential matrix, ie., det(E) = 0
|
// filling coefficients of 10-degree polynomial satisfying zero-determinant constraint of essential matrix, ie., det(E) = 0
|
||||||
// based on "An Efficient Solution to the Five-Point Relative Pose Problem" (David Nister)
|
// based on "An Efficient Solution to the Five-Point Relative Pose Problem" (David Nister)
|
||||||
// same as in five-point.cpp
|
// same as in five-point.cpp
|
||||||
c[10] = (b[0]*b[17]*b[34]+b[26]*b[4]*b[21]-b[26]*b[17]*b[8]-b[13]*b[4]*b[34]-b[0]*b[21]*b[30]+b[13]*b[30]*b[8]);
|
c[10] = (b[0]*b[17]*b[34]+b[26]*b[4]*b[21]-b[26]*b[17]*b[8]-b[13]*b[4]*b[34]-b[0]*b[21]*b[30]+b[13]*b[30]*b[8]);
|
||||||
|
@ -438,7 +438,7 @@ public:
|
|||||||
explicit CovarianceEpipolarSolverImpl (const Mat &points_, bool is_fundamental_) {
|
explicit CovarianceEpipolarSolverImpl (const Mat &points_, bool is_fundamental_) {
|
||||||
points_size = points_.rows;
|
points_size = points_.rows;
|
||||||
is_fundamental = is_fundamental_;
|
is_fundamental = is_fundamental_;
|
||||||
if (is_fundamental) { // normalize image points only for fundmantal matrix
|
if (is_fundamental) { // normalize image points only for fundamental matrix
|
||||||
std::vector<int> sample(points_size);
|
std::vector<int> sample(points_size);
|
||||||
for (int i = 0; i < points_size; i++) sample[i] = i;
|
for (int i = 0; i < points_size; i++) sample[i] = i;
|
||||||
const Ptr<NormTransform> normTr = NormTransform::create(points_);
|
const Ptr<NormTransform> normTr = NormTransform::create(points_);
|
||||||
@ -558,7 +558,7 @@ public:
|
|||||||
const auto * const pts_ = (float *) calib_points.data;
|
const auto * const pts_ = (float *) calib_points.data;
|
||||||
// a few point are enough to test
|
// a few point are enough to test
|
||||||
// actually due to Sampson error minimization, the input R,t do not really matter
|
// actually due to Sampson error minimization, the input R,t do not really matter
|
||||||
// for a correct pair there is a sligthly faster convergence
|
// for a correct pair there is a slightly faster convergence
|
||||||
for (int i = 0; i < 3; i++) { // could be 1 point
|
for (int i = 0; i < 3; i++) { // could be 1 point
|
||||||
const int rand_inl = 4 * sample[rng.uniform(0, sample_size)];
|
const int rand_inl = 4 * sample[rng.uniform(0, sample_size)];
|
||||||
Vec3d p1 (pts_[rand_inl], pts_[rand_inl+1], 1), p2(pts_[rand_inl+2], pts_[rand_inl+3], 1);
|
Vec3d p1 (pts_[rand_inl], pts_[rand_inl+1], 1), p2(pts_[rand_inl+2], pts_[rand_inl+3], 1);
|
||||||
|
@ -196,7 +196,7 @@ public:
|
|||||||
a2[10] = v * Z;
|
a2[10] = v * Z;
|
||||||
a2[11] = v;
|
a2[11] = v;
|
||||||
|
|
||||||
// fill covarinace matrix
|
// fill covariance matrix
|
||||||
for (int j = 0; j < 12; j++)
|
for (int j = 0; j < 12; j++)
|
||||||
for (int z = j; z < 12; z++)
|
for (int z = j; z < 12; z++)
|
||||||
AtA[j * 12 + z] += a1[j] * a1[z] + a2[j] * a2[z];
|
AtA[j * 12 + z] += a1[j] * a1[z] + a2[j] * a2[z];
|
||||||
@ -227,7 +227,7 @@ public:
|
|||||||
a2[10] = v * weight_Z;
|
a2[10] = v * weight_Z;
|
||||||
a2[11] = v * weight;
|
a2[11] = v * weight;
|
||||||
|
|
||||||
// fill covarinace matrix
|
// fill covariance matrix
|
||||||
for (int j = 0; j < 12; j++)
|
for (int j = 0; j < 12; j++)
|
||||||
for (int z = j; z < 12; z++)
|
for (int z = j; z < 12; z++)
|
||||||
AtA[j * 12 + z] += a1[j] * a1[z] + a2[j] * a2[z];
|
AtA[j * 12 + z] += a1[j] * a1[z] + a2[j] * a2[z];
|
||||||
|
@ -294,7 +294,7 @@ public:
|
|||||||
params->getUpperIncompleteOfSigmaQuantile()); break;
|
params->getUpperIncompleteOfSigmaQuantile()); break;
|
||||||
case ScoreMethod::SCORE_METHOD_LMEDS :
|
case ScoreMethod::SCORE_METHOD_LMEDS :
|
||||||
quality = LMedsQuality::create(points_size, threshold, error); break;
|
quality = LMedsQuality::create(points_size, threshold, error); break;
|
||||||
default: CV_Error(cv::Error::StsNotImplemented, "Score is not imeplemeted!");
|
default: CV_Error(cv::Error::StsNotImplemented, "Score is not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto is_ge_solver = params->getRansacSolver() == GEM_SOLVER;
|
const auto is_ge_solver = params->getRansacSolver() == GEM_SOLVER;
|
||||||
|
@ -62,8 +62,8 @@ Ptr<UniformSampler> UniformSampler::create(int state, int sample_size_, int poin
|
|||||||
/////////////////////////////////// PROSAC (SIMPLE) SAMPLER ///////////////////////////////////////
|
/////////////////////////////////// PROSAC (SIMPLE) SAMPLER ///////////////////////////////////////
|
||||||
/*
|
/*
|
||||||
* PROSAC (simple) sampler does not use array of precalculated T_n (n is subset size) samples, but computes T_n for
|
* PROSAC (simple) sampler does not use array of precalculated T_n (n is subset size) samples, but computes T_n for
|
||||||
* specific n directy in generateSample() function.
|
* specific n directly in generateSample() function.
|
||||||
* Also, the stopping length (or maximum subset size n*) by default is set to points_size (N) and does not updating
|
* Also, the stopping length (or maximum subset size n*) by default is set to points_size (N) and does not update
|
||||||
* during computation.
|
* during computation.
|
||||||
*/
|
*/
|
||||||
class ProsacSimpleSamplerImpl : public ProsacSimpleSampler {
|
class ProsacSimpleSamplerImpl : public ProsacSimpleSampler {
|
||||||
@ -176,7 +176,7 @@ protected:
|
|||||||
// In our experiments, the parameter was set to T_N = 200000
|
// In our experiments, the parameter was set to T_N = 200000
|
||||||
int growth_max_samples;
|
int growth_max_samples;
|
||||||
|
|
||||||
// how many time PROSAC generateSample() was called
|
// how many times PROSAC generateSample() was called
|
||||||
int kth_sample_number;
|
int kth_sample_number;
|
||||||
Ptr<UniformRandomGenerator> random_gen;
|
Ptr<UniformRandomGenerator> random_gen;
|
||||||
public:
|
public:
|
||||||
@ -488,7 +488,7 @@ public:
|
|||||||
|
|
||||||
points_large_neighborhood_size = 0;
|
points_large_neighborhood_size = 0;
|
||||||
|
|
||||||
// find indicies of points that have sufficient neighborhood (at least sample_size-1)
|
// find indices of points that have sufficient neighborhood (at least sample_size-1)
|
||||||
for (int pt_idx = 0; pt_idx < points_size; pt_idx++)
|
for (int pt_idx = 0; pt_idx < points_size; pt_idx++)
|
||||||
if ((int)neighborhood_graph->getNeighbors(pt_idx).size() >= sample_size-1)
|
if ((int)neighborhood_graph->getNeighbors(pt_idx).size() >= sample_size-1)
|
||||||
points_large_neighborhood[points_large_neighborhood_size++] = pt_idx;
|
points_large_neighborhood[points_large_neighborhood_size++] = pt_idx;
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Get upper bound iterations for any sample number
|
* Get upper bound iterations for any sample number
|
||||||
* n is points size, w is inlier ratio, p is desired probability, k is expceted number of iterations.
|
* n is points size, w is inlier ratio, p is desired probability, k is expected number of iterations.
|
||||||
* 1 - p = (1 - w^n)^k,
|
* 1 - p = (1 - w^n)^k,
|
||||||
* k = log_(1-w^n) (1-p)
|
* k = log_(1-w^n) (1-p)
|
||||||
* k = ln (1-p) / ln (1-w^n)
|
* k = ln (1-p) / ln (1-w^n)
|
||||||
|
@ -344,10 +344,10 @@ void Utils::decomposeProjection (const Mat &P, Matx33d &K, Matx33d &R, Vec3d &t,
|
|||||||
}
|
}
|
||||||
|
|
||||||
double Utils::getPoissonCDF (double lambda, int inliers) {
|
double Utils::getPoissonCDF (double lambda, int inliers) {
|
||||||
double exp_lamda = exp(-lambda), cdf = exp_lamda, lambda_i_div_fact_i = 1;
|
double exp_lambda = exp(-lambda), cdf = exp_lambda, lambda_i_div_fact_i = 1;
|
||||||
for (int i = 1; i <= inliers; i++) {
|
for (int i = 1; i <= inliers; i++) {
|
||||||
lambda_i_div_fact_i *= (lambda / i);
|
lambda_i_div_fact_i *= (lambda / i);
|
||||||
cdf += exp_lamda * lambda_i_div_fact_i;
|
cdf += exp_lambda * lambda_i_div_fact_i;
|
||||||
if (fabs(cdf - 1) < DBL_EPSILON) // cdf is almost 1
|
if (fabs(cdf - 1) < DBL_EPSILON) // cdf is almost 1
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user