nareshmlx/opencv-pr huggingface dataset:
**File:** modules/calib3d/src/stereosgbm.cpp
**Change Type:** modified
**Context:** PR #6373: Fixed uninitialized memory errors in stereoBM - ### What does this PR change? StereoBM implementation has a set of out of border readings wh...
**Review Line:** 118

**Code Changes:**
```diff
 {
     int x, c, width = img1.cols, cn = img1.channels();
-    int minX1 = max(-maxD, 0), maxX1 = width + min(minD, 0);
-    int minX2 = max(minX1 - maxD, 0), maxX2 = min(maxX1 - minD, width);
+    int minX1 = max(-maxD, 0), maxX1 = width + min(-minD, 0);
+    int minX2 = max(minX1 + minD, 0), maxX2 = min(maxX1 + maxD, width);
     int D = maxD - minD, width1 = maxX1 - minX1, width2 = maxX2 - minX2;
     const PixType *row1 = img1.ptr<PixType>(y), *row2 = img2.ptr<PixType>(y);
     PixType *prow1 = buffer + width2*2, *prow2 = prow1 + width*cn*2;
@@ -200,14 +200,27 @@ static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y,
             int u0 = min(ul, ur); u0 = min(u0, u);
```

Review comment:
minX1, maxX2 looks for me as a set of img1 pixels that could have pair with suitable disparity. In this case we have to had a shorter search window in case of positive minD. Also if we have [-img.width;img.width) disparity interval we get zero search window in case of original code which looks strange for such a wide disparity range
**File:** modules/imgproc/include/opencv2/imgproc/hal/hal.hpp
**Change Type:** added
**Context:** PR #6119: Filter2D HAL interface

**Code Changes:**
```diff
@@ -0,0 +1,51 @@
+#ifndef CV_IMGPROC_HAL_HPP
+#define CV_IMGPROC_HAL_HPP
+
+#include "opencv2/core/cvdef.h"
+#include "opencv2/core/cvstd.hpp"
+#include "opencv2/core/hal/interface.h"
+
+namespace cv { namespace hal {
+
```

Review comment:
I just thought that we could do it in our algorithm-like style: <pre> struct Filter2D { virtual ~Filter2D() {} virtual void apply(...) = 0; static Ptr<Filter2D> create(...); }; </pre> what do you think?
**File:** modules/imgproc/include/opencv2/imgproc/hal/hal.hpp
**Change Type:** added
**Context:** PR #6119: Filter2D HAL interface

**Code Changes:**
```diff
@@ -0,0 +1,51 @@
+#ifndef CV_IMGPROC_HAL_HPP
+#define CV_IMGPROC_HAL_HPP
+
+#include "opencv2/core/cvdef.h"
+#include "opencv2/core/cvstd.hpp"
+#include "opencv2/core/hal/interface.h"
+
+namespace cv { namespace hal {
+
```

Review comment:
whenever we keep C-style API or move to C++, let's use mixed-case naming style "initFilter2D", like we do everywhere else in the library
**File:** modules/imgproc/src/filter.cpp
**Change Type:** modified
**Context:** PR #6119: Filter2D HAL interface

**Code Changes:**
```diff
@@ -41,7 +41,9 @@
 //M*/
 
 #include "precomp.hpp"
+#include "opencv2/core/opencl/ocl_defs.hpp"
 #include "opencl_kernels_imgproc.hpp"
+#include "hal_replacement.hpp"
 
 /****************************************************************************************\
                                     Base Image Filter
```

Review comment:
as I see, you are using "Impl" paradigm anyway, so it's another reason to use OOP style for the HAL
**File:** modules/imgproc/src/hal_replacement.hpp
**Change Type:** added
**Context:** PR #6119: Filter2D HAL interface

