nareshmlx/opencv-pr huggingface dataset:
**File:** doc/tutorials/introduction/desktop_java/java_dev_intro.rst
**Change Type:** added
**Context:** PR #301: Adds samples for Java and Scala - A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face dete...

**Code Changes:**
```diff
@@ -0,0 +1,523 @@
+
+.. _Java_Dev_Intro:
+
+
+Introduction to Java Development
+********************************
+
+Last updated: 12 February, 2013.
+
```

Review comment:
Why Python is marked as code?
**File:** doc/tutorials/introduction/desktop_java/java_dev_intro.rst
**Change Type:** added
**Context:** PR #301: Adds samples for Java and Scala - A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face dete...
**Review Line:** 98

**Code Changes:**
```diff
+
+        .. code-block:: bat
+
+           msbuild /m OpenCV.sln /t:Build /p:Configuration=Release /v:m
+
+Besides all this will create a ``jar`` containing the Java interface (:file:`bin/opencv_2.4.4.jar`)
+and a native dynamic library containing Java bindings and all the OpenCV stuff
+(:file:`bin/Release/opencv_java244.dll` or :file:`bin/libopencv_java244.so` respectively).
+We'll use these files later.
+
+Create a simple Java sample and an Ant build file for it
```

Review comment:
May be: "Besides all, this command will ..."
**File:** doc/tutorials/introduction/desktop_java/java_dev_intro.rst
**Change Type:** added
**Context:** PR #301: Adds samples for Java and Scala - A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face dete...
**Review Line:** 111

**Code Changes:**
```diff
+.. note::
+    The described sample is provided with OpenCV library in the :file:`opencv/samples/java/ant` folder.
+
+* Create a folder where you'll develop this sample application.
+
+* In this folder create an XML file with the following content using any text editor:
+
+    .. code-block:: xml
+        :linenos:
+
+        <project name="SimpleSample" basedir="." default="rebuild-run">
```

Review comment:
**a** XML file I suppose... And I would remove "using any test editor" - this is noise.
**File:** doc/tutorials/introduction/desktop_java/java_dev_intro.rst
**Change Type:** added
**Context:** PR #301: Adds samples for Java and Scala - A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face dete...

**Code Changes:**
```diff
@@ -0,0 +1,523 @@
+
+.. _Java_Dev_Intro:
+
+
+Introduction to Java Development
+********************************
+
+Last updated: 12 February, 2013.
+
```

Review comment:
Run should be capitalized
**File:** doc/tutorials/introduction/desktop_java/java_dev_intro.rst
**Change Type:** added
**Context:** PR #301: Adds samples for Java and Scala - A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face dete...
**Review Line:** 223

**Code Changes:**
```diff
+    .. image:: images/ant_output.png
+        :alt: run app with Ant
+        :align: center
+
+Create a simple Java project in Eclipse
+***************************************
+
+Now let's look at the possiblity of using OpenCV in Java when developing in Eclipse IDE.
+
+* Create a new Eclipse workspace
+* Create a new Java project via :guilabel:`File --> New --> Java Project`
```

Review comment:
I would like to know how does it relates to the Ant approach. Reader may think that this is step-by-step instruction, while these are alternatives. So, I need something like: "So, now you know how to work from command line... But if you want to use IDE for development..."
**File:** doc/tutorials/introduction/desktop_java/java_dev_intro.rst
**Change Type:** added
**Context:** PR #301: Adds samples for Java and Scala - A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face dete...

**Code Changes:**
```diff
@@ -0,0 +1,523 @@
+
+.. _Java_Dev_Intro:
+
+
+Introduction to Java Development
+********************************
+
+Last updated: 12 February, 2013.
+
```

Review comment:
Put **some** simple...
**File:** doc/tutorials/introduction/desktop_java/java_dev_intro.rst
**Change Type:** added
**Context:** PR #301: Adds samples for Java and Scala - A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face dete...

**Code Changes:**
```diff
@@ -0,0 +1,523 @@
+
+.. _Java_Dev_Intro:
+
+
+Introduction to Java Development
+********************************
+
+Last updated: 12 February, 2013.
+
```

