nareshmlx/opencv-pr huggingface dataset:
**File:** modules/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #16246: VideoIO classes refactoring - Changes: - Added `explicit` to `VideoCapture` constructors with 2 arguments, 1 of them has default value - Ap...

**Code Changes:**
```diff
@@ -628,7 +628,7 @@ class CV_EXPORTS_W VideoCapture
     implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.
     @sa The list of supported API backends cv::VideoCaptureAPIs
     */
-    CV_WRAP VideoCapture(const String& filename, int apiPreference = CAP_ANY);
+    CV_WRAP explicit VideoCapture(const String& filename, int apiPreference = CAP_ANY);
 
     /** @overload
     @brief  Opens a camera for video capturing
@@ -640,7 +640,7 @@ class CV_EXPORTS_W VideoCapture
```

Review comment:
is noexcept really important here? let's undo it
**File:** modules/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #16246: VideoIO classes refactoring - Changes: - Added `explicit` to `VideoCapture` constructors with 2 arguments, 1 of them has default value - Ap...

**Code Changes:**
```diff
@@ -628,7 +628,7 @@ class CV_EXPORTS_W VideoCapture
     implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.
     @sa The list of supported API backends cv::VideoCaptureAPIs
     */
-    CV_WRAP VideoCapture(const String& filename, int apiPreference = CAP_ANY);
+    CV_WRAP explicit VideoCapture(const String& filename, int apiPreference = CAP_ANY);
 
     /** @overload
     @brief  Opens a camera for video capturing
@@ -640,7 +640,7 @@ class CV_EXPORTS_W VideoCapture
```

Review comment:
it's initialized in the constructor. why initialize it here?
**File:** modules/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #16246: VideoIO classes refactoring - Changes: - Added `explicit` to `VideoCapture` constructors with 2 arguments, 1 of them has default value - Ap...

**Code Changes:**
```diff
@@ -628,7 +628,7 @@ class CV_EXPORTS_W VideoCapture
     implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.
     @sa The list of supported API backends cv::VideoCaptureAPIs
     */
-    CV_WRAP VideoCapture(const String& filename, int apiPreference = CAP_ANY);
+    CV_WRAP explicit VideoCapture(const String& filename, int apiPreference = CAP_ANY);
 
     /** @overload
     @brief  Opens a camera for video capturing
@@ -640,7 +640,7 @@ class CV_EXPORTS_W VideoCapture
```

Review comment:
let's undo it. no enough reason to break compatibility
**File:** modules/videoio/src/cap.cpp
**Change Type:** modified
**Context:** PR #16246: VideoIO classes refactoring - Changes: - Added `explicit` to `VideoCapture` constructors with 2 arguments, 1 of them has default value - Ap...

**Code Changes:**
```diff
@@ -50,6 +50,17 @@ static bool param_VIDEOIO_DEBUG = utils::getConfigurationParameterBool("OPENCV_V
 static bool param_VIDEOCAPTURE_DEBUG = utils::getConfigurationParameterBool("OPENCV_VIDEOCAPTURE_DEBUG", false);
 static bool param_VIDEOWRITER_DEBUG = utils::getConfigurationParameterBool("OPENCV_VIDEOWRITER_DEBUG", false);
 
+#define CV_CAPTURE_LOG_DEBUG(tag, ...)                   \
+    if (param_VIDEOIO_DEBUG || param_VIDEOCAPTURE_DEBUG) \
+    {                                                    \
+        CV_LOG_WARNING(nullptr, __VA_ARGS__);            \
+    }
+
```

Review comment:
let's restore it
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #15993: This is a correction of the previously missleading documentation and a warning related to a common calibration failure described in issue #...