**Code Changes:**
```diff
@@ -0,0 +1,26 @@
+#ifndef OPENCV_IMGPROC_HAL_REPLACEMENT_HPP
+#define OPENCV_IMGPROC_HAL_REPLACEMENT_HPP
+
+#include "opencv2/core/hal/interface.h"
+
+struct cvhalFilter2D {};
+
+inline int hal_ni_filterInit(cvhalFilter2D **, uchar *, size_t, int, int, int, int, int, int, int, int, double, int, int, bool, bool) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
+inline int hal_ni_filter(cvhalFilter2D *, uchar *, size_t, uchar *, size_t, int, int, int, int, int, int) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
```

Review comment:
I would use struct cvhalFilter2D { ... }; and then pass pointer/double pointer to it to other functions, so that we have at least some compile-time control.
**File:** modules/imgproc/include/opencv2/imgproc/hal/hal.hpp
**Change Type:** added
**Context:** PR #6119: Filter2D HAL interface
**Review Line:** 13

**Code Changes:**
```diff
+namespace cv { namespace hal {
+
+//! @addtogroup core_hal_functions
+//! @{
+
+struct CV_EXPORTS Filter2D
+{
+    static Ptr<hal::Filter2D> create(uchar * kernel_data, size_t kernel_step, int kernel_type,
+                                     int kernel_width, int kernel_height,
+                                     int max_width, int max_height,
+                                     int stype, int dtype,
```

Review comment:
I would actually split it into 2 classes. One reason is clarity. The other reason is theorecitcal possiblity for the linker to throw away more unused code. createFilter2D/createSepFilter2D can then be renamed to simple "create"
**File:** modules/imgproc/src/colormap.cpp
**Change Type:** modified
**Context:** PR #6150: fix: 6149 (Incomplete description of applyColorMap parameters) - https://github.com/Itseez/opencv/issues/6149

**Code Changes:**
```diff
@@ -144,10 +144,7 @@ namespace colormap
 
         // Applies the colormap on a given image.
         //
-        // This function expects BGR-aligned data of type CV_8UC1 or
-        // CV_8UC3. If the wrong image type is given, the original image
-        // will be returned.
-        //
+        // This function expects BGR-aligned data of type CV_8UC1 or CV_8UC3.
         // Throws an error for wrong-aligned lookup table, which must be
```

Review comment:
This comment is obsolete, please remove it too.
**File:** modules/imgproc/src/colormap.cpp
**Change Type:** modified
**Context:** PR #6150: fix: 6149 (Incomplete description of applyColorMap parameters) - https://github.com/Itseez/opencv/issues/6149

**Code Changes:**
```diff
@@ -144,10 +144,7 @@ namespace colormap
 
         // Applies the colormap on a given image.
         //
-        // This function expects BGR-aligned data of type CV_8UC1 or
-        // CV_8UC3. If the wrong image type is given, the original image
-        // will be returned.
-        //
+        // This function expects BGR-aligned data of type CV_8UC1 or CV_8UC3.
         // Throws an error for wrong-aligned lookup table, which must be
```

Review comment:
done. There is also comment in brief docs, but I am waiting for PR 6150 to be accepted (otherwise there will be conflict).
**File:** modules/imgproc/src/colormap.cpp
**Change Type:** modified
**Context:** PR #6150: fix: 6149 (Incomplete description of applyColorMap parameters) - https://github.com/Itseez/opencv/issues/6149

**Code Changes:**
```diff
@@ -144,10 +144,7 @@ namespace colormap
 
         // Applies the colormap on a given image.
         //
-        // This function expects BGR-aligned data of type CV_8UC1 or
-        // CV_8UC3. If the wrong image type is given, the original image
-        // will be returned.
-        //
+        // This function expects BGR-aligned data of type CV_8UC1 or CV_8UC3.
         // Throws an error for wrong-aligned lookup table, which must be
```

Review comment:
line 148 can be merged in line 147
**File:** cmake/templates/opencv_run_all_tests_unix.sh.in
**Change Type:** modified
**Context:** PR #6279: Test data necessary for python samples added to test package. - ### What does this PR change? Test launch script updated to run whole set of...

