nareshmlx/opencv-pr huggingface dataset:
**File:** modules/imgproc/src/color.cpp
**Change Type:** modified
**Context:** PR #1901: [T-API] bug fixes in the base OCL layer; improved (?) performance of cvtcolor BGR=>Gray - fixed many bugs related to Mat::getUMat(), asynchr...

**Code Changes:**
```diff
@@ -2695,6 +2695,7 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
     UMat src = _src.getUMat(), dst;
     Size sz = src.size(), dstSz = sz;
     int scn = src.channels(), depth = src.depth(), bidx;
+    int dims = 2, stripeSize = 1;
     size_t globalsize[] = { src.cols, src.rows };
     ocl::Kernel k;
 
@@ -2765,7 +2766,9 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
         bidx = code == COLOR_BGR2GRAY || code == COLOR_BGRA2GRAY ? 0 : 2;
```

Review comment:
no, I experimented with my card. It can probably be a different number of different cards, but setting it &gt;&gt;1 should improve performance on most cards
**File:** modules/core/include/opencv2/core/mat.hpp
**Change Type:** modified
**Context:** PR #1901: [T-API] bug fixes in the base OCL layer; improved (?) performance of cvtcolor BGR=>Gray - fixed many bugs related to Mat::getUMat(), asynchr...

**Code Changes:**
```diff
@@ -279,21 +279,21 @@ class CV_EXPORTS MatAllocator
     //virtual void allocate(int dims, const int* sizes, int type, int*& refcount,
     //                      uchar*& datastart, uchar*& data, size_t* step) = 0;
     //virtual void deallocate(int* refcount, uchar* datastart, uchar* data) = 0;
-    virtual UMatData* allocate(int dims, const int* sizes,
-                               int type, size_t* step) const = 0;
+    virtual UMatData* allocate(int dims, const int* sizes, int type,
+                               void* data, size_t* step, int flags) const = 0;
     virtual bool allocate(UMatData* data, int accessflags) const = 0;
     virtual void deallocate(UMatData* data) const = 0;
```

Review comment:
Why test's problem can't be resolved by patching only `deallocate` method? Why `UMat::getMat` or `UMat::handle` is not enough to get synchronized data, if this data is really needed? What is about `ACCESS_FAST` behavior? Will it help here to prevent reallocations or it will prevent data transfers also?
**File:** modules/core/src/ocl.cpp
**Change Type:** modified
**Context:** PR #1901: [T-API] bug fixes in the base OCL layer; improved (?) performance of cvtcolor BGR=>Gray - fixed many bugs related to Mat::getUMat(), asynchr...
**Review Line:** 2276

**Code Changes:**
```diff
+        size_t val = _localsize ? _localsize[i] :
+            dims == 1 ? 64 : dims == 2 ? (16>>i) : dims == 3 ? (8>>(int)(i>0)) : 1;
+        CV_Assert( val > 0 );
+        total *= _globalsize[i];
+        globalsize[i] = ((_globalsize[i] + val - 1)/val)*val;
+    }
+    if( total == 0 )
+        return true;
+    if( p->haveTempDstUMats )
+        sync = true;
     cl_int retval = clEnqueueNDRangeKernel(qq, p->handle, (cl_uint)dims,
```

Review comment:
`clEnqueueNDRangeKernel` documentation says: "If local_work_size is specified, the values specified in global_work_size[0],... global_work_size[work_dim - 1] must be evenly **divisible** by the corresponding values specified in local_work_size[0],... local_work_size[work_dim - 1]" So your `val` here should be `k[i] * _localSize[i]`. Value of k[i] != 1 are definitely useless, so `val = _localSize[i]` exactly. Please look at `openCLExecuteKernel` implementation in ocl module. It is enough in the most cases. P.S. Try to use this: ``` inline size_t roundUp(size_t sz, size_t n) { // we don't assume that n is a power of 2 (see alignSize) // equal to divUp(sz, n) * n size_t t = sz + n - 1; size_t rem = t % n; size_t result = t - rem; return result; } ```
**File:** modules/imgproc/src/color.cpp
**Change Type:** modified
**Context:** PR #1901: [T-API] bug fixes in the base OCL layer; improved (?) performance of cvtcolor BGR=>Gray - fixed many bugs related to Mat::getUMat(), asynchr...

