nareshmlx/opencv-pr huggingface dataset:
**File:** modules/calib3d/src/usac/utils.cpp
**Change Type:** added
**Context:** PR #17683: [GSoC] New RANSAC. Homography part

**Code Changes:**
```diff
@@ -0,0 +1,526 @@
+// 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.
+
+#include "../precomp.hpp"
+#include "../usac.hpp"
+#include "opencv2/flann/miniflann.hpp"
+#include <map>
+
```

Review comment:
the current OpenCV version of decomposeProjectionMatrix() assumes non-zero k_12. However, in most cases and solvePnP assume k_12 = 0. So, as I wrote before if we use P6P RANSAC (without prior knowledge of calibration) we can find projection matrix which will be decomposed into unknown intrinsic, rotation and translation. Also, decomposeProjectionMatrix() returns K, rotation and center C: for example, if I want to know translation I have to normalize C (which is 4D) and then multiply it by rotation, but my function already outputs translation.
**File:** samples/data/essential_mat_data.txt
**Change Type:** added
**Context:** PR #17683: [GSoC] New RANSAC. Homography part

**Code Changes:**
```diff
@@ -0,0 +1,5 @@
+leuvenA.jpg
+leuvenB.jpg
+651.4462353114224 0 376.27522319223914
+0 653.7348054191838 280.1106539526218
+0 0 1
\ No newline at end of file
```

Review comment:
These are my images. I took them using my phone and resized them.
**File:** samples/cpp/epipolar_lines.cpp
**Change Type:** added
**Context:** PR #17683: [GSoC] New RANSAC. Homography part

**Code Changes:**
```diff
@@ -0,0 +1,106 @@
+// 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
+
+#include "opencv2/calib3d.hpp"
+#include "opencv2/highgui.hpp"
+#include "opencv2/imgproc.hpp"
+
+#include <vector>
```

Review comment:
I forgot to remove this path from testing on my computer. Will fix it.
**File:** samples/python/essential_mat_reconstr.py
**Change Type:** added
**Context:** PR #17683: [GSoC] New RANSAC. Homography part

**Code Changes:**
```diff
@@ -0,0 +1,137 @@
+import numpy as np, cv2 as cv, matplotlib.pyplot as plt, time, sys, os
+from mpl_toolkits.mplot3d import axes3d, Axes3D
+
+def getEpipolarError(F, pts1_, pts2_, inliers):
+    pts1 = np.concatenate((pts1_.T, np.ones((1, pts1_.shape[0]))))[:,inliers]
+    pts2 = np.concatenate((pts2_.T, np.ones((1, pts2_.shape[0]))))[:,inliers]
+    lines2 = np.dot(F  , pts1)
+    lines1 = np.dot(F.T, pts2)
+
```

Review comment:
we don't need, I will remove it as well
**File:** modules/calib3d/test/test_usac.cpp
**Change Type:** added
**Context:** PR #17683: [GSoC] New RANSAC. Homography part

**Code Changes:**
```diff
@@ -0,0 +1,408 @@
+// 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.
+
+#include "test_precomp.hpp"
+
+namespace opencv_test {
+enum TestSolver { Homogr, Fundam, Essen, PnP, Affine};
+/*
```

Review comment:
On Windows there is no Eigen and Lapack, however my essential solver assumes one of them - otherwise, it returns 0 solution every time. So, if I do not disable the test - it will fail.
**File:** modules/calib3d/test/test_usac.cpp
**Change Type:** added
**Context:** PR #17683: [GSoC] New RANSAC. Homography part

**Code Changes:**
```diff
@@ -0,0 +1,408 @@
+// 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.
+
+#include "test_precomp.hpp"
+
+namespace opencv_test {
+enum TestSolver { Homogr, Fundam, Essen, PnP, Affine};
+/*
```

Review comment:
I meant 1 to be something like EXIT_FAILURE. I will use GoogleTest error reporting then.
**File:** modules/calib3d/test/test_usac.cpp
**Change Type:** added
**Context:** PR #17683: [GSoC] New RANSAC. Homography part

