nareshmlx/opencv-pr huggingface dataset:
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #9871: Error in the documentation for cv::getRectSubPix. #9788 - The function name is corrected to GetRectSubPix since, it uses the notation of src...

**Code Changes:**
```diff
@@ -2470,13 +2470,12 @@ CV_EXPORTS_W Mat getAffineTransform( InputArray src, InputArray dst );
 
 The function getRectSubPix extracts pixels from src:
 
-\f[dst(x, y) = src(x +  \texttt{center.x} - ( \texttt{dst.cols} -1)*0.5, y +  \texttt{center.y} - ( \texttt{dst.rows} -1)*0.5)\f]
+\f[patch(x, y) = src(x +  \texttt{center.x} - ( \texttt{dst.cols} -1)*0.5, y +  \texttt{center.y} - ( \texttt{dst.rows} -1)*0.5)\f]
 
 where the values of the pixels at non-integer coordinates are retrieved using bilinear
-interpolation. Every channel of multi-channel images is processed independently. While the center of
-the rectangle must be inside the image, parts of the rectangle may be outside. In this case, the
```

Review comment:
Absolutely, But removing information about `dst` could seem like loss in important information in the documentation. Also borderInterpolate() isn't used/mentioned explicitly. It would be better to remove once confirms its non usability.
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #9871: Error in the documentation for cv::getRectSubPix. #9788 - The function name is corrected to GetRectSubPix since, it uses the notation of src...

**Code Changes:**
```diff
@@ -2470,13 +2470,12 @@ CV_EXPORTS_W Mat getAffineTransform( InputArray src, InputArray dst );
 
 The function getRectSubPix extracts pixels from src:
 
-\f[dst(x, y) = src(x +  \texttt{center.x} - ( \texttt{dst.cols} -1)*0.5, y +  \texttt{center.y} - ( \texttt{dst.rows} -1)*0.5)\f]
+\f[patch(x, y) = src(x +  \texttt{center.x} - ( \texttt{dst.cols} -1)*0.5, y +  \texttt{center.y} - ( \texttt{dst.rows} -1)*0.5)\f]
 
 where the values of the pixels at non-integer coordinates are retrieved using bilinear
-interpolation. Every channel of multi-channel images is processed independently. While the center of
-the rectangle must be inside the image, parts of the rectangle may be outside. In this case, the
```

Review comment:
One possible improvement is to change the `dst` in the formula to the output parameter `patch`.
**File:** modules/cudaoptflow/src/pyrlk.cpp
**Change Type:** modified
**Context:** PR #9627: async bugfix - ### This pullrequest changes I ran into a problem where if the input GPU stream was sufficiently ahead of the CPU, then the u...
**Review Line:** 93

**Code Changes:**
```diff
@@ -88,7 +90,8 @@ namespace
         void dense(const GpuMat& prevImg, const GpuMat& nextImg, GpuMat& u, GpuMat& v, Stream& stream);
 
     protected:
-        Size winSize_;
+        int winSize_[2];
+        int halfWinSize_[2];
         int maxLevel_;
         int iters_;
         bool useInitialFlow_;
@@ -100,8 +103,14 @@ namespace
```

Review comment:
This is a bad practice, please avoid this.
**File:** modules/cudaoptflow/src/pyrlk.cpp
**Change Type:** modified
**Context:** PR #9627: async bugfix - ### This pullrequest changes I ran into a problem where if the input GPU stream was sufficiently ahead of the CPU, then the u...
**Review Line:** 365

**Code Changes:**
```diff
+        virtual Size getWinSize() const { return cv::Size(winSize_[0], winSize_[1]); }
+        virtual void setWinSize(Size winSize) {
+            winSize_[0] = winSize.width;
+            winSize_[1] = winSize.height;
+            halfWinSize_[0] = (winSize.width - 1) / 2;
+            halfWinSize_[1] = (winSize.height -1) / 2;
+        }
 
         virtual int getMaxLevel() const { return maxLevel_; }
         virtual void setMaxLevel(int maxLevel) { maxLevel_ = maxLevel; }
```

