nareshmlx/opencv-pr huggingface dataset:
**File:** modules/calib3d/test/test_fisheye.cpp
**Change Type:** added
**Context:** PR #2726: Fisheye camera model for calibration and stereo rectification. - Added Fisheye camera model for calibration and stereo rectification. TestDa...
**Review Line:** 43

**Code Changes:**
```diff
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "test_precomp.hpp"
+#include <opencv2/ts/gpu_test.hpp>
+#include "../src/fisheye.hpp"
+
+class fisheyeTest : public ::testing::Test {
+
```

Review comment:
please, put the license here too
**File:** modules/objdetect/test/test_qrcode.cpp
**Change Type:** modified
**Context:** PR #16961: QRDetectMulti : different return value bug fix
**Review Line:** 517

**Code Changes:**
```diff
+    QRCodeDetector qrcode;
+    std::vector<Point> corners;
+    EXPECT_TRUE(qrcode.detectMulti(src, corners));
+    ASSERT_FALSE(corners.empty());
+    size_t expect_corners_size = 36;
+    EXPECT_EQ(corners.size(), expect_corners_size);
+}
+
 TEST(Objdetect_QRCode_basic, not_found_qrcode)
 {
     std::vector<Point> corners;
```

Review comment:
GoogleTests's `_EQ` args order is `(expected, actual)`.
**File:** modules/gapi/include/opencv2/gapi/video.hpp
**Change Type:** modified
**Context:** PR #17082: G-API: gapi::buildOpticalFlowPyramid() Implementation
**Review Line:** 27

**Code Changes:**
```diff
+
+using GOptFlowLKOutput = std::tuple<cv::GArray<cv::Point2f>,
+                                    cv::GArray<uchar>,
+                                    cv::GArray<float>>;
+
+G_TYPED_KERNEL(GBuildOptFlowPyramid, <GBuildPyrOutput(GMat,Size,GScalar,bool,int,int,bool)>,
+               "org.opencv.video.buildOpticalFlowPyramid")
+{
+    static std::tuple<GArrayDesc,GScalarDesc>
+            outMeta(GMatDesc,const Size&,GScalarDesc,bool,int,int,bool)
+    {
```

Review comment:
That's true, and `GOpaque` looks a better alternative (since it is typed). However, `GOpaque` doesn't support value-initialization while the `GScalar` does. It may be more useful sometimes. Let's continue this way and port to `GOpaque` later, after we introduce value initialization for it.
**File:** samples/python/qrcode.py
**Change Type:** added
**Context:** PR #16795: Added a sample file for qrcode detection in python

**Code Changes:**
```diff
@@ -0,0 +1,248 @@
+#!/usr/bin/env python
+
+'''
+This program detects the QR-codes using OpenCV Library.
+
+Usage:
+   qrcode.py
+'''
+
```

Review comment:
- please avoid using "tabs" - please use 4 spaces for indentation
**File:** samples/python/qrcode.py
**Change Type:** added
**Context:** PR #16795: Added a sample file for qrcode detection in python

**Code Changes:**
```diff
@@ -0,0 +1,248 @@
+#!/usr/bin/env python
+
+'''
+This program detects the QR-codes using OpenCV Library.
+
+Usage:
+   qrcode.py
+'''
+
```

Review comment:
> getopt Please use `argparse` instead (less code and more informative help and error messages). Refer to existed OpenCV samples code.
**File:** samples/python/qrcode.py
**Change Type:** added
**Context:** PR #16795: Added a sample file for qrcode detection in python

**Code Changes:**
```diff
@@ -0,0 +1,248 @@
+#!/usr/bin/env python
+
+'''
+This program detects the QR-codes using OpenCV Library.
+
+Usage:
+   qrcode.py
+'''
+
```

Review comment:
Lets avoid booleans in strings, especially in "processing" code.
**File:** samples/python/qrcode.py
**Change Type:** added
**Context:** PR #16795: Added a sample file for qrcode detection in python

