The following issues were found

modules/video/misc/python/test/test_tracking.py
17 issues
Unable to import 'cv2'
Error

Line: 4 Column: 1

              #!/usr/bin/env python
import os
import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests, unittest

class tracking_test(NewOpenCVTests):


            

Reported by Pylint.

Unable to import 'tests_common'
Error

Line: 6 Column: 1

              import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests, unittest

class tracking_test(NewOpenCVTests):

    def test_createTracker(self):
        t = cv.TrackerMIL_create()

            

Reported by Pylint.

Unused import os
Error

Line: 2 Column: 1

              #!/usr/bin/env python
import os
import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests, unittest

class tracking_test(NewOpenCVTests):


            

Reported by Pylint.

Unused numpy imported as np
Error

Line: 3 Column: 1

              #!/usr/bin/env python
import os
import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests, unittest

class tracking_test(NewOpenCVTests):


            

Reported by Pylint.

Unused unittest imported from tests_common
Error

Line: 6 Column: 1

              import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests, unittest

class tracking_test(NewOpenCVTests):

    def test_createTracker(self):
        t = cv.TrackerMIL_create()

            

Reported by Pylint.

Unused variable 't'
Error

Line: 11 Column: 9

              class tracking_test(NewOpenCVTests):

    def test_createTracker(self):
        t = cv.TrackerMIL_create()
        try:
            t = cv.TrackerGOTURN_create()
        except cv.error as e:
            pass  # may fail due to missing DL model files


            

Reported by Pylint.

Unused variable 'e'
Error

Line: 14 Column: 9

                      t = cv.TrackerMIL_create()
        try:
            t = cv.TrackerGOTURN_create()
        except cv.error as e:
            pass  # may fail due to missing DL model files


if __name__ == '__main__':
    NewOpenCVTests.bootstrap()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python
import os
import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests, unittest

class tracking_test(NewOpenCVTests):


            

Reported by Pylint.

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

Line: 8 Column: 1

              
from tests_common import NewOpenCVTests, unittest

class tracking_test(NewOpenCVTests):

    def test_createTracker(self):
        t = cv.TrackerMIL_create()
        try:
            t = cv.TrackerGOTURN_create()

            

Reported by Pylint.

Missing class docstring
Error

Line: 8 Column: 1

              
from tests_common import NewOpenCVTests, unittest

class tracking_test(NewOpenCVTests):

    def test_createTracker(self):
        t = cv.TrackerMIL_create()
        try:
            t = cv.TrackerGOTURN_create()

            

Reported by Pylint.

modules/calib3d/misc/python/test/test_calibration.py
17 issues
Unable to import 'cv2'
Error

Line: 12 Column: 1

              from __future__ import print_function

import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests

class calibration_test(NewOpenCVTests):


            

Reported by Pylint.

Unable to import 'tests_common'
Error

Line: 14 Column: 1

              import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests

class calibration_test(NewOpenCVTests):

    def test_calibration(self):
        img_names = []

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 16 Column: 1

              
from tests_common import NewOpenCVTests

class calibration_test(NewOpenCVTests):

    def test_calibration(self):
        img_names = []
        for i in range(1, 15):
            if i < 10:

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              
from tests_common import NewOpenCVTests

class calibration_test(NewOpenCVTests):

    def test_calibration(self):
        img_names = []
        for i in range(1, 15):
            if i < 10:

            

Reported by Pylint.

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

Line: 16 Column: 1

              
from tests_common import NewOpenCVTests

class calibration_test(NewOpenCVTests):

    def test_calibration(self):
        img_names = []
        for i in range(1, 15):
            if i < 10:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 5

              
class calibration_test(NewOpenCVTests):

    def test_calibration(self):
        img_names = []
        for i in range(1, 15):
            if i < 10:
                img_names.append('samples/data/left0{}.jpg'.format(str(i)))
            elif i != 10:

            

Reported by Pylint.

Too many local variables (25/15)
Error

Line: 18 Column: 5

              
class calibration_test(NewOpenCVTests):

    def test_calibration(self):
        img_names = []
        for i in range(1, 15):
            if i < 10:
                img_names.append('samples/data/left0{}.jpg'.format(str(i)))
            elif i != 10:

            