Review comment:
`halfWinSize_` is updated in three locations, but used in `loadWinSize` only. Consider to drop this field completely and calculate it on-the-fly.
**File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #9834: MediaSDK video backend: Windows support - ### This pullrequest changes Adds support for Windows version of MediaSDK. Specific `DeviceHandler...

**Code Changes:**
```diff
@@ -245,7 +245,7 @@ OCV_OPTION(WITH_INTELPERC      "Include Intel Perceptual Computing support"  OFF
 OCV_OPTION(WITH_MATLAB         "Include Matlab support"                      ON   IF (NOT ANDROID AND NOT IOS AND NOT WINRT))
 OCV_OPTION(WITH_VA             "Include VA support"                          OFF  IF (UNIX AND NOT ANDROID) )
 OCV_OPTION(WITH_VA_INTEL       "Include Intel VA-API/OpenCL support"         OFF  IF (UNIX AND NOT ANDROID) )
-OCV_OPTION(WITH_MFX            "Include Intel Media SDK support"             OFF   IF (UNIX AND NOT ANDROID) )
+OCV_OPTION(WITH_MFX            "Include Intel Media SDK support"             OFF   IF ((UNIX AND NOT ANDROID) OR (WIN32 AND NOT WINRT AND NOT MINGW)) )
 OCV_OPTION(WITH_GDAL           "Include GDAL Support"                        OFF  IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
 OCV_OPTION(WITH_GPHOTO2        "Include gPhoto2 library support"             ON   IF (UNIX AND NOT ANDROID) )
 OCV_OPTION(WITH_LAPACK         "Include Lapack library support"              ON   IF (NOT ANDROID AND NOT IOS) )
```

Review comment:
Please use braces here. CMake doesn't define AND/OR evaluation order prior version 3.0.
**File:** modules/videoio/src/cap_mfx_common.cpp
**Change Type:** modified
**Context:** PR #9834: MediaSDK video backend: Windows support - ### This pullrequest changes Adds support for Windows version of MediaSDK. Specific `DeviceHandler...

**Code Changes:**
```diff
@@ -5,10 +5,12 @@
 #include "cap_mfx_common.hpp"
 
 // Linux specific
+#ifdef __linux__
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#endif
```

Review comment:
`__linux__`
**File:** modules/videoio/src/cap_mfx_common.hpp
**Change Type:** modified
**Context:** PR #9834: MediaSDK video backend: Windows support - ### This pullrequest changes Adds support for Windows version of MediaSDK. Specific `DeviceHandler...

**Code Changes:**
```diff
@@ -168,7 +168,7 @@ inline void cleanup(T * &ptr)
 
 //==================================================================================================
 
-struct Plugin
+class Plugin
 {
 public:
     static Plugin * loadEncoderPlugin(MFXVideoSession &session, mfxU32 codecId)
@@ -206,7 +206,7 @@ struct Plugin
```

Review comment:
The same problem: detection of platform via compiler is wrong. `_WIN32` should be here.
**File:** modules/videoio/src/cap_mfx_common.hpp
**Change Type:** modified
**Context:** PR #9834: MediaSDK video backend: Windows support - ### This pullrequest changes Adds support for Windows version of MediaSDK. Specific `DeviceHandler...

**Code Changes:**
```diff
@@ -168,7 +168,7 @@ inline void cleanup(T * &ptr)
 
 //==================================================================================================
 
-struct Plugin
+class Plugin
 {
 public:
     static Plugin * loadEncoderPlugin(MFXVideoSession &session, mfxU32 codecId)
@@ -206,7 +206,7 @@ struct Plugin
```

Review comment:
It is not "msec" in Unix: https://linux.die.net/man/3/sleep
**File:** samples/cpp/tutorial_code/snippets/core_merge.cpp
**Change Type:** added
**Context:** PR #9458: improve the documentation.

**Code Changes:**
```diff
@@ -0,0 +1,36 @@
+/**
+ * @file core_merge.cpp
+ * @brief It demonstrates the usage of cv::merge.
+ *
+ * It shows how to merge 3 single channel matrices into a 3-channel matrix.
+ *
+ * @author KUANG Fangjun
+ * @date August 2017
+ */
```

