The following issues were found

platforms/osx/run_tests.py
21 issues
Unused import multiprocessing
Error

Line: 7 Column: 1

              """

from __future__ import print_function
import os, os.path, sys, argparse, traceback, multiprocessing

# import common code
sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios'))
from run_tests import TestRunner


            

Reported by Pylint.

Unused import traceback
Error

Line: 7 Column: 1

              """

from __future__ import print_function
import os, os.path, sys, argparse, traceback, multiprocessing

# import common code
sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios'))
from run_tests import TestRunner


            

Reported by Pylint.

Module import itself
Error

Line: 11 Column: 1

              
# import common code
sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios'))
from run_tests import TestRunner

MACOSX_DEPLOYMENT_TARGET='10.12'  # default, can be changed via command line options or environment variable

class OSXTestRunner(TestRunner):


            

Reported by Pylint.

Redefining name 'args' from outer scope (line 38)
Error

Line: 21 Column: 9

                      return None

    def getCMakeArgs(self):
        args = TestRunner.getCMakeArgs(self)
        args = args + [
            '-DMACOSX_DEPLOYMENT_TARGET=%s' % os.environ['MACOSX_DEPLOYMENT_TARGET']
        ]
        return args


            

Reported by Pylint.

Multiple imports on one line (os, os.path, sys, argparse, traceback, multiprocessing)
Error

