nareshmlx/opencv-pr huggingface dataset:
**File:** doc/tutorials/imgproc/out_of_focus_deblur_filter/out_of_focus_deblur_filter.markdown
**Change Type:** modified
**Context:** PR #12214: doc: fix English gramma in tutorial out-of-focus-deblur filter - doc: fix English grammar in the tutorial out-of-focus-deblur filter Thanks...
**Review Line:** 95

**Code Changes:**
```diff
 ![The restored (deblurred) image](images/recovered.jpg)
 
-The Wiener filter was used, values of \f$R\f$ and \f$SNR\f$ were selected manually to give the best possible visual result.
-We can see that the result is not perfect, but it gives us a hint to the image content. With some difficulty, the text is readable.
+The Wiener filter was used, and values of \f$R\f$ and \f$SNR\f$ were selected manually to give the best possible visual result.
+We can see that the result is not perfect, but it gives us a hint to the image's content. With some difficulty, the text is readable.
 
 @note The parameter \f$R\f$ is the most important. So you should adjust \f$R\f$ first, then \f$SNR\f$.
-@note Sometimes you can observe the ringing effect in an restored image. This effect can be reduced by several methods. For example, you can taper input image edges.
+@note Sometimes you can observe the ringing effect in a restored image. This effect can be reduced with several methods. For example, you can taper input image edges.
 
```

Review comment:
> image content looks ok for me.
**File:** modules/dnn/src/layers/crop_layer.cpp
**Change Type:** modified
**Context:** PR #12350: Replace Slice layer to Crop in Faster-RCNN networks from Caffe -  ### This pullrequest changes Enable OCV/OCL_fp16 tests for Faster-RCNN ne...
**Review Line:** 180

**Code Changes:**
```diff
+        ieLayer->axis.push_back(2);  // width
+        ieLayer->offset.push_back(crop_ranges[3].start);
+        ieLayer->dim.push_back(crop_ranges[3].end - crop_ranges[3].start);
+
+        return Ptr<BackendNode>(new InfEngineBackendNode(ieLayer));
+#endif  // HAVE_INF_ENGINE
+        return Ptr<BackendNode>();
+    }
+
     std::vector<Range> crop_ranges;
 };
```

Review comment:
when HAVE_INF_ENGINE is defined, the function will have 2 return statements; shall we place `#else` here?
**File:** modules/imgproc/test/test_subdivision2d.cpp
**Change Type:** added
**Context:** PR #12348: Fix bug in Subdiv2D::getTriangleList
**Review Line:** 1

**Code Changes:**
```diff
@@ -0,0 +1,53 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+// 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.
+//M*/
+#include "test_precomp.hpp"
```

Review comment:
Please use short license header: ``` // 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. ```
**File:** modules/imgproc/test/test_subdivision2d.cpp
**Change Type:** added
**Context:** PR #12348: Fix bug in Subdiv2D::getTriangleList

**Code Changes:**
```diff
@@ -0,0 +1,53 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+// 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.
+//M*/
+#include "test_precomp.hpp"
+
+namespace opencv_test { namespace {
+TEST(Imgproc_Subdiv2D_getTriangleList, regression_5788)
```

Review comment:
It is not necessary to use Legacy "BaseTest" class: ``` TEST(Imgproc_Subdiv2D_getTriangleList, regression_5788) { ... put all test code here ... } ```
**File:** modules/imgproc/src/subdivision2d.cpp
**Change Type:** modified
**Context:** PR #12348: Fix bug in Subdiv2D::getTriangleList

**Code Changes:**
```diff
@@ -758,6 +758,7 @@ void Subdiv2D::getTriangleList(std::vector<Vec6f>& triangleList) const
     triangleList.clear();
     int i, total = (int)(qedges.size()*4);
     std::vector<bool> edgemask(total, false);
+    Rect2f rect(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
 
     for( i = 4; i < total; i += 2 )
     {
@@ -773,7 +774,8 @@ void Subdiv2D::getTriangleList(std::vector<Vec6f>& triangleList) const
         edge = getEdge(edge, NEXT_AROUND_LEFT);
```

Review comment:
Try to reuse existed functionality: `Point2f::inside()` or `Rect::contains()` Note: right/bottom side of OpenCV rectangles is "open" (exclusive).
**File:** modules/dnn/src/nms.cpp
**Change Type:** modified
**Context:** PR #11390: Deep learning text detection sample - ### This pullrequest changes Added sample with deep learning text detection using EAST: An Efficient ...

