The following issues were found

samples/java/tutorial_code/ImgTrans/warp_affine/GeometricTransformsDemo.java
26 issues
System.err.println is used
Design

Line: 15

                      String filename = args.length > 0 ? args[0] : "../data/lena.jpg";
        Mat src = Imgcodecs.imread(filename);
        if (src.empty()) {
            System.err.println("Cannot read image: " + filename);
            System.exit(0);
        }
        //! [Load the image]

        //! [Set your 3 points to calculate the  Affine Transform]

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 14

                      //! [Load the image]
        String filename = args.length > 0 ? args[0] : "../data/lena.jpg";
        Mat src = Imgcodecs.imread(filename);
        if (src.empty()) {
            System.err.println("Cannot read image: " + filename);
            System.exit(0);
        }
        //! [Load the image]


            

Reported by PMD.

System.exit() should not be used in J2EE/JEE apps
Error

Line: 16

                      Mat src = Imgcodecs.imread(filename);
        if (src.empty()) {
            System.err.println("Cannot read image: " + filename);
            System.exit(0);
        }
        //! [Load the image]

        //! [Set your 3 points to calculate the  Affine Transform]
        Point[] srcTri = new Point[3];

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 23

                      //! [Set your 3 points to calculate the  Affine Transform]
        Point[] srcTri = new Point[3];
        srcTri[0] = new Point( 0, 0 );
        srcTri[1] = new Point( src.cols() - 1, 0 );
        srcTri[2] = new Point( 0, src.rows() - 1 );

        Point[] dstTri = new Point[3];
        dstTri[0] = new Point( 0, src.rows()*0.33 );
        dstTri[1] = new Point( src.cols()*0.85, src.rows()*0.25 );

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 24

                      Point[] srcTri = new Point[3];
        srcTri[0] = new Point( 0, 0 );
        srcTri[1] = new Point( src.cols() - 1, 0 );
        srcTri[2] = new Point( 0, src.rows() - 1 );

        Point[] dstTri = new Point[3];
        dstTri[0] = new Point( 0, src.rows()*0.33 );
        dstTri[1] = new Point( src.cols()*0.85, src.rows()*0.25 );
        dstTri[2] = new Point( src.cols()*0.15, src.rows()*0.7 );

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 27

                      srcTri[2] = new Point( 0, src.rows() - 1 );

        Point[] dstTri = new Point[3];
        dstTri[0] = new Point( 0, src.rows()*0.33 );
        dstTri[1] = new Point( src.cols()*0.85, src.rows()*0.25 );
        dstTri[2] = new Point( src.cols()*0.15, src.rows()*0.7 );
        //! [Set your 3 points to calculate the  Affine Transform]

        //! [Get the Affine Transform]

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 28

              
        Point[] dstTri = new Point[3];
        dstTri[0] = new Point( 0, src.rows()*0.33 );
        dstTri[1] = new Point( src.cols()*0.85, src.rows()*0.25 );
        dstTri[2] = new Point( src.cols()*0.15, src.rows()*0.7 );
        //! [Set your 3 points to calculate the  Affine Transform]

        //! [Get the Affine Transform]
        Mat warpMat = Imgproc.getAffineTransform( new MatOfPoint2f(srcTri), new MatOfPoint2f(dstTri) );

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 28

              
        Point[] dstTri = new Point[3];
        dstTri[0] = new Point( 0, src.rows()*0.33 );
        dstTri[1] = new Point( src.cols()*0.85, src.rows()*0.25 );
        dstTri[2] = new Point( src.cols()*0.15, src.rows()*0.7 );
        //! [Set your 3 points to calculate the  Affine Transform]

        //! [Get the Affine Transform]
        Mat warpMat = Imgproc.getAffineTransform( new MatOfPoint2f(srcTri), new MatOfPoint2f(dstTri) );

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 29

                      Point[] dstTri = new Point[3];
        dstTri[0] = new Point( 0, src.rows()*0.33 );
        dstTri[1] = new Point( src.cols()*0.85, src.rows()*0.25 );
        dstTri[2] = new Point( src.cols()*0.15, src.rows()*0.7 );
        //! [Set your 3 points to calculate the  Affine Transform]

        //! [Get the Affine Transform]
        Mat warpMat = Imgproc.getAffineTransform( new MatOfPoint2f(srcTri), new MatOfPoint2f(dstTri) );
        //! [Get the Affine Transform]

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 29

                      Point[] dstTri = new Point[3];
        dstTri[0] = new Point( 0, src.rows()*0.33 );
        dstTri[1] = new Point( src.cols()*0.85, src.rows()*0.25 );
        dstTri[2] = new Point( src.cols()*0.15, src.rows()*0.7 );
        //! [Set your 3 points to calculate the  Affine Transform]

        //! [Get the Affine Transform]
        Mat warpMat = Imgproc.getAffineTransform( new MatOfPoint2f(srcTri), new MatOfPoint2f(dstTri) );
        //! [Get the Affine Transform]

            