Line: 7 Column: 1

              """

from __future__ import print_function
import os, os.path, sys, argparse, traceback, multiprocessing

# import common code
sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios'))
from run_tests import TestRunner


            

Reported by Pylint.

Import "from run_tests import TestRunner" should be placed at the top of the module
Error

Line: 11 Column: 1

              
# import common code
sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios'))
from run_tests import TestRunner

MACOSX_DEPLOYMENT_TARGET='10.12'  # default, can be changed via command line options or environment variable

class OSXTestRunner(TestRunner):


            

Reported by Pylint.

Line too long (108/100)
Error

Line: 13 Column: 1

              sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios'))
from run_tests import TestRunner

MACOSX_DEPLOYMENT_TARGET='10.12'  # default, can be changed via command line options or environment variable

class OSXTestRunner(TestRunner):

    def getToolchain(self):
        return None

            

Reported by Pylint.

Missing class docstring
Error

Line: 15 Column: 1

              
MACOSX_DEPLOYMENT_TARGET='10.12'  # default, can be changed via command line options or environment variable

class OSXTestRunner(TestRunner):

    def getToolchain(self):
        return None

    def getCMakeArgs(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

              
class OSXTestRunner(TestRunner):

    def getToolchain(self):
        return None

    def getCMakeArgs(self):
        args = TestRunner.getCMakeArgs(self)
        args = args + [

            

Reported by Pylint.

Method name "getToolchain" doesn't conform to snake_case naming style
Error

Line: 17 Column: 5

              
class OSXTestRunner(TestRunner):

    def getToolchain(self):
        return None

    def getCMakeArgs(self):
        args = TestRunner.getCMakeArgs(self)
        args = args + [

            

Reported by Pylint.

samples/python/tutorial_code/imgProc/opening_closing_hats/morphology_2.py
21 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

morph_size = 0
max_operator = 4
max_elem = 2
max_kernel_size = 21

            

Reported by Pylint.

Unused numpy imported as np
Error

Line: 3 Column: 1

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

morph_size = 0
max_operator = 4
max_elem = 2
max_kernel_size = 21

            

Reported by Pylint.

Unused argument 'val'
Error

Line: 16 Column: 27

              title_window = 'Morphology Transformations Demo'
morph_op_dic = {0: cv.MORPH_OPEN, 1: cv.MORPH_CLOSE, 2: cv.MORPH_GRADIENT, 3: cv.MORPH_TOPHAT, 4: cv.MORPH_BLACKHAT}

def morphology_operations(val):
    morph_operator = cv.getTrackbarPos(title_trackbar_operator_type, title_window)
    morph_size = cv.getTrackbarPos(title_trackbar_kernel_size, title_window)
    morph_elem = 0
    val_type = cv.getTrackbarPos(title_trackbar_element_type, title_window)
    if val_type == 0:

            

Reported by Pylint.

Redefining name 'morph_size' from outer scope (line 6)
Error

Line: 18 Column: 5

              
def morphology_operations(val):
    morph_operator = cv.getTrackbarPos(title_trackbar_operator_type, title_window)
    morph_size = cv.getTrackbarPos(title_trackbar_kernel_size, title_window)
    morph_elem = 0
    val_type = cv.getTrackbarPos(title_trackbar_element_type, title_window)
    if val_type == 0:
        morph_elem = cv.MORPH_RECT
    elif val_type == 1:

            

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

morph_size = 0
max_operator = 4
max_elem = 2
max_kernel_size = 21

            

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

morph_size = 0
max_operator = 4
max_elem = 2
max_kernel_size = 21

            

Reported by Pylint.

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

Line: 6 Column: 1

              import numpy as np
import argparse

morph_size = 0
max_operator = 4
max_elem = 2
max_kernel_size = 21
title_trackbar_operator_type = 'Operator:\n 0: Opening - 1: Closing  \n 2: Gradient - 3: Top Hat \n 4: Black Hat'
title_trackbar_element_type = 'Element:\n 0: Rect - 1: Cross - 2: Ellipse'

            

Reported by Pylint.

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

Line: 7 Column: 1

              import argparse

morph_size = 0
max_operator = 4
max_elem = 2
max_kernel_size = 21
title_trackbar_operator_type = 'Operator:\n 0: Opening - 1: Closing  \n 2: Gradient - 3: Top Hat \n 4: Black Hat'
title_trackbar_element_type = 'Element:\n 0: Rect - 1: Cross - 2: Ellipse'
title_trackbar_kernel_size = 'Kernel size:\n 2n + 1'

            

Reported by Pylint.

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

Line: 8 Column: 1

              
morph_size = 0
max_operator = 4
max_elem = 2
max_kernel_size = 21
title_trackbar_operator_type = 'Operator:\n 0: Opening - 1: Closing  \n 2: Gradient - 3: Top Hat \n 4: Black Hat'
title_trackbar_element_type = 'Element:\n 0: Rect - 1: Cross - 2: Ellipse'
title_trackbar_kernel_size = 'Kernel size:\n 2n + 1'
title_window = 'Morphology Transformations Demo'

            

Reported by Pylint.

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

Line: 9 Column: 1

              morph_size = 0
max_operator = 4
max_elem = 2
max_kernel_size = 21
title_trackbar_operator_type = 'Operator:\n 0: Opening - 1: Closing  \n 2: Gradient - 3: Top Hat \n 4: Black Hat'
title_trackbar_element_type = 'Element:\n 0: Rect - 1: Cross - 2: Ellipse'
title_trackbar_kernel_size = 'Kernel size:\n 2n + 1'
title_window = 'Morphology Transformations Demo'
morph_op_dic = {0: cv.MORPH_OPEN, 1: cv.MORPH_CLOSE, 2: cv.MORPH_GRADIENT, 3: cv.MORPH_TOPHAT, 4: cv.MORPH_BLACKHAT}

            

Reported by Pylint.

modules/core/misc/java/test/Point3Test.java
21 issues
This class has too many methods, consider refactoring it.
Design

Line: 7

              import org.opencv.core.Point3;
import org.opencv.test.OpenCVTestCase;

public class Point3Test extends OpenCVTestCase {

    private Point3 p1;
    private Point3 p2;

    @Override

            

Reported by PMD.

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

Line: 9

              
public class Point3Test extends OpenCVTestCase {

    private Point3 p1;
    private Point3 p2;

    @Override
    protected void setUp() throws Exception {
        super.setUp();

            

Reported by PMD.

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

Line: 10

              public class Point3Test extends OpenCVTestCase {

    private Point3 p1;
    private Point3 p2;

    @Override
    protected void setUp() throws Exception {
        super.setUp();


            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 12

                  private Point3 p1;
    private Point3 p2;

    @Override
    protected void setUp() throws Exception {
        super.setUp();

        p1 = new Point3(2, 2, 2);
        p2 = new Point3(1, 1, 1);

            

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: 20

                      p2 = new Point3(1, 1, 1);
    }

    public void testClone() {
        Point3 truth = new Point3(1, 1, 1);
        p1 = truth.clone();
        assertEquals(truth, p1);
    }


            

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

                      assertEquals(truth, p1);
    }

    public void testCross() {
        Point3 dstPoint = p1.cross(p2);
        Point3 truth = new Point3(0, 0, 0);
        assertEquals(truth, dstPoint);
    }


            

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: 32

                      assertEquals(truth, dstPoint);
    }

    public void testDot() {
        double result = p1.dot(p2);
        assertEquals(6.0, result);
    }

    public void testEqualsObject() {

            

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: 37

                      assertEquals(6.0, result);
    }

    public void testEqualsObject() {
        boolean flag = p1.equals(p1);
        assertTrue(flag);

        flag = p1.equals(p2);
        assertFalse(flag);

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 37

                      assertEquals(6.0, result);
    }

    public void testEqualsObject() {
        boolean flag = p1.equals(p1);
        assertTrue(flag);

        flag = p1.equals(p2);
        assertFalse(flag);

            

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: 45

                      assertFalse(flag);
    }

    public void testHashCode() {
        assertEquals(p1.hashCode(), p1.hashCode());
    }

    public void testPoint3() {
        p1 = new Point3();

            

Reported by PMD.

modules/ml/misc/python/test/test_goodfeatures.py
21 issues
Unable to import 'cv2'
Error

Line: 6 Column: 1

              # Python 2/3 compatibility
from __future__ import print_function

import cv2 as cv
import numpy as np

from tests_common import NewOpenCVTests

class TestGoodFeaturesToTrack_test(NewOpenCVTests):

            

Reported by Pylint.

Unable to import 'tests_common'
Error

Line: 9 Column: 1

              import cv2 as cv
import numpy as np

from tests_common import NewOpenCVTests

class TestGoodFeaturesToTrack_test(NewOpenCVTests):
    def test_goodFeaturesToTrack(self):
        arr = self.get_sample('samples/data/lena.jpg', 0)
        original = arr.copy()

            

Reported by Pylint.

Unused numpy imported as np
Error

Line: 7 Column: 1

              from __future__ import print_function

import cv2 as cv
import numpy as np

from tests_common import NewOpenCVTests

class TestGoodFeaturesToTrack_test(NewOpenCVTests):
    def test_goodFeaturesToTrack(self):

            

Reported by Pylint.

Redefining name 'i' from outer scope (line 22)
Error

Line: 26 Column: 17

                          results2 = dict([(t, cv.goodFeaturesToTrack(arr, numPoints, t, 2, useHarrisDetector=True)) for t in threshes])
            for t in threshes:
                self.assertTrue(len(results2[t]) == len(results[t]))
                for i in range(len(results[t])):
                    self.assertTrue(cv.norm(results[t][i][0] - results2[t][i][0]) == 0)

        for t0,t1 in zip(threshes, threshes[1:]):
            r0 = results[t0]
            r1 = results[t1]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python

# Python 2/3 compatibility
from __future__ import print_function

import cv2 as cv
import numpy as np

from tests_common import NewOpenCVTests

            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              
from tests_common import NewOpenCVTests

class TestGoodFeaturesToTrack_test(NewOpenCVTests):
    def test_goodFeaturesToTrack(self):
        arr = self.get_sample('samples/data/lena.jpg', 0)
        original = arr.copy()
        threshes = [ x / 100. for x in range(1,10) ]
        numPoints = 20000

            

Reported by Pylint.

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

Line: 11 Column: 1

              
from tests_common import NewOpenCVTests

class TestGoodFeaturesToTrack_test(NewOpenCVTests):
    def test_goodFeaturesToTrack(self):
        arr = self.get_sample('samples/data/lena.jpg', 0)
        original = arr.copy()
        threshes = [ x / 100. for x in range(1,10) ]
        numPoints = 20000

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 11 Column: 1

              
from tests_common import NewOpenCVTests

class TestGoodFeaturesToTrack_test(NewOpenCVTests):
    def test_goodFeaturesToTrack(self):
        arr = self.get_sample('samples/data/lena.jpg', 0)
        original = arr.copy()
        threshes = [ x / 100. for x in range(1,10) ]
        numPoints = 20000

            

Reported by Pylint.

Method name "test_goodFeaturesToTrack" doesn't conform to snake_case naming style
Error

Line: 12 Column: 5

              from tests_common import NewOpenCVTests

class TestGoodFeaturesToTrack_test(NewOpenCVTests):
    def test_goodFeaturesToTrack(self):
        arr = self.get_sample('samples/data/lena.jpg', 0)
        original = arr.copy()
        threshes = [ x / 100. for x in range(1,10) ]
        numPoints = 20000


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 5

              from tests_common import NewOpenCVTests

class TestGoodFeaturesToTrack_test(NewOpenCVTests):
    def test_goodFeaturesToTrack(self):
        arr = self.get_sample('samples/data/lena.jpg', 0)
        original = arr.copy()
        threshes = [ x / 100. for x in range(1,10) ]
        numPoints = 20000


            

Reported by Pylint.

samples/java/tutorial_code/ImgProc/opening_closing_hats/MorphologyDemo2.java
21 issues
System.out.println is used
Design

Line: 43

                      String imagePath = args.length > 0 ? args[0] : "../data/LinuxLogo.jpg";
        matImgSrc = Imgcodecs.imread(imagePath);
        if (matImgSrc.empty()) {
            System.out.println("Empty image: " + imagePath);
            System.exit(0);
        }

        // Create and set up the window.
        frame = new JFrame("Morphology Transformations demo");

            

Reported by PMD.

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

Line: 31

                          Imgproc.MORPH_GRADIENT, Imgproc.MORPH_TOPHAT, Imgproc.MORPH_BLACKHAT };
    private static final String[] ELEMENT_TYPE = { "Rectangle", "Cross", "Ellipse" };
    private static final int MAX_KERNEL_SIZE = 21;
    private Mat matImgSrc;
    private Mat matImgDst = new Mat();
    private int morphOpType = Imgproc.MORPH_OPEN;
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private JFrame frame;

            

Reported by PMD.

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

Line: 31

                          Imgproc.MORPH_GRADIENT, Imgproc.MORPH_TOPHAT, Imgproc.MORPH_BLACKHAT };
    private static final String[] ELEMENT_TYPE = { "Rectangle", "Cross", "Ellipse" };
    private static final int MAX_KERNEL_SIZE = 21;
    private Mat matImgSrc;
    private Mat matImgDst = new Mat();
    private int morphOpType = Imgproc.MORPH_OPEN;
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private JFrame frame;

            

Reported by PMD.

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

Line: 32

                  private static final String[] ELEMENT_TYPE = { "Rectangle", "Cross", "Ellipse" };
    private static final int MAX_KERNEL_SIZE = 21;
    private Mat matImgSrc;
    private Mat matImgDst = new Mat();
    private int morphOpType = Imgproc.MORPH_OPEN;
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private JFrame frame;
    private JLabel imgLabel;

            

Reported by PMD.

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

Line: 32

                  private static final String[] ELEMENT_TYPE = { "Rectangle", "Cross", "Ellipse" };
    private static final int MAX_KERNEL_SIZE = 21;
    private Mat matImgSrc;
    private Mat matImgDst = new Mat();
    private int morphOpType = Imgproc.MORPH_OPEN;
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private JFrame frame;
    private JLabel imgLabel;

            

Reported by PMD.

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

Line: 33

                  private static final int MAX_KERNEL_SIZE = 21;
    private Mat matImgSrc;
    private Mat matImgDst = new Mat();
    private int morphOpType = Imgproc.MORPH_OPEN;
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private JFrame frame;
    private JLabel imgLabel;


            

Reported by PMD.

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

Line: 34

                  private Mat matImgSrc;
    private Mat matImgDst = new Mat();
    private int morphOpType = Imgproc.MORPH_OPEN;
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private JFrame frame;
    private JLabel imgLabel;

    public MorphologyDemo2(String[] args) {

            

Reported by PMD.

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

Line: 35

                  private Mat matImgDst = new Mat();
    private int morphOpType = Imgproc.MORPH_OPEN;
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private JFrame frame;
    private JLabel imgLabel;

    public MorphologyDemo2(String[] args) {
        String imagePath = args.length > 0 ? args[0] : "../data/LinuxLogo.jpg";

            

Reported by PMD.

Avoid using redundant field initializer for 'kernelSize'
Performance

Line: 35

                  private Mat matImgDst = new Mat();
    private int morphOpType = Imgproc.MORPH_OPEN;
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private JFrame frame;
    private JLabel imgLabel;

    public MorphologyDemo2(String[] args) {
        String imagePath = args.length > 0 ? args[0] : "../data/LinuxLogo.jpg";

            

Reported by PMD.

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

Line: 36

                  private int morphOpType = Imgproc.MORPH_OPEN;
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private JFrame frame;
    private JLabel imgLabel;

    public MorphologyDemo2(String[] args) {
        String imagePath = args.length > 0 ? args[0] : "../data/LinuxLogo.jpg";
        matImgSrc = Imgcodecs.imread(imagePath);

            

Reported by PMD.

samples/dnn/dnn_model_runner/dnn_conversion/common/test/model_test_pipeline.py
21 issues
Attempted relative import beyond top-level package
Error

Line: 5 Column: 1

              
import numpy as np

from .configs.test_config import CommonConfig
from ..utils import create_parser, plot_acc


class ModelTestPipeline:
    def __init__(

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 6 Column: 1

              import numpy as np

from .configs.test_config import CommonConfig
from ..utils import create_parser, plot_acc


class ModelTestPipeline:
    def __init__(
            self,

            

Reported by Pylint.

Value 'self._default_input_blob_preproc' is unsubscriptable
Error

Line: 46 Column: 50

                              self._test_module_config.model = self._net_model.model_path["full_path"]

            if cmd_args.default_img_preprocess:
                self._test_module_config.scale = self._default_input_blob_preproc["scale"]
                self._test_module_config.mean = self._default_input_blob_preproc["mean"]
                self._test_module_config.std = self._default_input_blob_preproc["std"]
                self._test_module_config.crop = self._default_input_blob_preproc["crop"]

                if "rsz_height" in self._default_input_blob_preproc and "rsz_width" in self._default_input_blob_preproc:

            

Reported by Pylint.

Value 'self._default_input_blob_preproc' is unsubscriptable
Error

Line: 47 Column: 49

              
            if cmd_args.default_img_preprocess:
                self._test_module_config.scale = self._default_input_blob_preproc["scale"]
                self._test_module_config.mean = self._default_input_blob_preproc["mean"]
                self._test_module_config.std = self._default_input_blob_preproc["std"]
                self._test_module_config.crop = self._default_input_blob_preproc["crop"]

                if "rsz_height" in self._default_input_blob_preproc and "rsz_width" in self._default_input_blob_preproc:
                    self._test_module_config.rsz_height = self._default_input_blob_preproc["rsz_height"]

            

Reported by Pylint.

Value 'self._default_input_blob_preproc' is unsubscriptable
Error

Line: 48 Column: 48

                          if cmd_args.default_img_preprocess:
                self._test_module_config.scale = self._default_input_blob_preproc["scale"]
                self._test_module_config.mean = self._default_input_blob_preproc["mean"]
                self._test_module_config.std = self._default_input_blob_preproc["std"]
                self._test_module_config.crop = self._default_input_blob_preproc["crop"]

                if "rsz_height" in self._default_input_blob_preproc and "rsz_width" in self._default_input_blob_preproc:
                    self._test_module_config.rsz_height = self._default_input_blob_preproc["rsz_height"]
                    self._test_module_config.rsz_width = self._default_input_blob_preproc["rsz_width"]

            

Reported by Pylint.

Value 'self._default_input_blob_preproc' is unsubscriptable
Error

Line: 49 Column: 49

                              self._test_module_config.scale = self._default_input_blob_preproc["scale"]
                self._test_module_config.mean = self._default_input_blob_preproc["mean"]
                self._test_module_config.std = self._default_input_blob_preproc["std"]
                self._test_module_config.crop = self._default_input_blob_preproc["crop"]

                if "rsz_height" in self._default_input_blob_preproc and "rsz_width" in self._default_input_blob_preproc:
                    self._test_module_config.rsz_height = self._default_input_blob_preproc["rsz_height"]
                    self._test_module_config.rsz_width = self._default_input_blob_preproc["rsz_width"]


            

Reported by Pylint.

Value 'self._default_input_blob_preproc' doesn't support membership test
Error

Line: 51 Column: 36

                              self._test_module_config.std = self._default_input_blob_preproc["std"]
                self._test_module_config.crop = self._default_input_blob_preproc["crop"]

                if "rsz_height" in self._default_input_blob_preproc and "rsz_width" in self._default_input_blob_preproc:
                    self._test_module_config.rsz_height = self._default_input_blob_preproc["rsz_height"]
                    self._test_module_config.rsz_width = self._default_input_blob_preproc["rsz_width"]

                self._test_module_param_list = [
                    '--model', self._test_module_config.model,

            

Reported by Pylint.

Value 'self._default_input_blob_preproc' doesn't support membership test
Error

Line: 51 Column: 88

                              self._test_module_config.std = self._default_input_blob_preproc["std"]
                self._test_module_config.crop = self._default_input_blob_preproc["crop"]

                if "rsz_height" in self._default_input_blob_preproc and "rsz_width" in self._default_input_blob_preproc:
                    self._test_module_config.rsz_height = self._default_input_blob_preproc["rsz_height"]
                    self._test_module_config.rsz_width = self._default_input_blob_preproc["rsz_width"]

                self._test_module_param_list = [
                    '--model', self._test_module_config.model,

            

Reported by Pylint.

Value 'self._default_input_blob_preproc' is unsubscriptable
Error

Line: 52 Column: 59

                              self._test_module_config.crop = self._default_input_blob_preproc["crop"]

                if "rsz_height" in self._default_input_blob_preproc and "rsz_width" in self._default_input_blob_preproc:
                    self._test_module_config.rsz_height = self._default_input_blob_preproc["rsz_height"]
                    self._test_module_config.rsz_width = self._default_input_blob_preproc["rsz_width"]

                self._test_module_param_list = [
                    '--model', self._test_module_config.model,
                    '--input', self._test_module_config.input_img,

            

Reported by Pylint.

Value 'self._default_input_blob_preproc' is unsubscriptable
Error

Line: 53 Column: 58

              
                if "rsz_height" in self._default_input_blob_preproc and "rsz_width" in self._default_input_blob_preproc:
                    self._test_module_config.rsz_height = self._default_input_blob_preproc["rsz_height"]
                    self._test_module_config.rsz_width = self._default_input_blob_preproc["rsz_width"]

                self._test_module_param_list = [
                    '--model', self._test_module_config.model,
                    '--input', self._test_module_config.input_img,
                    '--width', self._test_module_config.frame_width,

            

Reported by Pylint.

samples/java/tutorial_code/TrackingMotion/harris_detector/CornerHarrisDemo.java
21 issues
System.err.println is used
Design

Line: 39

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

        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: 24

              import org.opencv.imgproc.Imgproc;

class CornerHarris {
    private Mat srcGray = new Mat();
    private Mat dst = new Mat();
    private Mat dstNorm = new Mat();
    private Mat dstNormScaled = new Mat();
    private JFrame frame;
    private JLabel imgLabel;

            

Reported by PMD.

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

Line: 24

              import org.opencv.imgproc.Imgproc;

class CornerHarris {
    private Mat srcGray = new Mat();
    private Mat dst = new Mat();
    private Mat dstNorm = new Mat();
    private Mat dstNormScaled = new Mat();
    private JFrame frame;
    private JLabel imgLabel;

            

Reported by PMD.

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

Line: 25

              
class CornerHarris {
    private Mat srcGray = new Mat();
    private Mat dst = new Mat();
    private Mat dstNorm = new Mat();
    private Mat dstNormScaled = new Mat();
    private JFrame frame;
    private JLabel imgLabel;
    private JLabel cornerLabel;

            

Reported by PMD.

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

Line: 25

              
class CornerHarris {
    private Mat srcGray = new Mat();
    private Mat dst = new Mat();
    private Mat dstNorm = new Mat();
    private Mat dstNormScaled = new Mat();
    private JFrame frame;
    private JLabel imgLabel;
    private JLabel cornerLabel;

            

Reported by PMD.

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

Line: 26

              class CornerHarris {
    private Mat srcGray = new Mat();
    private Mat dst = new Mat();
    private Mat dstNorm = new Mat();
    private Mat dstNormScaled = new Mat();
    private JFrame frame;
    private JLabel imgLabel;
    private JLabel cornerLabel;
    private static final int MAX_THRESHOLD = 255;

            

Reported by PMD.

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

Line: 26

              class CornerHarris {
    private Mat srcGray = new Mat();
    private Mat dst = new Mat();
    private Mat dstNorm = new Mat();
    private Mat dstNormScaled = new Mat();
    private JFrame frame;
    private JLabel imgLabel;
    private JLabel cornerLabel;
    private static final int MAX_THRESHOLD = 255;

            

Reported by PMD.

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

Line: 27

                  private Mat srcGray = new Mat();
    private Mat dst = new Mat();
    private Mat dstNorm = new Mat();
    private Mat dstNormScaled = new Mat();
    private JFrame frame;
    private JLabel imgLabel;
    private JLabel cornerLabel;
    private static final int MAX_THRESHOLD = 255;
    private int threshold = 200;

            

Reported by PMD.

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

Line: 27

                  private Mat srcGray = new Mat();
    private Mat dst = new Mat();
    private Mat dstNorm = new Mat();
    private Mat dstNormScaled = new Mat();
    private JFrame frame;
    private JLabel imgLabel;
    private JLabel cornerLabel;
    private static final int MAX_THRESHOLD = 255;
    private int threshold = 200;

            

Reported by PMD.

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

Line: 28

                  private Mat dst = new Mat();
    private Mat dstNorm = new Mat();
    private Mat dstNormScaled = new Mat();
    private JFrame frame;
    private JLabel imgLabel;
    private JLabel cornerLabel;
    private static final int MAX_THRESHOLD = 255;
    private int threshold = 200;


            

Reported by PMD.

samples/java/tutorial_code/ImgProc/erosion_dilatation/MorphologyDemo1.java
21 issues
System.out.println is used
Design

Line: 42

                      String imagePath = args.length > 0 ? args[0] : "../data/LinuxLogo.jpg";
        matImgSrc = Imgcodecs.imread(imagePath);
        if (matImgSrc.empty()) {
            System.out.println("Empty image: " + imagePath);
            System.exit(0);
        }

        // Create and set up the window.
        frame = new JFrame("Erosion and dilatation demo");

            

Reported by PMD.

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

Line: 29

                  private static final String[] ELEMENT_TYPE = { "Rectangle", "Cross", "Ellipse" };
    private static final String[] MORPH_OP = { "Erosion", "Dilatation" };
    private static final int MAX_KERNEL_SIZE = 21;
    private Mat matImgSrc;
    private Mat matImgDst = new Mat();
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private boolean doErosion = true;
    private JFrame frame;

            

Reported by PMD.

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

Line: 29

                  private static final String[] ELEMENT_TYPE = { "Rectangle", "Cross", "Ellipse" };
    private static final String[] MORPH_OP = { "Erosion", "Dilatation" };
    private static final int MAX_KERNEL_SIZE = 21;
    private Mat matImgSrc;
    private Mat matImgDst = new Mat();
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private boolean doErosion = true;
    private JFrame frame;

            

Reported by PMD.

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

Line: 30

                  private static final String[] MORPH_OP = { "Erosion", "Dilatation" };
    private static final int MAX_KERNEL_SIZE = 21;
    private Mat matImgSrc;
    private Mat matImgDst = new Mat();
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private boolean doErosion = true;
    private JFrame frame;
    private JLabel imgLabel;

            

Reported by PMD.

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

Line: 30

                  private static final String[] MORPH_OP = { "Erosion", "Dilatation" };
    private static final int MAX_KERNEL_SIZE = 21;
    private Mat matImgSrc;
    private Mat matImgDst = new Mat();
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private boolean doErosion = true;
    private JFrame frame;
    private JLabel imgLabel;

            

Reported by PMD.

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

Line: 31

                  private static final int MAX_KERNEL_SIZE = 21;
    private Mat matImgSrc;
    private Mat matImgDst = new Mat();
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private boolean doErosion = true;
    private JFrame frame;
    private JLabel imgLabel;


            

Reported by PMD.

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

Line: 32

                  private Mat matImgSrc;
    private Mat matImgDst = new Mat();
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private boolean doErosion = true;
    private JFrame frame;
    private JLabel imgLabel;

    //! [constructor]

            

Reported by PMD.

Avoid using redundant field initializer for 'kernelSize'
Performance

Line: 32

                  private Mat matImgSrc;
    private Mat matImgDst = new Mat();
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private boolean doErosion = true;
    private JFrame frame;
    private JLabel imgLabel;

    //! [constructor]

            

Reported by PMD.

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

Line: 33

                  private Mat matImgDst = new Mat();
    private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private boolean doErosion = true;
    private JFrame frame;
    private JLabel imgLabel;

    //! [constructor]
    public MorphologyDemo1(String[] args) {

            

Reported by PMD.

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

Line: 34

                  private int elementType = Imgproc.CV_SHAPE_RECT;
    private int kernelSize = 0;
    private boolean doErosion = true;
    private JFrame frame;
    private JLabel imgLabel;

    //! [constructor]
    public MorphologyDemo1(String[] args) {
        String imagePath = args.length > 0 ? args[0] : "../data/LinuxLogo.jpg";

            

Reported by PMD.

samples/java/tutorial_code/core/AddingImages/AddingImages.java
21 issues
System.out.println is used
Design

Line: 14

              
        Mat src1, src2, dst = new Mat();

        System.out.println(" Simple Linear Blender ");
        System.out.println("-----------------------");
        System.out.println("* Enter alpha [0.0-1.0]: ");
        Scanner scan = new Scanner( System.in ).useLocale(Locale.US);
        input = scan.nextDouble();


            

Reported by PMD.

System.out.println is used
Design

Line: 15

                      Mat src1, src2, dst = new Mat();

        System.out.println(" Simple Linear Blender ");
        System.out.println("-----------------------");
        System.out.println("* Enter alpha [0.0-1.0]: ");
        Scanner scan = new Scanner( System.in ).useLocale(Locale.US);
        input = scan.nextDouble();

        if( input >= 0.0 && input <= 1.0 )

            

Reported by PMD.

System.out.println is used
Design

Line: 16

              
        System.out.println(" Simple Linear Blender ");
        System.out.println("-----------------------");
        System.out.println("* Enter alpha [0.0-1.0]: ");
        Scanner scan = new Scanner( System.in ).useLocale(Locale.US);
        input = scan.nextDouble();

        if( input >= 0.0 && input <= 1.0 )
            alpha = input;

            

Reported by PMD.

System.out.println is used
Design

Line: 28

                      src2 = Imgcodecs.imread("../../images/WindowsLogo.jpg");
        //! [load]

        if( src1.empty() == true ){ System.out.println("Error loading src1"); return;}
        if( src2.empty() == true ){ System.out.println("Error loading src2"); return;}

        //! [blend_images]
        beta = ( 1.0 - alpha );
        Core.addWeighted( src1, alpha, src2, beta, 0.0, dst);

            

Reported by PMD.

System.out.println is used
Design

Line: 29

                      //! [load]

        if( src1.empty() == true ){ System.out.println("Error loading src1"); return;}
        if( src2.empty() == true ){ System.out.println("Error loading src2"); return;}

        //! [blend_images]
        beta = ( 1.0 - alpha );
        Core.addWeighted( src1, alpha, src2, beta, 0.0, dst);
        //! [blend_images]

            

Reported by PMD.

Ensure that resources like this Scanner object are closed after use
Error

Line: 17

                      System.out.println(" Simple Linear Blender ");
        System.out.println("-----------------------");
        System.out.println("* Enter alpha [0.0-1.0]: ");
        Scanner scan = new Scanner( System.in ).useLocale(Locale.US);
        input = scan.nextDouble();

        if( input >= 0.0 && input <= 1.0 )
            alpha = input;


            

Reported by PMD.

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

Line: 28

                      src2 = Imgcodecs.imread("../../images/WindowsLogo.jpg");
        //! [load]

        if( src1.empty() == true ){ System.out.println("Error loading src1"); return;}
        if( src2.empty() == true ){ System.out.println("Error loading src2"); return;}

        //! [blend_images]
        beta = ( 1.0 - alpha );
        Core.addWeighted( src1, alpha, src2, beta, 0.0, dst);

            

Reported by PMD.

Avoid unnecessary comparisons in boolean expressions
Design

Line: 28

                      src2 = Imgcodecs.imread("../../images/WindowsLogo.jpg");
        //! [load]

        if( src1.empty() == true ){ System.out.println("Error loading src1"); return;}
        if( src2.empty() == true ){ System.out.println("Error loading src2"); return;}

        //! [blend_images]
        beta = ( 1.0 - alpha );
        Core.addWeighted( src1, alpha, src2, beta, 0.0, dst);

            

Reported by PMD.

Avoid unnecessary comparisons in boolean expressions
Design

Line: 29

                      //! [load]

        if( src1.empty() == true ){ System.out.println("Error loading src1"); return;}
        if( src2.empty() == true ){ System.out.println("Error loading src2"); return;}

        //! [blend_images]
        beta = ( 1.0 - alpha );
        Core.addWeighted( src1, alpha, src2, beta, 0.0, dst);
        //! [blend_images]

            

Reported by PMD.

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

Line: 29

                      //! [load]

        if( src1.empty() == true ){ System.out.println("Error loading src1"); return;}
        if( src2.empty() == true ){ System.out.println("Error loading src2"); return;}

        //! [blend_images]
        beta = ( 1.0 - alpha );
        Core.addWeighted( src1, alpha, src2, beta, 0.0, dst);
        //! [blend_images]

            

Reported by PMD.

samples/dnn/person_reid.py
21 issues
Unable to import 'cv2'
Error

Line: 19 Column: 1

              import argparse
import os.path
import numpy as np
import cv2 as cv

backends = (cv.dnn.DNN_BACKEND_DEFAULT,
    cv.dnn.DNN_BACKEND_INFERENCE_ENGINE,
    cv.dnn.DNN_BACKEND_OPENCV,
    cv.dnn.DNN_BACKEND_VKCOM,

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 54 Column: 5

                  images = np.array(img_list)
    images = (images / 255.0 - MEAN) / STD

    input = cv.dnn.blobFromImages(images.astype(np.float32), ddepth = cv.CV_32F)
    return input

def extract_feature(img_dir, model_path, batch_size = 32, resize_h = 384, resize_w = 128, backend=cv.dnn.DNN_BACKEND_OPENCV, target=cv.dnn.DNN_TARGET_CPU):
    """
    Extract features from images in a target directory

            