**Code Changes:**
```diff
@@ -2695,6 +2695,7 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
     UMat src = _src.getUMat(), dst;
     Size sz = src.size(), dstSz = sz;
     int scn = src.channels(), depth = src.depth(), bidx;
+    int dims = 2, stripeSize = 1;
     size_t globalsize[] = { src.cols, src.rows };
     ocl::Kernel k;
 
@@ -2765,7 +2766,9 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
         bidx = code == COLOR_BGR2GRAY || code == COLOR_BGRA2GRAY ? 0 : 2;
```

Review comment:
Oh, I see... Thread 0 reads pixels: 0, 1, 2, 3, ... 31 Thread 1 reads pixels: 32,33,34, ... 63 Thread 2 reads pixels: 64,65,66, ... 95 But memory access pattern for wavefront is: step1: th0: 0, th1: 32, th2: 64, 96, 128, 160, 192, 224, 256, ... step2: th0: 1, th1: 33, th2: 65, 97, 129, 161, 193, 225, 257, ... ... I'm not sure that it is a good pattern, so some investigation is required. Especially for C3 data.
**File:** modules/core/src/umatrix.cpp
**Change Type:** modified
**Context:** PR #1901: [T-API] bug fixes in the base OCL layer; improved (?) performance of cvtcolor BGR=>Gray - fixed many bugs related to Mat::getUMat(), asynchr...
**Review Line:** 291

**Code Changes:**
```diff
+
+UMat::~UMat()
+{
+    release();
+    if( step.p != step.buf )
+        fastFree(step.p);
+}
+
 void UMat::deallocate()
 {
     u->currAllocator->deallocate(u);
```

Review comment:
I believe that last two lines should be a part of `MatStep` destructor.
**File:** modules/core/src/ocl.cpp
**Change Type:** modified
**Context:** PR #1901: [T-API] bug fixes in the base OCL layer; improved (?) performance of cvtcolor BGR=>Gray - fixed many bugs related to Mat::getUMat(), asynchr...
**Review Line:** 2276

**Code Changes:**
```diff
+        size_t val = _localsize ? _localsize[i] :
+            dims == 1 ? 64 : dims == 2 ? (16>>i) : dims == 3 ? (8>>(int)(i>0)) : 1;
+        CV_Assert( val > 0 );
+        total *= _globalsize[i];
+        globalsize[i] = ((_globalsize[i] + val - 1)/val)*val;
+    }
+    if( total == 0 )
+        return true;
+    if( p->haveTempDstUMats )
+        sync = true;
     cl_int retval = clEnqueueNDRangeKernel(qq, p->handle, (cl_uint)dims,
```

Review comment:
this is what I do. Besides, we should take care of the case when localsize is NULL (which will be often situation in the new code). In this case globalize should also be made divisible by 16 or so, so that OpenCL runtime could choose the proper localsize, not {1,1}.
**File:** modules/core/src/umatrix.cpp
**Change Type:** modified
**Context:** PR #1901: [T-API] bug fixes in the base OCL layer; improved (?) performance of cvtcolor BGR=>Gray - fixed many bugs related to Mat::getUMat(), asynchr...
**Review Line:** 581

**Code Changes:**
```diff
         return Mat();
-    u->currAllocator->map(u, accessFlags);
+    u->currAllocator->map(u, accessFlags | ACCESS_READ);
     CV_Assert(u->data != 0);
     Mat hdr(dims, size.p, type(), u->data + offset, step.p);
     hdr.u = u;
@@ -568,12 +597,6 @@ void* UMat::handle(int /*accessFlags*/) const
         CV_Assert(u->refcount == 0);
         u->currAllocator->unmap(u);
     }
-    /*else if( u->refcount > 0 && (accessFlags & ACCESS_WRITE) )
```

Review comment:
the proper flags are set by the constructor <pre> Mat hdr(dims, size.p, type(), u->data + offset, step.p); </pre>
**File:** modules/core/src/umatrix.cpp
**Change Type:** modified
**Context:** PR #1901: [T-API] bug fixes in the base OCL layer; improved (?) performance of cvtcolor BGR=>Gray - fixed many bugs related to Mat::getUMat(), asynchr...
**Review Line:** 581