**Code Changes:**
```diff
@@ -0,0 +1,248 @@
+#!/usr/bin/env python
+
+'''
+This program detects the QR-codes using OpenCV Library.
+
+Usage:
+   qrcode.py
+'''
+
```

Review comment:
"global" code is not allowed in OpenCV Python samples (see "demo.py", it loads these files as modules). Move such code into the `main()` function.
**File:** samples/python/qrcode.py
**Change Type:** added
**Context:** PR #16795: Added a sample file for qrcode detection in python

**Code Changes:**
```diff
@@ -0,0 +1,248 @@
+#!/usr/bin/env python
+
+'''
+This program detects the QR-codes using OpenCV Library.
+
+Usage:
+   qrcode.py
+'''
+
```

Review comment:
Use `action='store_true'` in `.add_argument()` instead. Refer to other code in OpenCV repository.
**File:** samples/python/qrcode.py
**Change Type:** added
**Context:** PR #16795: Added a sample file for qrcode detection in python

**Code Changes:**
```diff
@@ -0,0 +1,248 @@
+#!/usr/bin/env python
+
+'''
+This program detects the QR-codes using OpenCV Library.
+
+Usage:
+   qrcode.py
+'''
+
```

Review comment:
`if` in Python doesn't require brackets
**File:** samples/python/qrcode.py
**Change Type:** added
**Context:** PR #16795: Added a sample file for qrcode detection in python

**Code Changes:**
```diff
@@ -0,0 +1,248 @@
+#!/usr/bin/env python
+
+'''
+This program detects the QR-codes using OpenCV Library.
+
+Usage:
+   qrcode.py
+'''
+
```

Review comment:
Please use "Pythonic" code. See "string format" examples: https://docs.python.org/2.7/library/string.html#format-examples (you may replace `.format` with ` % ` too - see `drawFPS()` above).
**File:** samples/python/qrcode.py
**Change Type:** added
**Context:** PR #16795: Added a sample file for qrcode detection in python

**Code Changes:**
```diff
@@ -0,0 +1,248 @@
+#!/usr/bin/env python
+
+'''
+This program detects the QR-codes using OpenCV Library.
+
+Usage:
+   qrcode.py
+'''
+
```

Review comment:
> Move such code into the main() function Not resolved.
**File:** samples/python/qrcode.py
**Change Type:** added
**Context:** PR #16795: Added a sample file for qrcode detection in python
**Review Line:** 214

**Code Changes:**
```diff
+        '--detect',
+        help="detect QR code only (skip decoding) (default: False)",
+        action='store_true')
+    parser.add_argument(
+        '-m',
+        '--multi',
+        help="enable multiple qr-codes detection",
+        action='store_true')
+    parser.add_argument(
+        '-o',
+        '--out',
```

Review comment:
I propose to run detectMulti by default and inverse the option like for detection case. The QR code images in OpenCV extra contains several QR codes per image and the sample started with default options produces garbage.
**File:** samples/python/qrcode.py
**Change Type:** added
**Context:** PR #16795: Added a sample file for qrcode detection in python
**Review Line:** 209

**Code Changes:**
```diff
+        help="input image path (for example, 'opencv_extra/testdata/cv/qrcode/multiple/*_qrcodes.png)",
+        default="",
+        metavar="")
+    parser.add_argument(
+        '-d',
+        '--detect',
+        help="detect QR code only (skip decoding) (default: False)",
+        action='store_true')
+    parser.add_argument(
+        '-m',
+        '--multi',
```

