nareshmlx/opencv-pr huggingface dataset:
**File:** modules/contrib/doc/facerec/facerec_api.rst
**Change Type:** modified
**Context:** PR #2705: [face rec] labels info string added

**Code Changes:**
```diff
@@ -46,6 +46,15 @@ a unified access to all face recongition algorithms in OpenCV. ::
 
       // Deserializes this object from a given cv::FileStorage.
       virtual void load(const FileStorage& fs) = 0;
+
+      // Sets additional information as pairs label - info.
+      void setLabelsInfo(const std::map<int, string>& labelsInfo);
+
+      // Gets string information by label
+      string getLabelInfo(const int &label);
```

Review comment:
The function searches for the labels containing the specified substring in the associated string info.
**File:** modules/contrib/src/facerec.cpp
**Change Type:** modified
**Context:** PR #2705: [face rec] labels info string added

**Code Changes:**
```diff
@@ -98,10 +98,84 @@ inline vector<_Tp> remove_dups(const vector<_Tp>& src) {
     return elems;
 }
 
+// The FaceRecognizer2 class is introduced to keep the FaceRecognizer binary backward compatibility in 2.4
+// In master setLabelInfo/getLabelInfo/getLabelsByString should be virtual and _labelsInfo should be moved
+// to FaceRecognizer, that allows to avoid FaceRecognizer2 in master
+class FaceRecognizer2 : public FaceRecognizer
+{
+protected:
```

Review comment:
I'd suggest: ``` // The FaceRecognizerBase class is introduced to keep the FaceRecognizer binary backward compatibility in 2.4 // In master setLabelInfo/getLabelInfo/getLabelsByString should be virtual and _labelsInfo should be moved to FaceRecognizer // that allows to avoid FaceRecognizerBase in master ```
**File:** modules/contrib/doc/facerec/facerec_api.rst
**Change Type:** modified
**Context:** PR #2705: [face rec] labels info string added
**Review Line:** 83

**Code Changes:**
```diff
@@ -70,6 +79,8 @@ Moreover every :ocv:class:`FaceRecognizer` supports the:
 
 * **Loading/Saving** the model state from/to a given XML or YAML.
 
+* **Setting/Getting labels info**, that is storaged as a string. String labels info is useful for keeping names of the recognized people.
+
 .. note:: When using the FaceRecognizer interface in combination with Python, please stick to Python 2. Some underlying scripts like create_csv will not work in other versions, like Python 3.
 
 Setting the Thresholds
@@ -293,6 +304,30 @@ to enable loading the model state. ``FaceRecognizer::load(FileStorage& fs)`` in
 turn gets called by ``FaceRecognizer::load(const string& filename)``, to ease
```

Review comment:
I sugges adding: `String labels info is useful for keeping names of the recognized people.`
**File:** modules/contrib/doc/facerec/facerec_api.rst
**Change Type:** modified
**Context:** PR #2705: [face rec] labels info string added
**Review Line:** 85

**Code Changes:**
```diff
 * **Loading/Saving** the model state from/to a given XML or YAML.
 
+* **Setting/Getting labels info**, that is storaged as a string. String labels info is useful for keeping names of the recognized people.
+
 .. note:: When using the FaceRecognizer interface in combination with Python, please stick to Python 2. Some underlying scripts like create_csv will not work in other versions, like Python 3.
 
 Setting the Thresholds
@@ -293,6 +304,30 @@ to enable loading the model state. ``FaceRecognizer::load(FileStorage& fs)`` in
 turn gets called by ``FaceRecognizer::load(const string& filename)``, to ease
 saving a model.
 
```

Review comment:
**Note**: `FaceRecognizerBase` class is introduced in OpenCV 2.4 to preserve `FaceRecognize` binary backward compatibility. It contains changes that should move to `FaceRecognize` in master/3.0 branch. The current `FaceRecognizerBase` class declaration is: ``` class FaceRecognizerBase : public FaceRecognizer { ... }; ```
**File:** modules/contrib/src/facerec.cpp
**Change Type:** modified
**Context:** PR #2705: [face rec] labels info string added