Review comment:
...and find the identity matrix in the ...
**File:** doc/tutorials/introduction/desktop_java/java_dev_intro.rst
**Change Type:** added
**Context:** PR #301: Adds samples for Java and Scala - A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face dete...

**Code Changes:**
```diff
@@ -0,0 +1,523 @@
+
+.. _Java_Dev_Intro:
+
+
+Introduction to Java Development
+********************************
+
+Last updated: 12 February, 2013.
+
```

Review comment:
What is opencv? OpenCV folder? Directory with OpenCV sources, repository?
**File:** doc/tutorials/introduction/desktop_java/java_dev_intro.rst
**Change Type:** added
**Context:** PR #301: Adds samples for Java and Scala - A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face dete...

**Code Changes:**
```diff
@@ -0,0 +1,523 @@
+
+.. _Java_Dev_Intro:
+
+
+Introduction to Java Development
+********************************
+
+Last updated: 12 February, 2013.
+
```

Review comment:
it will just **serve** as a text editor
**File:** doc/tutorials/introduction/desktop_java/java_dev_intro.rst
**Change Type:** added
**Context:** PR #301: Adds samples for Java and Scala - A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face dete...

**Code Changes:**
```diff
@@ -0,0 +1,523 @@
+
+.. _Java_Dev_Intro:
+
+
+Introduction to Java Development
+********************************
+
+Last updated: 12 February, 2013.
+
```

Review comment:
To test **that**?
**File:** doc/tutorials/introduction/desktop_java/java_dev_intro.rst
**Change Type:** added
**Context:** PR #301: Adds samples for Java and Scala - A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face dete...

**Code Changes:**
```diff
@@ -0,0 +1,523 @@
+
+.. _Java_Dev_Intro:
+
+
+Introduction to Java Development
+********************************
+
+Last updated: 12 February, 2013.
+
```

Review comment:
Well, if we do this, can we use the file from opencv/data folder and remove cascade from the pull request?
**File:** doc/tutorials/introduction/desktop_java/java_dev_intro.rst
**Change Type:** added
**Context:** PR #301: Adds samples for Java and Scala - A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face dete...
**Review Line:** 515

**Code Changes:**
```diff
+
+     .. image:: images/sbt_run_face.png
+        :alt: SBT run
+        :align: center
+
+It should also write the following image to :file:`faceDetection.png`:
+
+     .. image:: images/faceDetection.png
+        :alt: Detected face
+        :align: center
+
```

Review comment:
So?.. Any conclusion and congratulations? Where is my: "You're done! Now you have a sample Java application working with OpenCV, so you can start the work on your own. We wish you good luck and many years of joyful life!"
**File:** doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.rst
**Change Type:** modified
**Context:** PR #301: Adds samples for Java and Scala - A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face dete...

**Code Changes:**
```diff
@@ -101,6 +101,26 @@ Here you can read tutorials about how to set up your computer to work with the O
                       :height: 90pt
                       :width:  90pt
 
+* **Desktop Java**
+
+  .. tabularcolumns:: m{100pt} m{300pt}
+  .. cssclass:: toctableopencv
+
+  ================ =================================================
```

Review comment:
Andrey, I would add your name after comma. I think your contribution to this tutorial is substantial...
**File:** doc/tutorials/introduction/desktop_java/java_dev_intro.rst
**Change Type:** added
**Context:** PR #301: Adds samples for Java and Scala - A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face dete...

**Code Changes:**
```diff
@@ -0,0 +1,523 @@
+
+.. _Java_Dev_Intro:
+
+
+Introduction to Java Development
+********************************
+
+Last updated: 12 February, 2013.
+
```

Review comment:
I really can't catch why your suggestion is better than existing text, but OK, I'll rephrase the sentence.
**File:** doc/tutorials/introduction/desktop_java/java_dev_intro.rst
**Change Type:** added
**Context:** PR #301: Adds samples for Java and Scala - A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face dete...

**Code Changes:**
```diff
@@ -0,0 +1,523 @@
+
+.. _Java_Dev_Intro:
+
+
+Introduction to Java Development
+********************************
+
+Last updated: 12 February, 2013.
+
```