Reported by Pylint.

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

Line: 34 Column: 12

              
        obj_points = []
        img_points = []
        h, w = 0, 0
        for fn in img_names:
            img = self.get_sample(fn, 0)
            if img is None:
                continue


            

Reported by Pylint.

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

Line: 34 Column: 9

              
        obj_points = []
        img_points = []
        h, w = 0, 0
        for fn in img_names:
            img = self.get_sample(fn, 0)
            if img is None:
                continue


            

Reported by Pylint.

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

Line: 35 Column: 13

                      obj_points = []
        img_points = []
        h, w = 0, 0
        for fn in img_names:
            img = self.get_sample(fn, 0)
            if img is None:
                continue

            h, w = img.shape[:2]

            

Reported by Pylint.

modules/core/misc/java/test/KeyPointTest.java
17 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 9

              
public class KeyPointTest extends OpenCVTestCase {

    private float angle;
    private int classId;
    private KeyPoint keyPoint;
    private int octave;
    private float response;
    private float size;

            

Reported by PMD.

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

Line: 10

              public class KeyPointTest extends OpenCVTestCase {

    private float angle;
    private int classId;
    private KeyPoint keyPoint;
    private int octave;
    private float response;
    private float size;
    private float x;

            

Reported by PMD.

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

Line: 11

              
    private float angle;
    private int classId;
    private KeyPoint keyPoint;
    private int octave;
    private float response;
    private float size;
    private float x;
    private float y;

            

Reported by PMD.

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

Line: 12

                  private float angle;
    private int classId;
    private KeyPoint keyPoint;
    private int octave;
    private float response;
    private float size;
    private float x;
    private float y;


            

Reported by PMD.

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

Line: 13

                  private int classId;
    private KeyPoint keyPoint;
    private int octave;
    private float response;
    private float size;
    private float x;
    private float y;

    @Override

            

Reported by PMD.

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

Line: 14

                  private KeyPoint keyPoint;
    private int octave;
    private float response;
    private float size;
    private float x;
    private float y;