**Code Changes:**
```diff
@@ -0,0 +1,408 @@
+// 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.
+
+#include "test_precomp.hpp"
+
+namespace opencv_test {
+enum TestSolver { Homogr, Fundam, Essen, PnP, Affine};
+/*
```

Review comment:
Please use Error with `StsNotImplemented` instead of 0 solution. (you may catch that in tests)
**File:** modules/calib3d/src/usac/fundamental_solver.cpp
**Change Type:** added
**Context:** PR #17683: [GSoC] New RANSAC. Homography part

**Code Changes:**
```diff
@@ -0,0 +1,335 @@
+// 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.
+
+#include "../precomp.hpp"
+#include "../usac.hpp"
+#ifdef HAVE_EIGEN
+#include <Eigen/Eigen>
+#endif
```

Review comment:
Triangluar -> Triangular
**File:** modules/calib3d/src/solvepnp.cpp
**Change Type:** modified
**Context:** PR #17683: [GSoC] New RANSAC. Homography part
**Review Line:** 207

**Code Changes:**
```diff
@@ -201,6 +203,11 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
 {
     CV_INSTRUMENT_REGION();
 
+    if (flags >= 32 && flags <= 38)
+        return usac::solvePnPRansac(_opoints, _ipoints, _cameraMatrix, _distCoeffs,
+            _rvec, _tvec, useExtrinsicGuess, iterationsCount, reprojectionError,
+            confidence, _inliers, flags);
+
     Mat opoints0 = _opoints.getMat(), ipoints0 = _ipoints.getMat();
     Mat opoints, ipoints;
```

Review comment:
Indeed, there should be no need to have a super precise P3P for the the Minimal Sample Sets step since the final pose will be refined using all the data in the best consensus set (assuming USAC works similarly to the classical RANSAC). Just curious to know if you are using P3P with 4 points to have a unique solution or if you are using 3 points (that can produce up to 4 solutions, probably some can be eliminated using positive t_z)? --- > I haven't planned to change a whole logic of solvePnP. Yes, my comment was actually more general and I realise it is not really related to this GSoC work. Probably the answer I would have is that now that there is USAC method that should work better than RANSAC, there is no need to fix the logic inside `solvePnpRansac`. I personnally disagree with this.
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #17683: [GSoC] New RANSAC. Homography part

**Code Changes:**
```diff
@@ -441,9 +441,16 @@ namespace cv
 //! @{
 
 //! type of the robust estimation algorithm
-enum { LMEDS  = 4, //!< least-median of squares algorithm
-       RANSAC = 8, //!< RANSAC algorithm
-       RHO    = 16 //!< RHO algorithm
+enum { LMEDS  = 4,  //!< least-median of squares algorithm
+       RANSAC = 8,  //!< RANSAC algorithm
+       RHO    = 16, //!< RHO algorithm
```

Review comment:
please, use "all-capitals" notation; also, Uniform (and GC, SIGMA, Flann, Grid below) are too generic names; please, use `SAMPLING_UNIFORM, SAMPLING_PROGRESSIVE_NAPSAC, ...`, `LOCAL_OPTIM_NULL, LOCAL_OPTIM_GC, ...` etc. that is, use some prefix in each enumeration.
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #17683: [GSoC] New RANSAC. Homography part

**Code Changes:**
```diff
@@ -441,9 +441,16 @@ namespace cv
 //! @{
 
 //! type of the robust estimation algorithm
-enum { LMEDS  = 4, //!< least-median of squares algorithm
-       RANSAC = 8, //!< RANSAC algorithm
-       RHO    = 16 //!< RHO algorithm
+enum { LMEDS  = 4,  //!< least-median of squares algorithm
+       RANSAC = 8,  //!< RANSAC algorithm
+       RHO    = 16, //!< RHO algorithm
```

Review comment:
for public structures we use mixed case notation, `is_parallel` => `isParallel` etc.
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #17683: [GSoC] New RANSAC. Homography part
**Review Line:** 450

