nareshmlx/opencv-pr huggingface dataset:
**File:** modules/dnn/src/layers/pooling_layer.cpp
**Change Type:** modified
**Context:** PR #10724: fix faster_rcnn sample crashed at PoolingInvoker on Windows7(x64). - fix faster_rcnn sample crashed at PoolingInvoker operator() of pooling...

**Code Changes:**
```diff
@@ -287,7 +287,7 @@ class PoolingLayerImpl : public PoolingLayer
             bool compMaxIdx = computeMaxIdx;
 
 #if CV_SIMD128
-            const int* ofsptr = &ofsbuf[0];
+            const int* ofsptr = ofsbuf.empty() ? 0 : (const int*)&ofsbuf[0];
             v_float32x4 idx00(0.f, (float)stride_w, (float)(stride_w*2), (float)(stride_w*3));
             v_float32x4 ones = v_setall_f32(1.f);
             v_float32x4 idx_delta = v_setall_f32((float)(inp_width - kernel_w));
```

Review comment:
If we need some alignment requirement, we could use `AutoBuffer<int, 0>` to use OpenCV `fastAlloc()`.
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #10607: dnn : Added an imagesFromBlob method to the dnn module -   Added an std::vector < cv::Mat > imagesFromBlob( cv::Mat blob ) method to the dn...

**Code Changes:**
```diff
@@ -735,6 +735,15 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
                                    double scalefactor=1.0, Size size = Size(),
                                    const Scalar& mean = Scalar(), bool swapRB=true, bool crop=true);
 
+    /** @brief Parse a 4D blob and output the images it contains as 2D arrays through a simpler data structure
+     *  (std::vector<cv::Mat>).
+     *  @param[in] blob_ 4 dimensional array (images, channels, height, width) in floating point precision (CV_32F) from
+     *  which you would like to extract the images.
+     *  @param[out] images_ array of 2D Mat containing the images extracted from the blob in floating point precision
+     *  (CV_32F). They are non normalized neither mean added. The number of returned images equals the first dimension
```