Reported by PMD.

modules/stitching/misc/python/test/test_stitching.py
26 issues
Unable to import 'cv2'
Error

Line: 2 Column: 1

              #!/usr/bin/env python
import cv2 as cv

from tests_common import NewOpenCVTests

class stitching_test(NewOpenCVTests):

    def test_simple(self):


            

Reported by Pylint.

Unable to import 'tests_common'
Error

Line: 4 Column: 1

              #!/usr/bin/env python
import cv2 as cv

from tests_common import NewOpenCVTests

class stitching_test(NewOpenCVTests):

    def test_simple(self):


            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 81 Column: 1

                      blender = cv.detail.Blender_createDefault(cv.detail.Blender_MULTI_BAND)
        self.assertIsNotNone(blender)

        timelapser = cv.detail.Timelapser_createDefault(cv.detail.Timelapser_AS_IS);
        self.assertIsNotNone(timelapser)
        timelapser = cv.detail.Timelapser_createDefault(cv.detail.Timelapser_CROP);
        self.assertIsNotNone(timelapser)



            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 83 Column: 1

              
        timelapser = cv.detail.Timelapser_createDefault(cv.detail.Timelapser_AS_IS);
        self.assertIsNotNone(timelapser)
        timelapser = cv.detail.Timelapser_createDefault(cv.detail.Timelapser_CROP);
        self.assertIsNotNone(timelapser)


class stitching_compose_panorama_test_no_args(NewOpenCVTests):


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python
import cv2 as cv

from tests_common import NewOpenCVTests

class stitching_test(NewOpenCVTests):

    def test_simple(self):


            

Reported by Pylint.

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

Line: 6 Column: 1

              
from tests_common import NewOpenCVTests

class stitching_test(NewOpenCVTests):

    def test_simple(self):

        img1 = self.get_sample('stitching/a1.png')
        img2 = self.get_sample('stitching/a2.png')

            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              
from tests_common import NewOpenCVTests

class stitching_test(NewOpenCVTests):

    def test_simple(self):

        img1 = self.get_sample('stitching/a1.png')
        img2 = self.get_sample('stitching/a2.png')

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 6 Column: 1

              
from tests_common import NewOpenCVTests

class stitching_test(NewOpenCVTests):

    def test_simple(self):

        img1 = self.get_sample('stitching/a1.png')
        img2 = self.get_sample('stitching/a2.png')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 5

              
class stitching_test(NewOpenCVTests):

    def test_simple(self):

        img1 = self.get_sample('stitching/a1.png')
        img2 = self.get_sample('stitching/a2.png')

        stitcher = cv.Stitcher.create(cv.Stitcher_PANORAMA)

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 23 Column: 1

                      self.assertAlmostEqual(pano.shape[1], 1025, delta=100, msg="cols: %r" % list(pano.shape))


class stitching_detail_test(NewOpenCVTests):

    def test_simple(self):
        img = self.get_sample('stitching/a1.png')
        finder= cv.ORB.create()
        imgFea = cv.detail.computeImageFeatures2(finder,img)

            

Reported by Pylint.

modules/gapi/scripts/measure_privacy_masking.py
26 issues
Anomalous backslash in string: '\.'. String constant might be missing an r prefix.
Error

Line: 74 Column: 69

                                    , ("--noshow=%s" % fmt_bool(u[1]))    # UI mode (show/no show)
                      ]
                out = str(subprocess.check_output(cmd))
                match = re.search('Processed [0-9]+ frames \(([0-9]+\.[0-9]+) FPS\)', out)
                fps = float(match.group(1))
                print(cmd, fps, "FPS")
                table[m[0],u[0],f,p] = fps

# Write the performance summary

            

Reported by Pylint.

Anomalous backslash in string: '\('. String constant might be missing an r prefix.
Error

Line: 74 Column: 60

                                    , ("--noshow=%s" % fmt_bool(u[1]))    # UI mode (show/no show)
                      ]
                out = str(subprocess.check_output(cmd))
                match = re.search('Processed [0-9]+ frames \(([0-9]+\.[0-9]+) FPS\)', out)
                fps = float(match.group(1))
                print(cmd, fps, "FPS")
                table[m[0],u[0],f,p] = fps