**Code Changes:**
```diff
@@ -118,7 +118,18 @@ v = f_y \times y'' + c_y
 tangential distortion coefficients. \f$s_1\f$, \f$s_2\f$, \f$s_3\f$, and \f$s_4\f$, are the thin prism distortion
 coefficients. Higher-order coefficients are not considered in OpenCV.
 
-The next figures show two common types of radial distortion: barrel distortion (typically \f$ k_1 < 0 \f$) and pincushion distortion (typically \f$ k_1 > 0 \f$).
+The next figures show two common types of radial distortion: barrel distortion
+(\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically decreasing)
+and pincushion distortion (\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically increasing).
+Radial distortion is always monotonic for real lenses,
+and if the estimator produces a non monotonic result,
```

Review comment:
> See issue #15992 Please use full URL (issue numbers are not handled well in documentation): ``` Details: https://github.com/opencv/opencv/issues/15992 ```
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #15993: This is a correction of the previously missleading documentation and a warning related to a common calibration failure described in issue #...

**Code Changes:**
```diff
@@ -118,7 +118,18 @@ v = f_y \times y'' + c_y
 tangential distortion coefficients. \f$s_1\f$, \f$s_2\f$, \f$s_3\f$, and \f$s_4\f$, are the thin prism distortion
 coefficients. Higher-order coefficients are not considered in OpenCV.
 
-The next figures show two common types of radial distortion: barrel distortion (typically \f$ k_1 < 0 \f$) and pincushion distortion (typically \f$ k_1 > 0 \f$).
+The next figures show two common types of radial distortion: barrel distortion
+(\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically decreasing)
+and pincushion distortion (\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically increasing).
+Radial distortion is always monotonic for real lenses,
+and if the estimator produces a non monotonic result,
```

Review comment:
```suggestion (\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically decreasing) ```
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #15993: This is a correction of the previously missleading documentation and a warning related to a common calibration failure described in issue #...

**Code Changes:**
```diff
@@ -118,7 +118,18 @@ v = f_y \times y'' + c_y
 tangential distortion coefficients. \f$s_1\f$, \f$s_2\f$, \f$s_3\f$, and \f$s_4\f$, are the thin prism distortion
 coefficients. Higher-order coefficients are not considered in OpenCV.
 
-The next figures show two common types of radial distortion: barrel distortion (typically \f$ k_1 < 0 \f$) and pincushion distortion (typically \f$ k_1 > 0 \f$).
+The next figures show two common types of radial distortion: barrel distortion
+(\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically decreasing)
+and pincushion distortion (\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically increasing).
+Radial distortion is always monotonic for real lenses,
+and if the estimator produces a non monotonic result,
```

Review comment:
```suggestion and pincushion distortion (\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically increasing). ```
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #15993: This is a correction of the previously missleading documentation and a warning related to a common calibration failure described in issue #...

**Code Changes:**
```diff
@@ -118,7 +118,18 @@ v = f_y \times y'' + c_y
 tangential distortion coefficients. \f$s_1\f$, \f$s_2\f$, \f$s_3\f$, and \f$s_4\f$, are the thin prism distortion
 coefficients. Higher-order coefficients are not considered in OpenCV.
 
-The next figures show two common types of radial distortion: barrel distortion (typically \f$ k_1 < 0 \f$) and pincushion distortion (typically \f$ k_1 > 0 \f$).
+The next figures show two common types of radial distortion: barrel distortion
+(\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically decreasing)
+and pincushion distortion (\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically increasing).
+Radial distortion is always monotonic for real lenses,
+and if the estimator produces a non monotonic result,
```

Review comment:
```suggestion the required integer programming and polynomial inequalities. See [issue 15992](https://github.com/opencv/opencv/issues/15992) for additional information. ```
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #15993: This is a correction of the previously missleading documentation and a warning related to a common calibration failure described in issue #...