Review comment:
Sample executed with default options and just -d shows garbage as detection. ![qr_garbadge](https://user-images.githubusercontent.com/2536374/78868168-17e15280-7a4b-11ea-8314-3aa5dd16d894.png)
**File:** samples/python/qrcode.py
**Change Type:** added
**Context:** PR #16795: Added a sample file for qrcode detection in python
**Review Line:** 209

**Code Changes:**
```diff
+        help="input image path (for example, 'opencv_extra/testdata/cv/qrcode/multiple/*_qrcodes.png)",
+        default="",
+        metavar="")
+    parser.add_argument(
+        '-d',
+        '--detect',
+        help="detect QR code only (skip decoding) (default: False)",
+        action='store_true')
+    parser.add_argument(
+        '-m',
+        '--multi',
```

Review comment:
I have enabled the multiple detection by default and used the -m tag to disable the multiple detection so that single qrcodes can be detected and decoded. Now running on the opencv_extra dataset with default parameters doesn't give garbage values. Please let me know if some other changes are to be made in this.
**File:** modules/imgproc/src/drawing.cpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -156,96 +156,107 @@ bool clipLine( Rect img_rect, Point& pt1, Point& pt2 )
     return inside;
 }
 
-/*
-   Initializes line iterator.
-   Returns number of points on the line or negative number if error.
-*/
-LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
-                           int connectivity, bool left_to_right)
```

Review comment:
This causes "div by zero" error in ".pos()": `(offset/step)`
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -4714,10 +4714,39 @@ class CV_EXPORTS LineIterator
     the line is 8-connected or 4-connected
     If leftToRight=true, then the iteration is always done
     from the left-most point to the right most,
-    not to depend on the ordering of pt1 and pt2 parameters
+    not to depend on the ordering of pt1 and pt2 parameters;
     */
     LineIterator( const Mat& img, Point pt1, Point pt2,
-                  int connectivity = 8, bool leftToRight = false );
+                  int connectivity = 8, bool leftToRight = false )
```

Review comment:
I believe "offset"/"step" is over complication here. `Point` result is enough, especially in case of ROI (with step != width).
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -4714,10 +4714,39 @@ class CV_EXPORTS LineIterator
     the line is 8-connected or 4-connected
     If leftToRight=true, then the iteration is always done
     from the left-most point to the right most,
-    not to depend on the ordering of pt1 and pt2 parameters
+    not to depend on the ordering of pt1 and pt2 parameters;
     */
     LineIterator( const Mat& img, Point pt1, Point pt2,
-                  int connectivity = 8, bool leftToRight = false );
+                  int connectivity = 8, bool leftToRight = false )
```

Review comment:
> leftToRight I believe direction should be specified by `pt1`/`pt2` instead of additional parameter. Especially, in case `leftToRight = false` doesn't mean "right-to-left". --- Upd: `forceLeftToRight` naming makes more sense.
**File:** modules/imgproc/src/drawing.cpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -156,96 +156,107 @@ bool clipLine( Rect img_rect, Point& pt1, Point& pt2 )
     return inside;
 }
 
-/*
-   Initializes line iterator.
-   Returns number of points on the line or negative number if error.
-*/
-LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
-                           int connectivity, bool left_to_right)
```

Review comment:
"C" asserts must be avoided.
**File:** modules/imgproc/src/drawing.cpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -156,96 +156,107 @@ bool clipLine( Rect img_rect, Point& pt1, Point& pt2 )
     return inside;
 }
 
-/*
-   Initializes line iterator.
-   Returns number of points on the line or negative number if error.
-*/
-LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
-                           int connectivity, bool left_to_right)
```

Review comment:
> "undefined behavior" Lets try to avoid that. Compilers are smart enough (or at least this is not required in non "heavy" constructor calls).
**File:** modules/imgproc/src/drawing.cpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -156,96 +156,107 @@ bool clipLine( Rect img_rect, Point& pt1, Point& pt2 )
     return inside;
 }
 
-/*
-   Initializes line iterator.
-   Returns number of points on the line or negative number if error.
-*/
-LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
-                           int connectivity, bool left_to_right)
```

Review comment:
Not sure to understand this one. This is the LineIterator implementation; is there a problem here ?
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -4714,10 +4714,39 @@ class CV_EXPORTS LineIterator
     the line is 8-connected or 4-connected
     If leftToRight=true, then the iteration is always done
     from the left-most point to the right most,