**Code Changes:**
```diff
         return Mat();
-    u->currAllocator->map(u, accessFlags);
+    u->currAllocator->map(u, accessFlags | ACCESS_READ);
     CV_Assert(u->data != 0);
     Mat hdr(dims, size.p, type(), u->data + offset, step.p);
     hdr.u = u;
@@ -568,12 +597,6 @@ void* UMat::handle(int /*accessFlags*/) const
         CV_Assert(u->refcount == 0);
         u->currAllocator->unmap(u);
     }
-    /*else if( u->refcount > 0 && (accessFlags & ACCESS_WRITE) )
```

Review comment:
this constructor does not set `SUBMATRIX_FLAG`
**File:** modules/core/src/umatrix.cpp
**Change Type:** modified
**Context:** PR #1901: [T-API] bug fixes in the base OCL layer; improved (?) performance of cvtcolor BGR=>Gray - fixed many bugs related to Mat::getUMat(), asynchr...
**Review Line:** 581

**Code Changes:**
```diff
         return Mat();
-    u->currAllocator->map(u, accessFlags);
+    u->currAllocator->map(u, accessFlags | ACCESS_READ);
     CV_Assert(u->data != 0);
     Mat hdr(dims, size.p, type(), u->data + offset, step.p);
     hdr.u = u;
@@ -568,12 +597,6 @@ void* UMat::handle(int /*accessFlags*/) const
         CV_Assert(u->refcount == 0);
         u->currAllocator->unmap(u);
     }
-    /*else if( u->refcount > 0 && (accessFlags & ACCESS_WRITE) )
```

Review comment:
``` TEST(UMat, SubmatrixFlag) { ASSERT_TRUE(UMat(4, 4, CV_32FC1)(Rect(1, 1, 1, 1)).getMat(ACCESS_READ).isSubmatrix()); } ```
**File:** modules/highgui/src/cap_msmf.cpp
**Change Type:** modified
**Context:** PR #1986: Update cap_msmf.cpp - WinRT capture support: Add support for WinRT in the MF capture framework by removing the disallowed calls to enumerate...

**Code Changes:**
```diff
@@ -75,9 +75,31 @@
 #include <wrl/client.h>
 using namespace Microsoft::WRL;
 
+#include <mferror.h>
+
+#ifdef HAVE_WINRT
+#ifdef __cplusplus_winrt
+#include <agile.h>
+#include <vccorlib.h>
```

Review comment:
I cannot find the factory call in your patch. You need to modify modules/highgui/src/cap.cpp file too to make your VideoCapture impl available through OpenCV API.
**File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #1855: Affine3<T>::rvec(), compilation & minor
**Review Line:** 119

**Code Changes:**
```diff
@@ -116,6 +116,7 @@ endif()
 OCV_OPTION(WITH_1394           "Include IEEE1394 support"                    ON   IF (NOT ANDROID AND NOT IOS) )
 OCV_OPTION(WITH_AVFOUNDATION   "Use AVFoundation for Video I/O"              ON   IF IOS)
 OCV_OPTION(WITH_CARBON         "Use Carbon for UI instead of Cocoa"          OFF  IF APPLE )
+OCV_OPTION(WITH_VTK            "Include VTK library support (and build opencv_viz module eiher)"             OFF IF (NOT ANDROID AND NOT IOS) )
 OCV_OPTION(WITH_CUDA           "Include NVidia Cuda Runtime support"                                         ON  IF (NOT IOS) )
 OCV_OPTION(WITH_CUFFT          "Include NVidia Cuda Fast Fourier Transform (FFT) library support"            ON  IF (NOT IOS) )
 OCV_OPTION(WITH_CUBLAS         "Include NVidia Cuda Basic Linear Algebra Subprograms (BLAS) library support" OFF IF (NOT IOS) )
@@ -430,6 +431,8 @@ endif()
 # --- Matlab/Octave ---
```

Review comment:
I'm not sure what the parenthetical is supposed to mean here, but I suspect it's incorrect, because modules can be toggled independently.
**File:** cmake/OpenCVDetectVTK.cmake
**Change Type:** added
**Context:** PR #1855: Affine3<T>::rvec(), compilation & minor