# Write the performance summary

            

Reported by Pylint.

Anomalous backslash in string: '\)'. String constant might be missing an r prefix.
Error

Line: 74 Column: 82

                                    , ("--noshow=%s" % fmt_bool(u[1]))    # UI mode (show/no show)
                      ]
                out = str(subprocess.check_output(cmd))
                match = re.search('Processed [0-9]+ frames \(([0-9]+\.[0-9]+) FPS\)', out)
                fps = float(match.group(1))
                print(cmd, fps, "FPS")
                table[m[0],u[0],f,p] = fps

# Write the performance summary

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python3

import sys
import subprocess
import re
from enum import Enum

## Helper functions ##################################################
##

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

Line: 4
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              #!/usr/bin/env python3

import sys
import subprocess
import re
from enum import Enum

## Helper functions ##################################################
##

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 10 Column: 1

              
## Helper functions ##################################################
##
def fmt_bool(x):
    return ("true" if x else "false")

def fmt_bin(base, prec, model):
    return "%s/%s/%s/%s.xml" % (base, model, prec, model)


            

Reported by Pylint.

Argument name "x" doesn't conform to snake_case naming style
Error

Line: 10 Column: 1

              
## Helper functions ##################################################
##
def fmt_bool(x):
    return ("true" if x else "false")

def fmt_bin(base, prec, model):
    return "%s/%s/%s/%s.xml" % (base, model, prec, model)


            

Reported by Pylint.

Unnecessary parens after 'return' keyword
Error

Line: 11 Column: 1

              ## Helper functions ##################################################
##
def fmt_bool(x):
    return ("true" if x else "false")

def fmt_bin(base, prec, model):
    return "%s/%s/%s/%s.xml" % (base, model, prec, model)

## The script itself #################################################

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              def fmt_bool(x):
    return ("true" if x else "false")

def fmt_bin(base, prec, model):
    return "%s/%s/%s/%s.xml" % (base, model, prec, model)

## The script itself #################################################
##
if len(sys.argv) != 3:

            

Reported by Pylint.

Consider using sys.exit()
Error

Line: 20 Column: 5

              ##
if len(sys.argv) != 3:
    print("Usage: %s /path/to/input/video /path/to/models" % sys.argv[0])
    exit(1)

input_file_path   = sys.argv[1]
intel_models_path = sys.argv[2]

app             = "bin/example_gapi_privacy_masking_camera"

            

Reported by Pylint.

samples/java/tutorial_code/Histograms_Matching/back_projection/CalcBackProjectDemo2.java
26 issues
System.err.println is used
Design