**Code Changes:**
```diff
@@ -8,6 +8,8 @@
 #include "precomp.hpp"
 #include "nms.inl.hpp"
 
+#include <opencv2/imgproc.hpp>
+
 namespace cv
 {
 namespace dnn
@@ -28,6 +30,27 @@ void NMSBoxes(const std::vector<Rect>& bboxes, const std::vector<float>& scores,
```

Review comment:
I wonder if we can have a function like rotatedRectangleIntersectionArea(), which will compute area of the intersection without storing the coordinates explicitly. Another question - since a rotated rectangle is a convex polygon, its intersection is a convex polygon as well. Why is convexHull() called then?
**File:** samples/dnn/text_detection.cpp
**Change Type:** added
**Context:** PR #11390: Deep learning text detection sample - ### This pullrequest changes Added sample with deep learning text detection using EAST: An Efficient ...
**Review Line:** 117

**Code Changes:**
```diff
+        imshow(kWinName, frame);
+    }
+    return 0;
+}
+
+void decode(const Mat& scores, const Mat& geometry, float scoreThresh,
+            std::vector<RotatedRect>& detections, std::vector<float>& confidences)
+{
+    detections.clear();
+    CV_Assert(scores.dims == 4, geometry.dims == 4, scores.size[0] == 1,
+              geometry.size[0] == 1, scores.size[1] == 1, geometry.size[1] == 5,
```

Review comment:
probably, such a function should be put to objdetect module (or dnn module).
**File:** samples/dnn/text_detection.cpp
**Change Type:** added
**Context:** PR #11390: Deep learning text detection sample - ### This pullrequest changes Added sample with deep learning text detection using EAST: An Efficient ...

**Code Changes:**
```diff
@@ -0,0 +1,159 @@
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+#include <opencv2/dnn.hpp>
+
+#include "custom_layers.hpp"
+
+using namespace cv;
+using namespace cv::dnn;
+
```

Review comment:
Move this code below: ``` for (int y = 0; y < height; ++y) { float* scoresData = scores.ptr<float>(0, 0, y); float* x0_data = geometry.ptr<float>(0, 0, y); float* x1_data = geometry.ptr<float>(0, 1, y); float* x2_data = geometry.ptr<float>(0, 2, y); float* x3_data = geometry.ptr<float>(0, 3, y); float* anglesData = geometry.ptr<float>(0, 4, y); ... } ``` You can not do `x0_data += width;` due missing checks for `steps`.
**File:** samples/dnn/classification.cpp
**Change Type:** modified
**Context:** PR #11650: Default deep learning backend -  ### This pullrequest changes Intel's Inference Engine as a default backend is no preferable backend is spe...

**Code Changes:**
```diff
@@ -21,12 +21,15 @@ const char* keys =
     "{ height      |   | Preprocess input image by resizing to a specific height. }"
     "{ rgb         |   | Indicate that model works with RGB input images instead BGR ones. }"
     "{ backend     | 0 | Choose one of computation backends: "
-                        "0: default C++ backend, "
+                        "0: automatically (by default), "
                         "1: Halide language (http://halide-lang.org/), "
-                        "2: Intel's Deep Learning Inference Engine (https://software.intel.com/openvino-toolkit)}"
+                        "2: Intel's Deep Learning Inference Engine (https://software.intel.com/openvino-toolkit), "
+                        "3: OpenCV implementation }"
```

Review comment:
> 0: automatically (by default) > ... > 3: default implementation Perhaps "default" duplication should be avoided. Can we change description to something like "3: OpenCV implementation"?
**File:** samples/dnn/classification.cpp
**Change Type:** modified
**Context:** PR #11650: Default deep learning backend -  ### This pullrequest changes Intel's Inference Engine as a default backend is no preferable backend is spe...

**Code Changes:**
```diff
@@ -21,12 +21,15 @@ const char* keys =
     "{ height      |   | Preprocess input image by resizing to a specific height. }"
     "{ rgb         |   | Indicate that model works with RGB input images instead BGR ones. }"
     "{ backend     | 0 | Choose one of computation backends: "
-                        "0: default C++ backend, "
+                        "0: automatically (by default), "
                         "1: Halide language (http://halide-lang.org/), "
-                        "2: Intel's Deep Learning Inference Engine (https://software.intel.com/openvino-toolkit)}"
+                        "2: Intel's Deep Learning Inference Engine (https://software.intel.com/openvino-toolkit), "
+                        "3: OpenCV implementation }"
```