**Code Changes:**
```diff
@@ -0,0 +1,21 @@
+if(NOT WITH_VTK OR ANDROID OR IOS)
+  return()
+endif()
+
+find_package(VTK 6.0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture NO_MODULE)
+
+if(NOT DEFINED VTK_FOUND OR NOT VTK_FOUND)
+  find_package(VTK 5.10 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE)
+endif()
```

Review comment:
This message is just noise. If the user has `WITH_VTK` off, then presumably he doesn't care. Even if he does, there's still the status line. This is also inconsistent with how every other `WITH_` option works. Also, the condition above is partly redundant, because `WITH_VTK` can't be on if `ANDROID OR IOS` is true.
**File:** cmake/OpenCVDetectVTK.cmake
**Change Type:** added
**Context:** PR #1855: Affine3<T>::rvec(), compilation & minor

**Code Changes:**
```diff
@@ -0,0 +1,21 @@
+if(NOT WITH_VTK OR ANDROID OR IOS)
+  return()
+endif()
+
+find_package(VTK 6.0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture NO_MODULE)
+
+if(NOT DEFINED VTK_FOUND OR NOT VTK_FOUND)
+  find_package(VTK 5.10 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE)
+endif()
```

Review comment:
Why did you use `NO_MODULE` here?
**File:** cmake/OpenCVDetectVTK.cmake
**Change Type:** added
**Context:** PR #1855: Affine3<T>::rvec(), compilation & minor

**Code Changes:**
```diff
@@ -0,0 +1,21 @@
+if(NOT WITH_VTK OR ANDROID OR IOS)
+  return()
+endif()
+
+find_package(VTK 6.0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture NO_MODULE)
+
+if(NOT DEFINED VTK_FOUND OR NOT VTK_FOUND)
+  find_package(VTK 5.10 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE)
+endif()
```

Review comment:
And what's the problem with that?
**File:** cmake/OpenCVDetectVTK.cmake
**Change Type:** added
**Context:** PR #1855: Affine3<T>::rvec(), compilation & minor

**Code Changes:**
```diff
@@ -0,0 +1,21 @@
+if(NOT WITH_VTK OR ANDROID OR IOS)
+  return()
+endif()
+
+find_package(VTK 6.0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture NO_MODULE)
+
+if(NOT DEFINED VTK_FOUND OR NOT VTK_FOUND)
+  find_package(VTK 5.10 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE)
+endif()
```

Review comment:
Just for Windows? I'd think it works everywhere. Also, pretty sure it looks for `VTKConfig.cmake`, not `UseVTK.cmake`. And really, the two alternatives are pretty much the same, aren't they? You can just say something like "Please set `VTK_DIR` to a path containing `VTKConfig.cmake`", and it will cover all cases.
**File:** modules/viz/CMakeLists.txt
**Change Type:** modified
**Context:** PR #1855: Affine3<T>::rvec(), compilation & minor

**Code Changes:**
```diff
@@ -1,57 +1,11 @@
-macro(find_qvtk)
-  find_library (QVTK_LIBRARY QVTK HINTS ${VTK_DIR} ${VTK_DIR}/bin)
-  find_path (QVTK_INCLUDE_DIR QVTKWidget.h HINT ${VTK_INCLUDE_DIRS})
-  find_package_handle_standard_args(QVTK DEFAULT_MSG QVTK_LIBRARY QVTK_INCLUDE_DIR)
-
-  if(QVTK_FOUND)
-    get_filename_component (QVTK_LIBRARY_DIR ${QVTK_LIBRARY} PATH)
-    list(APPEND VTK_LIBRARY_DIRS ${QVTK_LIBRARY_DIR})
-    list(APPEND VTK_INCLUDE_DIRS ${QVTK_INCLUDE_DIR})
```

Review comment:
You need to use `ocv_module_disable` here, otherwise the build system won't even know the module exists. Look at the other modules for examples. Also, your condition should be just `NOT HAVE_VTK` - undefined variables are false, and `NOT HAVE_VTK` implies `NOT WITH_VTK`.
**File:** cmake/OpenCVDetectVTK.cmake
**Change Type:** added
**Context:** PR #1855: Affine3<T>::rvec(), compilation & minor

**Code Changes:**
```diff
@@ -0,0 +1,21 @@
+if(NOT WITH_VTK OR ANDROID OR IOS)
+  return()
+endif()
+
+find_package(VTK 6.0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture NO_MODULE)
+
+if(NOT DEFINED VTK_FOUND OR NOT VTK_FOUND)
+  find_package(VTK 5.10 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE)
+endif()
```

