Skip to content

Commit

Permalink
Merge pull request opencv#23900 from kai-waang:fixing-typo
Browse files Browse the repository at this point in the history
Fixing typos in usac opencv#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
  • Loading branch information
kai-waang authored Jul 3, 2023
1 parent 64be9c8 commit 0661aff
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion modules/calib3d/src/usac/degeneracy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class HomographyDegeneracyImpl : public HomographyDegeneracy {
return false;

// 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|
// (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|
Expand Down
2 changes: 1 addition & 1 deletion modules/calib3d/src/usac/essential_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class EssentialMinimalSolver5ptsImpl : public EssentialMinimalSolver5pts {
}

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)
// 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]);
Expand Down
4 changes: 2 additions & 2 deletions modules/calib3d/src/usac/fundamental_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ class CovarianceEpipolarSolverImpl : public CovarianceEpipolarSolver {
explicit CovarianceEpipolarSolverImpl (const Mat &points_, bool is_fundamental_) {
points_size = points_.rows;
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);
for (int i = 0; i < points_size; i++) sample[i] = i;
const Ptr<NormTransform> normTr = NormTransform::create(points_);
Expand Down Expand Up @@ -558,7 +558,7 @@ class LarssonOptimizerImpl : public LarssonOptimizer {
const auto * const pts_ = (float *) calib_points.data;
// a few point are enough to test
// 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
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);
Expand Down
4 changes: 2 additions & 2 deletions modules/calib3d/src/usac/pnp_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class PnPNonMinimalSolverImpl : public PnPNonMinimalSolver {
a2[10] = v * Z;
a2[11] = v;

// fill covarinace matrix
// fill covariance matrix
for (int j = 0; j < 12; j++)
for (int z = j; z < 12; z++)
AtA[j * 12 + z] += a1[j] * a1[z] + a2[j] * a2[z];
Expand Down Expand Up @@ -227,7 +227,7 @@ class PnPNonMinimalSolverImpl : public PnPNonMinimalSolver {
a2[10] = v * weight_Z;
a2[11] = v * weight;

// fill covarinace matrix
// fill covariance matrix
for (int j = 0; j < 12; j++)
for (int z = j; z < 12; z++)
AtA[j * 12 + z] += a1[j] * a1[z] + a2[j] * a2[z];
Expand Down
2 changes: 1 addition & 1 deletion modules/calib3d/src/usac/ransac_solvers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class Ransac {
params->getUpperIncompleteOfSigmaQuantile()); break;
case ScoreMethod::SCORE_METHOD_LMEDS :
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;
Expand Down
8 changes: 4 additions & 4 deletions modules/calib3d/src/usac/sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ Ptr<UniformSampler> UniformSampler::create(int state, int sample_size_, int poin
/////////////////////////////////// PROSAC (SIMPLE) SAMPLER ///////////////////////////////////////
/*
* 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.
* Also, the stopping length (or maximum subset size n*) by default is set to points_size (N) and does not updating
* 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 update
* during computation.
*/
class ProsacSimpleSamplerImpl : public ProsacSimpleSampler {
Expand Down Expand Up @@ -176,7 +176,7 @@ class ProsacSamplerImpl : public ProsacSampler {
// In our experiments, the parameter was set to T_N = 200000
int growth_max_samples;

// how many time PROSAC generateSample() was called
// how many times PROSAC generateSample() was called
int kth_sample_number;
Ptr<UniformRandomGenerator> random_gen;
public:
Expand Down Expand Up @@ -488,7 +488,7 @@ class NapsacSamplerImpl : public NapsacSampler {

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++)
if ((int)neighborhood_graph->getNeighbors(pt_idx).size() >= sample_size-1)
points_large_neighborhood[points_large_neighborhood_size++] = pt_idx;
Expand Down
2 changes: 1 addition & 1 deletion modules/calib3d/src/usac/termination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class StandardTerminationCriteriaImpl : public StandardTerminationCriteria {

/*
* 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,
* k = log_(1-w^n) (1-p)
* k = ln (1-p) / ln (1-w^n)
Expand Down
4 changes: 2 additions & 2 deletions modules/calib3d/src/usac/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,10 @@ void Utils::decomposeProjection (const Mat &P, Matx33d &K, Matx33d &R, Vec3d &t,
}

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++) {
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
break;
}
Expand Down

0 comments on commit 0661aff

Please sign in to comment.