Reported by Pylint.

Redefining name 'topk' from outer scope (line 139)
Error

Line: 139 Column: 36

                  dist = np.matmul(array1, array2.T)
    return dist

def topk(query_feat, gallery_feat, topk = 5):
    """
    Return the index of top K gallery images most similar to the query images
    :param query_feat: array of feature vectors of query images
    :param gallery_feat: array of feature vectors of gallery images
    :param topk: number of gallery images to return

            

Reported by Pylint.

Redefining name 'query_feat' from outer scope (line 236)
Error

Line: 139 Column: 10

                  dist = np.matmul(array1, array2.T)
    return dist

def topk(query_feat, gallery_feat, topk = 5):
    """
    Return the index of top K gallery images most similar to the query images
    :param query_feat: array of feature vectors of query images
    :param gallery_feat: array of feature vectors of gallery images
    :param topk: number of gallery images to return

            

Reported by Pylint.

Redefining name 'gallery_feat' from outer scope (line 237)
Error

Line: 139 Column: 22

                  dist = np.matmul(array1, array2.T)
    return dist

def topk(query_feat, gallery_feat, topk = 5):
    """
    Return the index of top K gallery images most similar to the query images
    :param query_feat: array of feature vectors of query images
    :param gallery_feat: array of feature vectors of gallery images
    :param topk: number of gallery images to return

            

Reported by Pylint.

Redefining name 'gallery_names' from outer scope (line 237)
Error

Line: 185 Column: 42

                  return ret


def visualization(topk_idx, query_names, gallery_names, output_dir = 'vis'):
    """
    Visualize the retrieval results with the person ReID model
    :param topk_idx: the index of ranked gallery images for each query image
    :param query_names: the list of paths of query images
    :param gallery_names: the list of paths of gallery images

            