Review comment:
This is recommended way inlcuding VTK
**File:** cmake/OpenCVDetectVTK.cmake
**Change Type:** added
**Context:** PR #1855: Affine3<T>::rvec(), compilation & minor

**Code Changes:**
```diff
@@ -0,0 +1,21 @@
+if(NOT WITH_VTK OR ANDROID OR IOS)
+  return()
+endif()
+
+find_package(VTK 6.0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture NO_MODULE)
+
+if(NOT DEFINED VTK_FOUND OR NOT VTK_FOUND)
+  find_package(VTK 5.10 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE)
+endif()
```

Review comment:
Don't want to support (and spend time for testing) of such mode.
**File:** cmake/OpenCVDetectVTK.cmake
**Change Type:** added
**Context:** PR #1855: Affine3<T>::rvec(), compilation & minor

**Code Changes:**
```diff
@@ -0,0 +1,21 @@
+if(NOT WITH_VTK OR ANDROID OR IOS)
+  return()
+endif()
+
+find_package(VTK 6.0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture NO_MODULE)
+
+if(NOT DEFINED VTK_FOUND OR NOT VTK_FOUND)
+  find_package(VTK 5.10 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE)
+endif()
```

Review comment:
Is it really any different from other modes? OpenCV will have a dependency on VTK either way. Also, you don't _have_ to test it if you don't have any special code to support it. I'm not going to insist on this one, but it seems like you wrote more code than necessary only to add a restriction that doesn't help users.
**File:** cmake/OpenCVDetectVTK.cmake
**Change Type:** added
**Context:** PR #1855: Affine3<T>::rvec(), compilation & minor

**Code Changes:**
```diff
@@ -0,0 +1,21 @@
+if(NOT WITH_VTK OR ANDROID OR IOS)
+  return()
+endif()
+
+find_package(VTK 6.0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture NO_MODULE)
+
+if(NOT DEFINED VTK_FOUND OR NOT VTK_FOUND)
+  find_package(VTK 5.10 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE)
+endif()
```

Review comment:
Not wrote, but copypasted from PCL. For some reason they disabled such mode and from my memory due to some issues.
**File:** cmake/OpenCVDetectVTK.cmake
**Change Type:** added
**Context:** PR #1855: Affine3<T>::rvec(), compilation & minor

**Code Changes:**
```diff
@@ -0,0 +1,21 @@
+if(NOT WITH_VTK OR ANDROID OR IOS)
+  return()
+endif()
+
+find_package(VTK 6.0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture NO_MODULE)
+
+if(NOT DEFINED VTK_FOUND OR NOT VTK_FOUND)
+  find_package(VTK 5.10 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE)
+endif()
```

Review comment:
Also I still don't know what is the best way to include different VTKs. Specifying version for find_package works as EXACT. If I don't specify it then I have to cancel components list (it differs for 5.x and 6.x) and search full library, which consumes many seconds for cmake and for linking. Probably I'll remove version specification and will disable Viz if old VTK found.
**File:** cmake/OpenCVDetectVTK.cmake
**Change Type:** added
**Context:** PR #1855: Affine3<T>::rvec(), compilation & minor

**Code Changes:**
```diff
@@ -0,0 +1,21 @@
+if(NOT WITH_VTK OR ANDROID OR IOS)
+  return()
+endif()
+
+find_package(VTK 6.0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture NO_MODULE)
+
+if(NOT DEFINED VTK_FOUND OR NOT VTK_FOUND)
+  find_package(VTK 5.10 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE)
+endif()
```

Review comment:
> Specifying version for find_package works as EXACT You mean, it doesn't allow patch versions other than 0? That's strange, `VTKConfigVersion.cmake` for 5.8 at least looks like it does the right thing. > Probably I'll remove version specification and will disable Viz if old VTK found. Well, if you're going to do that, make sure to include what you've just said as a comment.
**File:** cmake/OpenCVDetectVTK.cmake
**Change Type:** added
**Context:** PR #1855: Affine3<T>::rvec(), compilation & minor