**Code Changes:**
```diff
+       RANSAC = 8,  //!< RANSAC algorithm
+       RHO    = 16, //!< RHO algorithm
+       USAC_DEFAULT  = 32, //!< USAC algorithm, default settings
+       USAC_PARALLEL = 33, //!< USAC, parallel version
+       USAC_FM_8PTS = 34,  //!< USAC, fundamental matrix 8 points
+       USAC_FAST = 35,     //!< USAC, fast settings
+       USAC_ACCURATE = 36, //!< USAC, accurate settings
+       USAC_PROSAC = 37,   //!< USAC, sorted points, runs PROSAC
+       USAC_MAGSAC = 38    //!< USAC, sorted points, runs PROSAC
      };
 
```

Review comment:
I do not see where those present-related constants are used
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #17683: [GSoC] New RANSAC. Homography part
**Review Line:** 450

**Code Changes:**
```diff
+       RANSAC = 8,  //!< RANSAC algorithm
+       RHO    = 16, //!< RHO algorithm
+       USAC_DEFAULT  = 32, //!< USAC algorithm, default settings
+       USAC_PARALLEL = 33, //!< USAC, parallel version
+       USAC_FM_8PTS = 34,  //!< USAC, fundamental matrix 8 points
+       USAC_FAST = 35,     //!< USAC, fast settings
+       USAC_ACCURATE = 36, //!< USAC, accurate settings
+       USAC_PROSAC = 37,   //!< USAC, sorted points, runs PROSAC
+       USAC_MAGSAC = 38    //!< USAC, sorted points, runs PROSAC
      };
 
```

Review comment:
I use it to check for USAC flag, for example in fundam.cpp in findHomographyMat() I have condition: if (method >= 32 && method <= 37) then I will run my method
**File:** modules/calib3d/src/solvepnp.cpp
**Change Type:** modified
**Context:** PR #17683: [GSoC] New RANSAC. Homography part
**Review Line:** 207

**Code Changes:**
```diff
@@ -201,6 +203,11 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
 {
     CV_INSTRUMENT_REGION();
 
+    if (flags >= 32 && flags <= 38)
+        return usac::solvePnPRansac(_opoints, _ipoints, _cameraMatrix, _distCoeffs,
+            _rvec, _tvec, useExtrinsicGuess, iterationsCount, reprojectionError,
+            confidence, _inliers, flags);
+
     Mat opoints0 = _opoints.getMat(), ipoints0 = _ipoints.getMat();
     Mat opoints, ipoints;
```

Review comment:
I use the one which produces up to 4 solutions. However, solving 4-degrees polynomial can give you 0, 2 or 4 real roots. So, I experimented a bit and found that mostly it has only 2 real roots and average number of models after applying different verifications is around 1.38
**File:** samples/cpp/essential_mat_reconstr.cpp
**Change Type:** added
**Context:** PR #17683: [GSoC] New RANSAC. Homography part

**Code Changes:**
```diff
@@ -0,0 +1,342 @@
+// 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
+
+#include "opencv2/calib3d.hpp"
+#include "opencv2/highgui.hpp"
+#include "opencv2/imgproc.hpp"
+
+#include <vector>
```

Review comment:
instead of adding prototype for each function, just make all the functions, except 'main', static
**File:** modules/calib3d/src/fundam.cpp
**Change Type:** modified
**Context:** PR #17683: [GSoC] New RANSAC. Homography part
**Review Line:** 358

**Code Changes:**
```diff
 
@@ -353,6 +355,10 @@ cv::Mat cv::findHomography( InputArray _points1, InputArray _points2,
 {
     CV_INSTRUMENT_REGION();
 
+    if (method >= 32 && method <= 38)
+        return usac::findHomography(_points1, _points2, method, ransacReprojThreshold,
+            _mask, maxIters, confidence);
+
     const double defaultRANSACReprojThreshold = 3;
     bool result = false;
```