Review comment:
I'll update the tutorial after desktop Java is merged to `master`, now we need to state this explicitly.
**File:** modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java
**Change Type:** modified
**Context:** PR #150: Java test fix. Eclipse test execution fix.

**Code Changes:**
```diff
@@ -23,15 +23,20 @@
 import org.opencv.features2d.KeyPoint;
 import org.opencv.highgui.Highgui;
 
-public class OpenCVTestCase extends TestCase {
+import android.util.Log;
 
+public class OpenCVTestCase extends TestCase {
     //change to 'true' to unblock fail on fail("Not yet implemented")
     public static final boolean passNYI = true;
```

Review comment:
I suggest you use more descriptive var name, e.g. **setVideoCaptureNYI**
**File:** modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java
**Change Type:** modified
**Context:** PR #150: Java test fix. Eclipse test execution fix.
**Review Line:** 72

**Code Changes:**
```diff
-                if (name.contains("VideoCaptureTest"))
-                    it.remove();
-            }
-        }
-
+        // Note: VideoCapture tests turned off by flag field in VideoCaptureTest class
 
         super.onStart();
     }
```

Review comment:
Could you remove the outdated code instead of commenting it out? We have a version control system (currently git) to keep the history.
**File:** modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java
**Change Type:** modified
**Context:** PR #150: Java test fix. Eclipse test execution fix.
**Review Line:** 184

**Code Changes:**
```diff
     }
 
+    @Override
+    protected void runTest() throws Throwable {
+        // Do nothing if the precondition does not hold.
+        if (isTestCaseEnabled) {
+            super.runTest();
+        } else {
+            Log.e(TAG, "Test case \"" + this.getClass().getName() + "\" disabled!");
+        }
+    }
```

Review comment:
I would recommend adding `else` section putting into the logcat that the test case is disabled!
**File:** modules/core/src/hal_replacement.hpp
**Change Type:** modified
**Context:** PR #6535: Lapack hal - ### What does this PR change? - Add HAL interface for SVD and GEMM - Implement internal HAL for gemm and matrix decomposition s...
**Review Line:** 565

**Code Changes:**
```diff
+@param n number of columns in matrix \f$A\f$ or \f$A^T\f$
+@param k number of columns in matrix \f$B\f$ or \f$B^T\f$, equals to number of columns in matrix \f$D\f$
+@param flags algorithm options (combination of CV_HAL_GEMM_1_T, ...).
+ */
+
+//! @addtogroup core_hal_interface_matrix_multiplication Matrix multiplication
+//! @{
+inline int hal_ni_gemm32f(const float* src1, size_t src1_step, const float* src2, size_t src2_step,
+                          float alpha, const float* src3, size_t src3_step, float beta, float* dst, size_t dst_step,
+                          int m, int n, int k, int flags) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
+inline int hal_ni_gemm64f(const double* src1, size_t src1_step, const double* src2, size_t src2_step,
```

Review comment:
This group should be documented too.
**File:** modules/core/src/matmul.cpp
**Change Type:** modified
**Context:** PR #6535: Lapack hal - ### What does this PR change? - Add HAL interface for SVD and GEMM - Implement internal HAL for gemm and matrix decomposition s...

**Code Changes:**
```diff
@@ -864,73 +864,39 @@ static bool ocl_gemm( InputArray matA, InputArray matB, double alpha,
     return k.run(2, globalsize, block_size!=1 ? localsize : NULL, false);
 }
 #endif
-}
 
-void cv::gemm( InputArray matA, InputArray matB, double alpha,
-           InputArray matC, double beta, OutputArray _matD, int flags )
+static void gemmImpl( Mat A, Mat B, double alpha,
+           Mat C, double beta, Mat D, int flags )
```

Review comment:
It will be better to move all `CV_StaticAssert`s used in these four functions into `_callInternalGemmImpl` function.
**File:** modules/core/src/lapack.cpp
**Change Type:** modified
**Context:** PR #6535: Lapack hal - ### What does this PR change? - Add HAL interface for SVD and GEMM - Implement internal HAL for gemm and matrix decomposition s...

