nareshmlx/opencv-pr huggingface dataset:
**File:** modules/gapi/src/executor/gapi_itt.hpp
**Change Type:** added
**Context:** PR #17851: Sole tbb executor

**Code Changes:**
```diff
@@ -0,0 +1,59 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+//
+// Copyright (C) 2020 Intel Corporation
+
+#ifndef OPENCV_GAPI_GAPI_ITT_HPP
+#define OPENCV_GAPI_GAPI_ITT_HPP
+
```

Review comment:
> iostream Do we really need that here? (consider using `<ostream>` if `std::ostream` is required only without cout/cerr)
**File:** modules/gapi/src/executor/gapi_itt.hpp
**Change Type:** added
**Context:** PR #17851: Sole tbb executor

**Code Changes:**
```diff
@@ -0,0 +1,59 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+//
+// Copyright (C) 2020 Intel Corporation
+
+#ifndef OPENCV_GAPI_GAPI_ITT_HPP
+#define OPENCV_GAPI_GAPI_ITT_HPP
+
```

Review comment:
good catch - will change
**File:** modules/gapi/include/opencv2/gapi/util/copy_through_move.hpp
**Change Type:** added
**Context:** PR #17851: Sole tbb executor
**Review Line:** 16

**Code Changes:**
```diff
+
+namespace cv
+{
+namespace util
+{
+    //This is a tool to move initialize captures of a lambda in C++11
+    template<typename T>
+    struct copy_through_move_t{
+       T value;
+       const T& get() const {return value;}
+       T&       get()       {return value;}
```

Review comment:
If you do not mind, I will unify them in a separate PR.
**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 render Latex formula with Doxygen, [see](https://www.doxygen.nl/manual/formulas.html).
**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:
See the corresponding [tutorial](https://docs.opencv.org/master/d4/db1/tutorial_documentation.html). On Ubuntu, you can install doxygen with something like this: ``` sudo apt-get install doxygen sudo apt-get install graphviz sudo apt-get install texlive-latex-extra ``` By the way, to submit a pull request in OpenCV it is better to create a new branch. This way, the PR will be automatically tested on https://pullrequest.opencv.org/#/summary/opencv
**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:
As I said in earlier discussion, norm checking involves comparison of a (norm()-1) with an epsilon value which can be different in a source of quaternions. There may be an unpleasant situation when a user function produces unit quaternions and our implementation considers them not unit enough. I propose to get rid of such functions or to add an epsilon argument.
**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:
After discussion with Longbu, we think the assertNormal could remain to use for users with a param eps. They could check if a quaternion is a unit quaternion within the eps range that they can bear. What do you think?
**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:
Does it make sense to extend cv::Rodruigez? or add cv::RodruigezQ so that it works directly with a 4x1 cv::Mat?
**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 rather cv::RodruigezQ or cv::RodruigezQuat, as currently when a 3x1 vector is put in, a 3x3 matrix is expected.
**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 const double CV_QUAT_EPS = 1e-6`? Or better? `static constexpr double CV_QUAT_EPS = 1e-6`?
**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:
Something similar to `explicit Quat(const Vec<_Tp, 3> &rvec);`? `explicit Quat(const Mat<_Tp, 3, 3> &R);` for explicit shape?
**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 rather cv::RodruigezQ or cv::RodruigezQuat, as currently when a 3x1 vector is put in, a 3x3 matrix is expected. Do you mean to convert a quaternion to a Rodrigues vector? There is `cv::Vec<_Tp, 3> toRodrigues() const;` that can do that.
**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:
Also, in the [calib3d](https://docs.opencv.org/4.4.0/d9/d0c/group__calib3d.html) module, for Rodrigues vectors `rvec` naming is used. So for consistency `rvec`?
**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 think the same is OK and easy to understand for users.
**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:
Agreed. and referring to c++ primer: >Generally, it is a good idea to use constexpr for variables that you intend to use as constant expressions.
**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 meant it would be nice to have a functional way of converting from rVec to qVec (quaternion vector) instead of the objectoriented style with Quat. cv::rodruigez converts 3x1 mat to a 3x3 mat and vice versa. Other comment: Does it make sense to let Quat inherit from cv::Vec<type, 4>? This way we get all conversions from Quat to cv::Mat for 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:
It's OK to write the function rvecToQuat outside the class. But we will still keep this constructor, one is for the completeness of the class, and the other is that the functions under the cv outside the class are scattered, which may be difficult for users to find - - - - - - - - - - - - - - - I've seen the previous discussion between Rostislav and Vadim. Rostislav may perfer to make a new type here is the content ![screenshot](https://user-images.githubusercontent.com/49099366/94359351-3ad6f000-00d9-11eb-88e4-7de1aba85509.png)
**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:
Did you mean Matx？ We think that Matx is not as widely used as mat, and it can't be transformed from Mat to Matx implicitly, so we retain it.
**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:
Agree, this is a good solution
**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 think that the true OpenCV style is to use `InputArray` instead of `cv::Mat` as a function argument (if we need such a constructor at all, which is doubtful)
**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:
Is it not `InputArray` allows automatically generating bindings for Python and such?
**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:
Is it ok to have these `using std::*` in this header for the user?
**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:
No, it is not ok. It should be fixed.
**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:
We overload the sin function for queternion in Quat class, and we must use std::sin(angle) in the cpp file, otherwise, an error will be reported ``` error: no matching function for call to ‘cv::Quat<double>::sin(double)’ ``` In the quaternion file, we could call sin, cos in the way of std::sin and std::cos. but some cpp files which are already mergerd in opencv source use sin without std::sin to call sin(double). To have `using std::*` is the only way I know to solve this problem. Or is there a better solution to solve this 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:
I found change cv::Mat to InputArray will raise an ambiguous error, I think this maybe result from the constructor `Quat(const cv::Vec<_Tp, 4> &coeff)` and `Quat(const cv::Vec<_Tp, 3> &rvec)`. So I didn't modify it.
**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 avoid indentation in namespaces
**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:
avoid `cv::` in OpenCV code. It is not necessary.
**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 would suggest to remove this ctor. It can be misused (as mentioned above Vec4 coeff / Vec3 rvec). If you really want this overload then you may add this: ``` static inline Quat<_Tp> createFromCoeff(InputArray coeff); static inline Quat<_Tp> createFromRvec(InputArray rvec);
**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 `std::sin` (or `::std::sin` in worst case)
**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 move implementation into `quaternion.inl.hpp` file and include it here. (to avoid issues with documentation or bindings in the future).
**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:
There are too many methods with `assumeUnit` parameter. 1. It make sense to make it as a template parameter. 2. Or what is about creation of derived class for such quaternions handling? ``` base Quat=> QuatUnit or base QuatGeneric => Quat ``` (need to check terminology in articles and other libraries)
**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:
typo: expressed
**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:
typo? extrace -> extract