**Code Changes:**
```diff
@@ -98,10 +98,84 @@ inline vector<_Tp> remove_dups(const vector<_Tp>& src) {
     return elems;
 }
 
+// The FaceRecognizer2 class is introduced to keep the FaceRecognizer binary backward compatibility in 2.4
+// In master setLabelInfo/getLabelInfo/getLabelsByString should be virtual and _labelsInfo should be moved
+// to FaceRecognizer, that allows to avoid FaceRecognizer2 in master
+class FaceRecognizer2 : public FaceRecognizer
+{
+protected:
```

Review comment:
Why is this necessary? This shouldn't require any cast, let alone a dynamic one.
**File:** modules/contrib/src/facerec.cpp
**Change Type:** modified
**Context:** PR #2705: [face rec] labels info string added

**Code Changes:**
```diff
@@ -98,10 +98,84 @@ inline vector<_Tp> remove_dups(const vector<_Tp>& src) {
     return elems;
 }
 
+// The FaceRecognizer2 class is introduced to keep the FaceRecognizer binary backward compatibility in 2.4
+// In master setLabelInfo/getLabelInfo/getLabelsByString should be virtual and _labelsInfo should be moved
+// to FaceRecognizer, that allows to avoid FaceRecognizer2 in master
+class FaceRecognizer2 : public FaceRecognizer
+{
+protected:
```

Review comment:
This is because we're going to make `FaceRecognizer2` class totally internal (a temp workaround for keeping bin compat), user code should continue using `FaceRecognizer` to keep working with 3.0/master API.
**File:** modules/highgui/src/window_w32.cpp
**Change Type:** modified
**Context:** PR #2739: Bug 1523 - Fix suggested by Jukka Holappa who investigated the problem http://code.opencv.org/issues/1523

**Code Changes:**
```diff
@@ -1436,8 +1436,6 @@ static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
         if( window->on_mouse )
         {
             POINT pt;
-            RECT rect;
-            SIZE size = {0,0};
 
             int flags = (wParam & MK_LBUTTON ? CV_EVENT_FLAG_LBUTTON : 0)|
                         (wParam & MK_RBUTTON ? CV_EVENT_FLAG_RBUTTON : 0)|
@@ -1463,12 +1461,23 @@ static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
```

Review comment:
Missing closing closing parenthesis `}`
**File:** modules/highgui/src/window_w32.cpp
**Change Type:** modified
**Context:** PR #2739: Bug 1523 - Fix suggested by Jukka Holappa who investigated the problem http://code.opencv.org/issues/1523

**Code Changes:**
```diff
@@ -1436,8 +1436,6 @@ static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
         if( window->on_mouse )
         {
             POINT pt;
-            RECT rect;
-            SIZE size = {0,0};
 
             int flags = (wParam & MK_LBUTTON ? CV_EVENT_FLAG_LBUTTON : 0)|
                         (wParam & MK_RBUTTON ? CV_EVENT_FLAG_RBUTTON : 0)|
@@ -1463,12 +1461,23 @@ static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
```

Review comment:
Fixing in progress!
**File:** modules/highgui/src/window_w32.cpp
**Change Type:** modified
**Context:** PR #2739: Bug 1523 - Fix suggested by Jukka Holappa who investigated the problem http://code.opencv.org/issues/1523

**Code Changes:**
```diff
@@ -1436,8 +1436,6 @@ static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
         if( window->on_mouse )
         {
             POINT pt;
-            RECT rect;
-            SIZE size = {0,0};
 
             int flags = (wParam & MK_LBUTTON ? CV_EVENT_FLAG_LBUTTON : 0)|
                         (wParam & MK_RBUTTON ? CV_EVENT_FLAG_RBUTTON : 0)|
@@ -1463,12 +1461,23 @@ static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
```

Review comment:
I added a bracket :) It is under your remark.
**File:** modules/highgui/src/window_w32.cpp
**Change Type:** modified
**Context:** PR #2739: Bug 1523 - Fix suggested by Jukka Holappa who investigated the problem http://code.opencv.org/issues/1523
**Review Line:** 1469