**Code Changes:**
```diff
@@ -570,11 +570,44 @@ JacobiSVDImpl_(_Tp* At, size_t astep, _Tp* _W, _Tp* Vt, size_t vstep,
 
 static void JacobiSVD(float* At, size_t astep, float* W, float* Vt, size_t vstep, int m, int n, int n1=-1)
 {
-    JacobiSVDImpl_(At, astep, W, Vt, vstep, m, n, !Vt ? 0 : n1 < 0 ? n : n1, FLT_MIN, FLT_EPSILON*2);
+    hal::SVD32f(At, astep, W, NULL, astep, Vt, vstep, m, n, n1);
 }
 
 static void JacobiSVD(double* At, size_t astep, double* W, double* Vt, size_t vstep, int m, int n, int n1=-1)
 {
```

Review comment:
the function is declared as int, however it returns bool; can you please fix it?
**File:** modules/core/include/opencv2/core/hal/hal.hpp
**Change Type:** modified
**Context:** PR #6535: Lapack hal - ### What does this PR change? - Add HAL interface for SVD and GEMM - Implement internal HAL for gemm and matrix decomposition s...

**Code Changes:**
```diff
@@ -49,17 +49,6 @@
 #include "opencv2/core/cvstd.hpp"
 #include "opencv2/core/hal/interface.h"
 
-//! @cond IGNORED
-#define CALL_HAL(name, fun, ...) \
-    int res = fun(__VA_ARGS__); \
-    if (res == CV_HAL_ERROR_OK) \
-        return; \
-    else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \
```

Review comment:
all the exposed macros should start with CV_ or OPENCV_ prefix
**File:** modules/core/src/hal_replacement.hpp
**Change Type:** modified
**Context:** PR #6535: Lapack hal - ### What does this PR change? - Add HAL interface for SVD and GEMM - Implement internal HAL for gemm and matrix decomposition s...

**Code Changes:**
```diff
@@ -472,14 +472,148 @@ inline int hal_ni_dctFree2D(cvhalDFT *context) { return CV_HAL_ERROR_NOT_IMPLEME
 #define cv_hal_dctFree2D hal_ni_dctFree2D
 //! @endcond
 
+
+/**
+Performs \f$LU\f$ decomposition of square matrix \f$A=P*L*U\f$ (where \f$P\f$ is permutation matrix) and solves matrix equation \f$A*X=B\f$.
+Function returns the \f$sign\f$ of permutation \f$P\f$ via parameter info.
+@param src1 pointer to input matrix \f$A\f$ stored in row major order. After finish of work src1 contains at least \f$U\f$ part of \f$LU\f$
+decomposition which is appropriate for determainant calculation: \f$det(A)=sign*\prod_{j=1}^{M}a_{jj}\f$.
```

Review comment:
LU should be written in uppercase form
**File:** modules/core/src/hal_replacement.hpp
**Change Type:** modified
**Context:** PR #6535: Lapack hal - ### What does this PR change? - Add HAL interface for SVD and GEMM - Implement internal HAL for gemm and matrix decomposition s...

**Code Changes:**
```diff
@@ -472,14 +472,148 @@ inline int hal_ni_dctFree2D(cvhalDFT *context) { return CV_HAL_ERROR_NOT_IMPLEME
 #define cv_hal_dctFree2D hal_ni_dctFree2D
 //! @endcond
 
+
+/**
+Performs \f$LU\f$ decomposition of square matrix \f$A=P*L*U\f$ (where \f$P\f$ is permutation matrix) and solves matrix equation \f$A*X=B\f$.
+Function returns the \f$sign\f$ of permutation \f$P\f$ via parameter info.
+@param src1 pointer to input matrix \f$A\f$ stored in row major order. After finish of work src1 contains at least \f$U\f$ part of \f$LU\f$
+decomposition which is appropriate for determainant calculation: \f$det(A)=sign*\prod_{j=1}^{M}a_{jj}\f$.
```