Review comment:
Magic numbers must be avoided. (multiple places)
**File:** modules/calib3d/src/usac/local_optimization.cpp
**Change Type:** added
**Context:** PR #17683: [GSoC] New RANSAC. Homography part
**Review Line:** 173

**Code Changes:**
```diff
+                } else
+                    graph.addEdges(point_idx, actual_neighbor_idx, b, c);
+            }
+        }
+
+        graph.maxFlow();
+
+        int inlier_number = 0;
+        for (int pt = 0; pt < points_size; pt++)
+            if (! graph.inSourceSegment(pt)) // check for sink
+                labeling_inliers[inlier_number++] = pt;
```

Review comment:
This method may be called on **empty** `graph` in `usac_Homography.accuracy` test and others (see #18454) Implementation of the method doesn't expect that. Added checks: #18482
**File:** modules/calib3d/src/usac/local_optimization.cpp
**Change Type:** added
**Context:** PR #17683: [GSoC] New RANSAC. Homography part
**Review Line:** 173

**Code Changes:**
```diff
+                } else
+                    graph.addEdges(point_idx, actual_neighbor_idx, b, c);
+            }
+        }
+
+        graph.maxFlow();
+
+        int inlier_number = 0;
+        for (int pt = 0; pt < points_size; pt++)
+            if (! graph.inSourceSegment(pt)) // check for sink
+                labeling_inliers[inlier_number++] = pt;
```

Review comment:
There was another problem in this file which caused exception for me. I prepared a pull request https://github.com/opencv/opencv/pull/18483 with the fix.
**File:** modules/cudaarithm/test/test_core.cpp
**Change Type:** modified
**Context:** PR #18348: cudaarithm: use only even number for inplace flip
**Review Line:** 285

**Code Changes:**
```diff
@@ -281,6 +281,8 @@ CUDA_TEST_P(Flip, Accuracy)
 
 CUDA_TEST_P(Flip, AccuracyInplace)
 {
+    size.width  = (size.width  >> 1) << 1; // in-place version only accepts even number
+    size.height = (size.height >> 1) << 1; // in-place version only accepts even number
     cv::Mat src = randomMat(size, type);
 
     cv::cuda::GpuMat srcDst = loadMat(src, useRoi);
```

Review comment:
I propose to split tests for in-place and general cases and instantiate in-place cases with even size. It's more obvious behavior.
**File:** modules/cudaarithm/test/test_core.cpp
**Change Type:** modified
**Context:** PR #18348: cudaarithm: use only even number for inplace flip
**Review Line:** 285

**Code Changes:**
```diff
@@ -281,6 +281,8 @@ CUDA_TEST_P(Flip, Accuracy)
 
 CUDA_TEST_P(Flip, AccuracyInplace)
 {
+    size.width  = (size.width  >> 1) << 1; // in-place version only accepts even number
+    size.height = (size.height >> 1) << 1; // in-place version only accepts even number
     cv::Mat src = randomMat(size, type);
 
     cv::cuda::GpuMat srcDst = loadMat(src, useRoi);
```

Review comment:
Sorry, but I again changed my mind. I thought it would be simple, but it's really making a another copy of flip test code just for the in-place version. Now, there are one `Flip` test, but asmorkalov suggestion is to create `Flip` and `Flip_inplace` test case, which I don't prefer. Can I keep the current implementation as-is, since it'll make things much easier ?
**File:** modules/cudaarithm/src/core.cpp
**Change Type:** modified
**Context:** PR #18348: cudaarithm: use only even number for inplace flip
**Review Line:** 169

**Code Changes:**
```diff
     GpuMat dst = getOutputMat(_dst, src.size(), src.type(), stream);
+    if (src.data == dst.data && ((src.cols & 1) == 1 || (src.rows & 1) == 1))
+        CV_Error(Error::BadROISize, "In-place version of flip only accepts even width/height");
 
-    if (src.refcount != dst.refcount)
+    if (src.data != dst.data)
         funcs[src.depth()][src.channels() - 1](src, dst, flipCode, StreamAccessor::getStream(stream));
     else // in-place
         ifuncs[src.depth()][src.channels() - 1](src, flipCode, StreamAccessor::getStream(stream));
```

Review comment:
BTW, `refcount` is a pointer to reference counter which is allocated with underlying buffer/data and it is shared between GpuMats. At least, it is more reliable check in case of image ROIs. But it doesn't work if `refcount == NULL` (non-managed buffers). Better check should compare both values: ``` bool isInplace = (src.data == dst.data) || (src.refcount == dst.refcount); ``` (however there are still some non-covered cases)
**File:** modules/cudaarithm/test/test_core.cpp
**Change Type:** modified
**Context:** PR #18348: cudaarithm: use only even number for inplace flip
**Review Line:** 285

**Code Changes:**
```diff
@@ -281,6 +281,8 @@ CUDA_TEST_P(Flip, Accuracy)
 
 CUDA_TEST_P(Flip, AccuracyInplace)
 {
+    size.width  = (size.width  >> 1) << 1; // in-place version only accepts even number
+    size.height = (size.height >> 1) << 1; // in-place version only accepts even number
     cv::Mat src = randomMat(size, type);
 
     cv::cuda::GpuMat srcDst = loadMat(src, useRoi);
```

Review comment:
Another idea is to keep sizes intact but add bad args handling to the test: ```.cpp if (/* size is not even */) { EXPECT_THROW(...); return; } // current test body ```
**File:** modules/imgproc/test/test_templmatchmask.cpp
**Change Type:** added
**Context:** PR #15214: Imgproc: templmatch: Add support for mask for all methods - resolves #6919 resolves #14076 ### Current situation There are multiple request...

**Code Changes:**
```diff
@@ -0,0 +1,278 @@
+// 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.
+
+#include "test_precomp.hpp"
+
+namespace opencv_test { namespace {
+
+CV_ENUM(MatchTemplType, CV_TM_CCORR,  CV_TM_CCORR_NORMED,
```

Review comment:
Please use short license header: https://github.com/opencv/opencv/wiki/Coding_Style_Guide#file-structure
**File:** modules/imgproc/test/test_templmatchmask.cpp
**Change Type:** added
**Context:** PR #15214: Imgproc: templmatch: Add support for mask for all methods - resolves #6919 resolves #14076 ### Current situation There are multiple request...

**Code Changes:**
```diff
@@ -0,0 +1,278 @@
+// 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.
+
+#include "test_precomp.hpp"
+
+namespace opencv_test { namespace {
+
+CV_ENUM(MatchTemplType, CV_TM_CCORR,  CV_TM_CCORR_NORMED,
```

Review comment:
Be careful with min/max names. On Windows they may be defined as macros (OpenCV prevents that). It is better to use `min_value` / `max_value` instead.
**File:** modules/imgproc/test/test_templmatchmask.cpp
**Change Type:** added
**Context:** PR #15214: Imgproc: templmatch: Add support for mask for all methods - resolves #6919 resolves #14076 ### Current situation There are multiple request...

**Code Changes:**
```diff
@@ -0,0 +1,278 @@
+// 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.
+
+#include "test_precomp.hpp"
+
+namespace opencv_test { namespace {
+
+CV_ENUM(MatchTemplType, CV_TM_CCORR,  CV_TM_CCORR_NORMED,
```

Review comment:
Not needed. OpenCV test system guarantees stable state of OpenCV internal `theRNG()` before each test run. Use `randu()` to fill arrays.
**File:** modules/imgproc/test/test_templmatchmask.cpp
**Change Type:** added
**Context:** PR #15214: Imgproc: templmatch: Add support for mask for all methods - resolves #6919 resolves #14076 ### Current situation There are multiple request...

**Code Changes:**
```diff
@@ -0,0 +1,278 @@
+// 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.
+
+#include "test_precomp.hpp"
+
+namespace opencv_test { namespace {
+
+CV_ENUM(MatchTemplType, CV_TM_CCORR,  CV_TM_CCORR_NORMED,
```

Review comment:
`<int>` leads to > where GetParam() = 5 Use `MatType` instead to enable pretty-printer.
**File:** modules/imgproc/test/test_templmatchmask.cpp
**Change Type:** added
**Context:** PR #15214: Imgproc: templmatch: Add support for mask for all methods - resolves #6919 resolves #14076 ### Current situation There are multiple request...

**Code Changes:**
```diff
@@ -0,0 +1,278 @@
+// 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.
+
+#include "test_precomp.hpp"
+
+namespace opencv_test { namespace {
+
+CV_ENUM(MatchTemplType, CV_TM_CCORR,  CV_TM_CCORR_NORMED,
```

Review comment:
`mask` in OpenCV is `8UC1` or `8UC<N>` arrays(matrices). Element values are usually restricted to 0 and 255. ``` mask_testtype_.create(TEMPL_SIZE, CV_MAKE_TYPE(CV_8U, CV_MAT_CN(type))); randu(mask_testtype_, 0, 5); mask_testtype_ = mask_testtype_ != 0; // normalize mask values: 0 or 255 ```
**File:** modules/imgproc/test/test_templmatchmask.cpp
**Change Type:** added
**Context:** PR #15214: Imgproc: templmatch: Add support for mask for all methods - resolves #6919 resolves #14076 ### Current situation There are multiple request...

**Code Changes:**
```diff
@@ -0,0 +1,278 @@
+// 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.
+
+#include "test_precomp.hpp"
+
+namespace opencv_test { namespace {
+
+CV_ENUM(MatchTemplType, CV_TM_CCORR,  CV_TM_CCORR_NORMED,
```

Review comment:
`CompareNaiveImpl` doesn't look as a well defined test name. It should include tested function name, like: `matchTemplateWithMask`
**File:** modules/imgproc/test/test_templmatchmask.cpp
**Change Type:** added
**Context:** PR #15214: Imgproc: templmatch: Add support for mask for all methods - resolves #6919 resolves #14076 ### Current situation There are multiple request...

**Code Changes:**
```diff
@@ -0,0 +1,278 @@
+// 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.
+
+#include "test_precomp.hpp"
+
+namespace opencv_test { namespace {
+
+CV_ENUM(MatchTemplType, CV_TM_CCORR,  CV_TM_CCORR_NORMED,
```

Review comment:
`<int, int>` - `MatType` - `MatchTemplType` See `test/ocl/test_match_template.cpp` as reference: ``` CV_ENUM(MatchTemplType, CV_TM_CCORR, CV_TM_CCORR_NORMED, CV_TM_SQDIFF, CV_TM_SQDIFF_NORMED, CV_TM_CCOEFF, CV_TM_CCOEFF_NORMED) ```
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #15214: Imgproc: templmatch: Add support for mask for all methods - resolves #6919 resolves #14076 ### Current situation There are multiple request...

**Code Changes:**
```diff
@@ -3647,14 +3647,43 @@ CV_EXPORTS_W void HuMoments( const Moments& m, OutputArray hu );
 
 //! type of the template matching operation
 enum TemplateMatchModes {
-    TM_SQDIFF        = 0, //!< \f[R(x,y)= \sum _{x',y'} (T(x',y')-I(x+x',y+y'))^2\f]
-    TM_SQDIFF_NORMED = 1, //!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y')-I(x+x',y+y'))^2}{\sqrt{\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
-    TM_CCORR         = 2, //!< \f[R(x,y)= \sum _{x',y'} (T(x',y')  \cdot I(x+x',y+y'))\f]
-    TM_CCORR_NORMED  = 3, //!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y'))}{\sqrt{\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
-    TM_CCOEFF        = 4, //!< \f[R(x,y)= \sum _{x',y'} (T'(x',y')  \cdot I'(x+x',y+y'))\f]
-                          //!< where
```

Review comment:
> mask > It must have the same data type and size as templ. It should not. Masks in OpenCV have 8U depth.