Reported by Pylint.

Redefining name 'query_names' from outer scope (line 236)
Error

Line: 185 Column: 29

                  return ret


def visualization(topk_idx, query_names, gallery_names, output_dir = 'vis'):
    """
    Visualize the retrieval results with the person ReID model
    :param topk_idx: the index of ranked gallery images for each query image
    :param query_names: the list of paths of query images
    :param gallery_names: the list of paths of gallery images

            

Reported by Pylint.

Redefining name 'topk_idx' from outer scope (line 239)
Error

Line: 185 Column: 19

                  return ret


def visualization(topk_idx, query_names, gallery_names, output_dir = 'vis'):
    """
    Visualize the retrieval results with the person ReID model
    :param topk_idx: the index of ranked gallery images for each query image
    :param query_names: the list of paths of query images
    :param gallery_names: the list of paths of gallery images

            

Reported by Pylint.

Line too long (155/100)
Error

Line: 57 Column: 1

                  input = cv.dnn.blobFromImages(images.astype(np.float32), ddepth = cv.CV_32F)
    return input

def extract_feature(img_dir, model_path, batch_size = 32, resize_h = 384, resize_w = 128, backend=cv.dnn.DNN_BACKEND_OPENCV, target=cv.dnn.DNN_TARGET_CPU):
    """
    Extract features from images in a target directory
    :param img_dir: the input image directory
    :param model_path: path to ReID model
    :param batch_size: the batch size for each network inference iteration

            

Reported by Pylint.

Too many arguments (7/5)
Error

Line: 57 Column: 1

                  input = cv.dnn.blobFromImages(images.astype(np.float32), ddepth = cv.CV_32F)
    return input

def extract_feature(img_dir, model_path, batch_size = 32, resize_h = 384, resize_w = 128, backend=cv.dnn.DNN_BACKEND_OPENCV, target=cv.dnn.DNN_TARGET_CPU):
    """
    Extract features from images in a target directory
    :param img_dir: the input image directory
    :param model_path: path to ReID model
    :param batch_size: the batch size for each network inference iteration

            

Reported by Pylint.