Review comment:
Cholesky should start with a capital letter
**File:** modules/core/src/hal_replacement.hpp
**Change Type:** modified
**Context:** PR #6535: Lapack hal - ### What does this PR change? - Add HAL interface for SVD and GEMM - Implement internal HAL for gemm and matrix decomposition s...

**Code Changes:**
```diff
@@ -472,14 +472,148 @@ inline int hal_ni_dctFree2D(cvhalDFT *context) { return CV_HAL_ERROR_NOT_IMPLEME
 #define cv_hal_dctFree2D hal_ni_dctFree2D
 //! @endcond
 
+
+/**
+Performs \f$LU\f$ decomposition of square matrix \f$A=P*L*U\f$ (where \f$P\f$ is permutation matrix) and solves matrix equation \f$A*X=B\f$.
+Function returns the \f$sign\f$ of permutation \f$P\f$ via parameter info.
+@param src1 pointer to input matrix \f$A\f$ stored in row major order. After finish of work src1 contains at least \f$U\f$ part of \f$LU\f$
+decomposition which is appropriate for determainant calculation: \f$det(A)=sign*\prod_{j=1}^{M}a_{jj}\f$.
```

Review comment:
SVD should be written in uppercase form
**File:** modules/core/include/opencv2/core/hal/hal.hpp
**Change Type:** modified
**Context:** PR #6535: Lapack hal - ### What does this PR change? - Add HAL interface for SVD and GEMM - Implement internal HAL for gemm and matrix decomposition s...

**Code Changes:**
```diff
@@ -49,17 +49,6 @@
 #include "opencv2/core/cvstd.hpp"
 #include "opencv2/core/hal/interface.h"
 
-//! @cond IGNORED
-#define CALL_HAL(name, fun, ...) \
-    int res = fun(__VA_ARGS__); \
-    if (res == CV_HAL_ERROR_OK) \
-        return; \
-    else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \
```

Review comment:
Since these macros are only used to make internal calls to HAL, I suggest to move them to `core/src/hal_replacement.hpp` and a copy to `imgproc/src/hal_replacement.hpp` (or some other private header).
**File:** modules/core/src/matmul.cpp
**Change Type:** modified
**Context:** PR #6535: Lapack hal - ### What does this PR change? - Add HAL interface for SVD and GEMM - Implement internal HAL for gemm and matrix decomposition s...

**Code Changes:**
```diff
@@ -864,73 +864,39 @@ static bool ocl_gemm( InputArray matA, InputArray matB, double alpha,
     return k.run(2, globalsize, block_size!=1 ? localsize : NULL, false);
 }
 #endif
-}
 
-void cv::gemm( InputArray matA, InputArray matB, double alpha,
-           InputArray matC, double beta, OutputArray _matD, int flags )
+static void gemmImpl( Mat A, Mat B, double alpha,
+           Mat C, double beta, Mat D, int flags )
```

Review comment:
It is better to avoid names starting with `_`. I'd suggest renaming this function to `gemmImpl` and `_callInternalGemmImpl` to `callGemmImpl`.
**File:** modules/calib3d/src/calibration.cpp
**Change Type:** modified
**Context:** PR #5620: use cpp functions in cvCalibrateCamera2 to make it more readable

**Code Changes:**
```diff
@@ -1232,12 +1232,12 @@ CV_IMPL double cvCalibrateCamera2( const CvMat* objectPoints,
                     CvMat* rvecs, CvMat* tvecs, int flags, CvTermCriteria termCrit )
 {
     const int NINTRINSIC = 16;
-    Ptr<CvMat> matM, _m, _Ji, _Je, _err;
     CvLevMarq solver;
     double reprojErr = 0;
 
-    double A[9],  k[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
-    CvMat matA = cvMat(3, 3, CV_64F, A), _k;
```

Review comment:
looks like it should be += here too
**File:** modules/calib3d/src/calibration.cpp
**Change Type:** modified
**Context:** PR #5620: use cpp functions in cvCalibrateCamera2 to make it more readable