**Code Changes:**
```diff
@@ -118,7 +118,18 @@ v = f_y \times y'' + c_y
 tangential distortion coefficients. \f$s_1\f$, \f$s_2\f$, \f$s_3\f$, and \f$s_4\f$, are the thin prism distortion
 coefficients. Higher-order coefficients are not considered in OpenCV.
 
-The next figures show two common types of radial distortion: barrel distortion (typically \f$ k_1 < 0 \f$) and pincushion distortion (typically \f$ k_1 > 0 \f$).
+The next figures show two common types of radial distortion: barrel distortion
+(\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically decreasing)
+and pincushion distortion (\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically increasing).
+Radial distortion is always monotonic for real lenses,
+and if the estimator produces a non monotonic result,
```

Review comment:
```suggestion The optimization method used in OpenCV camera calibration does not include these constraints as the framework does not support ```
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #15993: This is a correction of the previously missleading documentation and a warning related to a common calibration failure described in issue #...

**Code Changes:**
```diff
@@ -118,7 +118,18 @@ v = f_y \times y'' + c_y
 tangential distortion coefficients. \f$s_1\f$, \f$s_2\f$, \f$s_3\f$, and \f$s_4\f$, are the thin prism distortion
 coefficients. Higher-order coefficients are not considered in OpenCV.
 
-The next figures show two common types of radial distortion: barrel distortion (typically \f$ k_1 < 0 \f$) and pincushion distortion (typically \f$ k_1 > 0 \f$).
+The next figures show two common types of radial distortion: barrel distortion
+(\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically decreasing)
+and pincushion distortion (\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically increasing).
+Radial distortion is always monotonic for real lenses,
+and if the estimator produces a non monotonic result,
```

Review comment:
Pedantic: left align the text to be consistent with the surrounding text. Maybe too many break lines.
**File:** modules/dnn/src/layers/pooling_layer.cpp
**Change Type:** modified
**Context:** PR #16223: Add human parsing demo - **Merge with extra:** opencv/opencv_extra#695 ``` force_builders=Custom,Custom Win,Custom Mac build_image:Custom=u...

**Code Changes:**
```diff
@@ -79,6 +79,7 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
     {
         computeMaxIdx = true;
         globalPooling = false;
+        isGlobalPooling = std::vector<bool>(3, false);
         stride = Size(1, 1);
         pad_t = pad_l = pad_b = pad_r = 0;
 
@@ -95,7 +96,8 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
             else
```

Review comment:
I'd like to recommend to introduce `global_pooling_w` and `global_pooling_h` as there are flags for `kernel` and `stride`.
**File:** modules/dnn/src/layers/pooling_layer.cpp
**Change Type:** modified
**Context:** PR #16223: Add human parsing demo - **Merge with extra:** opencv/opencv_extra#695 ``` force_builders=Custom,Custom Win,Custom Mac build_image:Custom=u...

**Code Changes:**
```diff
@@ -79,6 +79,7 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
     {
         computeMaxIdx = true;
         globalPooling = false;
+        isGlobalPooling = std::vector<bool>(3, false);
         stride = Size(1, 1);
         pad_t = pad_l = pad_b = pad_r = 0;
 
@@ -95,7 +96,8 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
             else
```

Review comment:
Do we also need to introduce `global_pooling_d`?
**File:** modules/dnn/src/layers/pooling_layer.cpp
**Change Type:** modified
**Context:** PR #16223: Add human parsing demo - **Merge with extra:** opencv/opencv_extra#695 ``` force_builders=Custom,Custom Win,Custom Mac build_image:Custom=u...

**Code Changes:**
```diff
@@ -79,6 +79,7 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
     {
         computeMaxIdx = true;
         globalPooling = false;
+        isGlobalPooling = std::vector<bool>(3, false);
         stride = Size(1, 1);
         pad_t = pad_l = pad_b = pad_r = 0;
 
@@ -95,7 +96,8 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
             else
```

Review comment:
Maybe just a vector like `std::vector<bool> isGlobalPooling`
**File:** modules/dnn/src/layers/pooling_layer.cpp
**Change Type:** modified
**Context:** PR #16223: Add human parsing demo - **Merge with extra:** opencv/opencv_extra#695 ``` force_builders=Custom,Custom Win,Custom Mac build_image:Custom=u...