Review comment:
Let's go from the following test case: ```cpp Mat img(rows, cols, CV_32FC3); Mat blob = blobFromImage(img, 1.0, Size(), Scalar(), false, false); std::vector<Mat> imgs = imagesFromBlob(blob); normAssert(img, imgs[0]); ``` I don't think we need inverse mean because in general case blob can have any number of channels but `cv::Scalar` no more than 4 [by definition](https://docs.opencv.org/master/d1/da0/classcv_1_1Scalar__.html). This way the rest of post-processing arguments are useless too. I think interleaving is the most complicated procedure so it's better to leave other operations out of this function.
**File:** modules/dnn/src/dnn.cpp
**Change Type:** modified
**Context:** PR #10607: dnn : Added an imagesFromBlob method to the dnn module -   Added an std::vector < cv::Mat > imagesFromBlob( cv::Mat blob ) method to the dn...

**Code Changes:**
```diff
@@ -192,6 +192,31 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef
     }
 }
 
+void imagesFromBlob(const cv::Mat& blob_, OutputArrayOfArrays images_)
+{
+    CV_TRACE_FUNCTION();
+
+    //A blob is a 4 dimensional matrix in floating point precision
+    //blob_[0] = batchSize = nbOfImages
```

Review comment:
That could be done much more easier like ```cpp for (int i = 0; i < nbOfImages; ++i) { std::vector<Mat> vectorOfChannels(nbOfChannels); for (int c = 0; c < nbOfChannels; ++c) vectorOfChannels[c] = slice(blob_, n, c); // function from shape_utils.hpp } ```
**File:** modules/dnn/src/dnn.cpp
**Change Type:** modified
**Context:** PR #10607: dnn : Added an imagesFromBlob method to the dnn module -   Added an std::vector < cv::Mat > imagesFromBlob( cv::Mat blob ) method to the dn...

**Code Changes:**
```diff
@@ -192,6 +192,31 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef
     }
 }
 
+void imagesFromBlob(const cv::Mat& blob_, OutputArrayOfArrays images_)
+{
+    CV_TRACE_FUNCTION();
+
+    //A blob is a 4 dimensional matrix in floating point precision
+    //blob_[0] = batchSize = nbOfImages
```

Review comment:
Am I right if I assume you wanted to use `Mat getPlane(const Mat &m, int n, int cn)` instead of the quoted `Mat slice(const Mat &m, const _Range &r0, const _Range &r1)`?
**File:** modules/dnn/src/dnn.cpp
**Change Type:** modified
**Context:** PR #10607: dnn : Added an imagesFromBlob method to the dnn module -   Added an std::vector < cv::Mat > imagesFromBlob( cv::Mat blob ) method to the dn...

**Code Changes:**
```diff
@@ -192,6 +192,31 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef
     }
 }
 
+void imagesFromBlob(const cv::Mat& blob_, OutputArrayOfArrays images_)
+{
+    CV_TRACE_FUNCTION();
+
+    //A blob is a 4 dimensional matrix in floating point precision
+    //blob_[0] = batchSize = nbOfImages
```

Review comment:
`slice` can manage it. There is a constructor of cv::Range for a single value, https://docs.opencv.org/master/d9/ddc/structcv_1_1dnn_1_1__Range.html#a5339946e5ddf17692f62956c28cbe623.
**File:** modules/dnn/src/dnn.cpp
**Change Type:** modified
**Context:** PR #10607: dnn : Added an imagesFromBlob method to the dnn module -   Added an std::vector < cv::Mat > imagesFromBlob( cv::Mat blob ) method to the dn...

**Code Changes:**
```diff
@@ -192,6 +192,31 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef
     }
 }
 
+void imagesFromBlob(const cv::Mat& blob_, OutputArrayOfArrays images_)
+{
+    CV_TRACE_FUNCTION();
+
+    //A blob is a 4 dimensional matrix in floating point precision
+    //blob_[0] = batchSize = nbOfImages
```

Review comment:
I agree, but as far as I understand it, `slice` will output a 4D array (1,1,size,size) for each channel. This will result in a (1,c,size,size) array for each image using `cv::merge()`, where c is the number of channels. This is fine if we want to output a blob per image, but it does not allow us to directly use the images with the OpenCV functions made for 2D arrays (e.g. `cv::imshow()` and `cv::imwrite()`). I propose to add a boolean flag to let the user choose if he prefers to get a 4D or a 2D array per image contained in a blob. ```c++ //slice channels std::vector<Mat> vectorOfChannels(nbOfChannels); for (int c = 0; c < nbOfChannels; ++c) { if(get2DArrays_) vectorOfChannels[c] = getPlane(blob_, i, c); // function from shape_utils.hpp in dnn module, a plane is 2D array else vectorOfChannels[c] = slice(blob_, i, c); // function from shape_utils.hpp in dnn module, a slice is a 4D array }//loop on channels ```
**File:** modules/dnn/src/dnn.cpp
**Change Type:** modified
**Context:** PR #10607: dnn : Added an imagesFromBlob method to the dnn module -   Added an std::vector < cv::Mat > imagesFromBlob( cv::Mat blob ) method to the dn...

**Code Changes:**
```diff
@@ -192,6 +192,31 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef
     }
 }
 
+void imagesFromBlob(const cv::Mat& blob_, OutputArrayOfArrays images_)
+{
+    CV_TRACE_FUNCTION();
+
+    //A blob is a 4 dimensional matrix in floating point precision
+    //blob_[0] = batchSize = nbOfImages
```

Review comment:
I think the next three assertions isn't so useful.
**File:** modules/dnn/src/dnn.cpp
**Change Type:** modified
**Context:** PR #10607: dnn : Added an imagesFromBlob method to the dnn module -   Added an std::vector < cv::Mat > imagesFromBlob( cv::Mat blob ) method to the dn...
**Review Line:** 207

**Code Changes:**
```diff
+    //blob_[2] = height
+    //blob_[3] = width
+    CV_Assert(blob_.depth() == CV_32F);
+    CV_Assert(blob_.dims == 4);
+
+    images_.create(cv::Size(1, blob_.size[0]), blob_.depth());
+
+    std::vector<Mat> vectorOfChannels(blob_.size[1]);
+    for (int n = 0; n <  blob_.size[0]; ++n)
+    {
+        for (int c = 0; c < blob_.size[1]; ++c)
```

Review comment:
Please add a test for new function at https://github.com/opencv/opencv/blob/master/modules/dnn/test/test_misc.cpp . I suggest you to generate several 3-channel images with `CV_32F` depth. Then create a blob using `blobFromImages` with no resize, mean subtraction, scale or channels swapping. Pass it to `imagesFromBlob` and check that output matches with origin images.
**File:** modules/dnn/test/test_misc.cpp
**Change Type:** modified
**Context:** PR #10607: dnn : Added an imagesFromBlob method to the dnn module -   Added an std::vector < cv::Mat > imagesFromBlob( cv::Mat blob ) method to the dn...

**Code Changes:**
```diff
@@ -36,4 +36,25 @@ TEST(blobFromImage, allocated)
     ASSERT_EQ(blobData, blob.data);
 }
 
+TEST(imagesFromBlob, Regression)
+{
+    int nbOfImages = 8;
+
+    std::vector<cv::Mat> inputImgs(nbOfImages);
+    for (int i = 0; i < nbOfImages; i++)
```

Review comment:
You compare two unsigned bytes here. Replace by `ASSERT_EQ(countNonZero(inputImgs[i] != outputImgs[i]), 0);`
**File:** modules/dnn/test/test_misc.cpp
**Change Type:** modified
**Context:** PR #10607: dnn : Added an imagesFromBlob method to the dnn module -   Added an std::vector < cv::Mat > imagesFromBlob( cv::Mat blob ) method to the dn...

**Code Changes:**
```diff
@@ -36,4 +36,25 @@ TEST(blobFromImage, allocated)
     ASSERT_EQ(blobData, blob.data);
 }
 
+TEST(imagesFromBlob, Regression)
+{
+    int nbOfImages = 8;
+
+    std::vector<cv::Mat> inputImgs(nbOfImages);
+    for (int i = 0; i < nbOfImages; i++)
```

Review comment:
Please use random generator like `cv::randu` to make test more robust.
**File:** modules/dnn/test/test_misc.cpp
**Change Type:** modified
**Context:** PR #10607: dnn : Added an imagesFromBlob method to the dnn module -   Added an std::vector < cv::Mat > imagesFromBlob( cv::Mat blob ) method to the dn...

**Code Changes:**
```diff
@@ -36,4 +36,25 @@ TEST(blobFromImage, allocated)
     ASSERT_EQ(blobData, blob.data);
 }
 
+TEST(imagesFromBlob, Regression)
+{
+    int nbOfImages = 8;
+
+    std::vector<cv::Mat> inputImgs(nbOfImages);
+    for (int i = 0; i < nbOfImages; i++)
```

Review comment:
Please make `nbOfImages` not equal to number of channels.
**File:** modules/core/include/opencv2/core/mat.hpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.

**Code Changes:**
```diff
@@ -989,6 +989,10 @@ class CV_EXPORTS Mat
     */
     template<typename _Tp, typename = typename std::enable_if<std::is_arithmetic<_Tp>::value>::type>
     explicit Mat(const std::initializer_list<_Tp> list);
+
+    /** @overload
+    */
+    template<typename _Tp> explicit Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list);
 #endif
 
```

Review comment:
explicit (both constructors)
**File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.

**Code Changes:**
```diff
@@ -584,6 +584,18 @@ Mat::Mat(const std::initializer_list<_Tp> list)
         return;
     Mat((int)list.size(), 1, traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
 }
+
+template<typename _Tp> inline
+Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list)
+    : Mat()
+{
+    size_t size_total = 1;
```

Review comment:
> `sizes.size() != 1` Why? This should be allowed to create ND matrices. > dims(2), rows((int)list.size()), cols(1), Should be fixed. Initialize fields for an empty `Mat`. It is better to use C++11 [Delegating constructor](http://en.cppreference.com/w/cpp/language/initializer_list) here. Also this check should be added: `sizes[0]*sizes[1]*..*sizes[dims-1] == list.total()` > return; No. This is an error => `CV_Error` / `CV_Assert`.
**File:** modules/core/test/test_mat.cpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.

**Code Changes:**
```diff
@@ -1719,17 +1719,23 @@ TEST(Mat, from_initializer_list)
 {
     Mat A({1.f, 2.f, 3.f});
     Mat_<float> B(3, 1); B << 1, 2, 3;
+    Mat_<float> C({3}, {1,2,3});
 
     ASSERT_EQ(A.type(), CV_32F);
     ASSERT_DOUBLE_EQ(cvtest::norm(A, B, NORM_INF), 0.);
+    ASSERT_DOUBLE_EQ(cvtest::norm(A, C, NORM_INF), 0.);
+    ASSERT_DOUBLE_EQ(cvtest::norm(B, C, NORM_INF), 0.);
```

Review comment:
This should not work (or better to compile). "Sizes" declares matrix with single element, but it is initialized with 3 values.
**File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.

**Code Changes:**
```diff
@@ -584,6 +584,18 @@ Mat::Mat(const std::initializer_list<_Tp> list)
         return;
     Mat((int)list.size(), 1, traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
 }
+
+template<typename _Tp> inline
+Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list)
+    : Mat()
+{
+    size_t size_total = 1;
```

Review comment:
`(int)list.size() / *sizes.begin()` This is not "dims" parameter. "dims" is `sizes.size()`
**File:** modules/core/include/opencv2/core/mat.hpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.

**Code Changes:**
```diff
@@ -989,6 +989,10 @@ class CV_EXPORTS Mat
     */
     template<typename _Tp, typename = typename std::enable_if<std::is_arithmetic<_Tp>::value>::type>
     explicit Mat(const std::initializer_list<_Tp> list);
+
+    /** @overload
+    */
+    template<typename _Tp> explicit Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list);
 #endif
 
```

Review comment:
I fix line 2216 as follows: explicit Mat_(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> values);
**File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.

**Code Changes:**
```diff
@@ -584,6 +584,18 @@ Mat::Mat(const std::initializer_list<_Tp> list)
         return;
     Mat((int)list.size(), 1, traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
 }
+
+template<typename _Tp> inline
+Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list)
+    : Mat()
+{
+    size_t size_total = 1;
```

Review comment:
I changed it to use Mat () as Delegating constructor.
**File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.

**Code Changes:**
```diff
@@ -584,6 +584,18 @@ Mat::Mat(const std::initializer_list<_Tp> list)
         return;
     Mat((int)list.size(), 1, traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
 }
+
+template<typename _Tp> inline
+Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list)
+    : Mat()
+{
+    size_t size_total = 1;
```

Review comment:
And added check using CV_Assert.
**File:** modules/core/test/test_mat.cpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.

**Code Changes:**
```diff
@@ -1719,17 +1719,23 @@ TEST(Mat, from_initializer_list)
 {
     Mat A({1.f, 2.f, 3.f});
     Mat_<float> B(3, 1); B << 1, 2, 3;
+    Mat_<float> C({3}, {1,2,3});
 
     ASSERT_EQ(A.type(), CV_32F);
     ASSERT_DOUBLE_EQ(cvtest::norm(A, B, NORM_INF), 0.);
+    ASSERT_DOUBLE_EQ(cvtest::norm(A, C, NORM_INF), 0.);
+    ASSERT_DOUBLE_EQ(cvtest::norm(B, C, NORM_INF), 0.);
```

Review comment:
I had tryed to use the following constructor for initialize. ->Mat (int rows, int cols, int type, const Scalar & s); But, as you say, using the constructor below is correct. ->Mat (int ndims, const int * sizes, int type, const Scalar & s); If I still do not understand what you say, I apologize.
**File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.

**Code Changes:**
```diff
@@ -584,6 +584,18 @@ Mat::Mat(const std::initializer_list<_Tp> list)
         return;
     Mat((int)list.size(), 1, traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
 }
+
+template<typename _Tp> inline
+Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list)
+    : Mat()
+{
+    size_t size_total = 1;
```

Review comment:
This condition is always true for any on-empty list. Also "size_total != list.size()" is wrong initially.
**File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.

**Code Changes:**
```diff
@@ -584,6 +584,18 @@ Mat::Mat(const std::initializer_list<_Tp> list)
         return;
     Mat((int)list.size(), 1, traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
 }
+
+template<typename _Tp> inline
+Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list)
+    : Mat()
+{
+    size_t size_total = 1;
```

Review comment:
> template<typename _Tp, **typename**> Why we need second "typename" here?
**File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.

**Code Changes:**
```diff
@@ -584,6 +584,18 @@ Mat::Mat(const std::initializer_list<_Tp> list)
         return;
     Mat((int)list.size(), 1, traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
 }
+
+template<typename _Tp> inline
+Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list)
+    : Mat()
+{
+    size_t size_total = 1;
```

Review comment:
```.diff -int i = 0 +size_t i = 0 ``` Because "sizes.size()" has size_t type (almost, http://en.cppreference.com/w/cpp/utility/initializer_list/size ). Anyway it is better to use C++11 "foreach": ``` for (auto s : sizes) { size_total *= s; } ```
**File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.

**Code Changes:**
```diff
@@ -584,6 +584,18 @@ Mat::Mat(const std::initializer_list<_Tp> list)
         return;
     Mat((int)list.size(), 1, traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
 }
+
+template<typename _Tp> inline
+Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list)
+    : Mat()
+{
+    size_t size_total = 1;
```

Review comment:
Touching "flags" is wrong - we should not make Mat inconsistent. Anyway this is not necessary - `copyTo()` will do it.
**File:** modules/core/test/test_mat.cpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.
**Review Line:** 1722

**Code Changes:**
```diff
@@ -1719,17 +1719,23 @@ TEST(Mat, from_initializer_list)
 {
     Mat A({1.f, 2.f, 3.f});
     Mat_<float> B(3, 1); B << 1, 2, 3;
+    Mat_<float> C({3}, {1,2,3});
 
     ASSERT_EQ(A.type(), CV_32F);
     ASSERT_DOUBLE_EQ(cvtest::norm(A, B, NORM_INF), 0.);
+    ASSERT_DOUBLE_EQ(cvtest::norm(A, C, NORM_INF), 0.);
+    ASSERT_DOUBLE_EQ(cvtest::norm(B, C, NORM_INF), 0.);
```

Review comment:
Original issue reports about creation of 2D Mat. I believe we should test them too.
**File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.

**Code Changes:**
```diff
@@ -584,6 +584,18 @@ Mat::Mat(const std::initializer_list<_Tp> list)
         return;
     Mat((int)list.size(), 1, traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
 }
+
+template<typename _Tp> inline
+Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list)
+    : Mat()
+{
+    size_t size_total = 1;
```

Review comment:
I made a mistake. What I want to do was not to generate an assertion if the condition of "size_total == list.size()" is satisfied. I fix this code soon.
**File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.

**Code Changes:**
```diff
@@ -584,6 +584,18 @@ Mat::Mat(const std::initializer_list<_Tp> list)
         return;
     Mat((int)list.size(), 1, traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
 }
+
+template<typename _Tp> inline
+Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list)
+    : Mat()
+{
+    size_t size_total = 1;
```

Review comment:
Actually, we don't need this second "typename". I fix two files to eraze them.
**File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #10808: Add new Mat constructor - resolves #10792 ### This pullrequest changes 1. Add new Mat constructor.

**Code Changes:**
```diff
@@ -584,6 +584,18 @@ Mat::Mat(const std::initializer_list<_Tp> list)
         return;
     Mat((int)list.size(), 1, traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
 }
+
+template<typename _Tp> inline
+Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list)
+    : Mat()
+{
+    size_t size_total = 1;
```

Review comment:
>for (auto s : sizes) >{ > size_total *= s; >} ->I think that this code is most simplified and suitable.
**File:** samples/dnn/colorization.cpp
**Change Type:** added
**Context:** PR #10777: dnn: add colorization.cpp - add a cpp counterpart for the colorization.py sample, also fix some links in the python script

**Code Changes:**
```diff
@@ -0,0 +1,125 @@
+//
+// This program is based on https://github.com/richzhang/colorization/blob/master/colorization/colorize.py
+//  download the caffemodel from: http://eecs.berkeley.edu/~rich.zhang/projects/2016_colorization/files/demo_v2/colorization_release_v2.caffemodel
+//  and the prototxt from: https://github.com/richzhang/colorization/blob/master/colorization/models/colorization_deploy_v2.prototxt
+//
+#include <opencv2/dnn.hpp>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+using namespace cv;
```

Review comment:
something like "print usage" or "print help message"
**File:** samples/dnn/colorization.cpp
**Change Type:** added
**Context:** PR #10777: dnn: add colorization.cpp - add a cpp counterpart for the colorization.py sample, also fix some links in the python script

**Code Changes:**
```diff
@@ -0,0 +1,125 @@
+//
+// This program is based on https://github.com/richzhang/colorization/blob/master/colorization/colorize.py
+//  download the caffemodel from: http://eecs.berkeley.edu/~rich.zhang/projects/2016_colorization/files/demo_v2/colorization_release_v2.caffemodel
+//  and the prototxt from: https://github.com/richzhang/colorization/blob/master/colorization/models/colorization_deploy_v2.prototxt
+//
+#include <opencv2/dnn.hpp>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+using namespace cv;
```

Review comment:
indeed. leftover from the googlenet sample.