**Code Changes:**
```diff
@@ -1232,12 +1232,12 @@ CV_IMPL double cvCalibrateCamera2( const CvMat* objectPoints,
                     CvMat* rvecs, CvMat* tvecs, int flags, CvTermCriteria termCrit )
 {
     const int NINTRINSIC = 16;
-    Ptr<CvMat> matM, _m, _Ji, _Je, _err;
     CvLevMarq solver;
     double reprojErr = 0;
 
-    double A[9],  k[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
-    CvMat matA = cvMat(3, 3, CV_64F, A), _k;
```

Review comment:
I am not sure what this part implements exactly, but the previous code was: `cvGEMM( _Je, _err, 1, 0, 0, &_part, CV_GEMM_A_T )` i.e. `_part = Je'*_err`
**File:** modules/calib3d/src/calibration.cpp
**Change Type:** modified
**Context:** PR #5620: use cpp functions in cvCalibrateCamera2 to make it more readable

**Code Changes:**
```diff
@@ -1232,12 +1232,12 @@ CV_IMPL double cvCalibrateCamera2( const CvMat* objectPoints,
                     CvMat* rvecs, CvMat* tvecs, int flags, CvTermCriteria termCrit )
 {
     const int NINTRINSIC = 16;
-    Ptr<CvMat> matM, _m, _Ji, _Je, _err;
     CvLevMarq solver;
     double reprojErr = 0;
 
-    double A[9],  k[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
-    CvMat matA = cvMat(3, 3, CV_64F, A), _k;
```

Review comment:
found out what this is doing. code is correct as is.
**File:** modules/calib3d/src/calibration.cpp
**Change Type:** modified
**Context:** PR #5620: use cpp functions in cvCalibrateCamera2 to make it more readable
**Review Line:** 1508

**Code Changes:**
```diff
+                JtJ(Rect(NINTRINSIC + i * 6, NINTRINSIC + i * 6, 6, 6)) = _Je.t() * _Je;
+                JtJ(Rect(NINTRINSIC + i * 6, 0, 6, NINTRINSIC)) = _Ji.t() * _Je;
 
-                cvGetRows( _JtErr, &_part, NINTRINSIC + i*6, NINTRINSIC + (i+1)*6 );
-                cvGEMM( _Je, _err, 1, 0, 0, &_part, CV_GEMM_A_T );
+                JtErr.rowRange(0, NINTRINSIC) += _Ji.t() * _err;
+                JtErr.rowRange(NINTRINSIC + i * 6, NINTRINSIC + (i + 1) * 6) = _Je.t() * _err;
             }
 
-            double errNorm = cvNorm( &_mp, 0, CV_L2 );
-            reprojErr += errNorm*errNorm;
```

Review comment:
ok, yet another question. I do not see where JtErr is cleared, to me it looks like it would be safe to clear JtErr (and probably JtJ too, because it's top-left 6x6 part is updated in the same way) before the loop over images.
**File:** modules/calib3d/src/calibration.cpp
**Change Type:** modified
**Context:** PR #5620: use cpp functions in cvCalibrateCamera2 to make it more readable
**Review Line:** 1508

**Code Changes:**
```diff
+                JtJ(Rect(NINTRINSIC + i * 6, NINTRINSIC + i * 6, 6, 6)) = _Je.t() * _Je;
+                JtJ(Rect(NINTRINSIC + i * 6, 0, 6, NINTRINSIC)) = _Ji.t() * _Je;
 
-                cvGetRows( _JtErr, &_part, NINTRINSIC + i*6, NINTRINSIC + (i+1)*6 );
-                cvGEMM( _Je, _err, 1, 0, 0, &_part, CV_GEMM_A_T );
+                JtErr.rowRange(0, NINTRINSIC) += _Ji.t() * _err;
+                JtErr.rowRange(NINTRINSIC + i * 6, NINTRINSIC + (i + 1) * 6) = _Je.t() * _err;
             }
 
-            double errNorm = cvNorm( &_mp, 0, CV_L2 );
-            reprojErr += errNorm*errNorm;
```

Review comment:
Both are cleared inside `CvLevMarq::updateAlt` - which is a very unfortunate design indeed..
**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:
There is a comment above, that doesn't correlate with code at this moment. Need to check