The following issues were found

samples/python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py
8 issues
Unable to import 'cv2'
Error

Line: 1 Column: 1

              import cv2 as cv
import numpy as np

W = 400
## [my_ellipse]
def my_ellipse(img, angle):
    thickness = 2
    line_type = 8


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import cv2 as cv
import numpy as np

W = 400
## [my_ellipse]
def my_ellipse(img, angle):
    thickness = 2
    line_type = 8


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 6 Column: 1

              
W = 400
## [my_ellipse]
def my_ellipse(img, angle):
    thickness = 2
    line_type = 8

    cv.ellipse(img,
                (W // 2, W // 2),

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 1

                              line_type)
## [my_ellipse]
## [my_filled_circle]
def my_filled_circle(img, center):
    thickness = -1
    line_type = 8

    cv.circle(img,
               center,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 33 Column: 1

                             line_type)
## [my_filled_circle]
## [my_polygon]
def my_polygon(img):
    line_type = 8

    # Create some points
    ppt = np.array([[W / 4, 7 * W / 8], [3 * W / 4, 7 * W / 8],
                    [3 * W / 4, 13 * W / 16], [11 * W / 16, 13 * W / 16],

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 53 Column: 1

                  # cv.polylines(img, [ppt], True, (255, 0, 255), line_type)
## [my_polygon]
## [my_line]
def my_line(img, start, end):
    thickness = 2
    line_type = 8

    cv.line(img,
             start,

            

Reported by Pylint.

Constant name "atom_window" doesn't conform to UPPER_CASE naming style
Error

Line: 66 Column: 1

              ## [my_line]
## [create_images]
# Windows names
atom_window = "Drawing 1: Atom"
rook_window = "Drawing 2: Rook"

# Create black empty images
size = W, W, 3
atom_image = np.zeros(size, dtype=np.uint8)

            

Reported by Pylint.

Constant name "rook_window" doesn't conform to UPPER_CASE naming style
Error

Line: 67 Column: 1

              ## [create_images]
# Windows names
atom_window = "Drawing 1: Atom"
rook_window = "Drawing 2: Rook"

# Create black empty images
size = W, W, 3
atom_image = np.zeros(size, dtype=np.uint8)
rook_image = np.zeros(size, dtype=np.uint8)

            

Reported by Pylint.

samples/python/tutorial_code/Histograms_Matching/histogram_comparison/compareHist_Demo.py
8 issues
Unable to import 'cv2'
Error

Line: 3 Column: 1

              from __future__ import print_function
from __future__ import division
import cv2 as cv
import numpy as np
import argparse

## [Load three images with different environment settings]
parser = argparse.ArgumentParser(description='Code for Histogram Comparison tutorial.')
parser.add_argument('--input1', help='Path to input image 1.')

            

Reported by Pylint.

Unused numpy imported as np
Error

Line: 4 Column: 1

              from __future__ import print_function
from __future__ import division
import cv2 as cv
import numpy as np
import argparse

## [Load three images with different environment settings]
parser = argparse.ArgumentParser(description='Code for Histogram Comparison tutorial.')
parser.add_argument('--input1', help='Path to input image 1.')

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import print_function
from __future__ import division
import cv2 as cv
import numpy as np
import argparse

## [Load three images with different environment settings]
parser = argparse.ArgumentParser(description='Code for Histogram Comparison tutorial.')
parser.add_argument('--input1', help='Path to input image 1.')

            

Reported by Pylint.

Module name "compareHist_Demo" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              from __future__ import print_function
from __future__ import division
import cv2 as cv
import numpy as np
import argparse

## [Load three images with different environment settings]
parser = argparse.ArgumentParser(description='Code for Histogram Comparison tutorial.')
parser.add_argument('--input1', help='Path to input image 1.')

            

Reported by Pylint.

standard import "import argparse" should be placed before "import cv2 as cv"
Error

Line: 5 Column: 1

              from __future__ import division
import cv2 as cv
import numpy as np
import argparse

## [Load three images with different environment settings]
parser = argparse.ArgumentParser(description='Code for Histogram Comparison tutorial.')
parser.add_argument('--input1', help='Path to input image 1.')
parser.add_argument('--input2', help='Path to input image 2.')

            

Reported by Pylint.

Consider using sys.exit()
Error

Line: 19 Column: 5

              src_test2 = cv.imread(args.input3)
if src_base is None or src_test1 is None or src_test2 is None:
    print('Could not open or find the images!')
    exit(0)
## [Load three images with different environment settings]

## [Convert to HSV]
hsv_base = cv.cvtColor(src_base, cv.COLOR_BGR2HSV)
hsv_test1 = cv.cvtColor(src_test1, cv.COLOR_BGR2HSV)

            

Reported by Pylint.

Constant name "h_bins" doesn't conform to UPPER_CASE naming style
Error

Line: 33 Column: 1

              ## [Convert to HSV half]

## [Using 50 bins for hue and 60 for saturation]
h_bins = 50
s_bins = 60
histSize = [h_bins, s_bins]

# hue varies from 0 to 179, saturation from 0 to 255
h_ranges = [0, 180]

            

Reported by Pylint.

Constant name "s_bins" doesn't conform to UPPER_CASE naming style
Error

Line: 34 Column: 1

              
## [Using 50 bins for hue and 60 for saturation]
h_bins = 50
s_bins = 60
histSize = [h_bins, s_bins]

# hue varies from 0 to 179, saturation from 0 to 255
h_ranges = [0, 180]
s_ranges = [0, 256]

            

Reported by Pylint.

modules/video/misc/java/test/KalmanFilterTest.java
8 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 8

              
public class KalmanFilterTest extends OpenCVTestCase {

    public void testCorrect() {
        fail("Not yet implemented");
    }

    public void testKalmanFilter() {
        KalmanFilter kf = new KalmanFilter();

            

Reported by PMD.

The String literal 'Not yet implemented' appears 6 times in this file; the first occurrence is on line 9
Error

Line: 9

              public class KalmanFilterTest extends OpenCVTestCase {

    public void testCorrect() {
        fail("Not yet implemented");
    }

    public void testKalmanFilter() {
        KalmanFilter kf = new KalmanFilter();


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 12

                      fail("Not yet implemented");
    }

    public void testKalmanFilter() {
        KalmanFilter kf = new KalmanFilter();

        assertNotNull(kf);
    }


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 18

                      assertNotNull(kf);
    }

    public void testKalmanFilterIntInt() {
        fail("Not yet implemented");
    }

    public void testKalmanFilterIntIntInt() {
        fail("Not yet implemented");

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 22

                      fail("Not yet implemented");
    }

    public void testKalmanFilterIntIntInt() {
        fail("Not yet implemented");
    }

    public void testKalmanFilterIntIntIntInt() {
        fail("Not yet implemented");

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 26

                      fail("Not yet implemented");
    }

    public void testKalmanFilterIntIntIntInt() {
        fail("Not yet implemented");
    }

    public void testPredict() {
        fail("Not yet implemented");

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 30

                      fail("Not yet implemented");
    }

    public void testPredict() {
        fail("Not yet implemented");
    }

    public void testPredictMat() {
        fail("Not yet implemented");

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 34

                      fail("Not yet implemented");
    }

    public void testPredictMat() {
        fail("Not yet implemented");
    }

}

            

Reported by PMD.

modules/core/misc/java/src/java/core+MatOfRect2d.java
8 issues
Overridable method 'fromArray' called during object construction
Error

Line: 36

              
    public MatOfRect2d(Rect2d...a) {
        super();
        fromArray(a);
    }

    public void alloc(int elemNumber) {
        if(elemNumber>0)
            super.create(elemNumber, 1, CvType.makeType(_depth, _channels));

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '49'-'52').
Error

Line: 49

                          return;
        int num = a.length;
        alloc(num);
        double buff[] = new double[num * _channels];
        for(int i=0; i<num; i++) {
            Rect2d r = a[i];
            buff[_channels*i+0] = (double) r.x;
            buff[_channels*i+1] = (double) r.y;
            buff[_channels*i+2] = (double) r.width;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '52'-'53').
Error

Line: 52

                      double buff[] = new double[num * _channels];
        for(int i=0; i<num; i++) {
            Rect2d r = a[i];
            buff[_channels*i+0] = (double) r.x;
            buff[_channels*i+1] = (double) r.y;
            buff[_channels*i+2] = (double) r.width;
            buff[_channels*i+3] = (double) r.height;
        }
        put(0, 0, buff); //TODO: check ret val!

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '53'-'54').
Error

Line: 53

                      for(int i=0; i<num; i++) {
            Rect2d r = a[i];
            buff[_channels*i+0] = (double) r.x;
            buff[_channels*i+1] = (double) r.y;
            buff[_channels*i+2] = (double) r.width;
            buff[_channels*i+3] = (double) r.height;
        }
        put(0, 0, buff); //TODO: check ret val!
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '54'-'55').
Error

Line: 54

                          Rect2d r = a[i];
            buff[_channels*i+0] = (double) r.x;
            buff[_channels*i+1] = (double) r.y;
            buff[_channels*i+2] = (double) r.width;
            buff[_channels*i+3] = (double) r.height;
        }
        put(0, 0, buff); //TODO: check ret val!
    }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '55'-'52').