**Code Changes:**
```diff
@@ -107,7 +107,7 @@ for t in $OPENCV_PYTHON_TESTS;
 do
     test_name=`basename "$t"`
 
-    cmd="py.test --junitxml $test_name.xml \"$OPENCV_TEST_PATH\"/$t"
+    cmd="python \"$OPENCV_TEST_PATH\"/$t -v"
 
     seg_reg="s/^/${TEXT_CYAN}[$test_name]${TEXT_RESET} /"                 # append test name
 
```

Review comment:
Does it generate some xml file or other testing report?
**File:** data/CMakeLists.txt
**Change Type:** modified
**Context:** PR #6279: Test data necessary for python samples added to test package. - ### What does this PR change? Test launch script updated to run whole set of...
**Review Line:** 21

**Code Changes:**
```diff
@@ -18,5 +18,37 @@ if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH)
             DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
               GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
             DESTINATION share/OpenCV/testdata COMPONENT tests)
+    if(BUILD_opencv_python)
+	  file(GLOB DATAFILES_CPP ../samples/cpp/left*.jpg)
+      list(APPEND DATAFILES_CPP
+          "../samples/cpp/board.jpg"
+          "../samples/cpp/pic1.png"
+          "../samples/cpp/pic6.png"
```

Review comment:
You should also check `INSTALL_TESTS` flag status. If it's disabled there is no reason to install additional test data.
**File:** data/CMakeLists.txt
**Change Type:** modified
**Context:** PR #6279: Test data necessary for python samples added to test package. - ### What does this PR change? Test launch script updated to run whole set of...
**Review Line:** 21

**Code Changes:**
```diff
@@ -18,5 +18,37 @@ if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH)
             DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
               GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
             DESTINATION share/OpenCV/testdata COMPONENT tests)
+    if(BUILD_opencv_python)
+	  file(GLOB DATAFILES_CPP ../samples/cpp/left*.jpg)
+      list(APPEND DATAFILES_CPP
+          "../samples/cpp/board.jpg"
+          "../samples/cpp/pic1.png"
+          "../samples/cpp/pic6.png"
```

Review comment:
INSTALL_TESTS is already checked in line 12. Here I've add data necessary for python tests to already packaged test data
**File:** cmake/templates/opencv_run_all_tests_unix.sh.in
**Change Type:** modified
**Context:** PR #6279: Test data necessary for python samples added to test package. - ### What does this PR change? Test launch script updated to run whole set of...

**Code Changes:**
```diff
@@ -107,7 +107,7 @@ for t in $OPENCV_PYTHON_TESTS;
 do
     test_name=`basename "$t"`
 
-    cmd="py.test --junitxml $test_name.xml \"$OPENCV_TEST_PATH\"/$t"
+    cmd="python \"$OPENCV_TEST_PATH\"/$t -v"
 
     seg_reg="s/^/${TEXT_CYAN}[$test_name]${TEXT_RESET} /"                 # append test name
 
```

Review comment:
No, it doesn't. py.test script could provide reports, but require different integration of additional tests and doesn't initialize data path. Also OpenCV buildbot doesn't use py.test for test execution so I think it would be better to use similar approach to run python tests in all places rather than try to fit both tests invocation schemes.
**File:** data/CMakeLists.txt
**Change Type:** modified
**Context:** PR #6279: Test data necessary for python samples added to test package. - ### What does this PR change? Test launch script updated to run whole set of...
**Review Line:** 21

**Code Changes:**
```diff
@@ -18,5 +18,37 @@ if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH)
             DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
               GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
             DESTINATION share/OpenCV/testdata COMPONENT tests)
+    if(BUILD_opencv_python)
+	  file(GLOB DATAFILES_CPP ../samples/cpp/left*.jpg)
+      list(APPEND DATAFILES_CPP
+          "../samples/cpp/board.jpg"
+          "../samples/cpp/pic1.png"
+          "../samples/cpp/pic6.png"
```

Review comment:
I see, never mind.
**File:** cmake/templates/opencv_run_all_tests_unix.sh.in
**Change Type:** modified
**Context:** PR #6279: Test data necessary for python samples added to test package. - ### What does this PR change? Test launch script updated to run whole set of...
**Review Line:** 110