Review comment:
Could you please move all `cout << ...` lines out of documentation snippet block to reduce its size. Same for other files.
**File:** samples/dnn/ssd_mobilenet_object_detection.cpp
**Change Type:** modified
**Context:** PR #9941: Improve C++ DNN object detection samples -  ### This pullrequest changes - Add camera/video/image input for C++ DNN object detection samples...

**Code Changes:**
```diff
@@ -23,23 +23,25 @@ const char* classNames[] = {"background",
                             "motorbike", "person", "pottedplant",
                             "sheep", "sofa", "train", "tvmonitor"};
 
-const char* about = "This sample uses Single-Shot Detector "
-                    "(https://arxiv.org/abs/1512.02325)"
-                    "to detect objects on image.\n"
-                    ".caffemodel model's file is avaliable here: "
-                    "https://github.com/chuanqi305/MobileNet-SSD\n";
+const char* about = "This sample uses MobileNet Single-Shot Detector "
```

Review comment:
`parser.get<String>("image")` used here 5 times in this example. Probably we could save this value into some variable: ``` String imagePath = parser.get<String>("image"); if (imagePath.empty()) ... ```
**File:** samples/dnn/ssd_mobilenet_object_detection.cpp
**Change Type:** modified
**Context:** PR #9941: Improve C++ DNN object detection samples -  ### This pullrequest changes - Add camera/video/image input for C++ DNN object detection samples...

**Code Changes:**
```diff
@@ -23,23 +23,25 @@ const char* classNames[] = {"background",
                             "motorbike", "person", "pottedplant",
                             "sheep", "sofa", "train", "tvmonitor"};
 
-const char* about = "This sample uses Single-Shot Detector "
-                    "(https://arxiv.org/abs/1512.02325)"
-                    "to detect objects on image.\n"
-                    ".caffemodel model's file is avaliable here: "
-                    "https://github.com/chuanqi305/MobileNet-SSD\n";
+const char* about = "This sample uses MobileNet Single-Shot Detector "
```

Review comment:
or we could use this condition here and below: `if (img.empty())`
**File:** samples/dnn/ssd_mobilenet_object_detection.cpp
**Change Type:** modified
**Context:** PR #9941: Improve C++ DNN object detection samples -  ### This pullrequest changes - Add camera/video/image input for C++ DNN object detection samples...

**Code Changes:**
```diff
@@ -23,23 +23,25 @@ const char* classNames[] = {"background",
                             "motorbike", "person", "pottedplant",
                             "sheep", "sofa", "train", "tvmonitor"};
 
-const char* about = "This sample uses Single-Shot Detector "
-                    "(https://arxiv.org/abs/1512.02325)"
-                    "to detect objects on image.\n"
-                    ".caffemodel model's file is avaliable here: "
-                    "https://github.com/chuanqi305/MobileNet-SSD\n";
+const char* about = "This sample uses MobileNet Single-Shot Detector "
```

Review comment:
``` if (img.empty()) { error message: missing file or unsupported image format } ```
**File:** samples/dnn/ssd_mobilenet_object_detection.cpp
**Change Type:** modified
**Context:** PR #9941: Improve C++ DNN object detection samples -  ### This pullrequest changes - Add camera/video/image input for C++ DNN object detection samples...

**Code Changes:**
```diff
@@ -23,23 +23,25 @@ const char* classNames[] = {"background",
                             "motorbike", "person", "pottedplant",
                             "sheep", "sofa", "train", "tvmonitor"};
 
-const char* about = "This sample uses Single-Shot Detector "
-                    "(https://arxiv.org/abs/1512.02325)"
-                    "to detect objects on image.\n"
-                    ".caffemodel model's file is avaliable here: "
-                    "https://github.com/chuanqi305/MobileNet-SSD\n";
+const char* about = "This sample uses MobileNet Single-Shot Detector "
```