    @Override
    protected void setUp() throws Exception {

            

Reported by PMD.

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

Line: 15

                  private int octave;
    private float response;
    private float size;
    private float x;
    private float y;

    @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: 16

                  private float response;
    private float size;
    private float x;
    private float y;

    @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: 18

                  private float x;
    private float y;

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

        keyPoint = null;
        x = 1.0f;

            

Reported by PMD.

Assigning an Object to null is a code smell. Consider refactoring.
Error

Line: 22

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

        keyPoint = null;
        x = 1.0f;
        y = 2.0f;
        size = 3.0f;
        angle = 30.0f;
        response = 2.0f;

            

Reported by PMD.

modules/core/misc/java/test/DMatchTest.java
17 issues
JUnit tests should include assert() or fail()
Design

Line: 8

              import junit.framework.TestCase;

public class DMatchTest extends TestCase {
    public void testDMatch() {
        new DMatch();
    }

    public void testDMatchIntIntFloat() {
        DMatch dm1 = new DMatch(1, 4, 4.0f);

            

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

              import junit.framework.TestCase;

public class DMatchTest extends TestCase {
    public void testDMatch() {
        new DMatch();
    }

    public void testDMatchIntIntFloat() {
        DMatch dm1 = new DMatch(1, 4, 4.0f);

            

Reported by PMD.

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

Line: 12

                      new DMatch();
    }

    public void testDMatchIntIntFloat() {
        DMatch dm1 = new DMatch(1, 4, 4.0f);

        assertEquals(1, dm1.queryIdx);
        assertEquals(4, dm1.trainIdx);
        assertEquals(4.0f, dm1.distance);

            

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

                      new DMatch();
    }

    public void testDMatchIntIntFloat() {
        DMatch dm1 = new DMatch(1, 4, 4.0f);

        assertEquals(1, dm1.queryIdx);
        assertEquals(4, dm1.trainIdx);
        assertEquals(4.0f, dm1.distance);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                  public void testDMatchIntIntFloat() {
        DMatch dm1 = new DMatch(1, 4, 4.0f);

        assertEquals(1, dm1.queryIdx);
        assertEquals(4, dm1.trainIdx);
        assertEquals(4.0f, dm1.distance);
    }

    public void testDMatchIntIntIntFloat() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      DMatch dm1 = new DMatch(1, 4, 4.0f);

        assertEquals(1, dm1.queryIdx);
        assertEquals(4, dm1.trainIdx);
        assertEquals(4.0f, dm1.distance);
    }

    public void testDMatchIntIntIntFloat() {
        DMatch dm2 = new DMatch(2, 6, -1, 8.0f);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

              
        assertEquals(1, dm1.queryIdx);
        assertEquals(4, dm1.trainIdx);
        assertEquals(4.0f, dm1.distance);
    }

    public void testDMatchIntIntIntFloat() {
        DMatch dm2 = new DMatch(2, 6, -1, 8.0f);


            

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

                      assertEquals(4.0f, dm1.distance);
    }

    public void testDMatchIntIntIntFloat() {
        DMatch dm2 = new DMatch(2, 6, -1, 8.0f);

        assertEquals(2, dm2.queryIdx);
        assertEquals(6, dm2.trainIdx);
        assertEquals(-1, dm2.imgIdx);

            

Reported by PMD.

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

Line: 20

                      assertEquals(4.0f, dm1.distance);
    }

    public void testDMatchIntIntIntFloat() {
        DMatch dm2 = new DMatch(2, 6, -1, 8.0f);

        assertEquals(2, dm2.queryIdx);
        assertEquals(6, dm2.trainIdx);
        assertEquals(-1, dm2.imgIdx);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 23

                  public void testDMatchIntIntIntFloat() {
        DMatch dm2 = new DMatch(2, 6, -1, 8.0f);

        assertEquals(2, dm2.queryIdx);
        assertEquals(6, dm2.trainIdx);
        assertEquals(-1, dm2.imgIdx);
        assertEquals(8.0f, dm2.distance);
    }


            

Reported by PMD.

samples/java/tutorial_code/features2D/feature_flann_matcher/SURFFLANNMatchingDemo.java
17 issues
System.err.println is used
Design

Line: 24

                      Mat img1 = Imgcodecs.imread(filename1, Imgcodecs.IMREAD_GRAYSCALE);
        Mat img2 = Imgcodecs.imread(filename2, Imgcodecs.IMREAD_GRAYSCALE);
        if (img1.empty() || img2.empty()) {
            System.err.println("Cannot read images!");
            System.exit(0);
        }

        //-- Step 1: Detect the keypoints using SURF Detector, compute the descriptors
        double hessianThreshold = 400;

            

Reported by PMD.

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

Line: 23

                      String filename2 = args.length > 1 ? args[1] : "../data/box_in_scene.png";
        Mat img1 = Imgcodecs.imread(filename1, Imgcodecs.IMREAD_GRAYSCALE);
        Mat img2 = Imgcodecs.imread(filename2, Imgcodecs.IMREAD_GRAYSCALE);
        if (img1.empty() || img2.empty()) {
            System.err.println("Cannot read images!");
            System.exit(0);
        }

        //-- Step 1: Detect the keypoints using SURF Detector, compute the descriptors

            

Reported by PMD.

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

Line: 23

                      String filename2 = args.length > 1 ? args[1] : "../data/box_in_scene.png";
        Mat img1 = Imgcodecs.imread(filename1, Imgcodecs.IMREAD_GRAYSCALE);
        Mat img2 = Imgcodecs.imread(filename2, Imgcodecs.IMREAD_GRAYSCALE);
        if (img1.empty() || img2.empty()) {
            System.err.println("Cannot read images!");
            System.exit(0);
        }

        //-- Step 1: Detect the keypoints using SURF Detector, compute the descriptors

            

Reported by PMD.

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

Line: 25

                      Mat img2 = Imgcodecs.imread(filename2, Imgcodecs.IMREAD_GRAYSCALE);
        if (img1.empty() || img2.empty()) {
            System.err.println("Cannot read images!");
            System.exit(0);
        }

        //-- Step 1: Detect the keypoints using SURF Detector, compute the descriptors
        double hessianThreshold = 400;
        int nOctaves = 4, nOctaveLayers = 3;

            

Reported by PMD.

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

Line: 42

                      // Since SURF is a floating-point descriptor NORM_L2 is used
        DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.FLANNBASED);
        List<MatOfDMatch> knnMatches = new ArrayList<>();
        matcher.knnMatch(descriptors1, descriptors2, knnMatches, 2);

        //-- Filter matches using the Lowe's ratio test
        float ratioThresh = 0.7f;
        List<DMatch> listOfGoodMatches = new ArrayList<>();
        for (int i = 0; i < knnMatches.size(); i++) {

            

Reported by PMD.

This for loop can be replaced by a foreach loop
Design

Line: 47

                      //-- Filter matches using the Lowe's ratio test
        float ratioThresh = 0.7f;
        List<DMatch> listOfGoodMatches = new ArrayList<>();
        for (int i = 0; i < knnMatches.size(); i++) {
            if (knnMatches.get(i).rows() > 1) {
                DMatch[] matches = knnMatches.get(i).toArray();
                if (matches[0].distance < ratioThresh * matches[1].distance) {
                    listOfGoodMatches.add(matches[0]);
                }

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 48

                      float ratioThresh = 0.7f;
        List<DMatch> listOfGoodMatches = new ArrayList<>();
        for (int i = 0; i < knnMatches.size(); i++) {
            if (knnMatches.get(i).rows() > 1) {
                DMatch[] matches = knnMatches.get(i).toArray();
                if (matches[0].distance < ratioThresh * matches[1].distance) {
                    listOfGoodMatches.add(matches[0]);
                }
            }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 48

                      float ratioThresh = 0.7f;
        List<DMatch> listOfGoodMatches = new ArrayList<>();
        for (int i = 0; i < knnMatches.size(); i++) {
            if (knnMatches.get(i).rows() > 1) {
                DMatch[] matches = knnMatches.get(i).toArray();
                if (matches[0].distance < ratioThresh * matches[1].distance) {
                    listOfGoodMatches.add(matches[0]);
                }
            }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 49

                      List<DMatch> listOfGoodMatches = new ArrayList<>();
        for (int i = 0; i < knnMatches.size(); i++) {
            if (knnMatches.get(i).rows() > 1) {
                DMatch[] matches = knnMatches.get(i).toArray();
                if (matches[0].distance < ratioThresh * matches[1].distance) {
                    listOfGoodMatches.add(matches[0]);
                }
            }
        }

            

Reported by PMD.

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

Line: 67

                      HighGui.imshow("Good Matches", imgMatches);
        HighGui.waitKey(0);

        System.exit(0);
    }
}

public class SURFFLANNMatchingDemo {
    public static void main(String[] args) {

            

Reported by PMD.

modules/python/test/test_cuda.py
17 issues
Unable to import 'cv2'
Error

Line: 11 Column: 1

              from __future__ import print_function

import numpy as np
import cv2 as cv
import os

from tests_common import NewOpenCVTests, unittest

class cuda_test(NewOpenCVTests):

            

Reported by Pylint.

Unused import os
Error

Line: 12 Column: 1

              
import numpy as np
import cv2 as cv
import os

from tests_common import NewOpenCVTests, unittest

class cuda_test(NewOpenCVTests):
    def setUp(self):

            

Reported by Pylint.

Unused unittest imported from tests_common
Error

Line: 14 Column: 1

              import cv2 as cv
import os

from tests_common import NewOpenCVTests, unittest

class cuda_test(NewOpenCVTests):
    def setUp(self):
        super(cuda_test, self).setUp()
        if not cv.cuda.getCudaEnabledDeviceCount():

            

Reported by Pylint.

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

Line: 12 Column: 1

              
import numpy as np
import cv2 as cv
import os

from tests_common import NewOpenCVTests, unittest

class cuda_test(NewOpenCVTests):
    def setUp(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              
from tests_common import NewOpenCVTests, unittest

class cuda_test(NewOpenCVTests):
    def setUp(self):
        super(cuda_test, self).setUp()
        if not cv.cuda.getCudaEnabledDeviceCount():
            self.skipTest("No CUDA-capable device is detected")


            

Reported by Pylint.

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

Line: 16 Column: 1

              
from tests_common import NewOpenCVTests, unittest

class cuda_test(NewOpenCVTests):
    def setUp(self):
        super(cuda_test, self).setUp()
        if not cv.cuda.getCudaEnabledDeviceCount():
            self.skipTest("No CUDA-capable device is detected")


            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 18 Column: 9

              
class cuda_test(NewOpenCVTests):
    def setUp(self):
        super(cuda_test, self).setUp()
        if not cv.cuda.getCudaEnabledDeviceCount():
            self.skipTest("No CUDA-capable device is detected")

    def test_cuda_upload_download(self):
        npMat = (np.random.random((128, 128, 3)) * 255).astype(np.uint8)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 5

                      if not cv.cuda.getCudaEnabledDeviceCount():
            self.skipTest("No CUDA-capable device is detected")

    def test_cuda_upload_download(self):
        npMat = (np.random.random((128, 128, 3)) * 255).astype(np.uint8)
        cuMat = cv.cuda_GpuMat()
        cuMat.upload(npMat)

        self.assertTrue(np.allclose(cuMat.download(), npMat))

            

Reported by Pylint.

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

Line: 23 Column: 9

                          self.skipTest("No CUDA-capable device is detected")

    def test_cuda_upload_download(self):
        npMat = (np.random.random((128, 128, 3)) * 255).astype(np.uint8)
        cuMat = cv.cuda_GpuMat()
        cuMat.upload(npMat)

        self.assertTrue(np.allclose(cuMat.download(), npMat))


            

Reported by Pylint.

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

Line: 24 Column: 9

              
    def test_cuda_upload_download(self):
        npMat = (np.random.random((128, 128, 3)) * 255).astype(np.uint8)
        cuMat = cv.cuda_GpuMat()
        cuMat.upload(npMat)

        self.assertTrue(np.allclose(cuMat.download(), npMat))

    def test_cuda_upload_download_stream(self):

            

Reported by Pylint.

modules/python/test/test_dft.py
17 issues
Unable to import 'cv2'
Error

Line: 10 Column: 1

              # Python 2/3 compatibility
from __future__ import print_function

import cv2 as cv
import numpy as np
import sys

from tests_common import NewOpenCVTests


            

Reported by Pylint.

Unused import sys
Error

Line: 12 Column: 1

              
import cv2 as cv
import numpy as np
import sys

from tests_common import NewOpenCVTests

class dft_test(NewOpenCVTests):
    def test_dft(self):

            

Reported by Pylint.

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

Line: 12 Column: 1

              
import cv2 as cv
import numpy as np
import sys

from tests_common import NewOpenCVTests

class dft_test(NewOpenCVTests):
    def test_dft(self):

            

Reported by Pylint.

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

Line: 16 Column: 1

              
from tests_common import NewOpenCVTests

class dft_test(NewOpenCVTests):
    def test_dft(self):

        img = self.get_sample('samples/data/rubberwhale1.png', 0)
        eps = 0.001


            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              
from tests_common import NewOpenCVTests

class dft_test(NewOpenCVTests):
    def test_dft(self):

        img = self.get_sample('samples/data/rubberwhale1.png', 0)
        eps = 0.001


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

              from tests_common import NewOpenCVTests

class dft_test(NewOpenCVTests):
    def test_dft(self):

        img = self.get_sample('samples/data/rubberwhale1.png', 0)
        eps = 0.001

        #test direct transform

            

Reported by Pylint.

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

Line: 23 Column: 9

                      eps = 0.001

        #test direct transform
        refDft = np.fft.fft2(img)
        refDftShift = np.fft.fftshift(refDft)
        refMagnitide = np.log(1.0 + np.abs(refDftShift))

        testDft = cv.dft(np.float32(img),flags = cv.DFT_COMPLEX_OUTPUT)
        testDftShift = np.fft.fftshift(testDft)

            

Reported by Pylint.

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

Line: 24 Column: 9

              
        #test direct transform
        refDft = np.fft.fft2(img)
        refDftShift = np.fft.fftshift(refDft)
        refMagnitide = np.log(1.0 + np.abs(refDftShift))

        testDft = cv.dft(np.float32(img),flags = cv.DFT_COMPLEX_OUTPUT)
        testDftShift = np.fft.fftshift(testDft)
        testMagnitude = np.log(1.0 + cv.magnitude(testDftShift[:,:,0], testDftShift[:,:,1]))

            

Reported by Pylint.

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

Line: 25 Column: 9

                      #test direct transform
        refDft = np.fft.fft2(img)
        refDftShift = np.fft.fftshift(refDft)
        refMagnitide = np.log(1.0 + np.abs(refDftShift))

        testDft = cv.dft(np.float32(img),flags = cv.DFT_COMPLEX_OUTPUT)
        testDftShift = np.fft.fftshift(testDft)
        testMagnitude = np.log(1.0 + cv.magnitude(testDftShift[:,:,0], testDftShift[:,:,1]))


            

Reported by Pylint.

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

Line: 27 Column: 9

                      refDftShift = np.fft.fftshift(refDft)
        refMagnitide = np.log(1.0 + np.abs(refDftShift))

        testDft = cv.dft(np.float32(img),flags = cv.DFT_COMPLEX_OUTPUT)
        testDftShift = np.fft.fftshift(testDft)
        testMagnitude = np.log(1.0 + cv.magnitude(testDftShift[:,:,0], testDftShift[:,:,1]))

        refMagnitide = cv.normalize(refMagnitide, 0.0, 1.0, cv.NORM_MINMAX)
        testMagnitude = cv.normalize(testMagnitude, 0.0, 1.0, cv.NORM_MINMAX)

            

Reported by Pylint.

samples/java/tutorial_code/ImgProc/morph_lines_detection/Morphology_3.java
17 issues
System.out.println is used
Design

Line: 18

                      //! [load_image]
        // Check number of arguments
        if (args.length == 0){
            System.out.println("Not enough parameters!");
            System.out.println("Program Arguments: [image_path]");
            System.exit(-1);
        }

        // Load the image

            

Reported by PMD.

System.out.println is used
Design

Line: 19

                      // Check number of arguments
        if (args.length == 0){
            System.out.println("Not enough parameters!");
            System.out.println("Program Arguments: [image_path]");
            System.exit(-1);
        }

        // Load the image
        Mat src = Imgcodecs.imread(args[0]);

            

Reported by PMD.

System.out.println is used
Design

Line: 28

              
        // Check if image is loaded fine
        if( src.empty() ) {
            System.out.println("Error opening image: " + args[0]);
            System.exit(-1);
        }

        // Show source image
        HighGui.imshow("src", src);

            

Reported by PMD.

Avoid really long methods.
Design

Line: 13

              
class Morphology_3Run {

    public void run(String[] args) {

        //! [load_image]
        // Check number of arguments
        if (args.length == 0){
            System.out.println("Not enough parameters!");

            

Reported by PMD.

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

Line: 20

                      if (args.length == 0){
            System.out.println("Not enough parameters!");
            System.out.println("Program Arguments: [image_path]");
            System.exit(-1);
        }

        // Load the image
        Mat src = Imgcodecs.imread(args[0]);


            

Reported by PMD.

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

Line: 27

                      Mat src = Imgcodecs.imread(args[0]);

        // Check if image is loaded fine
        if( src.empty() ) {
            System.out.println("Error opening image: " + args[0]);
            System.exit(-1);
        }

        // Show source image

            

Reported by PMD.

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

Line: 29

                      // Check if image is loaded fine
        if( src.empty() ) {
            System.out.println("Error opening image: " + args[0]);
            System.exit(-1);
        }

        // Show source image
        HighGui.imshow("src", src);
        //! [load_image]

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 40

                      // Transform source image to gray if it is not already
        Mat gray = new Mat();

        if (src.channels() == 3)
        {
            Imgproc.cvtColor(src, gray, Imgproc.COLOR_BGR2GRAY);
        }
        else
        {

            

Reported by PMD.

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

Line: 40

                      // Transform source image to gray if it is not already
        Mat gray = new Mat();

        if (src.channels() == 3)
        {
            Imgproc.cvtColor(src, gray, Imgproc.COLOR_BGR2GRAY);
        }
        else
        {

            

Reported by PMD.

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

Line: 71

              
        //! [horiz]
        // Specify size on horizontal axis
        int horizontal_size = horizontal.cols() / 30;

        // Create structure element for extracting horizontal lines through morphology operations
        Mat horizontalStructure = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(horizontal_size,1));

        // Apply morphology operations

            

Reported by PMD.

samples/java/tutorial_code/ImgTrans/canny_detector/CannyDetectorDemo.java
17 issues
System.out.println is used
Design

Line: 40

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

        // Create and set up the window.
        frame = new JFrame("Edge Map (Canny detector demo)");

            

Reported by PMD.

Avoid using redundant field initializer for 'lowThresh'
Performance

Line: 28

                  private static final int RATIO = 3;
    private static final int KERNEL_SIZE = 3;
    private static final Size BLUR_SIZE = new Size(3,3);
    private int lowThresh = 0;
    private Mat src;
    private Mat srcBlur = new Mat();
    private Mat detectedEdges = new Mat();
    private Mat dst = new Mat();
    private JFrame frame;

            

Reported by PMD.

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

Line: 28

                  private static final int RATIO = 3;
    private static final int KERNEL_SIZE = 3;
    private static final Size BLUR_SIZE = new Size(3,3);
    private int lowThresh = 0;
    private Mat src;
    private Mat srcBlur = new Mat();
    private Mat detectedEdges = new Mat();
    private Mat dst = new Mat();
    private JFrame frame;

            

Reported by PMD.

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

Line: 29

                  private static final int KERNEL_SIZE = 3;
    private static final Size BLUR_SIZE = new Size(3,3);
    private int lowThresh = 0;
    private Mat src;
    private Mat srcBlur = new Mat();
    private Mat detectedEdges = new Mat();
    private Mat dst = new Mat();
    private JFrame frame;
    private JLabel imgLabel;

            

Reported by PMD.

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

Line: 29

                  private static final int KERNEL_SIZE = 3;
    private static final Size BLUR_SIZE = new Size(3,3);
    private int lowThresh = 0;
    private Mat src;
    private Mat srcBlur = new Mat();
    private Mat detectedEdges = new Mat();
    private Mat dst = 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: 30

                  private static final Size BLUR_SIZE = new Size(3,3);
    private int lowThresh = 0;
    private Mat src;
    private Mat srcBlur = new Mat();
    private Mat detectedEdges = new Mat();
    private Mat dst = new Mat();
    private JFrame frame;
    private JLabel imgLabel;


            

Reported by PMD.

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

Line: 30

                  private static final Size BLUR_SIZE = new Size(3,3);
    private int lowThresh = 0;
    private Mat src;
    private Mat srcBlur = new Mat();
    private Mat detectedEdges = new Mat();
    private Mat dst = new Mat();
    private JFrame frame;
    private JLabel imgLabel;


            

Reported by PMD.

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

Line: 31

                  private int lowThresh = 0;
    private Mat src;
    private Mat srcBlur = new Mat();
    private Mat detectedEdges = new Mat();
    private Mat dst = new Mat();
    private JFrame frame;
    private JLabel imgLabel;

    public CannyDetectorDemo(String[] args) {

            

Reported by PMD.

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

Line: 31

                  private int lowThresh = 0;
    private Mat src;
    private Mat srcBlur = new Mat();
    private Mat detectedEdges = new Mat();
    private Mat dst = new Mat();
    private JFrame frame;
    private JLabel imgLabel;

    public CannyDetectorDemo(String[] args) {

            

Reported by PMD.

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

Line: 32

                  private Mat src;
    private Mat srcBlur = new Mat();
    private Mat detectedEdges = new Mat();
    private Mat dst = new Mat();
    private JFrame frame;
    private JLabel imgLabel;

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

            

Reported by PMD.

samples/python/squares.py
17 issues
Unable to import 'cv2'
Error

Line: 18 Column: 1

                  xrange = range

import numpy as np
import cv2 as cv


def angle_cos(p0, p1, p2):
    d1, d2 = (p0-p1).astype('float'), (p2-p1).astype('float')
    return abs( np.dot(d1, d2) / np.sqrt( np.dot(d1, d1)*np.dot(d2, d2) ) )

            

Reported by Pylint.

Redefining built-in 'bin'
Error

Line: 31 Column: 17

                  for gray in cv.split(img):
        for thrs in xrange(0, 255, 26):
            if thrs == 0:
                bin = cv.Canny(gray, 0, 50, apertureSize=5)
                bin = cv.dilate(bin, None)
            else:
                _retval, bin = cv.threshold(gray, thrs, 255, cv.THRESH_BINARY)
            contours, _hierarchy = cv.findContours(bin, cv.RETR_LIST, cv.CHAIN_APPROX_SIMPLE)
            for cnt in contours:

            

Reported by Pylint.

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

Line: 15 Column: 5

              PY3 = sys.version_info[0] == 3

if PY3:
    xrange = range

import numpy as np
import cv2 as cv



            

Reported by Pylint.

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

Line: 17 Column: 1

              if PY3:
    xrange = range

import numpy as np
import cv2 as cv


def angle_cos(p0, p1, p2):
    d1, d2 = (p0-p1).astype('float'), (p2-p1).astype('float')

            

Reported by Pylint.

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

Line: 18 Column: 1

                  xrange = range

import numpy as np
import cv2 as cv


def angle_cos(p0, p1, p2):
    d1, d2 = (p0-p1).astype('float'), (p2-p1).astype('float')
    return abs( np.dot(d1, d2) / np.sqrt( np.dot(d1, d1)*np.dot(d2, d2) ) )

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 1

              import cv2 as cv


def angle_cos(p0, p1, p2):
    d1, d2 = (p0-p1).astype('float'), (p2-p1).astype('float')
    return abs( np.dot(d1, d2) / np.sqrt( np.dot(d1, d1)*np.dot(d2, d2) ) )

def find_squares(img):
    img = cv.GaussianBlur(img, (5, 5), 0)

            

Reported by Pylint.

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

Line: 21 Column: 1

              import cv2 as cv


def angle_cos(p0, p1, p2):
    d1, d2 = (p0-p1).astype('float'), (p2-p1).astype('float')
    return abs( np.dot(d1, d2) / np.sqrt( np.dot(d1, d1)*np.dot(d2, d2) ) )

def find_squares(img):
    img = cv.GaussianBlur(img, (5, 5), 0)

            

Reported by Pylint.

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

Line: 21 Column: 1

              import cv2 as cv


def angle_cos(p0, p1, p2):
    d1, d2 = (p0-p1).astype('float'), (p2-p1).astype('float')
    return abs( np.dot(d1, d2) / np.sqrt( np.dot(d1, d1)*np.dot(d2, d2) ) )

def find_squares(img):
    img = cv.GaussianBlur(img, (5, 5), 0)

            

Reported by Pylint.

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

Line: 21 Column: 1

              import cv2 as cv


def angle_cos(p0, p1, p2):
    d1, d2 = (p0-p1).astype('float'), (p2-p1).astype('float')
    return abs( np.dot(d1, d2) / np.sqrt( np.dot(d1, d1)*np.dot(d2, d2) ) )

def find_squares(img):
    img = cv.GaussianBlur(img, (5, 5), 0)

            

Reported by Pylint.

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

Line: 22 Column: 9

              

def angle_cos(p0, p1, p2):
    d1, d2 = (p0-p1).astype('float'), (p2-p1).astype('float')
    return abs( np.dot(d1, d2) / np.sqrt( np.dot(d1, d1)*np.dot(d2, d2) ) )

def find_squares(img):
    img = cv.GaussianBlur(img, (5, 5), 0)
    squares = []

            

Reported by Pylint.