**Code Changes:**
```diff
@@ -79,6 +79,7 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
     {
         computeMaxIdx = true;
         globalPooling = false;
+        isGlobalPooling = std::vector<bool>(3, false);
         stride = Size(1, 1);
         pad_t = pad_l = pad_b = pad_r = 0;
 
@@ -95,7 +96,8 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
             else
```

Review comment:
There is already "global_pooling" flag so let's just use it in the same way as we use vector of kernel sizes or strides.
**File:** modules/dnn/src/tensorflow/tf_importer.cpp
**Change Type:** modified
**Context:** PR #16223: Add human parsing demo - **Merge with extra:** opencv/opencv_extra#695 ``` force_builders=Custom,Custom Win,Custom Mac build_image:Custom=u...

**Code Changes:**
```diff
@@ -1932,37 +1932,151 @@ void TFImporter::populateNet(Net dstNet)
         }
         else if (type == "Mean")
         {
+            // Computes the mean of elements across dimensions of a tensor.
+            // If keepdims is false (default) reduces input_tensor along the dimensions given in axis,
+            // else the reduced dimensions are retained with length 1.
+            // if indices = [1, 2] in NHWC layout we use global pooling: NxCxHxW --Pooling--> NxCx1x1
+            // if keepdims is false we use Flatten after Pooling: out_shape = NxC
+            // if indices = [0] we use a global pooling by indices.
```

Review comment:
I think we can just keep corresponding input layer ids instead of names
**File:** modules/dnn/src/layers/layers_common.cpp
**Change Type:** modified
**Context:** PR #16223: Add human parsing demo - **Merge with extra:** opencv/opencv_extra#695 ``` force_builders=Custom,Custom Win,Custom Mac build_image:Custom=u...

**Code Changes:**
```diff
@@ -144,26 +144,37 @@ void getStrideAndPadding(const LayerParams &params, std::vector<size_t>& pads_be
 }
 }
 
-void getPoolingKernelParams(const LayerParams &params, std::vector<size_t>& kernel, bool &globalPooling,
+void getPoolingKernelParams(const LayerParams &params, std::vector<size_t>& kernel, std::vector<bool>& globalPooling,
                             std::vector<size_t>& pads_begin, std::vector<size_t>& pads_end,
                             std::vector<size_t>& strides, cv::String &padMode)
 {
-    globalPooling = params.has("global_pooling") &&
```

Review comment:
`global_pooling_d`? (The same for `global_pooling_w` and `global_pooling_h`)
**File:** modules/dnn/src/layers/layers_common.cpp
**Change Type:** modified
**Context:** PR #16223: Add human parsing demo - **Merge with extra:** opencv/opencv_extra#695 ``` force_builders=Custom,Custom Win,Custom Mac build_image:Custom=u...

**Code Changes:**
```diff
@@ -144,26 +144,37 @@ void getStrideAndPadding(const LayerParams &params, std::vector<size_t>& pads_be
 }
 }
 
-void getPoolingKernelParams(const LayerParams &params, std::vector<size_t>& kernel, bool &globalPooling,
+void getPoolingKernelParams(const LayerParams &params, std::vector<size_t>& kernel, std::vector<bool>& globalPooling,
                             std::vector<size_t>& pads_begin, std::vector<size_t>& pads_end,
                             std::vector<size_t>& strides, cv::String &padMode)
 {
-    globalPooling = params.has("global_pooling") &&
```

Review comment:
What if we have two of the flags simultaneously? I think we need to have just `if`s here.
**File:** samples/dnn/human_parsing.py
**Change Type:** added
**Context:** PR #16223: Add human parsing demo - **Merge with extra:** opencv/opencv_extra#695 ``` force_builders=Custom,Custom Win,Custom Mac build_image:Custom=u...
**Review Line:** 156