Review comment:
We also can pass image path to VideoCapture. Extra waitKey might be added after the last frame processed.
**File:** samples/dnn/ssd_mobilenet_object_detection.cpp
**Change Type:** modified
**Context:** PR #9941: Improve C++ DNN object detection samples -  ### This pullrequest changes - Add camera/video/image input for C++ DNN object detection samples...

**Code Changes:**
```diff
@@ -23,23 +23,25 @@ const char* classNames[] = {"background",
                             "motorbike", "person", "pottedplant",
                             "sheep", "sofa", "train", "tvmonitor"};
 
-const char* about = "This sample uses Single-Shot Detector "
-                    "(https://arxiv.org/abs/1512.02325)"
-                    "to detect objects on image.\n"
-                    ".caffemodel model's file is avaliable here: "
-                    "https://github.com/chuanqi305/MobileNet-SSD\n";
+const char* about = "This sample uses MobileNet Single-Shot Detector "
```

Review comment:
I cannot do `bool readSingleImage = (int) cap.get(CV_CAP_PROP_FRAME_COUNT) == 1` as I got `VIDEOIO ERROR: V4L2: getting property #7 is not supported` when opening a camera stream.
**File:** samples/dnn/ssd_mobilenet_object_detection.cpp
**Change Type:** modified
**Context:** PR #9941: Improve C++ DNN object detection samples -  ### This pullrequest changes - Add camera/video/image input for C++ DNN object detection samples...

**Code Changes:**
```diff
@@ -23,23 +23,25 @@ const char* classNames[] = {"background",
                             "motorbike", "person", "pottedplant",
                             "sheep", "sofa", "train", "tvmonitor"};
 
-const char* about = "This sample uses Single-Shot Detector "
-                    "(https://arxiv.org/abs/1512.02325)"
-                    "to detect objects on image.\n"
-                    ".caffemodel model's file is avaliable here: "
-                    "https://github.com/chuanqi305/MobileNet-SSD\n";
+const char* about = "This sample uses MobileNet Single-Shot Detector "
```

Review comment:
Ok, I have removed the image option.
**File:** modules/imgproc/src/shapedescr.cpp
**Change Type:** modified
**Context:** PR #9802: minEnclosingCircle from three point. Issue #9797 - resolves #9797 ### Problem If you give 3 points to the minEnclosingCircle function, it ch...

**Code Changes:**
```diff
@@ -43,84 +43,29 @@
 namespace cv
 {
 
-// inner product
-static float innerProduct(Point2f &v1, Point2f &v2)
-{
-    return v1.x * v2.y - v1.y * v2.x;
-}
+const float EPS = 1.0e-4f;
```

Review comment:
I think it would be better to remove the unused code completely
**File:** modules/imgproc/test/test_convhull.cpp
**Change Type:** modified
**Context:** PR #9802: minEnclosingCircle from three point. Issue #9797 - resolves #9797 ### Problem If you give 3 points to the minEnclosingCircle function, it ch...

**Code Changes:**
```diff
@@ -1017,6 +1017,62 @@ int CV_MinCircleTest::validate_test_results( int test_case_idx )
     return code;
 }
 
+/****************************************************************************************\
+*                                 MinEnclosingCircle Test 2                              *
+\****************************************************************************************/
+
+class CV_MinCircleTest2 : public CV_BaseShapeDescrTest
+{
```

Review comment:
While the test designed such way could detect errors IMHO it's more obvious(and at least more common) to perform result evaluation in `run_func()` function and just verify the result quality in `validate_test_results()`. Also added test reverify once again the generic case though the original issue is related to specific 3-points case. Could you please add test or tests to verify specific cases with less than 4 points?
**File:** modules/imgproc/test/test_convhull.cpp
**Change Type:** modified
**Context:** PR #9802: minEnclosingCircle from three point. Issue #9797 - resolves #9797 ### Problem If you give 3 points to the minEnclosingCircle function, it ch...