Review comment:
Sure. Updated.
**File:** cmake/OpenCVDetectInferenceEngine.cmake
**Change Type:** modified
**Context:** PR #11587: Update Intel's Inference Engine deep learning backend -  ### This pullrequest changes * Update Intel's Inference Engine backend support ([O...

**Code Changes:**
```diff
@@ -41,8 +41,7 @@ set(INF_ENGINE_INCLUDE_DIRS "${INF_ENGINE_ROOT_DIR}/include" CACHE PATH "Path to
 
 if(NOT INF_ENGINE_ROOT_DIR
     OR NOT EXISTS "${INF_ENGINE_ROOT_DIR}"
-    OR NOT EXISTS "${INF_ENGINE_INCLUDE_DIRS}"
-    OR NOT EXISTS "${INF_ENGINE_INCLUDE_DIRS}/inference_engine.hpp"
+    OR NOT EXISTS "${INF_ENGINE_ROOT_DIR}/include/inference_engine.hpp"
 )
     ie_fail()
 endif()
```

Review comment:
Do we really need to link with CPU extension directly?
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #12172: core: move const tables outside of dispatched code - To avoid duplicates in binaries. Size of libopencv_core.so (GCC 8.1.1): - before: 1453...

**Code Changes:**
```diff
@@ -45,6 +45,7 @@
 #include "opencl_kernels_core.hpp"
 #include <limits>
 #include <iostream>
+#include "mathfuncs.hpp"
 
 namespace cv
 {
@@ -2023,4 +2024,382 @@ void cvSolvePoly(const CvMat* a, CvMat *r, int maxiter, int)
 }
```

Review comment:
could you please rename it to `getLogTab64f()` and `getLogTab32f()`, respectively, in order to be more consistent with HAL notation?
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #12172: core: move const tables outside of dispatched code - To avoid duplicates in binaries. Size of libopencv_core.so (GCC 8.1.1): - before: 1453...
**Review Line:** 2119

**Code Changes:**
```diff
+        for( int j = 0; j <= EXPTAB_MASK; j++ )
+            expTab_f[j] = (float)expTab[j];
+        expTab_f_initialized = true;
+    }
+    return expTab_f;
+}
+
+
+
+#define LOGTAB_SCALE        8
+#define LOGTAB_MASK         ((1 << LOGTAB_SCALE) - 1)
```

Review comment:
same, please, rename it to `getExpTab64f()`, `getExpTab32f()`
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #11104: Reading Darknet from cv::FileStorage - ### This pullrequest changes I added new constructor for DarknetImporter to load from std::istream. ...

**Code Changes:**
```diff
@@ -644,13 +644,39 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
     */
     CV_EXPORTS_W Net readNetFromDarknet(const String &cfgFile, const String &darknetModel = String());
 
+    /** @brief Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.
+     *  @param bufferCfg   A buffer contains a content of .cfg file with text description of the network architecture.
+     *  @param bufferModel A buffer contains a content of .weights file with learned network.
+     *  @returns Net object.
+     */
+    CV_EXPORTS_W Net readNetFromDarknet(const std::vector<uchar>& bufferCfg,
```

Review comment:
Due `std::istream` has no wrapping policy we need to use `CV_EXPORTS` here and below.
**File:** modules/dnn/src/darknet/darknet_io.cpp
**Change Type:** modified
**Context:** PR #11104: Reading Darknet from cv::FileStorage - ### This pullrequest changes I added new constructor for DarknetImporter to load from std::istream. ...

**Code Changes:**
```diff
@@ -476,68 +476,61 @@ namespace cv {
                 return dst;
             }
 
-            bool ReadDarknetFromCfgFile(const char *cfgFile, NetParameter *net)
+            bool ReadDarknetFromCfgStream(std::istream &ifile, NetParameter *net)
             {
-                std::ifstream ifile;
-                ifile.open(cfgFile);
-                if (ifile.is_open())
```

Review comment:
Do you mind just rename `darknetModelStream` to `ifile` here?
**File:** modules/dnn/src/darknet/darknet_importer.cpp
**Change Type:** modified
**Context:** PR #11104: Reading Darknet from cv::FileStorage - ### This pullrequest changes I added new constructor for DarknetImporter to load from std::istream. ...

**Code Changes:**
```diff
@@ -44,6 +44,7 @@
 #include "../precomp.hpp"
 
 #include <iostream>
+#include <fstream>
 #include <algorithm>
 #include <vector>
 #include <map>
@@ -66,14 +67,19 @@ class DarknetImporter
 
```