**Code Changes:**
```diff
@@ -107,7 +107,7 @@ for t in $OPENCV_PYTHON_TESTS;
 do
     test_name=`basename "$t"`
 
-    cmd="py.test --junitxml $test_name.xml \"$OPENCV_TEST_PATH\"/$t"
+    cmd="python \"$OPENCV_TEST_PATH\"/$t -v"
 
     seg_reg="s/^/${TEXT_CYAN}[$test_name]${TEXT_RESET} /"                 # append test name
 
```

Review comment:
Please remove py.test from deb package dependency though
**File:** modules/python/test/test.py
**Change Type:** modified
**Context:** PR #6025: Add new tests on python - Add new tests on python which are based on samples

**Code Changes:**
```diff
@@ -23,48 +23,16 @@
 except ImportError:
     from urllib import urlopen
 
-class NewOpenCVTests(unittest.TestCase):
-
-    # path to local repository folder containing 'samples' folder
-    repoPath = None
-    # github repository url
-    repoUrl = 'https://raw.github.com/Itseez/opencv/master'
```

Review comment:
``` basedir=os.path.abspath(os.path.dirname(__file__)) def load_tests(loader, tests, pattern): tests.addTests(loader.discover(basedir, pattern='test_*.py')) return tests ```
**File:** modules/python/test/test.py
**Change Type:** modified
**Context:** PR #6025: Add new tests on python - Add new tests on python which are based on samples
**Review Line:** 23

**Code Changes:**
```diff
@@ -23,48 +23,16 @@
 except ImportError:
     from urllib import urlopen
 
-class NewOpenCVTests(unittest.TestCase):
-
-    # path to local repository folder containing 'samples' folder
```

Review comment:
use run the test.py by passing it to python, probably we should get back to 644 permissions instead of 755
**File:** modules/python/test/test.py
**Change Type:** modified
**Context:** PR #6025: Add new tests on python - Add new tests on python which are based on samples
**Review Line:** 142

**Code Changes:**
```diff
+    except KeyError:
+        print('Missing opencv extra repository. Some of tests may fail.')
     random.seed(0)
     unit_argv = [sys.argv[0]] + other;
-    unittest.main(argv=unit_argv)
+    unittest.main(argv=unit_argv)
\ No newline at end of file
```

Review comment:
I do not see where all the other tests are imported? Our buildbot only runs "python test.py". How all the tests that you wrote are executed?
**File:** modules/python/test/test_houghcircles.py
**Change Type:** added
**Context:** PR #6025: Add new tests on python - Add new tests on python which are based on samples

**Code Changes:**
```diff
@@ -0,0 +1,81 @@
+#!/usr/bin/python
+
+'''
+This example illustrates how to use cv2.HoughCircles() function.
+'''
+
+# Python 2/3 compatibility
+from __future__ import print_function
+
```

Review comment:
probably, the circles should be matched more accurately; radius is rather small and in principle you can get completely different circle that is still within eps=7.
**File:** modules/python/test/test_houghlines.py
**Change Type:** added
**Context:** PR #6025: Add new tests on python - Add new tests on python which are based on samples
**Review Line:** 23

**Code Changes:**
```diff
+
+    norm1 = cv2.norm(line1 - line2, cv2.NORM_L2)
+    line3 = line1[2:4] + line1[0:2]
+    norm2 = cv2.norm(line3 - line2, cv2.NORM_L2)
+
+    return min(norm1, norm2)
+
+class houghlines_test(NewOpenCVTests):
+
+    def test_houghlines(self):
+
```

Review comment:
this one is good!
**File:** modules/python/test/test.py
**Change Type:** modified
**Context:** PR #6025: Add new tests on python - Add new tests on python which are based on samples
**Review Line:** 142

**Code Changes:**
```diff
+    except KeyError:
+        print('Missing opencv extra repository. Some of tests may fail.')
     random.seed(0)
     unit_argv = [sys.argv[0]] + other;
-    unittest.main(argv=unit_argv)
+    unittest.main(argv=unit_argv)
\ No newline at end of file
```