**Code Changes:**
```diff
+            if (window->flags & CV_WINDOW_AUTOSIZE)
+            {
+                // As user can't change window size, do not scale window coordinates. Underlying windowing system
+                // may prevent full window from being displayed and in this case coordinates should not be scaled.
+                window->on_mouse( event, pt.x, pt.y, flags, window->on_mouse_param );
+            } else {
+                // Full window is displayed using different size. Scale coordinates to match underlying positions.
+                RECT rect;
+                SIZE size = {0, 0};
+
+                GetClientRect( window->hwnd, &rect );
```

Review comment:
This is the only branch in which the `rect` and `size` variables are used, so move their declarations and everything that touches them here.
**File:** cmake/OpenCVModule.cmake
**Change Type:** modified
**Context:** PR #2446: Implicit CUDA control in CMake.

**Code Changes:**
```diff
@@ -27,7 +27,8 @@
 # The verbose template for OpenCV module:
 #
 #   ocv_add_module(modname <dependencies>)
-#   ocv_glob_module_sources() or glob them manually and ocv_set_module_sources(...)
+#   ocv_glob_module_sources(([EXCLUDE_CUDA] <extra sources&headers>)
+#                          or glob them manually and ocv_set_module_sources(...)
 #   ocv_module_include_directories(<extra include directories>)
 #   ocv_create_module()
 #   <add extra link dependencies, compiler options, etc>
```

Review comment:
1) `EXCLUDE_OPENCL` looks useless (not really used in this patch - do you have another?). 2) Why you didn't use special variables like `OPENCV_MODULE_${the_module}_EXCLUDE_CUDA`? 3) Why you can't track module dependency list and find CUDA dependencies?
**File:** cmake/OpenCVModule.cmake
**Change Type:** modified
**Context:** PR #2446: Implicit CUDA control in CMake.

**Code Changes:**
```diff
@@ -27,7 +27,8 @@
 # The verbose template for OpenCV module:
 #
 #   ocv_add_module(modname <dependencies>)
-#   ocv_glob_module_sources() or glob them manually and ocv_set_module_sources(...)
+#   ocv_glob_module_sources(([EXCLUDE_CUDA] <extra sources&headers>)
+#                          or glob them manually and ocv_set_module_sources(...)
 #   ocv_module_include_directories(<extra include directories>)
 #   ocv_create_module()
 #   <add extra link dependencies, compiler options, etc>
```

Review comment:
1) Yes, it is not used right now. The flag was done for future to control CUDA and OpenCL in the common way; 2) It's good idea. I need to think about it. 3) We need precise CUDA control for Android to enable CUDA not for all modules.
**File:** cmake/OpenCVModule.cmake
**Change Type:** modified
**Context:** PR #2446: Implicit CUDA control in CMake.

**Code Changes:**
```diff
@@ -27,7 +27,8 @@
 # The verbose template for OpenCV module:
 #
 #   ocv_add_module(modname <dependencies>)
-#   ocv_glob_module_sources() or glob them manually and ocv_set_module_sources(...)
+#   ocv_glob_module_sources(([EXCLUDE_CUDA] <extra sources&headers>)
+#                          or glob them manually and ocv_set_module_sources(...)
 #   ocv_module_include_directories(<extra include directories>)
 #   ocv_create_module()
 #   <add extra link dependencies, compiler options, etc>
```

Review comment:
> 1) Yes, it is not used right now. The flag was done for future to control CUDA and OpenCL in the common way; It seems to me that you shouldn't add it until you actually need it. You know, YAGNI and stuff. > It's good idea. I need to think about it. Well... did you? :smiley: You changed the usage of the command, but didn't update the usage string. In addition, I'd prefer if the interface was different. As you have it now, the function must be called like this: ``` ocv_glob_module_sources(YES NO) ``` Which is both unclear and backwards incompatible. I'd rather have it called like this: ``` ocv_glob_module_sources(EXCLUDE_CUDA) ```
**File:** cmake/OpenCVModule.cmake
**Change Type:** modified
**Context:** PR #2446: Implicit CUDA control in CMake.