-    not to depend on the ordering of pt1 and pt2 parameters
+    not to depend on the ordering of pt1 and pt2 parameters;
     */
     LineIterator( const Mat& img, Point pt1, Point pt2,
-                  int connectivity = 8, bool leftToRight = false );
+                  int connectivity = 8, bool leftToRight = false )
```

Review comment:
Documentary string should be updated too (`forceLeftToRight`).
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -4714,10 +4714,39 @@ class CV_EXPORTS LineIterator
     the line is 8-connected or 4-connected
     If leftToRight=true, then the iteration is always done
     from the left-most point to the right most,
-    not to depend on the ordering of pt1 and pt2 parameters
+    not to depend on the ordering of pt1 and pt2 parameters;
     */
     LineIterator( const Mat& img, Point pt1, Point pt2,
-                  int connectivity = 8, bool leftToRight = false );
+                  int connectivity = 8, bool leftToRight = false )
```

Review comment:
`forceLeftToRight`
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -4714,10 +4714,39 @@ class CV_EXPORTS LineIterator
     the line is 8-connected or 4-connected
     If leftToRight=true, then the iteration is always done
     from the left-most point to the right most,
-    not to depend on the ordering of pt1 and pt2 parameters
+    not to depend on the ordering of pt1 and pt2 parameters;
     */
     LineIterator( const Mat& img, Point pt1, Point pt2,
-                  int connectivity = 8, bool leftToRight = false );
+                  int connectivity = 8, bool leftToRight = false )
```

Review comment:
Constructors implementation should go to .cpp file, as it is done for `LineIterator` and `LineVirtualIterator` constructor from 2 points
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -4714,10 +4714,39 @@ class CV_EXPORTS LineIterator
     the line is 8-connected or 4-connected
     If leftToRight=true, then the iteration is always done
     from the left-most point to the right most,
-    not to depend on the ordering of pt1 and pt2 parameters
+    not to depend on the ordering of pt1 and pt2 parameters;
     */
     LineIterator( const Mat& img, Point pt1, Point pt2,
-                  int connectivity = 8, bool leftToRight = false );
+                  int connectivity = 8, bool leftToRight = false )
```

Review comment:
Use initializer list to prevent unnecessary copy.
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -4714,10 +4714,39 @@ class CV_EXPORTS LineIterator
     the line is 8-connected or 4-connected
     If leftToRight=true, then the iteration is always done
     from the left-most point to the right most,
-    not to depend on the ordering of pt1 and pt2 parameters
+    not to depend on the ordering of pt1 and pt2 parameters;
     */
     LineIterator( const Mat& img, Point pt1, Point pt2,
-                  int connectivity = 8, bool leftToRight = false );
+                  int connectivity = 8, bool leftToRight = false )
```

Review comment:
What is the purpose of public `init` method? All initialization stuff can be done by constructors chaining. Your main constructor is `LineVirtualIterator(const Size&, const Point&, const Point&, int, bool)` ```c++ struct A { A(int arg1, int arg2, int arg3) { std::cout << "Initialized with " << arg1 << ' ' << arg2 << ' ' << arg3 << '\n'; } A(int arg1, int arg2) : A(arg1, arg2, 123) {} explicit A(int arg1) : A(arg1, 4) {} }; ``` Also note, that sometimes it is reasonable to use a ["named" constructor idiom](https://isocpp.org/wiki/faq/ctors#named-ctor-idiom) to make user understanding clear, what object is going to be created. (RVO eliminates copy and move constructor calls)
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -4714,10 +4714,39 @@ class CV_EXPORTS LineIterator
     the line is 8-connected or 4-connected
     If leftToRight=true, then the iteration is always done
     from the left-most point to the right most,
-    not to depend on the ordering of pt1 and pt2 parameters
+    not to depend on the ordering of pt1 and pt2 parameters;
     */
     LineIterator( const Mat& img, Point pt1, Point pt2,
-                  int connectivity = 8, bool leftToRight = false );
+                  int connectivity = 8, bool leftToRight = false )
```

