nareshmlx/opencv-pr huggingface dataset:
**File:** modules/calib3d/src/usac.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -6,10 +6,11 @@
 #define OPENCV_USAC_USAC_HPP
 
 namespace cv { namespace usac {
-enum EstimationMethod { Homography, Fundamental, Fundamental8, Essential, Affine, P3P, P6P};
-enum VerificationMethod { NullVerifier, SprtVerifier };
-enum PolishingMethod { NonePolisher, LSQPolisher };
-enum ErrorMetric {DIST_TO_LINE, SAMPSON_ERR, SGD_ERR, SYMM_REPR_ERR, FORW_REPR_ERR, RERPOJ};
+enum EstimationMethod { HOMOGRAPHY=0, FUNDAMENTAL=1, FUNDAMENTAL8=2, ESSENTIAL=3, AFFINE=4, P3P=5, P6P=6};
+enum VerificationMethod { NULL_VERIFIER=0, SPRT_VERIFIER=1, ASPRT=2 };
```

Review comment:
Please do not use greek symbols. It cases issue with some compilers.
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC
**Review Line:** 574

**Code Changes:**
```diff
@@ -569,6 +570,8 @@ struct CV_EXPORTS_W_SIMPLE UsacParams
     CV_PROP_RW SamplingMethod sampler;
     CV_PROP_RW ScoreMethod score;
     CV_PROP_RW double threshold;
+    CV_PROP_RW PolishingMethod final_polisher;
+    CV_PROP_RW int final_polisher_iterations;
 };
 
 /** @brief Converts a rotation matrix to a rotation vector or vice versa.
```

Review comment:
Please add initialization to constructor.
**File:** modules/calib3d/src/usac.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -6,10 +6,11 @@
 #define OPENCV_USAC_USAC_HPP
 
 namespace cv { namespace usac {
-enum EstimationMethod { Homography, Fundamental, Fundamental8, Essential, Affine, P3P, P6P};
-enum VerificationMethod { NullVerifier, SprtVerifier };
-enum PolishingMethod { NonePolisher, LSQPolisher };
-enum ErrorMetric {DIST_TO_LINE, SAMPSON_ERR, SGD_ERR, SYMM_REPR_ERR, FORW_REPR_ERR, RERPOJ};
+enum EstimationMethod { HOMOGRAPHY=0, FUNDAMENTAL=1, FUNDAMENTAL8=2, ESSENTIAL=3, AFFINE=4, P3P=5, P6P=6};
+enum VerificationMethod { NULL_VERIFIER=0, SPRT_VERIFIER=1, ASPRT=2 };
```

Review comment:
why not `virtual int estimate (..)= 0`?
**File:** modules/calib3d/src/usac.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -6,10 +6,11 @@
 #define OPENCV_USAC_USAC_HPP
 
 namespace cv { namespace usac {
-enum EstimationMethod { Homography, Fundamental, Fundamental8, Essential, Affine, P3P, P6P};
-enum VerificationMethod { NullVerifier, SprtVerifier };
-enum PolishingMethod { NonePolisher, LSQPolisher };
-enum ErrorMetric {DIST_TO_LINE, SAMPSON_ERR, SGD_ERR, SYMM_REPR_ERR, FORW_REPR_ERR, RERPOJ};
+enum EstimationMethod { HOMOGRAPHY=0, FUNDAMENTAL=1, FUNDAMENTAL8=2, ESSENTIAL=3, AFFINE=4, P3P=5, P6P=6};
+enum VerificationMethod { NULL_VERIFIER=0, SPRT_VERIFIER=1, ASPRT=2 };
```

Review comment:
why not `= 0`?
**File:** modules/calib3d/src/usac.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -6,10 +6,11 @@
 #define OPENCV_USAC_USAC_HPP
 
 namespace cv { namespace usac {
-enum EstimationMethod { Homography, Fundamental, Fundamental8, Essential, Affine, P3P, P6P};
-enum VerificationMethod { NullVerifier, SprtVerifier };
-enum PolishingMethod { NonePolisher, LSQPolisher };
-enum ErrorMetric {DIST_TO_LINE, SAMPSON_ERR, SGD_ERR, SYMM_REPR_ERR, FORW_REPR_ERR, RERPOJ};
+enum EstimationMethod { HOMOGRAPHY=0, FUNDAMENTAL=1, FUNDAMENTAL8=2, ESSENTIAL=3, AFFINE=4, P3P=5, P6P=6};
+enum VerificationMethod { NULL_VERIFIER=0, SPRT_VERIFIER=1, ASPRT=2 };
```

Review comment:
why not `=0`?
**File:** modules/calib3d/src/usac/bundle.cpp
**Change Type:** added
**Context:** PR #23078: Update USAC
**Review Line:** 1

**Code Changes:**
```diff
@@ -0,0 +1,308 @@
+// Copyright (c) 2020, Viktor Larsson
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
```

Review comment:
What is origin of the file? Does does it make sense to place it as library to 3rd-party? The license text is not Apache 2.0 and we need to mentioned the library, author and license in OpenCv distributions.
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC
**Review Line:** 557

**Code Changes:**
```diff
+        SAMPLING_PROSAC=3 };
+enum LocalOptimMethod {LOCAL_OPTIM_NULL=0, LOCAL_OPTIM_INNER_LO=1, LOCAL_OPTIM_INNER_AND_ITER_LO=2,
+        LOCAL_OPTIM_GC=3, LOCAL_OPTIM_SIGMA=4};
+enum ScoreMethod {SCORE_METHOD_RANSAC=0, SCORE_METHOD_MSAC=1, SCORE_METHOD_MAGSAC=2, SCORE_METHOD_LMEDS=3};
+enum NeighborSearchMethod { NEIGH_FLANN_KNN=0, NEIGH_GRID=1, NEIGH_FLANN_RADIUS=2 };
+enum PolishingMethod { NONE_POLISHER=0, LSQ_POLISHER=1, MAGSAC=2, COV_POLISHER=3 };
 
 struct CV_EXPORTS_W_SIMPLE UsacParams
 { // in alphabetical order
@@ -569,6 +570,8 @@ struct CV_EXPORTS_W_SIMPLE UsacParams
     CV_PROP_RW SamplingMethod sampler;
```

Review comment:
Uniform "prefix" should be used for constants.
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -548,12 +548,13 @@ enum RobotWorldHandEyeCalibrationMethod
     CALIB_ROBOT_WORLD_HAND_EYE_LI   = 1  //!< Simultaneous robot-world and hand-eye calibration using dual-quaternions and kronecker product @cite Li2010SimultaneousRA
 };
 
-enum SamplingMethod { SAMPLING_UNIFORM, SAMPLING_PROGRESSIVE_NAPSAC, SAMPLING_NAPSAC,
-        SAMPLING_PROSAC };
-enum LocalOptimMethod {LOCAL_OPTIM_NULL, LOCAL_OPTIM_INNER_LO, LOCAL_OPTIM_INNER_AND_ITER_LO,
-        LOCAL_OPTIM_GC, LOCAL_OPTIM_SIGMA};
-enum ScoreMethod {SCORE_METHOD_RANSAC, SCORE_METHOD_MSAC, SCORE_METHOD_MAGSAC, SCORE_METHOD_LMEDS};
-enum NeighborSearchMethod { NEIGH_FLANN_KNN, NEIGH_GRID, NEIGH_FLANN_RADIUS };
```

Review comment:
It is better to keep params initialization in .cpp files (like other algorithms)
**File:** modules/calib3d/src/usac/bundle.cpp
**Change Type:** added
**Context:** PR #23078: Update USAC
**Review Line:** 1

**Code Changes:**
```diff
@@ -0,0 +1,308 @@
+// Copyright (c) 2020, Viktor Larsson
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
```

Review comment:
Discussed the issue on OpenCV core meeting. Decided to stay it as is. Sory for disturbance.
**File:** modules/calib3d/src/usac.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -6,10 +6,11 @@
 #define OPENCV_USAC_USAC_HPP
 
 namespace cv { namespace usac {
-enum EstimationMethod { Homography, Fundamental, Fundamental8, Essential, Affine, P3P, P6P};
-enum VerificationMethod { NullVerifier, SprtVerifier };
-enum PolishingMethod { NonePolisher, LSQPolisher };
-enum ErrorMetric {DIST_TO_LINE, SAMPSON_ERR, SGD_ERR, SYMM_REPR_ERR, FORW_REPR_ERR, RERPOJ};
+enum EstimationMethod { HOMOGRAPHY=0, FUNDAMENTAL=1, FUNDAMENTAL8=2, ESSENTIAL=3, AFFINE=4, P3P=5, P6P=6};
+enum VerificationMethod { NULL_VERIFIER=0, SPRT_VERIFIER=1, ASPRT=2 };
```

Review comment:
the function is quite sparse and not used in many classes. However, I made it virtual.
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC
**Review Line:** 557

**Code Changes:**
```diff
+        SAMPLING_PROSAC=3 };
+enum LocalOptimMethod {LOCAL_OPTIM_NULL=0, LOCAL_OPTIM_INNER_LO=1, LOCAL_OPTIM_INNER_AND_ITER_LO=2,
+        LOCAL_OPTIM_GC=3, LOCAL_OPTIM_SIGMA=4};
+enum ScoreMethod {SCORE_METHOD_RANSAC=0, SCORE_METHOD_MSAC=1, SCORE_METHOD_MAGSAC=2, SCORE_METHOD_LMEDS=3};
+enum NeighborSearchMethod { NEIGH_FLANN_KNN=0, NEIGH_GRID=1, NEIGH_FLANN_RADIUS=2 };
+enum PolishingMethod { NONE_POLISHER=0, LSQ_POLISHER=1, MAGSAC=2, COV_POLISHER=3 };
 
 struct CV_EXPORTS_W_SIMPLE UsacParams
 { // in alphabetical order
@@ -569,6 +570,8 @@ struct CV_EXPORTS_W_SIMPLE UsacParams
     CV_PROP_RW SamplingMethod sampler;
```

Review comment:
what "prefix" should I use in this case?
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC
**Review Line:** 557

**Code Changes:**
```diff
+        SAMPLING_PROSAC=3 };
+enum LocalOptimMethod {LOCAL_OPTIM_NULL=0, LOCAL_OPTIM_INNER_LO=1, LOCAL_OPTIM_INNER_AND_ITER_LO=2,
+        LOCAL_OPTIM_GC=3, LOCAL_OPTIM_SIGMA=4};
+enum ScoreMethod {SCORE_METHOD_RANSAC=0, SCORE_METHOD_MSAC=1, SCORE_METHOD_MAGSAC=2, SCORE_METHOD_LMEDS=3};
+enum NeighborSearchMethod { NEIGH_FLANN_KNN=0, NEIGH_GRID=1, NEIGH_FLANN_RADIUS=2 };
+enum PolishingMethod { NONE_POLISHER=0, LSQ_POLISHER=1, MAGSAC=2, COV_POLISHER=3 };
 
 struct CV_EXPORTS_W_SIMPLE UsacParams
 { // in alphabetical order
@@ -569,6 +570,8 @@ struct CV_EXPORTS_W_SIMPLE UsacParams
     CV_PROP_RW SamplingMethod sampler;
```

Review comment:
It's public interface part. Let's presume constant names.
**File:** modules/calib3d/src/usac.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -6,10 +6,11 @@
 #define OPENCV_USAC_USAC_HPP
 
 namespace cv { namespace usac {
-enum EstimationMethod { Homography, Fundamental, Fundamental8, Essential, Affine, P3P, P6P};
-enum VerificationMethod { NullVerifier, SprtVerifier };
-enum PolishingMethod { NonePolisher, LSQPolisher };
-enum ErrorMetric {DIST_TO_LINE, SAMPSON_ERR, SGD_ERR, SYMM_REPR_ERR, FORW_REPR_ERR, RERPOJ};
+enum EstimationMethod { HOMOGRAPHY=0, FUNDAMENTAL=1, FUNDAMENTAL8=2, ESSENTIAL=3, AFFINE=4, P3P=5, P6P=6};
+enum VerificationMethod { NULL_VERIFIER=0, SPRT_VERIFIER=1, ASPRT=2 };
```

Review comment:
Please align naming with other enums.
**File:** modules/calib3d/src/usac.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -6,10 +6,11 @@
 #define OPENCV_USAC_USAC_HPP
 
 namespace cv { namespace usac {
-enum EstimationMethod { Homography, Fundamental, Fundamental8, Essential, Affine, P3P, P6P};
-enum VerificationMethod { NullVerifier, SprtVerifier };
-enum PolishingMethod { NonePolisher, LSQPolisher };
-enum ErrorMetric {DIST_TO_LINE, SAMPSON_ERR, SGD_ERR, SYMM_REPR_ERR, FORW_REPR_ERR, RERPOJ};
+enum EstimationMethod { HOMOGRAPHY=0, FUNDAMENTAL=1, FUNDAMENTAL8=2, ESSENTIAL=3, AFFINE=4, P3P=5, P6P=6};
+enum VerificationMethod { NULL_VERIFIER=0, SPRT_VERIFIER=1, ASPRT=2 };
```

Review comment:
virtual = 0? If not, I propose to use `CV_UNUSED()` macro for all params.
**File:** modules/calib3d/src/usac.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -6,10 +6,11 @@
 #define OPENCV_USAC_USAC_HPP
 
 namespace cv { namespace usac {
-enum EstimationMethod { Homography, Fundamental, Fundamental8, Essential, Affine, P3P, P6P};
-enum VerificationMethod { NullVerifier, SprtVerifier };
-enum PolishingMethod { NonePolisher, LSQPolisher };
-enum ErrorMetric {DIST_TO_LINE, SAMPSON_ERR, SGD_ERR, SYMM_REPR_ERR, FORW_REPR_ERR, RERPOJ};
+enum EstimationMethod { HOMOGRAPHY=0, FUNDAMENTAL=1, FUNDAMENTAL8=2, ESSENTIAL=3, AFFINE=4, P3P=5, P6P=6};
+enum VerificationMethod { NULL_VERIFIER=0, SPRT_VERIFIER=1, ASPRT=2 };
```

Review comment:
restore parameter name.
**File:** modules/calib3d/src/usac.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -6,10 +6,11 @@
 #define OPENCV_USAC_USAC_HPP
 
 namespace cv { namespace usac {
-enum EstimationMethod { Homography, Fundamental, Fundamental8, Essential, Affine, P3P, P6P};
-enum VerificationMethod { NullVerifier, SprtVerifier };
-enum PolishingMethod { NonePolisher, LSQPolisher };
-enum ErrorMetric {DIST_TO_LINE, SAMPSON_ERR, SGD_ERR, SYMM_REPR_ERR, FORW_REPR_ERR, RERPOJ};
+enum EstimationMethod { HOMOGRAPHY=0, FUNDAMENTAL=1, FUNDAMENTAL8=2, ESSENTIAL=3, AFFINE=4, P3P=5, P6P=6};
+enum VerificationMethod { NULL_VERIFIER=0, SPRT_VERIFIER=1, ASPRT=2 };
```

Review comment:
restore parameters name.
**File:** modules/calib3d/src/usac/degeneracy.cpp
**Change Type:** modified
**Context:** PR #23078: Update USAC
**Review Line:** 16

**Code Changes:**
```diff
@@ -13,7 +13,7 @@ class EpipolarGeometryDegeneracyImpl : public EpipolarGeometryDegeneracy {
     const int min_sample_size;
 public:
     explicit EpipolarGeometryDegeneracyImpl (const Mat &points_, int sample_size_) :
-        points_mat(&points_), points ((float*) points_.data), min_sample_size (sample_size_) {}
+        points_mat(&points_), points ((float*) points_mat->data), min_sample_size (sample_size_) {}
     /*
      * Do oriented constraint to verify if epipolar geometry is in front or behind the camera.
      * Return: true if all points are in front of the camers w.r.t. tested epipolar geometry - satisfies constraint.
@@ -23,39 +23,27 @@ class EpipolarGeometryDegeneracyImpl : public EpipolarGeometryDegeneracy {
      * e  × x ~+ x'^T F
```

Review comment:
Why `points_mat` is a pointer? In case if, your are 100% sure that it's not removed object usage, you can store it as `const Mat&` field with initialization in constructor initialization list. If not - please store a copy of `cv::Mat`. It works as smart pointer and relatively lightweight. Also `const float * const points` is dangerous. It may be re-allocated, if something happens with Mat. We'll get "use-after-free" issue. I would say, that points field is redundant. You always create local pointer in method from `Mat::data`.
**File:** modules/calib3d/src/usac/degeneracy.cpp
**Change Type:** modified
**Context:** PR #23078: Update USAC
**Review Line:** 71

**Code Changes:**
```diff
 void EpipolarGeometryDegeneracy::recoverRank (Mat &model, bool is_fundamental_mat) {
     /*
@@ -81,9 +69,10 @@ class HomographyDegeneracyImpl : public HomographyDegeneracy {
 private:
     const Mat * points_mat;
     const float * const points;
+    const float TOLERANCE = 2 * FLT_EPSILON; // 2 from area of triangle
 public:
     explicit HomographyDegeneracyImpl (const Mat &points_) :
-            points_mat(&points_), points ((float *)points_.data) {}
+            points_mat(&points_), points ((float *)points_mat->data) {}
```

Review comment:
The same for `points_mat`, `points` here and all places in inheritance hierarchy.
**File:** modules/calib3d/src/usac/dls_solver.cpp
**Change Type:** modified
**Context:** PR #23078: Update USAC
**Review Line:** 52

**Code Changes:**
```diff
 namespace cv { namespace usac {
-// This is the estimator class for estimating a homography matrix between two images. A model estimation method and error calculation method are implemented
 class DLSPnPImpl : public DLSPnP {
+#if defined(HAVE_LAPACK) || defined(HAVE_EIGEN)
 private:
     const Mat * points_mat, * calib_norm_points_mat;
-    const Matx33d * K_mat;
-#if defined(HAVE_LAPACK) || defined(HAVE_EIGEN)
-    const Matx33d &K;
+    const Matx33d K;
     const float * const calib_norm_points, * const points;
```

Review comment:
The same thing on Mat pointer.
**File:** modules/calib3d/src/usac/fundamental_solver.cpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -4,19 +4,20 @@
 
 #include "../precomp.hpp"
 #include "../usac.hpp"
+#include "../polynom_solver.h"
 #ifdef HAVE_EIGEN
 #include <Eigen/Eigen>
 #endif
 
 namespace cv { namespace usac {
```

Review comment:
The same on pointers.
**File:** modules/calib3d/src/usac/utils.cpp
**Change Type:** modified
**Context:** PR #23078: Update USAC
**Review Line:** 15

**Code Changes:**
```diff
-                         K2(0, 0) + K2(1, 1)) / 4.0);
+/*
+SolvePoly is used to find only real roots of N-degree polynomial using Sturm sequence.
+It recursively finds interval where a root lies, and the actual root is found using Regula-Falsi method.
+*/
+class SolvePoly : public SolverPoly {
+private:
+    static int sgn(double val) {
+        return (double(0) < val) - (val < double(0));
+    }
+    class Poly {
```

Review comment:
What method is used here? There is `cv::SolvePoly` https://docs.opencv.org/4.x/d2/de8/group__core__array.html#gac2f5e953016fabcdf793d762f4ec5dce. cv::SolvePoly implementation depends on initial value and may not converge. It case if the proposed implementation does not have this issue, I propose to update replace `cv::SolvePoly` with your impl and reuse it here.
**File:** modules/calib3d/src/usac/termination.cpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -28,7 +28,8 @@ class StandardTerminationCriteriaImpl : public StandardTerminationCriteria {
      * (1 - w^n) is probability that at least one point of N is outlier.
      * 1 - p = (1-w^n)^k is probability that in K steps of getting at least one outlier is 1% (5%).
      */
-    int update (const Mat &/*model*/, int inlier_number) override {
+    int update (const Mat &model, int inlier_number) const override {
+        CV_UNUSED(model);
         const double predicted_iters = log_confidence / log(1 - std::pow
             (static_cast<double>(inlier_number) / points_size, sample_size));
 
```

Review comment:
`CV_UNUSED`
**File:** modules/calib3d/src/usac/local_optimization.cpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -22,14 +22,18 @@ class GraphCutImpl : public GraphCut {
     std::vector<double> energies, weights;
     std::vector<bool> used_edges;
     std::vector<Mat> gc_models;
+
+    Ptr<Termination> termination;
+    int num_lo_optimizations = 0, current_ransac_iter = 0;
 public:
+    void setCurrentRANSACiter (int ransac_iter) override { current_ransac_iter = ransac_iter; }
 
```

Review comment:
It's not clear from name why you need the second generator.
**File:** modules/calib3d/test/test_usac.cpp
**Change Type:** modified
**Context:** PR #23078: Update USAC
**Review Line:** 362

**Code Changes:**
```diff
                 FAIL() << "Essential matrix estimation failed!\n";
             else continue;
         }
-        EXPECT_NE(roll_results_sum, 0);
     }
+    EXPECT_NE(roll_results_sum, 0);
 }
 
 INSTANTIATE_TEST_CASE_P(Calib3d, usac_Essential, UsacMethod::all());
```

Review comment:
It's not obvious that `roll_results_sum += cv::norm(E1, E2, NORM_L1) != 0;` happens even once. Previous line may hide actual behavior. We need to check amount of successful `findEssentialMat` at least.
**File:** modules/calib3d/src/usac.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -6,10 +6,11 @@
 #define OPENCV_USAC_USAC_HPP
 
 namespace cv { namespace usac {
-enum EstimationMethod { Homography, Fundamental, Fundamental8, Essential, Affine, P3P, P6P};
-enum VerificationMethod { NullVerifier, SprtVerifier };
-enum PolishingMethod { NonePolisher, LSQPolisher };
-enum ErrorMetric {DIST_TO_LINE, SAMPSON_ERR, SGD_ERR, SYMM_REPR_ERR, FORW_REPR_ERR, RERPOJ};
+enum EstimationMethod { HOMOGRAPHY=0, FUNDAMENTAL=1, FUNDAMENTAL8=2, ESSENTIAL=3, AFFINE=4, P3P=5, P6P=6};
+enum VerificationMethod { NULL_VERIFIER=0, SPRT_VERIFIER=1, ASPRT=2 };
```

Review comment:
renamed to ModelConfidence
**File:** modules/calib3d/src/usac.hpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -6,10 +6,11 @@
 #define OPENCV_USAC_USAC_HPP
 
 namespace cv { namespace usac {
-enum EstimationMethod { Homography, Fundamental, Fundamental8, Essential, Affine, P3P, P6P};
-enum VerificationMethod { NullVerifier, SprtVerifier };
-enum PolishingMethod { NonePolisher, LSQPolisher };
-enum ErrorMetric {DIST_TO_LINE, SAMPSON_ERR, SGD_ERR, SYMM_REPR_ERR, FORW_REPR_ERR, RERPOJ};
+enum EstimationMethod { HOMOGRAPHY=0, FUNDAMENTAL=1, FUNDAMENTAL8=2, ESSENTIAL=3, AFFINE=4, P3P=5, P6P=6};
+enum VerificationMethod { NULL_VERIFIER=0, SPRT_VERIFIER=1, ASPRT=2 };
```

Review comment:
I'd keep without virtual=0 because this function is very sparse. So, I added CV_UNUSED() macro for all params.
**File:** modules/calib3d/src/usac/fundamental_solver.cpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -4,19 +4,20 @@
 
 #include "../precomp.hpp"
 #include "../usac.hpp"
+#include "../polynom_solver.h"
 #ifdef HAVE_EIGEN
 #include <Eigen/Eigen>
 #endif
 
 namespace cv { namespace usac {
```

Review comment:
added comment
**File:** modules/calib3d/src/usac/utils.cpp
**Change Type:** modified
**Context:** PR #23078: Update USAC
**Review Line:** 15

**Code Changes:**
```diff
-                         K2(0, 0) + K2(1, 1)) / 4.0);
+/*
+SolvePoly is used to find only real roots of N-degree polynomial using Sturm sequence.
+It recursively finds interval where a root lies, and the actual root is found using Regula-Falsi method.
+*/
+class SolvePoly : public SolverPoly {
+private:
+    static int sgn(double val) {
+        return (double(0) < val) - (val < double(0));
+    }
+    class Poly {
```

Review comment:
added description
**File:** modules/calib3d/src/usac/local_optimization.cpp
**Change Type:** modified
**Context:** PR #23078: Update USAC

**Code Changes:**
```diff
@@ -22,14 +22,18 @@ class GraphCutImpl : public GraphCut {
     std::vector<double> energies, weights;
     std::vector<bool> used_edges;
     std::vector<Mat> gc_models;
+
+    Ptr<Termination> termination;
+    int num_lo_optimizations = 0, current_ransac_iter = 0;
 public:
+    void setCurrentRANSACiter (int ransac_iter) override { current_ransac_iter = ransac_iter; }
 
```

Review comment:
I added description, it is more efficient to have a separate one.
**File:** modules/calib3d/test/test_usac.cpp
**Change Type:** modified
**Context:** PR #23078: Update USAC
**Review Line:** 362

**Code Changes:**
```diff
                 FAIL() << "Essential matrix estimation failed!\n";
             else continue;
         }
-        EXPECT_NE(roll_results_sum, 0);
     }
+    EXPECT_NE(roll_results_sum, 0);
 }
 
 INSTANTIATE_TEST_CASE_P(Calib3d, usac_Essential, UsacMethod::all());
```

Review comment:
I have not written this test, and I do not think it is necessary. As I understand, it checks that output of RANSAC is not the same for 1 and 1000 iterations. However, given random behaviour of RANSAC it could happen that the output will be the same.
**File:** modules/objdetect/include/opencv2/objdetect/barcode.hpp
**Change Type:** added
**Context:** PR #23666: Moved barcode from opencv_contrib - Merge with https://github.com/opencv/opencv_contrib/pull/3497 ##### TODO - [x] Documentation (bib) - [x...

**Code Changes:**
```diff
@@ -0,0 +1,65 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+// Copyright (c) 2020-2021 darkliang wangberlinT Certseeds
+
+#ifndef OPENCV_OBJDETECT_BARCODE_HPP
+#define OPENCV_OBJDETECT_BARCODE_HPP
+
+#include <opencv2/core.hpp>
```

Review comment:
Underscore prefixes before capital letter are reserved.
**File:** modules/objdetect/include/opencv2/objdetect/barcode.hpp
**Change Type:** added
**Context:** PR #23666: Moved barcode from opencv_contrib - Merge with https://github.com/opencv/opencv_contrib/pull/3497 ##### TODO - [x] Documentation (bib) - [x...

**Code Changes:**
```diff
@@ -0,0 +1,65 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+// Copyright (c) 2020-2021 darkliang wangberlinT Certseeds
+
+#ifndef OPENCV_OBJDETECT_BARCODE_HPP
+#define OPENCV_OBJDETECT_BARCODE_HPP
+
+#include <opencv2/core.hpp>
```

Review comment:
> NONE Enum values should be prefixed, or moved to parent class, or used `enum class`
**File:** modules/objdetect/include/opencv2/objdetect/barcode.hpp
**Change Type:** added
**Context:** PR #23666: Moved barcode from opencv_contrib - Merge with https://github.com/opencv/opencv_contrib/pull/3497 ##### TODO - [x] Documentation (bib) - [x...

**Code Changes:**
```diff
@@ -0,0 +1,65 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+// Copyright (c) 2020-2021 darkliang wangberlinT Certseeds
+
+#ifndef OPENCV_OBJDETECT_BARCODE_HPP
+#define OPENCV_OBJDETECT_BARCODE_HPP
+
+#include <opencv2/core.hpp>
```

Review comment:
`OPENCV_OBJDETECT_BARCODE_HPP`