**Code Changes:**
```diff
@@ -27,7 +27,8 @@
 # The verbose template for OpenCV module:
 #
 #   ocv_add_module(modname <dependencies>)
-#   ocv_glob_module_sources() or glob them manually and ocv_set_module_sources(...)
+#   ocv_glob_module_sources(([EXCLUDE_CUDA] <extra sources&headers>)
+#                          or glob them manually and ocv_set_module_sources(...)
 #   ocv_module_include_directories(<extra include directories>)
 #   ocv_create_module()
 #   <add extra link dependencies, compiler options, etc>
```

Review comment:
Wouldn't `list(FIND)` be easier?
**File:** cmake/OpenCVModule.cmake
**Change Type:** modified
**Context:** PR #2446: Implicit CUDA control in CMake.

**Code Changes:**
```diff
@@ -27,7 +27,8 @@
 # The verbose template for OpenCV module:
 #
 #   ocv_add_module(modname <dependencies>)
-#   ocv_glob_module_sources() or glob them manually and ocv_set_module_sources(...)
+#   ocv_glob_module_sources(([EXCLUDE_CUDA] <extra sources&headers>)
+#                          or glob them manually and ocv_set_module_sources(...)
 #   ocv_module_include_directories(<extra include directories>)
 #   ocv_create_module()
 #   <add extra link dependencies, compiler options, etc>
```

Review comment:
Drop the `${}`.
**File:** cmake/OpenCVModule.cmake
**Change Type:** modified
**Context:** PR #2446: Implicit CUDA control in CMake.

**Code Changes:**
```diff
@@ -27,7 +27,8 @@
 # The verbose template for OpenCV module:
 #
 #   ocv_add_module(modname <dependencies>)
-#   ocv_glob_module_sources() or glob them manually and ocv_set_module_sources(...)
+#   ocv_glob_module_sources(([EXCLUDE_CUDA] <extra sources&headers>)
+#                          or glob them manually and ocv_set_module_sources(...)
 #   ocv_module_include_directories(<extra include directories>)
 #   ocv_create_module()
 #   <add extra link dependencies, compiler options, etc>
```

Review comment:
Usage not adjusted.
**File:** modules/ocl/perf/perf_hough.cpp
**Change Type:** added
**Context:** PR #267: added HoughCircles in ocl module - Demo video clip and formal documentation are available at: http://seunghoon-cis565.blogspot.com/2012/12/fi...

