nareshmlx/opencv-pr huggingface dataset:
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #10331: Changed wrapping mode for dnn::Net::forward -  ### This pullrequest changes Changed wrapping mode for cv::dnn::Net::forward to avoid confli...

**Code Changes:**
```diff
@@ -423,8 +423,8 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
          *  @param outputBlobs contains all output blobs for each layer specified in @p outBlobNames.
          *  @param outBlobNames names for layers which outputs are needed to get
          */
-        void forward(std::vector<std::vector<Mat> >& outputBlobs,
-                     const std::vector<String>& outBlobNames);
+        CV_WRAP_AS(forwardAndRetrieve) void forward(CV_OUT std::vector<std::vector<Mat> >& outputBlobs,
+                                                    const std::vector<String>& outBlobNames);
 
         //TODO:
```

Review comment:
We've removed `CV_WRAP` macro here because it's wrapped similarly to a previous one method. So there are two ways to do `forward` pass in python: with a single string or with a list of strings. May be it's better to wrap it by `CV_WRAP_AS` using different name?
**File:** modules/dnn/src/layers/prior_box_layer.cpp
**Change Type:** modified
**Context:** PR #10341: add ocl accleration for prior box layer and depthwise convolution - with depthwise convolution kernel, we can dramatically improve mobilene...

**Code Changes:**
```diff
@@ -45,6 +45,7 @@
 #include <float.h>
 #include <algorithm>
 #include <cmath>
+#include "opencl_kernels_dnn.hpp"
 
 namespace cv
 {
@@ -270,11 +271,108 @@ class PriorBoxLayerImpl : public PriorBoxLayer
         return false;
```

Review comment:
BTW, I believe we should not increase memory usage for non-OpenCL backends. This should be moved into OpenCL specific code (for example, in `forward_ocl()` and called under some "initialization" flag once per layer instance).
**File:** modules/dnn/src/layers/prior_box_layer.cpp
**Change Type:** modified
**Context:** PR #10341: add ocl accleration for prior box layer and depthwise convolution - with depthwise convolution kernel, we can dramatically improve mobilene...

**Code Changes:**
```diff
@@ -45,6 +45,7 @@
 #include <float.h>
 #include <algorithm>
 #include <cmath>
+#include "opencl_kernels_dnn.hpp"
 
 namespace cv
 {
@@ -270,11 +271,108 @@ class PriorBoxLayerImpl : public PriorBoxLayer
         return false;
```

Review comment:
agree. Such extensive consumption of OpenCL-only memory should not happen by default
**File:** modules/dnn/src/layers/prior_box_layer.cpp
**Change Type:** modified
**Context:** PR #10341: add ocl accleration for prior box layer and depthwise convolution - with depthwise convolution kernel, we can dramatically improve mobilene...

**Code Changes:**
```diff
@@ -45,6 +45,7 @@
 #include <float.h>
 #include <algorithm>
 #include <cmath>
+#include "opencl_kernels_dnn.hpp"
 
 namespace cv
 {
@@ -270,11 +271,108 @@ class PriorBoxLayerImpl : public PriorBoxLayer
         return false;
```

Review comment:
Fixed in the new update, moved the code into forward_ocl().
**File:** modules/imgproc/src/hal_replacement.hpp
**Change Type:** modified
**Context:** PR #10107: medianBlur hal - ### This pullrequest changes 1. Change border type for medianBlur to BORDER_ISOLATED 1. Add hal interface for medianBlur `...

**Code Changes:**
```diff
@@ -615,6 +615,21 @@ inline int hal_ni_integral(int depth, int sdepth, int sqdepth, const uchar * src
 #define cv_hal_integral hal_ni_integral
 //! @endcond
 
+/**
+   @brief Calculate medianBlur filter
+   @param src_data,src_step Source image
+   @param dst_data,dst_step Destination image
+   @param width,height Source image dimensions
+   @param depth Depths of source and destination image
```

Review comment:
BTW, depth and cn: - may be combined into "int type" - or placed on closer parameters positions (Anyway looks like this is grabbed from other functions design)
**File:** 3rdparty/protobuf/src/google/protobuf/stubs/port.h
**Change Type:** modified
**Context:** PR #10215: JavaScript bindings for dnn module - ``` force_builders=Custom docker_image:Docs=docs-js docker_image:Custom=javascript ```