Review comment:
Import is done by load_tests function (line 32).
**File:** modules/python/test/test_calibration.py
**Change Type:** added
**Context:** PR #6025: Add new tests on python - Add new tests on python which are based on samples

**Code Changes:**
```diff
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+
+'''
+camera calibration for distorted images with chess board samples
+reads distorted images, calculates the calibration and write undistorted images
+'''
+
+# Python 2/3 compatibility
+from __future__ import print_function
```

Review comment:
I will correct it to 0.005
**File:** modules/python/test/test_houghcircles.py
**Change Type:** added
**Context:** PR #6025: Add new tests on python - Add new tests on python which are based on samples

**Code Changes:**
```diff
@@ -0,0 +1,81 @@
+#!/usr/bin/python
+
+'''
+This example illustrates how to use cv2.HoughCircles() function.
+'''
+
+# Python 2/3 compatibility
+from __future__ import print_function
+
```

Review comment:
I think, it's better use more complicated criteria here: check centers and radiuses separatly.
**File:** modules/ml/include/opencv2/ml.hpp
**Change Type:** modified
**Context:** PR #6096: Mn/svmsgd to opencv3 0 - **Merge with extra**: https://github.com/Itseez/opencv_extra/pull/288 Implemented SVMSGD classifier.
**Review Line:** 1560

**Code Changes:**
```diff
+To use SVMSGD algorithm do as follows:
+
+- first, create the SVMSGD object. The algoorithm will set optimal parameters by default, but you can set your own parameters via functions setSvmsgdType(),
+  setMarginType(), setMarginRegularization(), setInitialStepSize(), and setStepDecreasingPower().
+
+- then the SVM model can be trained using the train features and the correspondent labels by the method train().
+
+- after that, the label of a new feature vector can be predicted using the method predict().
+
+@code
+// Create empty object
```

Review comment:
I guess `trainData` format is specified somewhere? Can we have a link here?
**File:** modules/ml/include/opencv2/ml.hpp
**Change Type:** modified
**Context:** PR #6096: Mn/svmsgd to opencv3 0 - **Merge with extra**: https://github.com/Itseez/opencv_extra/pull/288 Implemented SVMSGD classifier.

**Code Changes:**
```diff
@@ -1496,6 +1496,165 @@ class CV_EXPORTS_W LogisticRegression : public StatModel
     CV_WRAP static Ptr<LogisticRegression> create();
 };
 
+
+/****************************************************************************************\
+*                        Stochastic Gradient Descent SVM Classifier                      *
+\****************************************************************************************/
+
+/*!
```

Review comment:
Is this a common pattern to have the illegal states? Why not to set good defaults? =)
**File:** modules/ml/include/opencv2/ml.hpp
**Change Type:** modified
**Context:** PR #6096: Mn/svmsgd to opencv3 0 - **Merge with extra**: https://github.com/Itseez/opencv_extra/pull/288 Implemented SVMSGD classifier.

**Code Changes:**
```diff
@@ -1496,6 +1496,165 @@ class CV_EXPORTS_W LogisticRegression : public StatModel
     CV_WRAP static Ptr<LogisticRegression> create();
 };
 
+
+/****************************************************************************************\
+*                        Stochastic Gradient Descent SVM Classifier                      *
+\****************************************************************************************/
+
+/*!
```

Review comment:
linearly -> linear
**File:** modules/ml/include/opencv2/ml.hpp
**Change Type:** modified
**Context:** PR #6096: Mn/svmsgd to opencv3 0 - **Merge with extra**: https://github.com/Itseez/opencv_extra/pull/288 Implemented SVMSGD classifier.

**Code Changes:**
```diff
@@ -1496,6 +1496,165 @@ class CV_EXPORTS_W LogisticRegression : public StatModel
     CV_WRAP static Ptr<LogisticRegression> create();
 };
 
+
+/****************************************************************************************\
+*                        Stochastic Gradient Descent SVM Classifier                      *
+\****************************************************************************************/
+
+/*!
```