Error

Line: 55

                          buff[_channels*i+0] = (double) r.x;
            buff[_channels*i+1] = (double) r.y;
            buff[_channels*i+2] = (double) r.width;
            buff[_channels*i+3] = (double) r.height;
        }
        put(0, 0, buff); //TODO: check ret val!
    }



            

Reported by PMD.

Found 'DD'-anomaly for variable 'a' (lines '63'-'69').
Error

Line: 63

              
    public Rect2d[] toArray() {
        int num = (int) total();
        Rect2d[] a = new Rect2d[num];
        if(num == 0)
            return a;
        double buff[] = new double[num * _channels];
        get(0, 0, buff); //TODO: check ret val!
        for(int i=0; i<num; i++)

            

Reported by PMD.

Found 'DD'-anomaly for variable 'a' (lines '69'-'69').
Error

Line: 69

                      double buff[] = new double[num * _channels];
        get(0, 0, buff); //TODO: check ret val!
        for(int i=0; i<num; i++)
            a[i] = new Rect2d(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2], buff[i*_channels+3]);
        return a;
    }
    public void fromList(List<Rect2d> lr) {
        Rect2d ap[] = lr.toArray(new Rect2d[0]);
        fromArray(ap);

            

Reported by PMD.

modules/python/test/test_persistence.py
8 issues
Unable to import 'cv2'
Error

Line: 5 Column: 1

              """"Core serialization tests."""
import tempfile
import os
import cv2 as cv
import numpy as np
from tests_common import NewOpenCVTests


class persistence_test(NewOpenCVTests):

            

Reported by Pylint.

Class name "persistence_test" doesn't conform to PascalCase naming style
Error

Line: 10 Column: 1

              from tests_common import NewOpenCVTests


class persistence_test(NewOpenCVTests):
    def test_yml_rw(self):
        fd, fname = tempfile.mkstemp(prefix="opencv_python_persistence_", suffix=".yml")
        os.close(fd)

        # Writing ...

            

Reported by Pylint.

Missing class docstring
Error

Line: 10 Column: 1

              from tests_common import NewOpenCVTests


class persistence_test(NewOpenCVTests):
    def test_yml_rw(self):
        fd, fname = tempfile.mkstemp(prefix="opencv_python_persistence_", suffix=".yml")
        os.close(fd)

        # Writing ...

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 5

              

class persistence_test(NewOpenCVTests):
    def test_yml_rw(self):
        fd, fname = tempfile.mkstemp(prefix="opencv_python_persistence_", suffix=".yml")
        os.close(fd)

        # Writing ...
        expected = np.array([[[0, 1, 2, 3, 4]]])

            

Reported by Pylint.

Variable name "fd" doesn't conform to snake_case naming style
Error

Line: 12 Column: 9

              
class persistence_test(NewOpenCVTests):
    def test_yml_rw(self):
        fd, fname = tempfile.mkstemp(prefix="opencv_python_persistence_", suffix=".yml")
        os.close(fd)

        # Writing ...
        expected = np.array([[[0, 1, 2, 3, 4]]])
        expected_str = ("Hello", "World", "!")

            

Reported by Pylint.

Variable name "fs" doesn't conform to snake_case naming style
Error

Line: 18 Column: 9

                      # Writing ...
        expected = np.array([[[0, 1, 2, 3, 4]]])
        expected_str = ("Hello", "World", "!")
        fs = cv.FileStorage(fname, cv.FILE_STORAGE_WRITE)
        fs.write("test", expected)
        fs.write("strings", expected_str)
        fs.release()

        # Reading ...

            

Reported by Pylint.

Variable name "fs" doesn't conform to snake_case naming style
Error

Line: 24 Column: 9

                      fs.release()

        # Reading ...
        fs = cv.FileStorage(fname, cv.FILE_STORAGE_READ)
        root = fs.getFirstTopLevelNode()
        self.assertEqual(root.name(), "test")

        test = fs.getNode("test")
        self.assertEqual(test.empty(), False)

            

Reported by Pylint.

Line too long (103/100)
Error

Line: 41 Column: 1

                      self.assertEqual(strings.isSeq(), True)
        self.assertEqual(strings.size(), len(expected_str))
        self.assertEqual(all(strings.at(i).isString() for i in range(strings.size())), True)
        self.assertSequenceEqual([strings.at(i).string() for i in range(strings.size())], expected_str)
        fs.release()

        os.remove(fname)

            

Reported by Pylint.

modules/core/misc/java/src/java/core+MatOfRect.java
8 issues
Overridable method 'fromArray' called during object construction
Error

Line: 36

              
    public MatOfRect(Rect...a) {
        super();
        fromArray(a);
    }

    public void alloc(int elemNumber) {
        if(elemNumber>0)
            super.create(elemNumber, 1, CvType.makeType(_depth, _channels));

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '49'-'52').
Error

Line: 49

                          return;
        int num = a.length;
        alloc(num);
        int buff[] = new int[num * _channels];
        for(int i=0; i<num; i++) {
            Rect r = a[i];
            buff[_channels*i+0] = (int) r.x;
            buff[_channels*i+1] = (int) r.y;
            buff[_channels*i+2] = (int) r.width;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '52'-'53').
Error

Line: 52

                      int buff[] = new int[num * _channels];
        for(int i=0; i<num; i++) {
            Rect r = a[i];
            buff[_channels*i+0] = (int) r.x;
            buff[_channels*i+1] = (int) r.y;
            buff[_channels*i+2] = (int) r.width;
            buff[_channels*i+3] = (int) r.height;
        }
        put(0, 0, buff); //TODO: check ret val!

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '53'-'54').
Error