**Code Changes:**
```diff
@@ -1017,6 +1017,62 @@ int CV_MinCircleTest::validate_test_results( int test_case_idx )
     return code;
 }
 
+/****************************************************************************************\
+*                                 MinEnclosingCircle Test 2                              *
+\****************************************************************************************/
+
+class CV_MinCircleTest2 : public CV_BaseShapeDescrTest
+{
```

Review comment:
Ok, I will edit this. But I didn't understand. Do you want me to change this test so it works only for 3 points or less, or do you want me to add one more?
**File:** modules/imgproc/test/test_convhull.cpp
**Change Type:** modified
**Context:** PR #9802: minEnclosingCircle from three point. Issue #9797 - resolves #9797 ### Problem If you give 3 points to the minEnclosingCircle function, it ch...

**Code Changes:**
```diff
@@ -1017,6 +1017,62 @@ int CV_MinCircleTest::validate_test_results( int test_case_idx )
     return code;
 }
 
+/****************************************************************************************\
+*                                 MinEnclosingCircle Test 2                              *
+\****************************************************************************************/
+
+class CV_MinCircleTest2 : public CV_BaseShapeDescrTest
+{
```

Review comment:
And why do we need to test the case with 2 and 1 points? Maybe it's worth the test for only 3?
**File:** modules/features2d/src/fast.avx2.cpp
**Change Type:** added
**Context:** PR #9875: FAST performance improvement - ### This pullrequest changes AVX2 optimization for FAST corner tracking provided by Victoria Zhislina

**Code Changes:**
```diff
@@ -0,0 +1,184 @@
+/* This is FAST corner detector, contributed to OpenCV by the author, Edward Rosten.
+   Below is the original copyright and the references */
+
+/*
+Copyright (c) 2006, 2008 Edward Rosten
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
```

Review comment:
This is always non-optimal to store constants as fields.
**File:** modules/features2d/src/fast.hpp
**Change Type:** added
**Context:** PR #9875: FAST performance improvement - ### This pullrequest changes AVX2 optimization for FAST corner tracking provided by Victoria Zhislina

**Code Changes:**
```diff
@@ -0,0 +1,62 @@
+/* This is FAST corner detector, contributed to OpenCV by the author, Edward Rosten.
+   Below is the original copyright and the references */
+
+/*
+Copyright (c) 2006, 2008 Edward Rosten
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
```

Review comment:
Don't use precomp.hpp from header files.
**File:** modules/features2d/src/fast.avx2.cpp
**Change Type:** added
**Context:** PR #9875: FAST performance improvement - ### This pullrequest changes AVX2 optimization for FAST corner tracking provided by Victoria Zhislina

**Code Changes:**
```diff
@@ -0,0 +1,184 @@
+/* This is FAST corner detector, contributed to OpenCV by the author, Edward Rosten.
+   Below is the original copyright and the references */
+
+/*
+Copyright (c) 2006, 2008 Edward Rosten
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
```

Review comment:
Does this header safe for using with dispatched code? What version of `cornerScore<>` would be used by linker in binary file: from this .cpp file (AVX2-based code) or from generic code (non-AVX2 code)?
**File:** modules/python/src2/cv2.cpp
**Change Type:** modified
**Context:** PR #9839: Python wrappers for Vec and Matx - ### This pullrequest changes Added python wrappers for Vec and Matx

**Code Changes:**
```diff
@@ -394,6 +394,24 @@ bool pyopencv_to(PyObject* o, Mat& m, const char* name)
     return pyopencv_to(o, m, ArgInfo(name, 0));
 }
 
+template<typename _Tp, int m, int n>
+bool pyopencv_to(PyObject* o, Matx<_Tp, m, n>& mx, const ArgInfo info)
+{
+    Mat tmp;
+    if (!pyopencv_to(o, tmp, info)) {
+        return false;
```

Review comment:
`info.name` is more clear and safe. "Hack" operator should not be used at all (it is here for some build problems only) - it candidate for removal.
**File:** modules/dnn/src/layers/scale_layer.cpp
**Change Type:** modified
**Context:** PR #9778: Deep learning colorization model -  ### This pullrequest changes Colorization model from https://github.com/richzhang/colorization into DNN....