Review comment:
I wonder if the parameters could have better names, than just some Greek letters?
**File:** modules/ml/src/svmsgd.cpp
**Change Type:** added
**Context:** PR #6096: Mn/svmsgd to opencv3 0 - **Merge with extra**: https://github.com/Itseez/opencv_extra/pull/288 Implemented SVMSGD classifier.

**Code Changes:**
```diff
@@ -0,0 +1,510 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+//  By downloading, copying, installing or using the software you agree to this license.
+//  If you do not agree to this license, do not download, install,
+//  copy or use the software.
+//
+//
```

Review comment:
I guess the parameters can, in fact, have better names than just some Greek letters =)
**File:** modules/ml/src/svmsgd.cpp
**Change Type:** added
**Context:** PR #6096: Mn/svmsgd to opencv3 0 - **Merge with extra**: https://github.com/Itseez/opencv_extra/pull/288 Implemented SVMSGD classifier.

**Code Changes:**
```diff
@@ -0,0 +1,510 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+//  By downloading, copying, installing or using the software you agree to this license.
+//  If you do not agree to this license, do not download, install,
+//  copy or use the software.
+//
+//
```

Review comment:
please, correct the copyright notes.
**File:** modules/ml/src/svmsgd.cpp
**Change Type:** added
**Context:** PR #6096: Mn/svmsgd to opencv3 0 - **Merge with extra**: https://github.com/Itseez/opencv_extra/pull/288 Implemented SVMSGD classifier.

**Code Changes:**
```diff
@@ -0,0 +1,510 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+//  By downloading, copying, installing or using the software you agree to this license.
+//  If you do not agree to this license, do not download, install,
+//  copy or use the software.
+//
+//
```

Review comment:
Why the type is `Scalar`? You're applying `[0]` to the return value.
**File:** modules/ml/src/svmsgd.cpp
**Change Type:** added
**Context:** PR #6096: Mn/svmsgd to opencv3 0 - **Merge with extra**: https://github.com/Itseez/opencv_extra/pull/288 Implemented SVMSGD classifier.
**Review Line:** 156

**Code Changes:**
```diff
+        samples.row(sampleIndex) -= average;
+    }
+
+    double normValue = norm(samples);
+
+    multiplier = static_cast<float>(sqrt(samples.total()) / normValue);
+
+    samples *= multiplier;
+}
+
+void SVMSGDImpl::makeExtendedTrainSamples(const Mat &trainSamples, Mat &extendedTrainSamples, Mat &average, float &multiplier)
```

Review comment:
Shouldn't each feature be normalized individually?
**File:** modules/ml/src/svmsgd.cpp
**Change Type:** added
**Context:** PR #6096: Mn/svmsgd to opencv3 0 - **Merge with extra**: https://github.com/Itseez/opencv_extra/pull/288 Implemented SVMSGD classifier.

**Code Changes:**
```diff
@@ -0,0 +1,510 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+//  By downloading, copying, installing or using the software you agree to this license.
+//  If you do not agree to this license, do not download, install,
+//  copy or use the software.
+//
+//
```

Review comment:
What is the reason to pass `average` to `normalizeSamples`?
**File:** modules/ml/src/svmsgd.cpp
**Change Type:** added
**Context:** PR #6096: Mn/svmsgd to opencv3 0 - **Merge with extra**: https://github.com/Itseez/opencv_extra/pull/288 Implemented SVMSGD classifier.
**Review Line:** 161

**Code Changes:**
```diff
+    multiplier = static_cast<float>(sqrt(samples.total()) / normValue);
+
+    samples *= multiplier;
+}
+
+void SVMSGDImpl::makeExtendedTrainSamples(const Mat &trainSamples, Mat &extendedTrainSamples, Mat &average, float &multiplier)
+{
+    Mat normalizedTrainSamples = trainSamples.clone();
+    int samplesCount = normalizedTrainSamples.rows;
+
+    normalizeSamples(normalizedTrainSamples, average, multiplier);
```

Review comment:
I believe the correct term for this procedure is "homogenization". Not sure if it's a better idea to use it, though =)