Review comment:
`const`
**File:** modules/imgproc/src/drawing.cpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -156,96 +156,107 @@ bool clipLine( Rect img_rect, Point& pt1, Point& pt2 )
     return inside;
 }
 
-/*
-   Initializes line iterator.
-   Returns number of points on the line or negative number if error.
-*/
-LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
-                           int connectivity, bool left_to_right)
```

Review comment:
Use `initializer_list` to initialize member
**File:** modules/imgproc/test/test_drawing.cpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -54,6 +54,7 @@ class CV_DrawingTest : public cvtest::BaseTest
     void run( int );
     virtual void draw( Mat& img ) = 0;
     virtual int checkLineIterator( Mat& img) = 0;
+    virtual int checkLineVirtualIterator() = 0;
 };
 
 void CV_DrawingTest::run( int )
@@ -93,6 +94,7 @@ void CV_DrawingTest::run( int )
             ts->set_failed_test_info(checkLineIterator( testImg ));
```

Review comment:
Can be removed
**File:** modules/imgproc/test/test_drawing.cpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -54,6 +54,7 @@ class CV_DrawingTest : public cvtest::BaseTest
     void run( int );
     virtual void draw( Mat& img ) = 0;
     virtual int checkLineIterator( Mat& img) = 0;
+    virtual int checkLineVirtualIterator() = 0;
 };
 
 void CV_DrawingTest::run( int )
@@ -93,6 +94,7 @@ void CV_DrawingTest::run( int )
             ts->set_failed_test_info(checkLineIterator( testImg ));
```

Review comment:
This checks only the case when `currentPosOffset` is (0, 0), so can be reduced to constructor with the `Size` as the first argument. Consider to add case for non-zero offset too.
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -4714,10 +4714,39 @@ class CV_EXPORTS LineIterator
     the line is 8-connected or 4-connected
     If leftToRight=true, then the iteration is always done
     from the left-most point to the right most,
-    not to depend on the ordering of pt1 and pt2 parameters
+    not to depend on the ordering of pt1 and pt2 parameters;
     */
     LineIterator( const Mat& img, Point pt1, Point pt2,
-                  int connectivity = 8, bool leftToRight = false );
+                  int connectivity = 8, bool leftToRight = false )
```

Review comment:
As an alternative you can give better names to parameters instead of `aSize`/`aRect`
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -4714,10 +4714,39 @@ class CV_EXPORTS LineIterator
     the line is 8-connected or 4-connected
     If leftToRight=true, then the iteration is always done
     from the left-most point to the right most,
-    not to depend on the ordering of pt1 and pt2 parameters
+    not to depend on the ordering of pt1 and pt2 parameters;
     */
     LineIterator( const Mat& img, Point pt1, Point pt2,
-                  int connectivity = 8, bool leftToRight = false );
+                  int connectivity = 8, bool leftToRight = false )
```

Review comment:
basically, I mean that these 2 lines (`currentPos.y=...; currentPos.x=...;`) should be removed; instead, you should update currentPos directly using the Bresenham algorithm
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -4714,10 +4714,39 @@ class CV_EXPORTS LineIterator
     the line is 8-connected or 4-connected
     If leftToRight=true, then the iteration is always done
     from the left-most point to the right most,
-    not to depend on the ordering of pt1 and pt2 parameters
+    not to depend on the ordering of pt1 and pt2 parameters;
     */
     LineIterator( const Mat& img, Point pt1, Point pt2,
-                  int connectivity = 8, bool leftToRight = false );
+                  int connectivity = 8, bool leftToRight = false )
```

Review comment:
The current implementation is rather far from standard Bresenham's algorithm descriptions, so it is not that straightfoward to rewrite differently all the cases in both 4 and 8 connectivity.