**Code Changes:**
```diff
+    grayscale_out = postprocess(output, (input_w, input_h))
+    segmentation = decode_labels(grayscale_out)
+    return segmentation
+
+
+if __name__ == '__main__':
+    parser = argparse.ArgumentParser(description='Use this script to run human parsing using JPPNet',
+                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+    parser.add_argument('--input', '-i', required=True, help='Path to input image.')
+    parser.add_argument('--model', '-m', required=True, help='Path to pb model.')
+    parser.add_argument('--backend', choices=backends, default=cv.dnn.DNN_BACKEND_DEFAULT, type=int,
```

Review comment:
Please move ArgumentParser under `f __name__ == '__main__':`
**File:** modules/dnn/src/layers/layers_common.cpp
**Change Type:** modified
**Context:** PR #16223: Add human parsing demo - **Merge with extra:** opencv/opencv_extra#695 ``` force_builders=Custom,Custom Win,Custom Mac build_image:Custom=u...

**Code Changes:**
```diff
@@ -144,26 +144,37 @@ void getStrideAndPadding(const LayerParams &params, std::vector<size_t>& pads_be
 }
 }
 
-void getPoolingKernelParams(const LayerParams &params, std::vector<size_t>& kernel, bool &globalPooling,
+void getPoolingKernelParams(const LayerParams &params, std::vector<size_t>& kernel, std::vector<bool>& globalPooling,
                             std::vector<size_t>& pads_begin, std::vector<size_t>& pads_end,
                             std::vector<size_t>& strides, cv::String &padMode)
 {
-    globalPooling = params.has("global_pooling") &&
```

Review comment:
Let's try once again to simplify it considering the following rules: 1) Paddings. User should specify either `pad` or `pad_w` && `pad_h` (getParameter) or `pad_l` && `pad_t` && `pad_r` && `pad_b` (current 3.4 works in this way.). So in case of global pooling by a specific axis, all the other padding will be specified anyway. 2) Strides similar as (1) but with `stride` or `stride_w` && `stride_h` 3) check only parameters which conflict with each other: ``` (!params.has("global_pooling") || !params.has("kernel_size")) && (!params.has("global_pooling_d") || !params.has("kernel_size_d")) && (!params.has("global_pooling_h") || !params.has("kernel_size_h")) && (!params.has("global_pooling_w") || !params.has("kernel_size_w")) ```
**File:** modules/dnn/src/layers/layers_common.cpp
**Change Type:** modified
**Context:** PR #16223: Add human parsing demo - **Merge with extra:** opencv/opencv_extra#695 ``` force_builders=Custom,Custom Win,Custom Mac build_image:Custom=u...

**Code Changes:**
```diff
@@ -144,26 +144,37 @@ void getStrideAndPadding(const LayerParams &params, std::vector<size_t>& pads_be
 }
 }
 
-void getPoolingKernelParams(const LayerParams &params, std::vector<size_t>& kernel, bool &globalPooling,
+void getPoolingKernelParams(const LayerParams &params, std::vector<size_t>& kernel, std::vector<bool>& globalPooling,
                             std::vector<size_t>& pads_begin, std::vector<size_t>& pads_end,
                             std::vector<size_t>& strides, cv::String &padMode)
 {
-    globalPooling = params.has("global_pooling") &&
```

Review comment:
Let's keep `if (is_global) { ... } else { ... }`
**File:** modules/dnn/src/layers/layers_common.cpp
**Change Type:** modified
**Context:** PR #16223: Add human parsing demo - **Merge with extra:** opencv/opencv_extra#695 ``` force_builders=Custom,Custom Win,Custom Mac build_image:Custom=u...
**Review Line:** 170