Review comment:
There were assertions include paths to files, ``` CV_Error(cv::Error::StsParseError, "Failed to parse NetParameter file: " + std::string(cfgFile)); ``` I think it's useful to keep some kind of error message that prints actual paths.
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #11104: Reading Darknet from cv::FileStorage - ### This pullrequest changes I added new constructor for DarknetImporter to load from std::istream. ...

**Code Changes:**
```diff
@@ -644,13 +644,39 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
     */
     CV_EXPORTS_W Net readNetFromDarknet(const String &cfgFile, const String &darknetModel = String());
 
+    /** @brief Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.
+     *  @param bufferCfg   A buffer contains a content of .cfg file with text description of the network architecture.
+     *  @param bufferModel A buffer contains a content of .weights file with learned network.
+     *  @returns Net object.
+     */
+    CV_EXPORTS_W Net readNetFromDarknet(const std::vector<uchar>& bufferCfg,
```

Review comment:
OK, now I will to replace `std::istream` to `IStream` of 3rdparty. Can I add `3rdparty/openexr/IlmImf/ImfIO.h` ? Or what do I should use?
**File:** modules/dnn/src/darknet/darknet_importer.cpp
**Change Type:** modified
**Context:** PR #11104: Reading Darknet from cv::FileStorage - ### This pullrequest changes I added new constructor for DarknetImporter to load from std::istream. ...

**Code Changes:**
```diff
@@ -44,6 +44,7 @@
 #include "../precomp.hpp"
 
 #include <iostream>
+#include <fstream>
 #include <algorithm>
 #include <vector>
 #include <map>
@@ -66,14 +67,19 @@ class DarknetImporter
 
```

Review comment:
I think so too. I added it.
**File:** modules/dnn/src/darknet/darknet_io.cpp
**Change Type:** modified
**Context:** PR #11104: Reading Darknet from cv::FileStorage - ### This pullrequest changes I added new constructor for DarknetImporter to load from std::istream. ...

**Code Changes:**
```diff
@@ -476,68 +476,61 @@ namespace cv {
                 return dst;
             }
 
-            bool ReadDarknetFromCfgFile(const char *cfgFile, NetParameter *net)
+            bool ReadDarknetFromCfgStream(std::istream &ifile, NetParameter *net)
             {
-                std::ifstream ifile;
-                ifile.open(cfgFile);
-                if (ifile.is_open())
```

Review comment:
Of course. I renamed.
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #11104: Reading Darknet from cv::FileStorage - ### This pullrequest changes I added new constructor for DarknetImporter to load from std::istream. ...

**Code Changes:**
```diff
@@ -644,13 +644,39 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
     */
     CV_EXPORTS_W Net readNetFromDarknet(const String &cfgFile, const String &darknetModel = String());
 
+    /** @brief Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.
+     *  @param bufferCfg   A buffer contains a content of .cfg file with text description of the network architecture.
+     *  @param bufferModel A buffer contains a content of .weights file with learned network.
+     *  @returns Net object.
+     */
+    CV_EXPORTS_W Net readNetFromDarknet(const std::vector<uchar>& bufferCfg,
```

Review comment:
I got your saying. I will change std::istream to the other buffered structure like #9994.
**File:** modules/dnn/test/test_darknet_importer.cpp
**Change Type:** modified
**Context:** PR #11104: Reading Darknet from cv::FileStorage - ### This pullrequest changes I added new constructor for DarknetImporter to load from std::istream. ...

**Code Changes:**
```diff
@@ -65,6 +65,34 @@ TEST(Test_Darknet, read_yolo_voc)
     ASSERT_FALSE(net.empty());
 }
 
+TEST(Test_Darknet, read_yolo_voc_stream)
+{
+    Mat ref;
+    Mat sample = imread(_tf("dog416.png"));
+    Mat inp = blobFromImage(sample, 1.0/255, Size(416, 416), Scalar(), true, false);
+    const std::string cfgFile = findDataFile("dnn/yolo-voc.cfg", false);
```

Review comment:
I think we need to check an accuracy too. Could you make some of existing accuracy tests to be parametric similar to one of our tests for loading models from a buffer? https://github.com/opencv/opencv/blob/1031dfe4e8b039955a738140e39316e14f18ae28/modules/dnn/test/test_caffe_importer.cpp#L85-L116
**File:** modules/dnn/misc/java/test/DnnTensorFlowTest.java
**Change Type:** modified
**Context:** PR #11104: Reading Darknet from cv::FileStorage - ### This pullrequest changes I added new constructor for DarknetImporter to load from std::istream. ...