**Code Changes:**
```diff
@@ -0,0 +1,21 @@
+if(NOT WITH_VTK OR ANDROID OR IOS)
+  return()
+endif()
+
+find_package(VTK 6.0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture NO_MODULE)
+
+if(NOT DEFINED VTK_FOUND OR NOT VTK_FOUND)
+  find_package(VTK 5.10 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE)
+endif()
```

Review comment:
I think root cause is in different components lists, not in VTKConfigVersion.cmake
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #1119: LSD (Line Segment Detector) - The pull request includes the LSD class, accuracy tests and a sample program.
**Review Line:** 194

**Code Changes:**
```diff
@@ -191,6 +191,12 @@ enum { HOUGH_STANDARD      = 0,
        HOUGH_GRADIENT      = 3
      };
 
+//! Variants of Line Segment Detector
+enum { LSD_REFINE_NONE = 0,
+       LSD_REFINE_STD  = 1,
+       LSD_REFINE_ADV  = 2
+     };
+
```

Review comment:
please, make the enumeration anonymous (without lsd_refine_lvl). In OpenCV we do not use named enumerations and, besides, it's not compatible with our automatic wrapper generators for Python/Java/... . Also, please, put it inside the class if possible
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #1119: LSD (Line Segment Detector) - The pull request includes the LSD class, accuracy tests and a sample program.

**Code Changes:**
```diff
@@ -191,6 +191,12 @@ enum { HOUGH_STANDARD      = 0,
        HOUGH_GRADIENT      = 3
      };
 
+//! Variants of Line Segment Detector
+enum { LSD_REFINE_NONE = 0,
+       LSD_REFINE_STD  = 1,
+       LSD_REFINE_ADV  = 2
+     };
+
```

Review comment:
1. Please, change name to LineSegmentDetector. LSD is probably not quite good acronym. 2. The whole class needs to refactored according to the Algorithm concept. Please, see http://code.opencv.org/projects/opencv/wiki/Coding_Style_Guide, see "High-level C++ interface. Algorithms" section.
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #1119: LSD (Line Segment Detector) - The pull request includes the LSD class, accuracy tests and a sample program.

**Code Changes:**
```diff
@@ -191,6 +191,12 @@ enum { HOUGH_STANDARD      = 0,
        HOUGH_GRADIENT      = 3
      };
 
+//! Variants of Line Segment Detector
+enum { LSD_REFINE_NONE = 0,
+       LSD_REFINE_STD  = 1,
+       LSD_REFINE_ADV  = 2
+     };
+
```

Review comment:
constructor should be replaced with external "factory" function
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #1119: LSD (Line Segment Detector) - The pull request includes the LSD class, accuracy tests and a sample program.

**Code Changes:**
```diff
@@ -191,6 +191,12 @@ enum { HOUGH_STANDARD      = 0,
        HOUGH_GRADIENT      = 3
      };
 
+//! Variants of Line Segment Detector
+enum { LSD_REFINE_NONE = 0,
+       LSD_REFINE_STD  = 1,
+       LSD_REFINE_ADV  = 2
+     };
+
```

Review comment:
extra cv:: make the code less readable. They are not needed here. Please, remove them
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #1119: LSD (Line Segment Detector) - The pull request includes the LSD class, accuracy tests and a sample program.

**Code Changes:**
```diff
@@ -191,6 +191,12 @@ enum { HOUGH_STANDARD      = 0,
        HOUGH_GRADIENT      = 3
      };
 
+//! Variants of Line Segment Detector
+enum { LSD_REFINE_NONE = 0,
+       LSD_REFINE_STD  = 1,
+       LSD_REFINE_ADV  = 2
+     };
+
```

Review comment:
cv::Mat& should be replaced with InputOutputArray. std::vector&lt;Vec4i&gt;& should be replaced with InputArray
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #1119: LSD (Line Segment Detector) - The pull request includes the LSD class, accuracy tests and a sample program.

**Code Changes:**
```diff
@@ -191,6 +191,12 @@ enum { HOUGH_STANDARD      = 0,
        HOUGH_GRADIENT      = 3
      };
 
+//! Variants of Line Segment Detector
+enum { LSD_REFINE_NONE = 0,
+       LSD_REFINE_STD  = 1,
+       LSD_REFINE_ADV  = 2
+     };
+
```

Review comment:
all this should be moved to the separate implementation class in .cpp