**Code Changes:**
```diff
@@ -224,8 +224,7 @@ static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF);
 
 #if defined(__clang__) && defined(__has_cpp_attribute) \
     && !defined(GOOGLE_PROTOBUF_OS_APPLE)
-# if defined(GOOGLE_PROTOBUF_OS_NACL) || defined(EMSCRIPTEN) || \
-     __has_cpp_attribute(clang::fallthrough)
+# if defined(GOOGLE_PROTOBUF_OS_NACL) || __has_cpp_attribute(clang::fallthrough)
 #  define GOOGLE_FALLTHROUGH_INTENDED [[clang::fallthrough]]
 # endif
 #endif
```

Review comment:
It might be a bit better to change `(defined(EMSCRIPTEN)` to `(defined(EMSCRIPTEN) && __has_cpp_attribute(clang::fallthrough))` instead of commenting out all these lines.
**File:** doc/tutorials/dnn/table_of_content_dnn.markdown
**Change Type:** modified
**Context:** PR #10215: JavaScript bindings for dnn module - ``` force_builders=Custom docker_image:Docs=docs-js docker_image:Custom=javascript ```
**Review Line:** 28

**Code Changes:**
```diff
@@ -25,10 +25,26 @@ Deep Neural Networks (dnn module) {#tutorial_table_of_content_dnn}
 
     In this tutorial we describe the ways to schedule your networks using Halide backend in OpenCV deep learning module.
 
+-   @subpage tutorial_dnn_android
+
+    *Compatibility:* \> OpenCV 3.3
+
+    *Author:* Dmitry Kurtaev
+
```

Review comment:
Why include the android tutorial?
**File:** samples/dnn/js_face_recognition.html
**Change Type:** added
**Context:** PR #10215: JavaScript bindings for dnn module - ``` force_builders=Custom docker_image:Docs=docs-js docker_image:Custom=javascript ```

**Code Changes:**
```diff
@@ -0,0 +1,205 @@
+<!DOCTYPE html>
+
+<html>
+
+<head>
+  <script async src="../../opencv.js" type="text/javascript"></script>
+  <script src="../../utils.js" type="text/javascript"></script>
+
+<script type='text/javascript'>
```

Review comment:
In my test, browser reports 404 not found error when loading `opencv.js` and `utils.js`. The reason is this page is copied to a folder (e.g. `d5/d86/tutorial_dnn_javascript.html`). However, `opencv.js` and `utils.js` is copied to doc root.
**File:** samples/dnn/js_face_recognition.html
**Change Type:** added
**Context:** PR #10215: JavaScript bindings for dnn module - ``` force_builders=Custom docker_image:Docs=docs-js docker_image:Custom=javascript ```

**Code Changes:**
```diff
@@ -0,0 +1,205 @@
+<!DOCTYPE html>
+
+<html>
+
+<head>
+  <script async src="../../opencv.js" type="text/javascript"></script>
+  <script src="../../utils.js" type="text/javascript"></script>
+
+<script type='text/javascript'>
```

Review comment:
You may consider to use async loading of opencv.js because it is big. Utils provides a tool to async load it. See https://github.com/opencv/opencv/blob/master/doc/js_tutorials/js_assets/utils.js#L6
**File:** samples/dnn/js_face_recognition.html
**Change Type:** added
**Context:** PR #10215: JavaScript bindings for dnn module - ``` force_builders=Custom docker_image:Docs=docs-js docker_image:Custom=javascript ```

**Code Changes:**
```diff
@@ -0,0 +1,205 @@
+<!DOCTYPE html>
+
+<html>
+
+<head>
+  <script async src="../../opencv.js" type="text/javascript"></script>
+  <script src="../../utils.js" type="text/javascript"></script>
+
+<script type='text/javascript'>
```

Review comment:
It might not be your desire to schedule next `captureFrame` after 40ms especially when `captureFrame` takes more than 40ms. You may refer to https://github.com/opencv/opencv/blob/master/doc/js_tutorials/js_assets/js_video_display.html#L55 where it computes the next time and uses `setTimeout` to schedule.
**File:** 3rdparty/protobuf/src/google/protobuf/stubs/port.h
**Change Type:** modified
**Context:** PR #10215: JavaScript bindings for dnn module - ``` force_builders=Custom docker_image:Docs=docs-js docker_image:Custom=javascript ```

