nareshmlx/opencv-pr huggingface dataset:
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
`MatExpr` can be avoided
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
`constexpr`?
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
You can squash this to copy constructor calls, not default constructors and copy assignments.
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
I believe this is done for "documentation" purposes. See: http://pullrequest.opencv.org/buildbot/export/pr/18335/docs/da/d4a/classcv_1_1Quat.html#friends
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
Indeed Rodrigues' rotation formula is about rotating a vector by an axis of rotation and an angle. --- Still, I am not convinced about using `tan(psi / 2) * n` rotation representation. It is the first time I have seen this representation. Granted, I am not an expert. In my opinion, `rvec` variable name should mean `angle * axis()` and match the meaning of `rvec` in the `calib3d` module. If `tan(psi / 2) * n` representation should be supported, it should be non-ambiguous for a novice user, and no confusion should be possible with `angle * axis()` representation. --- Is there really an usage for `tan(psi / 2) * n` rotation representation? Is it really needed to support it? I don't think Eigen supports this representation. I don't think it is described in the [Handbook of Robotics](https://www.cc.gatech.edu/~hic/4632B-07/kinematics-draft.pdf). And I would like to see a library that supports this rotation representation to be convinced that it can be useful.
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
I also vote for `axis*angle` vector instead of "true" tan-based Rodrigues vector - here and everywhere in OpenCV. But, to avoid mixing the terms, this should be called "rotation vector", not a "Rodrigues vector". First, because it fails to represent rotations close to pi around any axis. Second, because it's more conventional and it's used everywhere, from calib3d to Eigen.
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
Maybe adding a template parameter `assumeUnit` is a good idea. A note should be added for a user that when this flag is on, this would make the code a bit faster but wouldn't preserve the unit norm or perform normalization, it's a user's responsibility. Also, this would leave class members public.
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
OK. We will change it to `axis*angle` form and corresponding description
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
Could I ask why we should avoid `MatExpr`? Can `MatExpr` handle complex operations with higher efficiency?
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
If it's free function, user can't find it in Quat documentation
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
`static_assert` should be OK here, see no problem.
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
`MatExpr` is too heavy for such small matrices: it involves `Mat` copying several times, sub-expression creation and so on. `MatExpr` has more sense for complex Mat-based expressions. For small matrices there is a `Matx` which is almost overhead-free.
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
During the process of converting assumeUnit to template parameter, I have encountered some problem and I think make this param to template is not flexible enough. Here are two problems: 1. Some functions will change the quaternion from unit to not unit one or from not unit to unit one. like exp(), log(). If a user set `Quat<double, true> q{1/2,1/2,1/2,1/2};` and it will become not unit one after `log(q)`， while the flag is still on(true). 2. In interpolation function, all inputs must be same including the `assumeUnit` in each quaternion, otherwise it can't match the function. But this is not required in this code. So I think left assumeUnit in each function is better.
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
Please fix docs: `theta` => `theta/2` as it should be
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
OK, for uniformity purposes, let's keep some functions with `assumeUnit` argument.
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion
**Review Line:** 429

**Code Changes:**
```diff
+    /**
+     * @brief return a normalized \f$p\f$.
+     * \f[p = \frac{q}{||q||}\f]
+     * where \f$p\f$ satisfies \f$(p.x)^2 + (p.y)^2 + (p.z)^2 + (p.w)^2 = 1.\f$
+     */
+    Quat<_Tp> normalize() const;
+
+    /**
+     * @brief return \f$q^{-1}\f$ which is an inverse of \f$q\f$
+     * which satisfies \f$q * q^{-1} = 1\f$.
+     * @param q a quaternion.
```

Review comment:
I think `normalized` has more sense here; `normalize` looks more like a method that changes its object
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion
**Review Line:** 429

**Code Changes:**
```diff
+    /**
+     * @brief return a normalized \f$p\f$.
+     * \f[p = \frac{q}{||q||}\f]
+     * where \f$p\f$ satisfies \f$(p.x)^2 + (p.y)^2 + (p.z)^2 + (p.w)^2 = 1.\f$
+     */
+    Quat<_Tp> normalize() const;
+
+    /**
+     * @brief return \f$q^{-1}\f$ which is an inverse of \f$q\f$
+     * which satisfies \f$q * q^{-1} = 1\f$.
+     * @param q a quaternion.
```