**Code Changes:**
```diff
@@ -33,6 +33,7 @@ class ScaleLayerImpl : public ScaleLayer
                          std::vector<MatShape> &outputs,
                          std::vector<MatShape> &internals) const
     {
+        CV_Assert(blobs.size() == 1 + hasBias);
         Layer::getMemoryShapes(inputs, requiredOutputs, outputs, internals);
         return true;
     }
@@ -48,8 +49,6 @@ class ScaleLayerImpl : public ScaleLayer
         CV_TRACE_FUNCTION();
```

Review comment:
We can add an extra layers in `.prototxt` that were not used during training. So they have no weights. In this model it's a Scale layer.
**File:** samples/cpp/minarea.cpp
**Change Type:** modified
**Context:** PR #9824: Updates min_enclosing_triangle.cpp - ### This pullrequest changes a small improvement on minEnclosingTriangle

**Code Changes:**
```diff
@@ -11,10 +11,7 @@ static void help()
     cout << "This program demonstrates finding the minimum enclosing box, triangle or circle of a set\n"
          << "of points using functions: minAreaRect() minEnclosingTriangle() minEnclosingCircle().\n"
          << "Random points are generated and then enclosed.\n\n"
-         << "Press ESC, 'q' or 'Q' to exit and any other key to regenerate the set of points.\n\n"
-         << "Call:\n"
-         << "./minarea\n"
-         << "Using OpenCV v" << CV_VERSION << "\n" << endl;
+         << "Press ESC, 'q' or 'Q' to exit and any other key to regenerate the set of points.\n\n";
 }
```

Review comment:
Please use 4 spaces instead of tabs.
**File:** modules/dnn/src/caffe/caffe.proto
**Change Type:** modified
**Context:** PR #9820: dnn: modify priorBox layer - Make sufficient changes in PriorBox layer to be able to run model from https://github.com/MhLiao/TextBoxes Requ...

**Code Changes:**
```diff
@@ -145,6 +145,8 @@ message PriorBoxParameter {
   optional float step_w = 12;
   // Offset to the top left corner of each cell.
   optional float offset = 13 [default = 0.5];
+  // If true, two additional boxes for each center will be generated. Their centers will be shifted by y coordinate.
+  optional bool additional_y_offset = 14 [default = false];
 }
 
 // Message that store parameters used by DetectionOutputLayer
```

Review comment:
1) boxex =&gt; boxes; 2) is `additional_y_offset` name taken from the original patch?
**File:** modules/dnn/src/caffe/caffe.proto
**Change Type:** modified
**Context:** PR #9820: dnn: modify priorBox layer - Make sufficient changes in PriorBox layer to be able to run model from https://github.com/MhLiao/TextBoxes Requ...

**Code Changes:**
```diff
@@ -145,6 +145,8 @@ message PriorBoxParameter {
   optional float step_w = 12;
   // Offset to the top left corner of each cell.
   optional float offset = 13 [default = 0.5];
+  // If true, two additional boxes for each center will be generated. Their centers will be shifted by y coordinate.
+  optional bool additional_y_offset = 14 [default = false];
 }
 
 // Message that store parameters used by DetectionOutputLayer
```

Review comment:
The original [patch](https://github.com/MhLiao/TextBoxes/commit/f615ff6d929d55d8d97dc7c0ece0ca22eea34117) doesn't contain any parameters, all changes are hardcoded.
**File:** samples/python/tutorial_code/imgProc/HitMiss/hit_miss.py
**Change Type:** added
**Context:** PR #9424: GSoC - Update Imgproc tutorials

**Code Changes:**
```diff
@@ -0,0 +1,38 @@
+import cv2
+import numpy as np
+
+input_image = np.array((
+    [0, 0, 0, 0, 0, 0, 0, 0],
+    [0, 255, 255, 255, 0, 0, 0, 255],
+    [0, 255, 255, 255, 0, 0, 0, 0],
+    [0, 255, 255, 255, 0, 255, 0, 0],
+    [0, 0, 255, 0, 0, 0, 0, 0],
```

Review comment:
no tabs in Python