**Code Changes:**
```diff
-            if (pads_begin[i] != 0 || pads_end[i] != 0)
+
+        kernel.resize(3);
+        kernel[0] = params.get<int>("kernel_d", 1);
+        kernel[1] = params.get<int>("kernel_h", 1);
+        kernel[2] = params.get<int>("kernel_w", 1);
+
+        for (int i = 0, j = globalPooling.size() - pads_begin.size(); i < pads_begin.size(); i++, j++) {
+            if ((pads_begin[i] != 0 || pads_end[i] != 0) && globalPooling[j])
                 CV_Error(cv::Error::StsBadArg, "In global_pooling mode, pads must be = 0");
         }
```

Review comment:
Do we still need this here?
**File:** modules/dnn/src/layers/pooling_layer.cpp
**Change Type:** modified
**Context:** PR #16223: Add human parsing demo - **Merge with extra:** opencv/opencv_extra#695 ``` force_builders=Custom,Custom Win,Custom Mac build_image:Custom=u...

**Code Changes:**
```diff
@@ -79,6 +79,7 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
     {
         computeMaxIdx = true;
         globalPooling = false;
+        isGlobalPooling = std::vector<bool>(3, false);
         stride = Size(1, 1);
         pad_t = pad_l = pad_b = pad_r = 0;
 
@@ -95,7 +96,8 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
             else
```

Review comment:
let's compare with `isGlobalPooling.size()` instead of hardcoded value
**File:** modules/dnn/src/layers/pooling_layer.cpp
**Change Type:** modified
**Context:** PR #16223: Add human parsing demo - **Merge with extra:** opencv/opencv_extra#695 ``` force_builders=Custom,Custom Win,Custom Mac build_image:Custom=u...

**Code Changes:**
```diff
@@ -79,6 +79,7 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
     {
         computeMaxIdx = true;
         globalPooling = false;
+        isGlobalPooling = std::vector<bool>(3, false);
         stride = Size(1, 1);
         pad_t = pad_l = pad_b = pad_r = 0;
 
@@ -95,7 +96,8 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
             else
```

Review comment:
Shall we check that at least one of the flags is true instead? As we do above: `is_global = globalPooling[0] || globalPooling[1] || globalPooling[2];`
**File:** modules/dnn/src/layers/pooling_layer.cpp
**Change Type:** modified
**Context:** PR #16223: Add human parsing demo - **Merge with extra:** opencv/opencv_extra#695 ``` force_builders=Custom,Custom Win,Custom Mac build_image:Custom=u...

**Code Changes:**
```diff
@@ -79,6 +79,7 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
     {
         computeMaxIdx = true;
         globalPooling = false;
+        isGlobalPooling = std::vector<bool>(3, false);
         stride = Size(1, 1);
         pad_t = pad_l = pad_b = pad_r = 0;
 
@@ -95,7 +96,8 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
             else
```

Review comment:
I think we do not need this due in the next loop we can iterate over input shape and change `kernel_size`: ```cpp CV_Assert(isGlobalPooling.size() == kernel_size.size()); std::vector<size_t> finalKernel; for (int i = 0; i < inp.size(); i++) { int idx = isGlobalPooling.size() - inp.size() + i; finalKernel.push_back(isGlobalPooling[idx] ? inp[i] : kernel_size[idx]); } kernel_size = finalKernel; ```
**File:** modules/dnn/src/layers/pooling_layer.cpp
**Change Type:** modified
**Context:** PR #16223: Add human parsing demo - **Merge with extra:** opencv/opencv_extra#695 ``` force_builders=Custom,Custom Win,Custom Mac build_image:Custom=u...

**Code Changes:**
```diff
@@ -79,6 +79,7 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
     {
         computeMaxIdx = true;
         globalPooling = false;
+        isGlobalPooling = std::vector<bool>(3, false);
         stride = Size(1, 1);
         pad_t = pad_l = pad_b = pad_r = 0;
 
@@ -95,7 +96,8 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
             else
```

Review comment:
Always `isGlobalPooling.size() = 3`. If pooling type is `ROI` then kernel_size is empty.