Review comment:
I think what you mean is as follows: ```cpp // change q and return None q.normalize() // q is not changed and return normalized q q2 = q.normalized() ``` It is a bit strange using adjectives as the names of built-in member functions. And since this module only has one of the above member functions, I think it is enough to use the verb without causing confusion.
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
OK. I will improve the definition of variables in each function.
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
Use ``` -double theta = acos(c); +double theta = std::acos(c); ``` `std::` directly instead. Avoid using of "using" in public headers.
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion

**Code Changes:**
```diff
@@ -0,0 +1,1194 @@
+// 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.
+//
+//
+//                          License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved.
```

Review comment:
This line of code is in other file（affine.hpp）. Can I directly change it?
**File:** modules/core/include/opencv2/core/quaternion.inl.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion
**Review Line:** 205

**Code Changes:**
```diff
+{
+    T qw, qx, qy, qz;
+    qw = w * q1.w - x * q1.x - y * q1.y - z * q1.z;
+    qx = x * q1.w + w * q1.x + y * q1.z - z * q1.y;
+    qy = y * q1.w + w * q1.y + z * q1.x - x * q1.z;
+    qz = z * q1.w + w * q1.z + x * q1.y - y * q1.x;
+    w = qw;
+    x = qx;
+    y = qy;
+    z = qz;
+    return *this;
```

Review comment:
In general users expect the same operations under `operator*()` and `operator*=()` ``` c = a * b; a *= b; ASSERT(a == c); ``` This is not true for current implementation. If this can't be unified, then it is better to undefine these operators and use dedicated well-named and documented functions.
**File:** modules/core/include/opencv2/core/quaternion.inl.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion
**Review Line:** 205

**Code Changes:**
```diff
+{
+    T qw, qx, qy, qz;
+    qw = w * q1.w - x * q1.x - y * q1.y - z * q1.z;
+    qx = x * q1.w + w * q1.x + y * q1.z - z * q1.y;
+    qy = y * q1.w + w * q1.y + z * q1.x - x * q1.z;
+    qz = z * q1.w + w * q1.z + x * q1.y - y * q1.x;
+    w = qw;
+    x = qx;
+    y = qy;
+    z = qz;
+    return *this;
```

Review comment:
I'm so sorry I didn't repeat the mistake you mentioned. Here is my test code: ``` Quatd a{-2.1, 1.7, 0, 3.1415926}; Quatd b{2.5, 0, -2, 0.5}; Quatd c = a * b; a *= b; CV_Assert(a == c); ``` But I found no issue here. Could you please describe more details?
**File:** modules/core/include/opencv2/core/quaternion.inl.hpp
**Change Type:** added
**Context:** PR #18335: Ordinary quaternion
**Review Line:** 205

**Code Changes:**
```diff
+{
+    T qw, qx, qy, qz;
+    qw = w * q1.w - x * q1.x - y * q1.y - z * q1.z;
+    qx = x * q1.w + w * q1.x + y * q1.z - z * q1.y;
+    qy = y * q1.w + w * q1.y + z * q1.x - x * q1.z;
+    qz = z * q1.w + w * q1.z + x * q1.y - y * q1.x;
+    w = qw;
+    x = qx;
+    y = qy;
+    z = qz;
+    return *this;
```

Review comment:
You are right. My mistake (forgot about cross product for `Vec` type).
**File:** modules/java/generator/gen_java.py
**Change Type:** modified
**Context:** PR #11940: Add Java overloads for each default argument -  ### This pullrequest changes * Bind Java functions considering all the default parameters. ...

**Code Changes:**
```diff
@@ -67,6 +67,10 @@ def checkFileRemap(path):
     "double[]": { "j_type" : "double[]", "jn_type" : "double[]", "jni_type" : "jdoubleArray", "suffix" : "_3D" }
 }
 
+# Defines a rule to add extra prefixes for names from specific namespaces.
+# In example, cv::fisheye::stereoRectify from namespace fisheye is wrapped as fisheye_stereoRectify
+namespaces_dict = {}
+
 # { class : { func : {j_code, jn_code, cpp_code} } }
 ManualFuncs = {}
```