**Code Changes:**
```diff
@@ -1,10 +1,14 @@
 package org.opencv.test.dnn;
 
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import org.opencv.core.Core;
 import org.opencv.core.Mat;
```

Review comment:
In tests we can use this: ``` fail("DNN forward() failed: " + e.getMessage()); ```
**File:** modules/core/include/opencv2/core/persistence.hpp
**Change Type:** modified
**Context:** PR #11883: core: FileStorage - add support for writing vector<String> with bindings
**Review Line:** 447

**Code Changes:**
```diff
@@ -444,7 +444,9 @@ class CV_EXPORTS_W FileStorage
     /// @overload
     CV_WRAP void write(const String& name, const String& val);
     /// @overload
-    CV_WRAP void write(const String& name, InputArray val);
+    CV_WRAP void write(const String& name, const Mat& val);
+    /// @overload
+    CV_WRAP void write(const String& name, const std::vector<String>& val);
 
     /** @brief Writes a comment.
 
```

Review comment:
does it mean that we loose ability to write `UMat` or `std::vector<float>` into the FileStorage? Can we just add the second signature `CV_WRAP void write(const String& name, const std::vector<String>& val);` without changing the first one?
**File:** modules/core/include/opencv2/core/persistence.hpp
**Change Type:** modified
**Context:** PR #11883: core: FileStorage - add support for writing vector<String> with bindings
**Review Line:** 447

**Code Changes:**
```diff
@@ -444,7 +444,9 @@ class CV_EXPORTS_W FileStorage
     /// @overload
     CV_WRAP void write(const String& name, const String& val);
     /// @overload
-    CV_WRAP void write(const String& name, InputArray val);
+    CV_WRAP void write(const String& name, const Mat& val);
+    /// @overload
+    CV_WRAP void write(const String& name, const std::vector<String>& val);
 
     /** @brief Writes a comment.
 
```

Review comment:
for `UMat`, yes. Python tuples are converted into a Mat, so a `std::vector<float>` does not exists in the context of wrapping. just adding the `vector<String>` version does not work because the implicit Mat to std::vector conversion: ``` pyopencv_generated_types.h:10611:41: error: call of overloaded ‘write(cv::String&, cv::Mat&)’ is ambiguous ```
**File:** modules/objdetect/test/test_qrcode.cpp
**Change Type:** modified
**Context:** PR #11921: Detect QRCode (Update) - Along with this algorithm there are related data in opencv_extra: PR link: [https://github.com/opencv/opencv_extra...

**Code Changes:**
```diff
@@ -1,74 +1,115 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
```

Review comment:
Do we really need this file? - don't create monster test cases. Use test parameters instead. - one image - one test. It is too hard to debug what is wrong with 10th picture, because you should process first 9 before that. - multiple parsing of summary file should be avoided. Configuration per file looks much better (`20110817_030.jpg` + `20110817_030.json`) - Finally, image name + 4 points can be added into tests code directly. I hope you collected these validation points in more accurate debug build with all disabled optimizations (like IPP).
**File:** modules/objdetect/test/test_qrcode.cpp
**Change Type:** modified
**Context:** PR #11921: Detect QRCode (Update) - Along with this algorithm there are related data in opencv_extra: PR link: [https://github.com/opencv/opencv_extra...

**Code Changes:**
```diff
@@ -1,74 +1,115 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
```

Review comment:
For floats use `fabs`. It is better to use `EXPECT_NEAR(v1, v2, abs_error)` for that.
**File:** modules/objdetect/test/test_qrcode.cpp
**Change Type:** modified
**Context:** PR #11921: Detect QRCode (Update) - Along with this algorithm there are related data in opencv_extra: PR link: [https://github.com/opencv/opencv_extra...

**Code Changes:**
```diff
@@ -1,74 +1,115 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
```

Review comment:
"else" case is not properly handled.
**File:** modules/objdetect/test/test_qrcode.cpp
**Change Type:** modified
**Context:** PR #11921: Detect QRCode (Update) - Along with this algorithm there are related data in opencv_extra: PR link: [https://github.com/opencv/opencv_extra...

**Code Changes:**
```diff
@@ -1,74 +1,115 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
```

Review comment:
We can run QRCode code itself anyway. At least to test for crashes like fresh bugreport.