**Code Changes:**
```diff
@@ -224,8 +224,7 @@ static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF);
 
 #if defined(__clang__) && defined(__has_cpp_attribute) \
     && !defined(GOOGLE_PROTOBUF_OS_APPLE)
-# if defined(GOOGLE_PROTOBUF_OS_NACL) || defined(EMSCRIPTEN) || \
-     __has_cpp_attribute(clang::fallthrough)
+# if defined(GOOGLE_PROTOBUF_OS_NACL) || __has_cpp_attribute(clang::fallthrough)
 #  define GOOGLE_FALLTHROUGH_INTENDED [[clang::fallthrough]]
 # endif
 #endif
```

Review comment:
Fixed. Just a `__has_cpp_attribute(clang::fallthrough)` condition for now.
**File:** doc/tutorials/dnn/table_of_content_dnn.markdown
**Change Type:** modified
**Context:** PR #10215: JavaScript bindings for dnn module - ``` force_builders=Custom docker_image:Docs=docs-js docker_image:Custom=javascript ```
**Review Line:** 28

**Code Changes:**
```diff
@@ -25,10 +25,26 @@ Deep Neural Networks (dnn module) {#tutorial_table_of_content_dnn}
 
     In this tutorial we describe the ways to schedule your networks using Halide backend in OpenCV deep learning module.
 
+-   @subpage tutorial_dnn_android
+
+    *Compatibility:* \> OpenCV 3.3
+
+    *Author:* Dmitry Kurtaev
+
```

Review comment:
I just missed to add this at https://github.com/opencv/opencv/pull/9476.
**File:** samples/dnn/js_face_recognition.html
**Change Type:** added
**Context:** PR #10215: JavaScript bindings for dnn module - ``` force_builders=Custom docker_image:Docs=docs-js docker_image:Custom=javascript ```

**Code Changes:**
```diff
@@ -0,0 +1,205 @@
+<!DOCTYPE html>
+
+<html>
+
+<head>
+  <script async src="../../opencv.js" type="text/javascript"></script>
+  <script src="../../utils.js" type="text/javascript"></script>
+
+<script type='text/javascript'>
```

Review comment:
To my understanding, you are right.
**File:** modules/core/src/kmeans.cpp
**Change Type:** modified
**Context:** PR #10258: kmeans: number of channels in _centers fixed

**Code Changes:**
```diff
@@ -458,7 +458,12 @@ double cv::kmeans( InputArray _data, int K,
         {
             best_compactness = compactness;
             if( _centers.needed() )
-                centers.copyTo(_centers);
+            {
+                Mat reshaped = centers;
+                if(_centers.fixedType() && _centers.channels() == dims)
+                    reshaped = centers.reshape(dims);
+                reshaped.copyTo(_centers);
```

Review comment:
It looks like the function allow to pass complex configuration of input points since in L239 `int dims = (isrow ? 1 : data0.cols)*data0.channels()`. IMHO it should be possible for the user to provide the same configuration for the `OutputArray _centers`
**File:** modules/core/src/kmeans.cpp
**Change Type:** modified
**Context:** PR #10258: kmeans: number of channels in _centers fixed

**Code Changes:**
```diff
@@ -458,7 +458,12 @@ double cv::kmeans( InputArray _data, int K,
         {
             best_compactness = compactness;
             if( _centers.needed() )
-                centers.copyTo(_centers);
+            {
+                Mat reshaped = centers;
+                if(_centers.fixedType() && _centers.channels() == dims)
+                    reshaped = centers.reshape(dims);
+                reshaped.copyTo(_centers);
```

Review comment:
This makes sense, will be implemented
**File:** modules/core/src/kmeans.cpp
**Change Type:** modified
**Context:** PR #10258: kmeans: number of channels in _centers fixed

**Code Changes:**
```diff
@@ -458,7 +458,12 @@ double cv::kmeans( InputArray _data, int K,
         {
             best_compactness = compactness;
             if( _centers.needed() )
-                centers.copyTo(_centers);
+            {
+                Mat reshaped = centers;
+                if(_centers.fixedType() && _centers.channels() == dims)
+                    reshaped = centers.reshape(dims);
+                reshaped.copyTo(_centers);
```

Review comment:
the fix is incorrect. The function behavior should not be dependent on the current shape of the output array. Instead, you should check whether the output array (`_centers`) has the fixed type (e.g. when `_centers` is `std::vector<someT>`) or not.
**File:** modules/core/src/kmeans.cpp
**Change Type:** modified
**Context:** PR #10258: kmeans: number of channels in _centers fixed