Review comment:
Perhaps, it would be better to move this to ["misc" configuration files](https://github.com/opencv/opencv/blob/3.4.2/modules/calib3d/misc/java/gen_dict.json).
**File:** modules/dnn/src/layers/convolution_layer.cpp
**Change Type:** modified
**Context:** PR #18783: Add support for Conv1D on OpenCV backend - resolves https://github.com/opencv/opencv/issues/18205 **merge with extra:** https://github.com/...

**Code Changes:**
```diff
@@ -113,17 +113,22 @@ class BaseConvolutionLayerImpl : public ConvolutionLayer
         MatSize weightShape = blobs.empty() ? inputs[1].size : blobs[0].size;
 
         CV_Assert(inputs[0].dims == outputs[0].dims);
+        if (weightShape.dims() == 3)
+        {
+            kernel_size.assign(1, kernel_size[0]);
+            strides.assign(1, strides[0]);
+        }
         CV_Assert(weightShape.dims() == kernel_size.size() + 2);
```

Review comment:
better to format as `else if (isConv2D) {`
**File:** modules/dnn/perf/perf_convolution1d.cpp
**Change Type:** added
**Context:** PR #18783: Add support for Conv1D on OpenCV backend - resolves https://github.com/opencv/opencv/issues/18205 **merge with extra:** https://github.com/...

**Code Changes:**
```diff
@@ -0,0 +1,163 @@
+// 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 "perf_precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace opencv_test {
+
```

Review comment:
If-else branches havw the same code.
**File:** modules/dnn/perf/perf_convolution1d.cpp
**Change Type:** added
**Context:** PR #18783: Add support for Conv1D on OpenCV backend - resolves https://github.com/opencv/opencv/issues/18205 **merge with extra:** https://github.com/...

**Code Changes:**
```diff
@@ -0,0 +1,163 @@
+// 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 "perf_precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace opencv_test {
+
```

Review comment:
`flops` is integer value. Check should be exact without epsilon.
**File:** modules/dnn/perf/perf_convolution1d.cpp
**Change Type:** added
**Context:** PR #18783: Add support for Conv1D on OpenCV backend - resolves https://github.com/opencv/opencv/issues/18205 **merge with extra:** https://github.com/...

**Code Changes:**
```diff
@@ -0,0 +1,163 @@
+// 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 "perf_precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace opencv_test {
+
```

Review comment:
Please add some check for output result. At least output shape.
**File:** modules/dnn/perf/perf_convolution1d.cpp
**Change Type:** added
**Context:** PR #18783: Add support for Conv1D on OpenCV backend - resolves https://github.com/opencv/opencv/issues/18205 **merge with extra:** https://github.com/...

**Code Changes:**
```diff
@@ -0,0 +1,163 @@
+// 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 "perf_precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace opencv_test {
+
```

Review comment:
> Indentation. Sorry, my formatter broke (again)
**File:** modules/dnn/perf/perf_convolution1d.cpp
**Change Type:** added
**Context:** PR #18783: Add support for Conv1D on OpenCV backend - resolves https://github.com/opencv/opencv/issues/18205 **merge with extra:** https://github.com/...

**Code Changes:**
```diff
@@ -0,0 +1,163 @@
+// 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 "perf_precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace opencv_test {
+
```

Review comment:
Actually, this is a warmup iteration, I don't think it is necessary to check the correctness of output shapes inside performance tests (it is already covered in other tests)
**File:** modules/dnn/src/layers/convolution_layer.cpp
**Change Type:** modified
**Context:** PR #18783: Add support for Conv1D on OpenCV backend - resolves https://github.com/opencv/opencv/issues/18205 **merge with extra:** https://github.com/...

**Code Changes:**
```diff
@@ -113,17 +113,22 @@ class BaseConvolutionLayerImpl : public ConvolutionLayer
         MatSize weightShape = blobs.empty() ? inputs[1].size : blobs[0].size;
 
         CV_Assert(inputs[0].dims == outputs[0].dims);
+        if (weightShape.dims() == 3)
+        {
+            kernel_size.assign(1, kernel_size[0]);
+            strides.assign(1, strides[0]);
+        }
         CV_Assert(weightShape.dims() == kernel_size.size() + 2);
```

Review comment:
``` else if (isConv2D) {
**File:** modules/dnn/src/layers/convolution_layer.cpp
**Change Type:** modified
**Context:** PR #18783: Add support for Conv1D on OpenCV backend - resolves https://github.com/opencv/opencv/issues/18205 **merge with extra:** https://github.com/...

**Code Changes:**
```diff
@@ -113,17 +113,22 @@ class BaseConvolutionLayerImpl : public ConvolutionLayer
         MatSize weightShape = blobs.empty() ? inputs[1].size : blobs[0].size;
 
         CV_Assert(inputs[0].dims == outputs[0].dims);
+        if (weightShape.dims() == 3)
+        {
+            kernel_size.assign(1, kernel_size[0]);
+            strides.assign(1, strides[0]);
+        }
         CV_Assert(weightShape.dims() == kernel_size.size() + 2);
```

Review comment:
``` } else {