Line: 53

                      for(int i=0; i<num; i++) {
            Rect r = a[i];
            buff[_channels*i+0] = (int) r.x;
            buff[_channels*i+1] = (int) r.y;
            buff[_channels*i+2] = (int) r.width;
            buff[_channels*i+3] = (int) r.height;
        }
        put(0, 0, buff); //TODO: check ret val!
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '54'-'55').
Error

Line: 54

                          Rect r = a[i];
            buff[_channels*i+0] = (int) r.x;
            buff[_channels*i+1] = (int) r.y;
            buff[_channels*i+2] = (int) r.width;
            buff[_channels*i+3] = (int) r.height;
        }
        put(0, 0, buff); //TODO: check ret val!
    }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '55'-'52').
Error

Line: 55

                          buff[_channels*i+0] = (int) r.x;
            buff[_channels*i+1] = (int) r.y;
            buff[_channels*i+2] = (int) r.width;
            buff[_channels*i+3] = (int) r.height;
        }
        put(0, 0, buff); //TODO: check ret val!
    }



            

Reported by PMD.

Found 'DD'-anomaly for variable 'a' (lines '63'-'69').
Error

Line: 63

              
    public Rect[] toArray() {
        int num = (int) total();
        Rect[] a = new Rect[num];
        if(num == 0)
            return a;
        int buff[] = new int[num * _channels];
        get(0, 0, buff); //TODO: check ret val!
        for(int i=0; i<num; i++)

            

Reported by PMD.

Found 'DD'-anomaly for variable 'a' (lines '69'-'69').
Error

Line: 69

                      int buff[] = new int[num * _channels];
        get(0, 0, buff); //TODO: check ret val!
        for(int i=0; i<num; i++)
            a[i] = new Rect(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2], buff[i*_channels+3]);
        return a;
    }
    public void fromList(List<Rect> lr) {
        Rect ap[] = lr.toArray(new Rect[0]);
        fromArray(ap);

            

Reported by PMD.

samples/python/tutorial_code/imgProc/morph_lines_detection/morph_lines_detection.py
8 issues
Unable to import 'cv2'
Error

Line: 7 Column: 1

              """
import numpy as np
import sys
import cv2 as cv


def show_wait_destroy(winname, img):
    cv.imshow(winname, img)
    cv.moveWindow(winname, 500, 0)

            

Reported by Pylint.

String statement has no effect
Error

Line: 100 Column: 5

                  vertical = cv.bitwise_not(vertical)
    show_wait_destroy("vertical_bit", vertical)

    '''
    Extract edges and smooth image according to the logic
    1. extract edges
    2. dilate(edges)
    3. src.copyTo(smooth)
    4. blur smooth img

            

Reported by Pylint.

standard import "import sys" should be placed before "import numpy as np"
Error

Line: 6 Column: 1

              @brief Use morphology transformations for extracting horizontal and vertical lines sample code
"""
import numpy as np
import sys
import cv2 as cv


def show_wait_destroy(winname, img):
    cv.imshow(winname, img)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              import cv2 as cv


def show_wait_destroy(winname, img):
    cv.imshow(winname, img)
    cv.moveWindow(winname, 500, 0)
    cv.waitKey(0)
    cv.destroyWindow(winname)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

                  cv.destroyWindow(winname)


def main(argv):
    # [load_image]
    # Check number of arguments
    if len(argv) < 1:
        print ('Not enough parameters')
        print ('Usage:\nmorph_lines_detection.py < path_to_image >')

            

Reported by Pylint.

Variable name "bw" doesn't conform to snake_case naming style
Error

Line: 51 Column: 5

                  # [bin]
    # Apply adaptiveThreshold at the bitwise_not of gray, notice the ~ symbol
    gray = cv.bitwise_not(gray)
    bw = cv.adaptiveThreshold(gray, 255, cv.ADAPTIVE_THRESH_MEAN_C, \
                                cv.THRESH_BINARY, 15, -2)
    # Show binary image
    show_wait_destroy("binary", bw)
    # [bin]


            

Reported by Pylint.

Variable name "horizontalStructure" doesn't conform to snake_case naming style
Error

Line: 69 Column: 5

                  horizontal_size = cols // 30

    # Create structure element for extracting horizontal lines through morphology operations
    horizontalStructure = cv.getStructuringElement(cv.MORPH_RECT, (horizontal_size, 1))

    # Apply morphology operations
    horizontal = cv.erode(horizontal, horizontalStructure)
    horizontal = cv.dilate(horizontal, horizontalStructure)


            

Reported by Pylint.

Variable name "verticalStructure" doesn't conform to snake_case naming style
Error

Line: 85 Column: 5

                  verticalsize = rows // 30

    # Create structure element for extracting vertical lines through morphology operations
    verticalStructure = cv.getStructuringElement(cv.MORPH_RECT, (1, verticalsize))

    # Apply morphology operations
    vertical = cv.erode(vertical, verticalStructure)
    vertical = cv.dilate(vertical, verticalStructure)


            

Reported by Pylint.

samples/python/tutorial_code/features2D/akaze_matching/AKAZE_match.py
8 issues
Unable to import 'cv2'
Error

Line: 2 Column: 1

              from __future__ import print_function
import cv2 as cv
import numpy as np
import argparse
from math import sqrt

## [load]
parser = argparse.ArgumentParser(description='Code for AKAZE local features matching tutorial.')
parser.add_argument('--input1', help='Path to input image 1.', default='graf1.png')

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import print_function
import cv2 as cv
import numpy as np
import argparse
from math import sqrt

## [load]
parser = argparse.ArgumentParser(description='Code for AKAZE local features matching tutorial.')
parser.add_argument('--input1', help='Path to input image 1.', default='graf1.png')

            

Reported by Pylint.

Module name "AKAZE_match" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              from __future__ import print_function
import cv2 as cv
import numpy as np
import argparse
from math import sqrt

## [load]
parser = argparse.ArgumentParser(description='Code for AKAZE local features matching tutorial.')
parser.add_argument('--input1', help='Path to input image 1.', default='graf1.png')

            

Reported by Pylint.

standard import "import argparse" should be placed before "import cv2 as cv"
Error

Line: 4 Column: 1

              from __future__ import print_function
import cv2 as cv
import numpy as np
import argparse
from math import sqrt

## [load]
parser = argparse.ArgumentParser(description='Code for AKAZE local features matching tutorial.')
parser.add_argument('--input1', help='Path to input image 1.', default='graf1.png')

            

Reported by Pylint.

standard import "from math import sqrt" should be placed before "import cv2 as cv"
Error

Line: 5 Column: 1

              import cv2 as cv
import numpy as np
import argparse
from math import sqrt

## [load]
parser = argparse.ArgumentParser(description='Code for AKAZE local features matching tutorial.')
parser.add_argument('--input1', help='Path to input image 1.', default='graf1.png')
parser.add_argument('--input2', help='Path to input image 2.', default='graf3.png')

            

Reported by Pylint.

Consider using sys.exit()
Error

Line: 18 Column: 5

              img2 = cv.imread(cv.samples.findFile(args.input2), cv.IMREAD_GRAYSCALE)
if img1 is None or img2 is None:
    print('Could not open or find the images!')
    exit(0)

fs = cv.FileStorage(cv.samples.findFile(args.homography), cv.FILE_STORAGE_READ)
homography = fs.getFirstTopLevelNode().mat()
## [load]


            

Reported by Pylint.

Constant name "nn_match_ratio" doesn't conform to UPPER_CASE naming style
Error

Line: 38 Column: 1

              ## [ratio test filtering]
matched1 = []
matched2 = []
nn_match_ratio = 0.8 # Nearest neighbor matching ratio
for m, n in nn_matches:
    if m.distance < nn_match_ratio * n.distance:
        matched1.append(kpts1[m.queryIdx])
        matched2.append(kpts2[m.trainIdx])
## [ratio test filtering]

            

Reported by Pylint.

Constant name "inlier_threshold" doesn't conform to UPPER_CASE naming style
Error

Line: 49 Column: 1

              inliers1 = []
inliers2 = []
good_matches = []
inlier_threshold = 2.5 # Distance threshold to identify inliers with homography check
for i, m in enumerate(matched1):
    col = np.ones((3,1), dtype=np.float64)
    col[0:2,0] = m.pt

    col = np.dot(homography, col)

            

Reported by Pylint.

samples/python/tutorial_code/video/background_subtraction/bg_sub.py
8 issues
Unable to import 'cv2'
Error

Line: 2 Column: 1

              from __future__ import print_function
import cv2 as cv
import argparse

parser = argparse.ArgumentParser(description='This program shows how to use background subtraction methods provided by \
                                              OpenCV. You can process both videos and images.')
parser.add_argument('--input', type=str, help='Path to a video or a sequence of image.', default='vtest.avi')
parser.add_argument('--algo', type=str, help='Background subtraction method (KNN, MOG2).', default='MOG2')
args = parser.parse_args()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import print_function
import cv2 as cv
import argparse

parser = argparse.ArgumentParser(description='This program shows how to use background subtraction methods provided by \
                                              OpenCV. You can process both videos and images.')
parser.add_argument('--input', type=str, help='Path to a video or a sequence of image.', default='vtest.avi')
parser.add_argument('--algo', type=str, help='Background subtraction method (KNN, MOG2).', default='MOG2')
args = parser.parse_args()

            

Reported by Pylint.

standard import "import argparse" should be placed before "import cv2 as cv"
Error

Line: 3 Column: 1

              from __future__ import print_function
import cv2 as cv
import argparse

parser = argparse.ArgumentParser(description='This program shows how to use background subtraction methods provided by \
                                              OpenCV. You can process both videos and images.')
parser.add_argument('--input', type=str, help='Path to a video or a sequence of image.', default='vtest.avi')
parser.add_argument('--algo', type=str, help='Background subtraction method (KNN, MOG2).', default='MOG2')
args = parser.parse_args()

            

Reported by Pylint.

Line too long (120/100)
Error

Line: 5 Column: 1

              import cv2 as cv
import argparse

parser = argparse.ArgumentParser(description='This program shows how to use background subtraction methods provided by \
                                              OpenCV. You can process both videos and images.')
parser.add_argument('--input', type=str, help='Path to a video or a sequence of image.', default='vtest.avi')
parser.add_argument('--algo', type=str, help='Background subtraction method (KNN, MOG2).', default='MOG2')
args = parser.parse_args()


            

Reported by Pylint.

Line too long (109/100)
Error

Line: 7 Column: 1

              
parser = argparse.ArgumentParser(description='This program shows how to use background subtraction methods provided by \
                                              OpenCV. You can process both videos and images.')
parser.add_argument('--input', type=str, help='Path to a video or a sequence of image.', default='vtest.avi')
parser.add_argument('--algo', type=str, help='Background subtraction method (KNN, MOG2).', default='MOG2')
args = parser.parse_args()

## [create]
#create Background Subtractor objects

            

Reported by Pylint.

Line too long (106/100)
Error

Line: 8 Column: 1

              parser = argparse.ArgumentParser(description='This program shows how to use background subtraction methods provided by \
                                              OpenCV. You can process both videos and images.')
parser.add_argument('--input', type=str, help='Path to a video or a sequence of image.', default='vtest.avi')
parser.add_argument('--algo', type=str, help='Background subtraction method (KNN, MOG2).', default='MOG2')
args = parser.parse_args()

## [create]
#create Background Subtractor objects
if args.algo == 'MOG2':

            

Reported by Pylint.

Consider using sys.exit()
Error

Line: 23 Column: 5

              capture = cv.VideoCapture(cv.samples.findFileOrKeep(args.input))
if not capture.isOpened():
    print('Unable to open: ' + args.input)
    exit(0)
## [capture]

while True:
    ret, frame = capture.read()
    if frame is None:

            

Reported by Pylint.

Consider merging these comparisons with "in" to "keyboard in ('q', 27)"
Error

Line: 50 Column: 8

                  ## [show]

    keyboard = cv.waitKey(30)
    if keyboard == 'q' or keyboard == 27:
        break

            

Reported by Pylint.

modules/core/misc/java/src/java/core+MatOfByte.java
7 issues
Avoid throwing null pointer exceptions.
Design

Line: 60

                      if (offset < 0)
            throw new IllegalArgumentException("offset < 0");
        if (a == null)
            throw new NullPointerException();
        if (length < 0 || length + offset > a.length)
            throw new IllegalArgumentException("invalid 'length' parameter: " + Integer.toString(length));
        if (a.length == 0)
            return;
        int num = length / _channels;

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 73

                  public byte[] toArray() {
        int num = checkVector(_channels, _depth);
        if(num < 0)
            throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
        byte[] a = new byte[num * _channels];
        if(num == 0)
            return a;
        get(0, 0, a); //TODO: check ret val!
        return a;

            

Reported by PMD.

Substitute calls to size() == 0 (or size() != 0, size() > 0, size() < 1) with calls to isEmpty()
Design

Line: 82

                  }

    public void fromList(List<Byte> lb) {
        if(lb==null || lb.size()==0)
            return;
        Byte ab[] = lb.toArray(new Byte[0]);
        byte a[] = new byte[ab.length];
        for(int i=0; i<ab.length; i++)
            a[i] = ab[i];

            

Reported by PMD.

Found 'DD'-anomaly for variable 'a' (lines '85'-'87').
Error

Line: 85

                      if(lb==null || lb.size()==0)
            return;
        Byte ab[] = lb.toArray(new Byte[0]);
        byte a[] = new byte[ab.length];
        for(int i=0; i<ab.length; i++)
            a[i] = ab[i];
        fromArray(a);
    }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'a' (lines '87'-'87').
Error

Line: 87

                      Byte ab[] = lb.toArray(new Byte[0]);
        byte a[] = new byte[ab.length];
        for(int i=0; i<ab.length; i++)
            a[i] = ab[i];
        fromArray(a);
    }

    public List<Byte> toList() {
        byte[] a = toArray();

            

Reported by PMD.

Found 'DD'-anomaly for variable 'ab' (lines '93'-'95').
Error

Line: 93

              
    public List<Byte> toList() {
        byte[] a = toArray();
        Byte ab[] = new Byte[a.length];
        for(int i=0; i<a.length; i++)
            ab[i] = a[i];
        return Arrays.asList(ab);
    }
}

            

Reported by PMD.

Found 'DD'-anomaly for variable 'ab' (lines '95'-'95').
Error

Line: 95

                      byte[] a = toArray();
        Byte ab[] = new Byte[a.length];
        for(int i=0; i<a.length; i++)
            ab[i] = a[i];
        return Arrays.asList(ab);
    }
}

            

Reported by PMD.