Line: 46

                  public CalcBackProject2(String[] args) {
        /// Read the image
        if (args.length != 1) {
            System.err.println("You must supply one argument that corresponds to the path to the image.");
            System.exit(0);
        }

        src = Imgcodecs.imread(args[0]);
        if (src.empty()) {

            

Reported by PMD.

System.err.println is used
Design

Line: 52

              
        src = Imgcodecs.imread(args[0]);
        if (src.empty()) {
            System.err.println("Empty image: " + args[0]);
            System.exit(0);
        }

        /// Transform it to HSV
        Imgproc.cvtColor(src, hsv, Imgproc.COLOR_BGR2HSV);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 32

              import org.opencv.imgproc.Imgproc;

class CalcBackProject2 {
    private Mat src;
    private Mat hsv = new Mat();
    private Mat mask = new Mat();
    private JFrame frame;
    private JLabel imgLabel;
    private JLabel backprojLabel;

            

Reported by PMD.

Private field 'src' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 32

              import org.opencv.imgproc.Imgproc;

class CalcBackProject2 {
    private Mat src;
    private Mat hsv = new Mat();
    private Mat mask = new Mat();
    private JFrame frame;
    private JLabel imgLabel;
    private JLabel backprojLabel;

            

Reported by PMD.

Private field 'hsv' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 33

              
class CalcBackProject2 {
    private Mat src;
    private Mat hsv = new Mat();
    private Mat mask = new Mat();
    private JFrame frame;
    private JLabel imgLabel;
    private JLabel backprojLabel;
    private JLabel maskImgLabel;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 33

              
class CalcBackProject2 {
    private Mat src;
    private Mat hsv = new Mat();
    private Mat mask = new Mat();
    private JFrame frame;
    private JLabel imgLabel;
    private JLabel backprojLabel;
    private JLabel maskImgLabel;

            

Reported by PMD.

Perhaps 'mask' could be replaced by a local variable.
Design

Line: 34

              class CalcBackProject2 {
    private Mat src;
    private Mat hsv = new Mat();
    private Mat mask = new Mat();
    private JFrame frame;
    private JLabel imgLabel;
    private JLabel backprojLabel;
    private JLabel maskImgLabel;
    private static final int MAX_SLIDER = 255;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 34

              class CalcBackProject2 {
    private Mat src;
    private Mat hsv = new Mat();
    private Mat mask = new Mat();
    private JFrame frame;
    private JLabel imgLabel;
    private JLabel backprojLabel;
    private JLabel maskImgLabel;
    private static final int MAX_SLIDER = 255;

            

Reported by PMD.

Private field 'frame' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 35

                  private Mat src;
    private Mat hsv = new Mat();
    private Mat mask = new Mat();
    private JFrame frame;
    private JLabel imgLabel;
    private JLabel backprojLabel;
    private JLabel maskImgLabel;
    private static final int MAX_SLIDER = 255;
    private int low = 20;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 35

                  private Mat src;
    private Mat hsv = new Mat();
    private Mat mask = new Mat();
    private JFrame frame;
    private JLabel imgLabel;
    private JLabel backprojLabel;
    private JLabel maskImgLabel;
    private static final int MAX_SLIDER = 255;
    private int low = 20;

            

Reported by PMD.

modules/core/src/opencl/runtime/generator/parser_cl.py
26 issues
Unnecessary semicolon
Error

Line: 6 Column: 1

              #     cat opencl11/cl.h | $0 cl_runtime_opencl11
#     cat opencl12/cl.h | $0 cl_runtime_opencl12
from __future__ import print_function
import sys, re;

from common import remove_comments, getTokens, getParameters, postProcessParameters

try:
    if len(sys.argv) > 1:

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 23 Column: 1

                          f = sys.stdin
    else:
        sys.exit("ERROR. Specify output file")
except:
    sys.exit("ERROR. Can't open input/output file, check parameters")

fns = []

while True:

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 33 Column: 1

                  if len(line) == 0:
        break
    assert isinstance(line, str)
    parts = line.split();
    if line.startswith('extern') and line.find('CL_API_CALL') != -1:
        # read block of lines
        while True:
            nl = f.readline()
            nl = nl.strip()

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 41 Column: 1

                          nl = nl.strip()
            nl = re.sub(r'\n', r'', nl)
            if len(nl) == 0:
                break;
            line += ' ' + nl

        line = remove_comments(line)

        parts = getTokens(line)

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 79 Column: 1

                      # print 'ret='+' '.join(type)
        # print 'calling='+' '.join(calling)

        name = parts[i]; i += 1;
        fn['name'] = name
        print('name=' + name)

        params = getParameters(i, parts)


            

Reported by Pylint.

Unused import getParameter from wildcard import
Error

Line: 99 Column: 1

              from pprint import pprint
pprint(fns)

from common import *

filterFileName = './filter/%s_functions.list' % module_name
numEnabled = readFunctionFilter(fns, filterFileName)

functionsFilter = generateFilterNames(fns)

            

Reported by Pylint.

Unused import outputToString from wildcard import
Error

Line: 99 Column: 1

              from pprint import pprint
pprint(fns)

from common import *

filterFileName = './filter/%s_functions.list' % module_name
numEnabled = readFunctionFilter(fns, filterFileName)

functionsFilter = generateFilterNames(fns)

            

Reported by Pylint.

Unused import os from wildcard import
Error

Line: 99 Column: 1

              from pprint import pprint
pprint(fns)

from common import *

filterFileName = './filter/%s_functions.list' % module_name
numEnabled = readFunctionFilter(fns, filterFileName)

functionsFilter = generateFilterNames(fns)

            

Reported by Pylint.

Wildcard import common
Error

Line: 99 Column: 1

              from pprint import pprint
pprint(fns)

from common import *

filterFileName = './filter/%s_functions.list' % module_name
numEnabled = readFunctionFilter(fns, filterFileName)

functionsFilter = generateFilterNames(fns)

            

Reported by Pylint.

Unused import callback_check from wildcard import
Error

Line: 99 Column: 1

              from pprint import pprint
pprint(fns)

from common import *

filterFileName = './filter/%s_functions.list' % module_name
numEnabled = readFunctionFilter(fns, filterFileName)

functionsFilter = generateFilterNames(fns)

            

Reported by Pylint.

samples/java/tutorial_code/ImgProc/changing_contrast_brightness_image/BasicLinearTransformsDemo.java
26 issues
System.out.println is used
Design

Line: 21

                      String imagePath = args.length > 0 ? args[0] : "../data/lena.jpg";
        Mat image = Imgcodecs.imread(imagePath);
        if (image.empty()) {
            System.out.println("Empty image: " + imagePath);
            System.exit(0);
        }
        //! [basic-linear-transform-load]

        //! [basic-linear-transform-output]

            

Reported by PMD.

System.out.println is used
Design

Line: 35

                      int beta = 0;       /*< Simple brightness control */

        /// Initialize values
        System.out.println(" Basic Linear Transforms ");
        System.out.println("-------------------------");
        try (Scanner scanner = new Scanner(System.in)) {
            System.out.print("* Enter the alpha value [1.0-3.0]: ");
            alpha = scanner.nextDouble();
            System.out.print("* Enter the beta value [0-100]: ");

            

Reported by PMD.

System.out.println is used
Design

Line: 36

              
        /// Initialize values
        System.out.println(" Basic Linear Transforms ");
        System.out.println("-------------------------");
        try (Scanner scanner = new Scanner(System.in)) {
            System.out.print("* Enter the alpha value [1.0-3.0]: ");
            alpha = scanner.nextDouble();
            System.out.print("* Enter the beta value [0-100]: ");
            beta = scanner.nextInt();

            

Reported by PMD.

System.out.print is used
Design

Line: 38

                      System.out.println(" Basic Linear Transforms ");
        System.out.println("-------------------------");
        try (Scanner scanner = new Scanner(System.in)) {
            System.out.print("* Enter the alpha value [1.0-3.0]: ");
            alpha = scanner.nextDouble();
            System.out.print("* Enter the beta value [0-100]: ");
            beta = scanner.nextInt();
        }
        //! [basic-linear-transform-parameters]

            

Reported by PMD.

System.out.print is used
Design

Line: 40

                      try (Scanner scanner = new Scanner(System.in)) {
            System.out.print("* Enter the alpha value [1.0-3.0]: ");
            alpha = scanner.nextDouble();
            System.out.print("* Enter the beta value [0-100]: ");
            beta = scanner.nextInt();
        }
        //! [basic-linear-transform-parameters]

        /// Do the operation newImage(i,j) = alpha*image(i,j) + beta

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 20

                      //! [basic-linear-transform-load]
        String imagePath = args.length > 0 ? args[0] : "../data/lena.jpg";
        Mat image = Imgcodecs.imread(imagePath);
        if (image.empty()) {
            System.out.println("Empty image: " + imagePath);
            System.exit(0);
        }
        //! [basic-linear-transform-load]


            

Reported by PMD.

System.exit() should not be used in J2EE/JEE apps
Error

Line: 22

                      Mat image = Imgcodecs.imread(imagePath);
        if (image.empty()) {
            System.out.println("Empty image: " + imagePath);
            System.exit(0);
        }
        //! [basic-linear-transform-load]

        //! [basic-linear-transform-output]
        Mat newImage = Mat.zeros(image.size(), image.type());

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 27

                      //! [basic-linear-transform-load]

        //! [basic-linear-transform-output]
        Mat newImage = Mat.zeros(image.size(), image.type());
        //! [basic-linear-transform-output]

        //! [basic-linear-transform-parameters]
        double alpha = 1.0; /*< Simple contrast control */
        int beta = 0;       /*< Simple brightness control */

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 27

                      //! [basic-linear-transform-load]

        //! [basic-linear-transform-output]
        Mat newImage = Mat.zeros(image.size(), image.type());
        //! [basic-linear-transform-output]

        //! [basic-linear-transform-parameters]
        double alpha = 1.0; /*< Simple contrast control */
        int beta = 0;       /*< Simple brightness control */

            

Reported by PMD.

The initializer for variable 'alpha' is never used (overwritten on line 39)
Design

Line: 31

                      //! [basic-linear-transform-output]

        //! [basic-linear-transform-parameters]
        double alpha = 1.0; /*< Simple contrast control */
        int beta = 0;       /*< Simple brightness control */

        /// Initialize values
        System.out.println(" Basic Linear Transforms ");
        System.out.println("-------------------------");

            

Reported by PMD.

modules/python/test/test_fitline.py
25 issues
Unable to import 'cv2'
Error

Line: 22 Column: 1

              PY3 = sys.version_info[0] == 3

import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests

w, h = 512, 256


            

Reported by Pylint.

Import "import numpy as np" should be placed at the top of the module
Error

Line: 21 Column: 1

              import sys
PY3 = sys.version_info[0] == 3

import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests

w, h = 512, 256

            

Reported by Pylint.

Import "import cv2 as cv" should be placed at the top of the module
Error

Line: 22 Column: 1

              PY3 = sys.version_info[0] == 3

import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests

w, h = 512, 256


            

Reported by Pylint.

Import "from tests_common import NewOpenCVTests" should be placed at the top of the module
Error

Line: 24 Column: 1

              import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests

w, h = 512, 256

def toint(p):
    return tuple(map(int, p))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 1

              
w, h = 512, 256

def toint(p):
    return tuple(map(int, p))

def sample_line(p1, p2, n, noise=0.0):
    np.random.seed(10)
    p1 = np.float32(p1)

            

Reported by Pylint.

Argument name "p" doesn't conform to snake_case naming style
Error

Line: 28 Column: 1

              
w, h = 512, 256

def toint(p):
    return tuple(map(int, p))

def sample_line(p1, p2, n, noise=0.0):
    np.random.seed(10)
    p1 = np.float32(p1)

            

Reported by Pylint.

Argument name "p2" doesn't conform to snake_case naming style
Error

Line: 31 Column: 1

              def toint(p):
    return tuple(map(int, p))

def sample_line(p1, p2, n, noise=0.0):
    np.random.seed(10)
    p1 = np.float32(p1)
    t = np.random.rand(n,1)
    return p1 + (p2-p1)*t + np.random.normal(size=(n, 2))*noise


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 31 Column: 1

              def toint(p):
    return tuple(map(int, p))

def sample_line(p1, p2, n, noise=0.0):
    np.random.seed(10)
    p1 = np.float32(p1)
    t = np.random.rand(n,1)
    return p1 + (p2-p1)*t + np.random.normal(size=(n, 2))*noise


            

Reported by Pylint.

Argument name "p1" doesn't conform to snake_case naming style
Error

Line: 31 Column: 1

              def toint(p):
    return tuple(map(int, p))

def sample_line(p1, p2, n, noise=0.0):
    np.random.seed(10)
    p1 = np.float32(p1)
    t = np.random.rand(n,1)
    return p1 + (p2-p1)*t + np.random.normal(size=(n, 2))*noise


            

Reported by Pylint.

Argument name "n" doesn't conform to snake_case naming style
Error

Line: 31 Column: 1

              def toint(p):
    return tuple(map(int, p))

def sample_line(p1, p2, n, noise=0.0):
    np.random.seed(10)
    p1 = np.float32(p1)
    t = np.random.rand(n,1)
    return p1 + (p2-p1)*t + np.random.normal(size=(n, 2))*noise


            

Reported by Pylint.

modules/python/test/test_camshift.py
25 issues
Unable to import 'cv2'
Error

Line: 24 Column: 1

                  xrange = range

import numpy as np
import cv2 as cv
from tst_scene_render import TestSceneRender

from tests_common import NewOpenCVTests, intersectionRate

class camshift_test(NewOpenCVTests):

            

Reported by Pylint.

Attribute 'hist' defined outside __init__
Error

Line: 68 Column: 17

                              mask_roi = mask[y0:y1, x0:x1]
                hist = cv.calcHist( [hsv_roi], [0], mask_roi, [16], [0, 180] )
                cv.normalize(hist, hist, 0, 255, cv.NORM_MINMAX)
                self.hist = hist.reshape(-1)
                self.selection = False

            if self.track_window and self.track_window[2] > 0 and self.track_window[3] > 0:
                self.selection = None
                prob = cv.calcBackProject([hsv], [0], self.hist, [0, 180], 1)

            

Reported by Pylint.

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

Line: 21 Column: 5

              PY3 = sys.version_info[0] == 3

if PY3:
    xrange = range

import numpy as np
import cv2 as cv
from tst_scene_render import TestSceneRender


            

Reported by Pylint.

Import "import numpy as np" should be placed at the top of the module
Error

Line: 23 Column: 1

              if PY3:
    xrange = range

import numpy as np
import cv2 as cv
from tst_scene_render import TestSceneRender

from tests_common import NewOpenCVTests, intersectionRate


            

Reported by Pylint.

Import "import cv2 as cv" should be placed at the top of the module
Error

Line: 24 Column: 1

                  xrange = range

import numpy as np
import cv2 as cv
from tst_scene_render import TestSceneRender

from tests_common import NewOpenCVTests, intersectionRate

class camshift_test(NewOpenCVTests):

            

Reported by Pylint.

Import "from tst_scene_render import TestSceneRender" should be placed at the top of the module
Error

Line: 25 Column: 1

              
import numpy as np
import cv2 as cv
from tst_scene_render import TestSceneRender

from tests_common import NewOpenCVTests, intersectionRate

class camshift_test(NewOpenCVTests):


            

Reported by Pylint.

Import "from tests_common import NewOpenCVTests, intersectionRate" should be placed at the top of the module
Error

Line: 27 Column: 1

              import cv2 as cv
from tst_scene_render import TestSceneRender

from tests_common import NewOpenCVTests, intersectionRate

class camshift_test(NewOpenCVTests):

    framesNum = 300
    frame = None

            

Reported by Pylint.

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

Line: 29 Column: 1

              
from tests_common import NewOpenCVTests, intersectionRate

class camshift_test(NewOpenCVTests):

    framesNum = 300
    frame = None
    selection = None
    drag_start = None

            

Reported by Pylint.

Missing class docstring
Error

Line: 29 Column: 1

              
from tests_common import NewOpenCVTests, intersectionRate

class camshift_test(NewOpenCVTests):

    framesNum = 300
    frame = None
    selection = None
    drag_start = None

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 40 Column: 5

                  render = None
    errors = 0

    def prepareRender(self):

        self.render = TestSceneRender(self.get_sample('samples/data/pca_test1.jpg'), deformation = True)

    def runTracker(self):


            

Reported by Pylint.

samples/python/plane_ar.py
25 issues
Unable to import 'cv2'
Error

Line: 29 Column: 1

              from __future__ import print_function

import numpy as np
import cv2 as cv
import video
import common
from plane_tracker import PlaneTracker
from video import presets


            

Reported by Pylint.

No exception type(s) specified
Error

Line: 109 Column: 5

                  import sys
    try:
        video_src = sys.argv[1]
    except:
        video_src = 0
    App(video_src).run()

            

Reported by Pylint.

Missing class docstring
Error

Line: 44 Column: 1

                          (0, 4), (1, 5), (2, 6), (3, 7),
            (4, 8), (5, 8), (6, 9), (7, 9), (8, 9)]

class App:
    def __init__(self, src):
        self.cap = video.create_capture(src, presets['book'])
        self.frame = None
        self.paused = False
        self.tracker = PlaneTracker()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 55 Column: 5

                      cv.createTrackbar('focal', 'plane', 25, 50, common.nothing)
        self.rect_sel = common.RectSelector('plane', self.on_rect)

    def on_rect(self, rect):
        self.tracker.add_target(self.frame, rect)

    def run(self):
        while True:
            playing = not self.paused and not self.rect_sel.dragging

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 58 Column: 5

                  def on_rect(self, rect):
        self.tracker.add_target(self.frame, rect)

    def run(self):
        while True:
            playing = not self.paused and not self.rect_sel.dragging
            if playing or self.frame is None:
                ret, frame = self.cap.read()
                if not ret:

            

Reported by Pylint.

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

Line: 70 Column: 21

                          vis = self.frame.copy()
            if playing:
                tracked = self.tracker.track(self.frame)
                for tr in tracked:
                    cv.polylines(vis, [np.int32(tr.quad)], True, (255, 255, 255), 2)
                    for (x, y) in np.int32(tr.p1):
                        cv.circle(vis, (x, y), 2, (255, 255, 255))
                    self.draw_overlay(vis, tr)


            

Reported by Pylint.

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

Line: 72 Column: 26

                              tracked = self.tracker.track(self.frame)
                for tr in tracked:
                    cv.polylines(vis, [np.int32(tr.quad)], True, (255, 255, 255), 2)
                    for (x, y) in np.int32(tr.p1):
                        cv.circle(vis, (x, y), 2, (255, 255, 255))
                    self.draw_overlay(vis, tr)

            self.rect_sel.draw(vis)
            cv.imshow('plane', vis)

            

Reported by Pylint.

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

Line: 72 Column: 29

                              tracked = self.tracker.track(self.frame)
                for tr in tracked:
                    cv.polylines(vis, [np.int32(tr.quad)], True, (255, 255, 255), 2)
                    for (x, y) in np.int32(tr.p1):
                        cv.circle(vis, (x, y), 2, (255, 255, 255))
                    self.draw_overlay(vis, tr)

            self.rect_sel.draw(vis)
            cv.imshow('plane', vis)

            

Reported by Pylint.

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

Line: 78 Column: 13

              
            self.rect_sel.draw(vis)
            cv.imshow('plane', vis)
            ch = cv.waitKey(1)
            if ch == ord(' '):
                self.paused = not self.paused
            if ch == ord('c'):
                self.tracker.clear()
            if ch == 27:

            

Reported by Pylint.

Too many local variables (19/15)
Error

Line: 86 Column: 5

                          if ch == 27:
                break

    def draw_overlay(self, vis, tracked):
        x0, y0, x1, y1 = tracked.target.rect
        quad_3d = np.float32([[x0, y0, 0], [x1, y0, 0], [x1, y1, 0], [x0, y1, 0]])
        fx = 0.5 + cv.getTrackbarPos('focal', 'plane') / 50.0
        h, w = vis.shape[:2]
        K = np.float64([[fx*w, 0, 0.5*(w-1)],

            

Reported by Pylint.

samples/java/tutorial_code/ShapeDescriptors/hull/HullDemo.java
25 issues
System.err.println is used
Design

Line: 43

                      String filename = args.length > 0 ? args[0] : "../data/stuff.jpg";
        Mat src = Imgcodecs.imread(filename);
        if (src.empty()) {
            System.err.println("Cannot read image: " + filename);
            System.exit(0);
        }

        /// Convert image to gray and blur it
        Imgproc.cvtColor(src, srcGray, Imgproc.COLOR_BGR2GRAY);

            

Reported by PMD.

Private field 'srcGray' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 30

              import org.opencv.imgproc.Imgproc;

class Hull {
    private Mat srcGray = new Mat();
    private JFrame frame;
    private JLabel imgSrcLabel;
    private JLabel imgContoursLabel;
    private static final int MAX_THRESHOLD = 255;
    private int threshold = 100;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 30

              import org.opencv.imgproc.Imgproc;

class Hull {
    private Mat srcGray = new Mat();
    private JFrame frame;
    private JLabel imgSrcLabel;
    private JLabel imgContoursLabel;
    private static final int MAX_THRESHOLD = 255;
    private int threshold = 100;

            

Reported by PMD.

Private field 'frame' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 31

              
class Hull {
    private Mat srcGray = new Mat();
    private JFrame frame;
    private JLabel imgSrcLabel;
    private JLabel imgContoursLabel;
    private static final int MAX_THRESHOLD = 255;
    private int threshold = 100;
    private Random rng = new Random(12345);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 31

              
class Hull {
    private Mat srcGray = new Mat();
    private JFrame frame;
    private JLabel imgSrcLabel;
    private JLabel imgContoursLabel;
    private static final int MAX_THRESHOLD = 255;
    private int threshold = 100;
    private Random rng = new Random(12345);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 32

              class Hull {
    private Mat srcGray = new Mat();
    private JFrame frame;
    private JLabel imgSrcLabel;
    private JLabel imgContoursLabel;
    private static final int MAX_THRESHOLD = 255;
    private int threshold = 100;
    private Random rng = new Random(12345);


            

Reported by PMD.

Perhaps 'imgSrcLabel' could be replaced by a local variable.
Design

Line: 32

              class Hull {
    private Mat srcGray = new Mat();
    private JFrame frame;
    private JLabel imgSrcLabel;
    private JLabel imgContoursLabel;
    private static final int MAX_THRESHOLD = 255;
    private int threshold = 100;
    private Random rng = new Random(12345);


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 33

                  private Mat srcGray = new Mat();
    private JFrame frame;
    private JLabel imgSrcLabel;
    private JLabel imgContoursLabel;
    private static final int MAX_THRESHOLD = 255;
    private int threshold = 100;
    private Random rng = new Random(12345);

    public Hull(String[] args) {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 35

                  private JLabel imgSrcLabel;
    private JLabel imgContoursLabel;
    private static final int MAX_THRESHOLD = 255;
    private int threshold = 100;
    private Random rng = new Random(12345);

    public Hull(String[] args) {
        /// Load source image
        String filename = args.length > 0 ? args[0] : "../data/stuff.jpg";

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 36

                  private JLabel imgContoursLabel;
    private static final int MAX_THRESHOLD = 255;
    private int threshold = 100;
    private Random rng = new Random(12345);

    public Hull(String[] args) {
        /// Load source image
        String filename = args.length > 0 ? args[0] : "../data/stuff.jpg";
        Mat src = Imgcodecs.imread(filename);

            

Reported by PMD.