**Code Changes:**
```diff
@@ -458,7 +458,12 @@ double cv::kmeans( InputArray _data, int K,
         {
             best_compactness = compactness;
             if( _centers.needed() )
-                centers.copyTo(_centers);
+            {
+                Mat reshaped = centers;
+                if(_centers.fixedType() && _centers.channels() == dims)
+                    reshaped = centers.reshape(dims);
+                reshaped.copyTo(_centers);
```

Review comment:
Done. But we need to check actual `channels()` number (which shouldn't depend on current shape of array).
**File:** samples/cpp/tutorial_code/features2D/Homography/tutorial_homography_ex4_decompose_homography.cpp
**Change Type:** added
**Context:** PR #10304: Add a tutorial about the homography - ### This pullrequest changes I would like to add a tutorial about the homography concept. While this ...

**Code Changes:**
```diff
@@ -0,0 +1,195 @@
+#include <iostream>
+#include <opencv2/opencv_modules.hpp>
+#ifdef HAVE_OPENCV_ARUCO
+#include <opencv2/opencv.hpp>
+#include <opencv2/aruco.hpp>
+
+using namespace std;
+using namespace cv;
+
```

Review comment:
``` #ifdef HAVE_OPENCV_ARUCO // defined in opencv_modules.hpp #include <opencv2/aruco.hpp> ... all other sample code ... #else int main(int argc, char **argv) { std::cerr << "FATAL ERROR: This sample requires opencv_aruco module (from opencv_contrib)"; return 0; } #endif ```
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #9468: Bitexact resize - ### This pullrequest changes Added bit-exact implementation for linear resize Should be merged with [extra#414](https://gi...

**Code Changes:**
```diff
@@ -279,6 +279,8 @@ enum InterpolationFlags{
     INTER_AREA           = 3,
     /** Lanczos interpolation over 8x8 neighborhood */
     INTER_LANCZOS4       = 4,
+    /** Bit exact bilinear interpolation */
+    INTER_LINEAR_EXACT = 5,
     /** mask for interpolation codes */
     INTER_MAX            = 7,
     /** flag, fills all of the destination image pixels. If some of them correspond to outliers in the
```

Review comment:
I prefer to have `resizeFast()` instead of flag. Also this would allow to minimize code binary size (like `cvtColor()` size hell). Or add `resizeBitExact()/cv::bit_exact::resize()` instead because it doesn't support all current resize modes.
**File:** modules/imgproc/src/resize.cpp
**Change Type:** modified
**Context:** PR #9468: Bitexact resize - ### This pullrequest changes Added bit-exact implementation for linear resize Should be merged with [extra#414](https://gi...

**Code Changes:**
```diff
@@ -50,12 +50,633 @@
 #include "precomp.hpp"
 #include "opencl_kernels_imgproc.hpp"
 #include "hal_replacement.hpp"
+#include "opencv2/core/hal/intrin.hpp"
 
 #include "opencv2/core/openvx/ovx_defs.hpp"
 #include "resize.hpp"
 
+#include "opencv2/core/softfloat.hpp"
```

Review comment:
Check for existed "CV_INLINE" macro.
**File:** modules/imgproc/src/resize.cpp
**Change Type:** modified
**Context:** PR #9468: Bitexact resize - ### This pullrequest changes Added bit-exact implementation for linear resize Should be merged with [extra#414](https://gi...

**Code Changes:**
```diff
@@ -50,12 +50,633 @@
 #include "precomp.hpp"
 #include "opencl_kernels_imgproc.hpp"
 #include "hal_replacement.hpp"
+#include "opencv2/core/hal/intrin.hpp"
 
 #include "opencv2/core/openvx/ovx_defs.hpp"
 #include "resize.hpp"
 
+#include "opencv2/core/softfloat.hpp"
```

Review comment:
What is the source of this implementation?
**File:** modules/imgproc/src/resize.cpp
**Change Type:** modified
**Context:** PR #9468: Bitexact resize - ### This pullrequest changes Added bit-exact implementation for linear resize Should be merged with [extra#414](https://gi...

**Code Changes:**
```diff
@@ -50,12 +50,633 @@
 #include "precomp.hpp"
 #include "opencl_kernels_imgproc.hpp"
 #include "hal_replacement.hpp"
+#include "opencv2/core/hal/intrin.hpp"
 
 #include "opencv2/core/openvx/ovx_defs.hpp"
 #include "resize.hpp"
 
+#include "opencv2/core/softfloat.hpp"
```

Review comment:
`fixedround` is already defined as static const. Static code analyzers dislikes this.
**File:** modules/imgproc/src/resize.cpp
**Change Type:** modified
**Context:** PR #9468: Bitexact resize - ### This pullrequest changes Added bit-exact implementation for linear resize Should be merged with [extra#414](https://gi...

**Code Changes:**
```diff
@@ -50,12 +50,633 @@
 #include "precomp.hpp"
 #include "opencl_kernels_imgproc.hpp"
 #include "hal_replacement.hpp"
+#include "opencv2/core/hal/intrin.hpp"
 
 #include "opencv2/core/openvx/ovx_defs.hpp"
 #include "resize.hpp"
 
+#include "opencv2/core/softfloat.hpp"
```

Review comment:
We still need C++98 code.
**File:** modules/imgproc/src/resize.cpp
**Change Type:** modified
**Context:** PR #9468: Bitexact resize - ### This pullrequest changes Added bit-exact implementation for linear resize Should be merged with [extra#414](https://gi...

**Code Changes:**
```diff
@@ -50,12 +50,633 @@
 #include "precomp.hpp"
 #include "opencl_kernels_imgproc.hpp"
 #include "hal_replacement.hpp"
+#include "opencv2/core/hal/intrin.hpp"
 
 #include "opencv2/core/openvx/ovx_defs.hpp"
 #include "resize.hpp"
 
+#include "opencv2/core/softfloat.hpp"
```

Review comment:
The code was implemented from scratch, but implementation could be influenced by discussions I've read during investigation of existing approaches.
**File:** modules/imgproc/src/resize.cpp
**Change Type:** modified
**Context:** PR #9468: Bitexact resize - ### This pullrequest changes Added bit-exact implementation for linear resize Should be merged with [extra#414](https://gi...

**Code Changes:**
```diff
@@ -50,12 +50,633 @@
 #include "precomp.hpp"
 #include "opencl_kernels_imgproc.hpp"
 #include "hal_replacement.hpp"
+#include "opencv2/core/hal/intrin.hpp"
 
 #include "opencv2/core/openvx/ovx_defs.hpp"
 #include "resize.hpp"
 
+#include "opencv2/core/softfloat.hpp"
```

Review comment:
CV_INLINE doesn't force inlining and could add `static` modificator,
**File:** apps/createsamples/utility.cpp
**Change Type:** modified
**Context:** PR #9468: Bitexact resize - ### This pullrequest changes Added bit-exact implementation for linear resize Should be merged with [extra#414](https://gi...

**Code Changes:**
```diff
@@ -686,8 +686,8 @@ void icvPlaceDistortedSample( Mat background,
     Mat img( background.size(), CV_8UC1 );
     Mat maskimg( background.size(), CV_8UC1 );
 
-    resize( data->img(roi), img, img.size(), 0, 0, INTER_LINEAR);
-    resize( data->maskimg(roi), maskimg, maskimg.size(), 0, 0, INTER_LINEAR);
+    resize( data->img(roi), img, img.size(), 0, 0, INTER_LINEAR_EXACT);
+    resize( data->maskimg(roi), maskimg, maskimg.size(), 0, 0, INTER_LINEAR_EXACT);
 
     forecolordev = (int) (maxintensitydev * (2.0 * rand() / RAND_MAX - 1.0));
```

Review comment:
I believe it is better to extract these 600 changes into a separate PR.
**File:** modules/imgproc/test/test_imgwarp.cpp
**Change Type:** modified
**Context:** PR #9468: Bitexact resize - ### This pullrequest changes Added bit-exact implementation for linear resize Should be merged with [extra#414](https://gi...

**Code Changes:**
```diff
@@ -335,6 +335,30 @@ void CV_ResizeTest::prepare_to_validation( int /*test_case_idx*/ )
     cvReleaseMat( &y_idx );
 }
 
+class CV_ResizeExactTest : public CV_ResizeTest
+{
+public:
+    CV_ResizeExactTest();
+
+protected:
```

Review comment:
Please avoid magic numbers
**File:** 3rdparty/carotene/src/resize.cpp
**Change Type:** modified
**Context:** PR #9468: Bitexact resize - ### This pullrequest changes Added bit-exact implementation for linear resize Should be merged with [extra#414](https://gi...

**Code Changes:**
```diff
@@ -106,7 +106,8 @@ bool isResizeLinearOpenCVSupported(const Size2D &ssize, const Size2D &dsize, u32
             && !(ssize.width > 0xffffFFFF || ssize.height > 0xffffFFFF)// Restrict image size since internal index evaluation
                                                                        // is performed with u32
 #endif
-            && dsize.width >= 2 && dsize.height >= 8)
+            && dsize.width >= 2 && dsize.height >= 8
+            && (2*dsize.width != ssize.width || 2*dsize.height != ssize.height)) // 2x downscaling is performed as area in OpenCV which differs from this implementation
             return isSupportedConfiguration();
     default:
         return false;
```

Review comment:
typo: `which`
**File:** modules/imgproc/src/resize.cpp
**Change Type:** modified
**Context:** PR #9468: Bitexact resize - ### This pullrequest changes Added bit-exact implementation for linear resize Should be merged with [extra#414](https://gi...

**Code Changes:**
```diff
@@ -50,12 +50,633 @@
 #include "precomp.hpp"
 #include "opencl_kernels_imgproc.hpp"
 #include "hal_replacement.hpp"
+#include "opencv2/core/hal/intrin.hpp"
 
 #include "opencv2/core/openvx/ovx_defs.hpp"
 #include "resize.hpp"
 
+#include "opencv2/core/softfloat.hpp"
```

Review comment:
``` val = ((int64_t)_val) << fixedShift; ```
**File:** modules/imgproc/src/resize.cpp
**Change Type:** modified
**Context:** PR #9468: Bitexact resize - ### This pullrequest changes Added bit-exact implementation for linear resize Should be merged with [extra#414](https://gi...

**Code Changes:**
```diff
@@ -50,12 +50,633 @@
 #include "precomp.hpp"
 #include "opencl_kernels_imgproc.hpp"
 #include "hal_replacement.hpp"
+#include "opencv2/core/hal/intrin.hpp"
 
 #include "opencv2/core/openvx/ovx_defs.hpp"
 #include "resize.hpp"
 
+#include "opencv2/core/softfloat.hpp"
```

Review comment:
I believe these 250 lines with fixedpoint implementation can be moved into separate .inl.hpp file (in `src` directory)
**File:** apps/createsamples/utility.cpp
**Change Type:** modified
**Context:** PR #10226: fixed createsample info message - resolves https://github.com/opencv/opencv/issues/10214 Changed the verbose call to be after data->last = ...

**Code Changes:**
```diff
@@ -995,12 +995,12 @@ void icvGetNextFromBackgroundData( CvBackgroundData* data,
         {
             round = data->round;
 
+            data->last = rand() % data->count;
+
 #ifdef CV_VERBOSE
             printf( "Open background image: %s\n", data->filename[data->last] );
 #endif /* CV_VERBOSE */
 
```

Review comment:
IMHO the second line do nothing since the result of the first line is already a remainder. I think it would be better to remove it.
**File:** modules/imgproc/src/lsd.cpp
**Change Type:** modified
**Context:** PR #10024: Clearing data into the detect method of the class cv::LineSegmentDete… - close #10023 ### Clearing data into the detect method of the class...
**Review Line:** 435

**Code Changes:**
```diff
     if(w_needed) Mat(w).copyTo(_width);
     if(p_needed) Mat(p).copyTo(_prec);
     if(n_needed) Mat(n).copyTo(_nfa);
+
+    // Clear used structures
+    list.clear();
 }
 
 void LineSegmentDetectorImpl::flsd(std::vector<Vec4f>& lines,
```

Review comment:
It looks like `list` vector isn't used in any meaningful way. IMHO it could be completely removed.
**File:** modules/imgproc/src/lsd.cpp
**Change Type:** modified
**Context:** PR #10024: Clearing data into the detect method of the class cv::LineSegmentDete… - close #10023 ### Clearing data into the detect method of the class...
**Review Line:** 435

**Code Changes:**
```diff
     if(w_needed) Mat(w).copyTo(_width);
     if(p_needed) Mat(p).copyTo(_prec);
     if(n_needed) Mat(n).copyTo(_nfa);
+
+    // Clear used structures
+    list.clear();
 }
 
 void LineSegmentDetectorImpl::flsd(std::vector<Vec4f>& lines,
```

Review comment:
What do you mean? It is used in other methods: - ll_angle() - flsd()