**Code Changes:**
```diff
@@ -0,0 +1,98 @@
+/*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:
In OpenCV we do not put our emails to the code. Actually you shouldn't modify standard header at all. All information about your commitment will remain in git commits' info. So, I would ask you to remove information about your names from _all_ file headers.
**File:** modules/ocl/perf/perf_hough.cpp
**Change Type:** added
**Context:** PR #267: added HoughCircles in ocl module - Demo video clip and formal documentation are available at: http://seunghoon-cis565.blogspot.com/2012/12/fi...

**Code Changes:**
```diff
@@ -0,0 +1,98 @@
+/*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:
This perf test is not properly designed and implemented. You shouldn't use `cvGetTickCount` at all, you should use constructs like `TEST_CYCLE()`, and you _must_ use `PERF_TEST_P` instead of `INSTANTIATE_TEST_CASE_P`. The reason is that your test can't be analyzed with OpenCV scripts. To find more about all of this, you should read http://opencv.willowgarage.com/wiki/ValueParameterizedPerfTests (this page describes how you should design your perf test) and http://opencv.willowgarage.com/wiki/AnalyzePerfTestsLogs (this page describes how you should analyze performance). For examples you can study these files: - http://code.opencv.org/projects/opencv/repository/revisions/2.4/entry/modules/imgproc/perf/perf_houghLines.cpp - http://code.opencv.org/projects/opencv/repository/revisions/master/entry/modules/gpu/perf/perf_imgproc.cpp
**File:** modules/python/src2/gen2.py
**Change Type:** modified
**Context:** PR #2724: Work on python wrapper generation automation - - all parsed headers are included into "cv2.cpp" with "pyopencv_generated_include.h" - types ...

**Code Changes:**
```diff
@@ -351,9 +351,15 @@ def __init__(self, name, val):
         self.name = self.name.upper()
         self.value = val
 
+def handle_ptr(tp):
+    if tp.startswith('Ptr_'):
+        tp = 'Ptr<' + "::".join(tp.split('_')[1:]) + '>'
+    return tp
+
+
```

Review comment:
Is this going to work on Windows? Also, I'd use `rindex` instead of `find` here - `r` because the OpenCV source might itself be inside a directory named `opencv2`, and `index` so that we don't try to read `hdr[-1:]` in case of failure.
**File:** modules/imgproc/src/thresh.cpp
**Change Type:** modified
**Context:** PR #2584: Added ippiThreshold to cv::threshold - check_regression=_Threshold_:_ThreshType_threshold_
**Review Line:** 77

**Code Changes:**
```diff
+    IppiSize sz = { roi.width, roi.height };
+    switch( type )
+    {
+    case THRESH_TRUNC:
+        if (0 <= ippiThreshold_GT_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh))
+            return;
+        break;
+    case THRESH_TOZERO:
+        if (0 <= ippiThreshold_LTVal_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh+1, 0))
+            return;
+        break;
```

Review comment:
you've lost `break;` anywhere
**File:** modules/imgproc/src/thresh.cpp
**Change Type:** modified
**Context:** PR #2584: Added ippiThreshold to cv::threshold - check_regression=_Threshold_:_ThreshType_threshold_
**Review Line:** 77

**Code Changes:**
```diff
+    IppiSize sz = { roi.width, roi.height };
+    switch( type )
+    {
+    case THRESH_TRUNC:
+        if (0 <= ippiThreshold_GT_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh))
+            return;
+        break;
+    case THRESH_TOZERO:
+        if (0 <= ippiThreshold_LTVal_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh+1, 0))
+            return;
+        break;
```

Review comment:
Shame on me. Fixed.
**File:** modules/contrib/doc/facerec/src/crop_face.py
**Change Type:** modified
**Context:** PR #2578: Update crop_face.py - I propose some changes, to automate file cropping
**Review Line:** 89

**Code Changes:**
```diff
+def readFileNames():
+    try:
+        inFile = open('path_to_created_csv_file.csv')
+    except:
+        raise IOError('There is no file named path_to_created_csv_file.csv in current directory.')
+        return False
+
+    picPath = []
+    picIndex = []
+
+    for line in inFile.readlines():
```

Review comment:
The `return` can never happen; the exception you raise is the same that would be risen anyway, except that you assume every error is a file-not-found error, which may not be the case; you never close the file; and you should use the standard `csv` module.
**File:** modules/imgproc/src/opencl/cvtcolor.cl
**Change Type:** modified
**Context:** PR #2593: Optimizations for OpenCL color conversion. - Optimizes OpenCL color conversion. Specifically: - Favors vload over pointer dereferences - Doe...
**Review Line:** 195

**Code Changes:**
```diff
     {
-        __global const DATA_TYPE* src = (__global const DATA_TYPE*)(srcptr + mad24(y, srcstep, srcoffset + x * scnbytes));
-        __global DATA_TYPE* dst = (__global DATA_TYPE*)(dstptr + mad24(y, dststep, dstoffset + x * dcnbytes));
-        DATA_TYPE b=src[bidx], g=src[1], r=src[bidx^2];
+        #pragma unroll
+        for (int cy = 0; cy < PIX_PER_WI_Y; ++cy)
+        {
+            if (y < rows)
+            {
+                __global const DATA_TYPE* src = (__global const DATA_TYPE*)(srcptr + mad24(y, srcstep, srcoffset + x * scnbytes));
+                __global DATA_TYPE* dst = (__global DATA_TYPE*)(dstptr + mad24(y, dststep, dstoffset + x * dcnbytes));
```

Review comment:
don't you think these cycles should be unrolled?
**File:** modules/imgproc/src/color.cpp
**Change Type:** modified
**Context:** PR #2593: Optimizations for OpenCL color conversion. - Optimizes OpenCL color conversion. Specifically: - Favors vload over pointer dereferences - Doe...

**Code Changes:**
```diff
@@ -2690,6 +2690,8 @@ struct mRGBA2RGBA
 
 #ifdef HAVE_OPENCL
 
+#define DIVUP(total, grain) (((total) + (grain) - 1) / (grain))
+
 static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
 {
     bool ok = false;
@@ -2703,6 +2705,17 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
```

Review comment:
who says that `src.rows` is multiple of `4`?
**File:** modules/imgproc/src/opencl/cvtcolor.cl
**Change Type:** modified
**Context:** PR #2593: Optimizations for OpenCL color conversion. - Optimizes OpenCL color conversion. Specifically: - Favors vload over pointer dereferences - Doe...
**Review Line:** 195

**Code Changes:**
```diff
     {
-        __global const DATA_TYPE* src = (__global const DATA_TYPE*)(srcptr + mad24(y, srcstep, srcoffset + x * scnbytes));
-        __global DATA_TYPE* dst = (__global DATA_TYPE*)(dstptr + mad24(y, dststep, dstoffset + x * dcnbytes));
-        DATA_TYPE b=src[bidx], g=src[1], r=src[bidx^2];
+        #pragma unroll
+        for (int cy = 0; cy < PIX_PER_WI_Y; ++cy)
+        {
+            if (y < rows)
+            {
+                __global const DATA_TYPE* src = (__global const DATA_TYPE*)(srcptr + mad24(y, srcstep, srcoffset + x * scnbytes));
+                __global DATA_TYPE* dst = (__global DATA_TYPE*)(dstptr + mad24(y, dststep, dstoffset + x * dcnbytes));
```

Review comment:
The Intel compiler seems to be doing the unrolling automatically. Do other compilers rely more on the #pragma unroll hint? If so, I'd be happy to add that.
**File:** modules/imgproc/src/opencl/cvtcolor.cl
**Change Type:** modified
**Context:** PR #2593: Optimizations for OpenCL color conversion. - Optimizes OpenCL color conversion. Specifically: - Favors vload over pointer dereferences - Doe...
**Review Line:** 195

**Code Changes:**
```diff
     {
-        __global const DATA_TYPE* src = (__global const DATA_TYPE*)(srcptr + mad24(y, srcstep, srcoffset + x * scnbytes));
-        __global DATA_TYPE* dst = (__global DATA_TYPE*)(dstptr + mad24(y, dststep, dstoffset + x * dcnbytes));
-        DATA_TYPE b=src[bidx], g=src[1], r=src[bidx^2];
+        #pragma unroll
+        for (int cy = 0; cy < PIX_PER_WI_Y; ++cy)
+        {
+            if (y < rows)
+            {
+                __global const DATA_TYPE* src = (__global const DATA_TYPE*)(srcptr + mad24(y, srcstep, srcoffset + x * scnbytes));
+                __global DATA_TYPE* dst = (__global DATA_TYPE*)(dstptr + mad24(y, dststep, dstoffset + x * dcnbytes));
```

Review comment:
yes, it would be great
**File:** modules/imgproc/src/color.cpp
**Change Type:** modified
**Context:** PR #2593: Optimizations for OpenCL color conversion. - Optimizes OpenCL color conversion. Specifically: - Favors vload over pointer dereferences - Doe...

**Code Changes:**
```diff
@@ -2690,6 +2690,8 @@ struct mRGBA2RGBA
 
 #ifdef HAVE_OPENCL
 
+#define DIVUP(total, grain) (((total) + (grain) - 1) / (grain))
+
 static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
 {
     bool ok = false;
@@ -2703,6 +2705,17 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
```

Review comment:
The kernels are written to check against src.rows in each loop iteration. So this code should work even if the number of rows is not evenly divisible by 4.