The following issues were found

modules/python/test/test_legacy.py
32 issues
Unable to import 'cv2'
Error

Line: 5 Column: 1

              from __future__ import print_function

import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests

class Hackathon244Tests(NewOpenCVTests):


            

Reported by Pylint.

Value 'objpt.shape' is unsubscriptable
Error

Line: 30 Column: 41

                      objpt = np.float64([[1,2,3]])
        imgpt0, jac0 = cv.projectPoints(objpt, np.zeros(3), np.zeros(3), np.eye(3), np.float64([]))
        imgpt1, jac1 = cv.projectPoints(objpt, np.zeros(3), np.zeros(3), np.eye(3), None)
        self.assertEqual(imgpt0.shape, (objpt.shape[0], 1, 2))
        self.assertEqual(imgpt1.shape, imgpt0.shape)
        self.assertEqual(jac0.shape, jac1.shape)
        self.assertEqual(jac0.shape[0], 2*objpt.shape[0])

    def test_estimateAffine3D(self):

            

Reported by Pylint.

Value 'objpt.shape' is unsubscriptable
Error

Line: 33 Column: 43

                      self.assertEqual(imgpt0.shape, (objpt.shape[0], 1, 2))
        self.assertEqual(imgpt1.shape, imgpt0.shape)
        self.assertEqual(jac0.shape, jac1.shape)
        self.assertEqual(jac0.shape[0], 2*objpt.shape[0])

    def test_estimateAffine3D(self):
        pattern_size = (11, 8)
        pattern_points = np.zeros((np.prod(pattern_size), 3), np.float32)
        pattern_points[:,:2] = np.indices(pattern_size).T.reshape(-1, 2)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python
from __future__ import print_function

import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests

class Hackathon244Tests(NewOpenCVTests):

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              
from tests_common import NewOpenCVTests

class Hackathon244Tests(NewOpenCVTests):

    def test_int_array(self):
        a = np.array([-1, 2, -3, 4, -5])
        absa0 = np.abs(a)
        self.assertTrue(cv.norm(a, cv.NORM_L1) == 15)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 5

              
class Hackathon244Tests(NewOpenCVTests):

    def test_int_array(self):
        a = np.array([-1, 2, -3, 4, -5])
        absa0 = np.abs(a)
        self.assertTrue(cv.norm(a, cv.NORM_L1) == 15)
        absa1 = cv.absdiff(a, 0)
        self.assertEqual(cv.norm(absa1, absa0, cv.NORM_INF), 0)

            

Reported by Pylint.

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

Line: 12 Column: 9

              class Hackathon244Tests(NewOpenCVTests):

    def test_int_array(self):
        a = np.array([-1, 2, -3, 4, -5])
        absa0 = np.abs(a)
        self.assertTrue(cv.norm(a, cv.NORM_L1) == 15)
        absa1 = cv.absdiff(a, 0)
        self.assertEqual(cv.norm(absa1, absa0, cv.NORM_INF), 0)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 5

                      absa1 = cv.absdiff(a, 0)
        self.assertEqual(cv.norm(absa1, absa0, cv.NORM_INF), 0)

    def test_imencode(self):
        a = np.zeros((480, 640), dtype=np.uint8)
        flag, ajpg = cv.imencode("img_q90.jpg", a, [cv.IMWRITE_JPEG_QUALITY, 90])
        self.assertEqual(flag, True)
        self.assertEqual(ajpg.dtype, np.uint8)
        self.assertGreater(ajpg.shape[0], 1)

            

Reported by Pylint.

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

Line: 19 Column: 9

                      self.assertEqual(cv.norm(absa1, absa0, cv.NORM_INF), 0)

    def test_imencode(self):
        a = np.zeros((480, 640), dtype=np.uint8)
        flag, ajpg = cv.imencode("img_q90.jpg", a, [cv.IMWRITE_JPEG_QUALITY, 90])
        self.assertEqual(flag, True)
        self.assertEqual(ajpg.dtype, np.uint8)
        self.assertGreater(ajpg.shape[0], 1)
        self.assertEqual(ajpg.shape[1], 1)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 5

                      self.assertGreater(ajpg.shape[0], 1)
        self.assertEqual(ajpg.shape[1], 1)

    def test_projectPoints(self):
        objpt = np.float64([[1,2,3]])
        imgpt0, jac0 = cv.projectPoints(objpt, np.zeros(3), np.zeros(3), np.eye(3), np.float64([]))
        imgpt1, jac1 = cv.projectPoints(objpt, np.zeros(3), np.zeros(3), np.eye(3), None)
        self.assertEqual(imgpt0.shape, (objpt.shape[0], 1, 2))
        self.assertEqual(imgpt1.shape, imgpt0.shape)

            

Reported by Pylint.

samples/dnn/segmentation.py
32 issues
Unable to import 'cv2'
Error

Line: 1 Column: 1

              import cv2 as cv
import argparse
import numpy as np
import sys

from common import *

backends = (cv.dnn.DNN_BACKEND_DEFAULT, cv.dnn.DNN_BACKEND_HALIDE, cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_BACKEND_OPENCV,
            cv.dnn.DNN_BACKEND_VKCOM, cv.dnn.DNN_BACKEND_CUDA)

            

Reported by Pylint.

Unused import sys
Error

Line: 4 Column: 1

              import cv2 as cv
import argparse
import numpy as np
import sys

from common import *

backends = (cv.dnn.DNN_BACKEND_DEFAULT, cv.dnn.DNN_BACKEND_HALIDE, cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_BACKEND_OPENCV,
            cv.dnn.DNN_BACKEND_VKCOM, cv.dnn.DNN_BACKEND_CUDA)

            

Reported by Pylint.

Wildcard import common
Error

Line: 6 Column: 1

              import numpy as np
import sys

from common import *

backends = (cv.dnn.DNN_BACKEND_DEFAULT, cv.dnn.DNN_BACKEND_HALIDE, cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_BACKEND_OPENCV,
            cv.dnn.DNN_BACKEND_VKCOM, cv.dnn.DNN_BACKEND_CUDA)
targets = (cv.dnn.DNN_TARGET_CPU, cv.dnn.DNN_TARGET_OPENCL, cv.dnn.DNN_TARGET_OPENCL_FP16, cv.dnn.DNN_TARGET_MYRIAD, cv.dnn.DNN_TARGET_HDDL,
           cv.dnn.DNN_TARGET_VULKAN, cv.dnn.DNN_TARGET_CUDA, cv.dnn.DNN_TARGET_CUDA_FP16)

            

Reported by Pylint.

Unused import add_argument from wildcard import
Error

Line: 6 Column: 1

              import numpy as np
import sys

from common import *

backends = (cv.dnn.DNN_BACKEND_DEFAULT, cv.dnn.DNN_BACKEND_HALIDE, cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_BACKEND_OPENCV,
            cv.dnn.DNN_BACKEND_VKCOM, cv.dnn.DNN_BACKEND_CUDA)
targets = (cv.dnn.DNN_TARGET_CPU, cv.dnn.DNN_TARGET_OPENCL, cv.dnn.DNN_TARGET_OPENCL_FP16, cv.dnn.DNN_TARGET_MYRIAD, cv.dnn.DNN_TARGET_HDDL,
           cv.dnn.DNN_TARGET_VULKAN, cv.dnn.DNN_TARGET_CUDA, cv.dnn.DNN_TARGET_CUDA_FP16)

            

Reported by Pylint.

Redefining name 'classes' from outer scope (line 54)
Error

Line: 66 Column: 16

                      colors = [np.array(color.split(' '), np.uint8) for color in f.read().rstrip('\n').split('\n')]

legend = None
def showLegend(classes):
    global legend
    if not classes is None and legend is None:
        blockHeight = 30
        assert(len(classes) == len(colors))


            

Reported by Pylint.

Using the global statement
Error

Line: 67 Column: 5

              
legend = None
def showLegend(classes):
    global legend
    if not classes is None and legend is None:
        blockHeight = 30
        assert(len(classes) == len(colors))

        legend = np.zeros((blockHeight * len(colors), 200, 3), np.uint8)

            

Reported by Pylint.

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

Line: 73 Column: 13

                      assert(len(classes) == len(colors))

        legend = np.zeros((blockHeight * len(colors), 200, 3), np.uint8)
        for i in range(len(classes)):
            block = legend[i * blockHeight:(i + 1) * blockHeight]
            block[:,:] = colors[i]
            cv.putText(block, classes[i], (0, blockHeight//2), cv.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255))

        cv.namedWindow('Legend', cv.WINDOW_NORMAL)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import cv2 as cv
import argparse
import numpy as np
import sys

from common import *

backends = (cv.dnn.DNN_BACKEND_DEFAULT, cv.dnn.DNN_BACKEND_HALIDE, cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_BACKEND_OPENCV,
            cv.dnn.DNN_BACKEND_VKCOM, cv.dnn.DNN_BACKEND_CUDA)

            

Reported by Pylint.

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

Line: 2 Column: 1

              import cv2 as cv
import argparse
import numpy as np
import sys

from common import *

backends = (cv.dnn.DNN_BACKEND_DEFAULT, cv.dnn.DNN_BACKEND_HALIDE, cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_BACKEND_OPENCV,
            cv.dnn.DNN_BACKEND_VKCOM, cv.dnn.DNN_BACKEND_CUDA)

            

Reported by Pylint.

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

Line: 4 Column: 1

              import cv2 as cv
import argparse
import numpy as np
import sys

from common import *

backends = (cv.dnn.DNN_BACKEND_DEFAULT, cv.dnn.DNN_BACKEND_HALIDE, cv.dnn.DNN_BACKEND_INFERENCE_ENGINE, cv.dnn.DNN_BACKEND_OPENCV,
            cv.dnn.DNN_BACKEND_VKCOM, cv.dnn.DNN_BACKEND_CUDA)

            

Reported by Pylint.

modules/java/test/android_test/src/org/opencv/test/android/UtilsTest.java
31 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 20

              
public class UtilsTest extends OpenCVTestCase {

    public void testBitmapToMat() {
        BitmapFactory.Options opt16 = new BitmapFactory.Options();
        opt16.inPreferredConfig = Bitmap.Config.RGB_565;
        Bitmap bmp16 = BitmapFactory.decodeFile(OpenCVTestRunner.LENA_PATH, opt16);
        Mat m16 = new Mat();
        Utils.bitmapToMat(bmp16, m16);

            

Reported by PMD.

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

Line: 20

              
public class UtilsTest extends OpenCVTestCase {

    public void testBitmapToMat() {
        BitmapFactory.Options opt16 = new BitmapFactory.Options();
        opt16.inPreferredConfig = Bitmap.Config.RGB_565;
        Bitmap bmp16 = BitmapFactory.decodeFile(OpenCVTestRunner.LENA_PATH, opt16);
        Mat m16 = new Mat();
        Utils.bitmapToMat(bmp16, m16);

            

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

                      assertTrue(maxDiff <= 8 /* 8 == 2^8 / 2^5 */);
    }

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

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

            

Reported by PMD.

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

Line: 44

                  }

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

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

            

Reported by PMD.

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

Line: 47

                      fail("Not yet implemented");
    }

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

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

            

Reported by PMD.

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

Line: 51

                      fail("Not yet implemented");
    }

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

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

            

Reported by PMD.

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

Line: 55

                      fail("Not yet implemented");
    }

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

    public void testMatToBitmap() {
        Mat imgBGR = Imgcodecs.imread( OpenCVTestRunner.LENA_PATH );

            

Reported by PMD.

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

Line: 59

                      fail("Not yet implemented");
    }

    public void testMatToBitmap() {
        Mat imgBGR = Imgcodecs.imread( OpenCVTestRunner.LENA_PATH );
        assertTrue(imgBGR != null && !imgBGR.empty() && imgBGR.channels() == 3);

        Mat m16 = new Mat(imgBGR.rows(), imgBGR.cols(), CvType.CV_8UC4);
        Mat m32 = new Mat(imgBGR.rows(), imgBGR.cols(), CvType.CV_8UC4);

            

Reported by PMD.

The method 'testMatToBitmap()' has a NCSS line count of 65.
Design

Line: 59

                      fail("Not yet implemented");
    }

    public void testMatToBitmap() {
        Mat imgBGR = Imgcodecs.imread( OpenCVTestRunner.LENA_PATH );
        assertTrue(imgBGR != null && !imgBGR.empty() && imgBGR.channels() == 3);

        Mat m16 = new Mat(imgBGR.rows(), imgBGR.cols(), CvType.CV_8UC4);
        Mat m32 = new Mat(imgBGR.rows(), imgBGR.cols(), CvType.CV_8UC4);

            

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

                      fail("Not yet implemented");
    }

    public void testMatToBitmap() {
        Mat imgBGR = Imgcodecs.imread( OpenCVTestRunner.LENA_PATH );
        assertTrue(imgBGR != null && !imgBGR.empty() && imgBGR.channels() == 3);

        Mat m16 = new Mat(imgBGR.rows(), imgBGR.cols(), CvType.CV_8UC4);
        Mat m32 = new Mat(imgBGR.rows(), imgBGR.cols(), CvType.CV_8UC4);

            

Reported by PMD.

platforms/android/service/engine/src/org/opencv/engine/OpenCVEngineService.java
31 issues
The class 'OpenCVEngineService' has a Standard Cyclomatic Complexity of 4 (Highest = 12).
Design

Line: 18

              import java.util.List;
import org.xmlpull.v1.XmlPullParser;

public class OpenCVEngineService extends Service {
    private static final String TAG = "OpenCVEngine/Service";
    private IBinder mEngineInterface = null;
    private List<LibVariant> variants = new ArrayList<LibVariant>();

    private class LibVariant {

            

Reported by PMD.

The class 'OpenCVEngineService' has a Modified Cyclomatic Complexity of 4 (Highest = 12).
Design

Line: 18

              import java.util.List;
import org.xmlpull.v1.XmlPullParser;

public class OpenCVEngineService extends Service {
    private static final String TAG = "OpenCVEngine/Service";
    private IBinder mEngineInterface = null;
    private List<LibVariant> variants = new ArrayList<LibVariant>();

    private class LibVariant {

            

Reported by PMD.

Avoid using redundant field initializer for 'mEngineInterface'
Performance

Line: 20

              
public class OpenCVEngineService extends Service {
    private static final String TAG = "OpenCVEngine/Service";
    private IBinder mEngineInterface = null;
    private List<LibVariant> variants = new ArrayList<LibVariant>();

    private class LibVariant {
        public String version;
        public List<String> files;

            

Reported by PMD.

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

Line: 20

              
public class OpenCVEngineService extends Service {
    private static final String TAG = "OpenCVEngine/Service";
    private IBinder mEngineInterface = null;
    private List<LibVariant> variants = new ArrayList<LibVariant>();

    private class LibVariant {
        public String version;
        public List<String> files;

            

Reported by PMD.

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

Line: 21

              public class OpenCVEngineService extends Service {
    private static final String TAG = "OpenCVEngine/Service";
    private IBinder mEngineInterface = null;
    private List<LibVariant> variants = new ArrayList<LibVariant>();

    private class LibVariant {
        public String version;
        public List<String> files;


            

Reported by PMD.

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

Line: 21

              public class OpenCVEngineService extends Service {
    private static final String TAG = "OpenCVEngine/Service";
    private IBinder mEngineInterface = null;
    private List<LibVariant> variants = new ArrayList<LibVariant>();

    private class LibVariant {
        public String version;
        public List<String> files;


            

Reported by PMD.

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

Line: 24

                  private List<LibVariant> variants = new ArrayList<LibVariant>();

    private class LibVariant {
        public String version;
        public List<String> files;

        public void parseFile(XmlResourceParser p) {
            try {
                int eventType = p.getEventType();

            

Reported by PMD.

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

Line: 25

              
    private class LibVariant {
        public String version;
        public List<String> files;

        public void parseFile(XmlResourceParser p) {
            try {
                int eventType = p.getEventType();
                while (eventType != XmlPullParser.END_DOCUMENT) {

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 32

                              int eventType = p.getEventType();
                while (eventType != XmlPullParser.END_DOCUMENT) {
                    if (eventType == XmlPullParser.START_TAG) {
                        if (p.getName().equals("library")) {
                            parseLibraryTag(p);
                        } else if (p.getName().equals("file")) {
                            parseFileTag(p);
                        }
                    }

            

Reported by PMD.

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

Line: 32

                              int eventType = p.getEventType();
                while (eventType != XmlPullParser.END_DOCUMENT) {
                    if (eventType == XmlPullParser.START_TAG) {
                        if (p.getName().equals("library")) {
                            parseLibraryTag(p);
                        } else if (p.getName().equals("file")) {
                            parseFileTag(p);
                        }
                    }

            

Reported by PMD.

samples/java/tutorial_code/ImgProc/threshold_inRange/ThresholdInRange.java
31 issues
System.err.println is used
Design

Line: 57

                      cap = new VideoCapture(cameraDevice);
        //! [cap]
        if (!cap.isOpened()) {
            System.err.println("Cannot open camera: " + cameraDevice);
            System.exit(0);
        }
        if (!cap.read(matFrame)) {
            System.err.println("Cannot read camera stream.");
            System.exit(0);

            

Reported by PMD.

System.err.println is used
Design

Line: 61

                          System.exit(0);
        }
        if (!cap.read(matFrame)) {
            System.err.println("Cannot read camera stream.");
            System.exit(0);
        }

        //! [window]
        // Create and set up the window.

            

Reported by PMD.

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

Line: 35

                  private static final String HIGH_H_NAME = "High H";
    private static final String HIGH_S_NAME = "High S";
    private static final String HIGH_V_NAME = "High V";
    private JSlider sliderLowH;
    private JSlider sliderHighH;
    private JSlider sliderLowS;
    private JSlider sliderHighS;
    private JSlider sliderLowV;
    private JSlider sliderHighV;

            

Reported by PMD.

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

Line: 36

                  private static final String HIGH_S_NAME = "High S";
    private static final String HIGH_V_NAME = "High V";
    private JSlider sliderLowH;
    private JSlider sliderHighH;
    private JSlider sliderLowS;
    private JSlider sliderHighS;
    private JSlider sliderLowV;
    private JSlider sliderHighV;
    private VideoCapture cap;

            

Reported by PMD.

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

Line: 37

                  private static final String HIGH_V_NAME = "High V";
    private JSlider sliderLowH;
    private JSlider sliderHighH;
    private JSlider sliderLowS;
    private JSlider sliderHighS;
    private JSlider sliderLowV;
    private JSlider sliderHighV;
    private VideoCapture cap;
    private Mat matFrame = new Mat();

            

Reported by PMD.

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

Line: 38

                  private JSlider sliderLowH;
    private JSlider sliderHighH;
    private JSlider sliderLowS;
    private JSlider sliderHighS;
    private JSlider sliderLowV;
    private JSlider sliderHighV;
    private VideoCapture cap;
    private Mat matFrame = new Mat();
    private JFrame frame;

            

Reported by PMD.

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

Line: 39

                  private JSlider sliderHighH;
    private JSlider sliderLowS;
    private JSlider sliderHighS;
    private JSlider sliderLowV;
    private JSlider sliderHighV;
    private VideoCapture cap;
    private Mat matFrame = new Mat();
    private JFrame frame;
    private JLabel imgCaptureLabel;

            

Reported by PMD.

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

Line: 40

                  private JSlider sliderLowS;
    private JSlider sliderHighS;
    private JSlider sliderLowV;
    private JSlider sliderHighV;
    private VideoCapture cap;
    private Mat matFrame = new Mat();
    private JFrame frame;
    private JLabel imgCaptureLabel;
    private JLabel imgDetectionLabel;

            

Reported by PMD.

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

Line: 41

                  private JSlider sliderHighS;
    private JSlider sliderLowV;
    private JSlider sliderHighV;
    private VideoCapture cap;
    private Mat matFrame = new Mat();
    private JFrame frame;
    private JLabel imgCaptureLabel;
    private JLabel imgDetectionLabel;
    private CaptureTask captureTask;

            

Reported by PMD.

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

Line: 41

                  private JSlider sliderHighS;
    private JSlider sliderLowV;
    private JSlider sliderHighV;
    private VideoCapture cap;
    private Mat matFrame = new Mat();
    private JFrame frame;
    private JLabel imgCaptureLabel;
    private JLabel imgDetectionLabel;
    private CaptureTask captureTask;

            

Reported by PMD.

samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CameraCalibrator.java
31 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 23

              public class CameraCalibrator {
    private static final String TAG = "OCV::CameraCalibrator";

    private final Size mPatternSize = new Size(4, 11);
    private final int mCornersSize = (int)(mPatternSize.width * mPatternSize.height);
    private boolean mPatternWasFound = false;
    private MatOfPoint2f mCorners = new MatOfPoint2f();
    private List<Mat> mCornersBuffer = new ArrayList<>();
    private boolean mIsCalibrated = false;

            

Reported by PMD.

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

Line: 24

                  private static final String TAG = "OCV::CameraCalibrator";

    private final Size mPatternSize = new Size(4, 11);
    private final int mCornersSize = (int)(mPatternSize.width * mPatternSize.height);
    private boolean mPatternWasFound = false;
    private MatOfPoint2f mCorners = new MatOfPoint2f();
    private List<Mat> mCornersBuffer = new ArrayList<>();
    private boolean mIsCalibrated = false;


            

Reported by PMD.

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

Line: 25

              
    private final Size mPatternSize = new Size(4, 11);
    private final int mCornersSize = (int)(mPatternSize.width * mPatternSize.height);
    private boolean mPatternWasFound = false;
    private MatOfPoint2f mCorners = new MatOfPoint2f();
    private List<Mat> mCornersBuffer = new ArrayList<>();
    private boolean mIsCalibrated = false;

    private Mat mCameraMatrix = new Mat();

            

Reported by PMD.

Avoid using redundant field initializer for 'mPatternWasFound'
Performance

Line: 25

              
    private final Size mPatternSize = new Size(4, 11);
    private final int mCornersSize = (int)(mPatternSize.width * mPatternSize.height);
    private boolean mPatternWasFound = false;
    private MatOfPoint2f mCorners = new MatOfPoint2f();
    private List<Mat> mCornersBuffer = new ArrayList<>();
    private boolean mIsCalibrated = false;

    private Mat mCameraMatrix = new Mat();

            

Reported by PMD.

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

Line: 26

                  private final Size mPatternSize = new Size(4, 11);
    private final int mCornersSize = (int)(mPatternSize.width * mPatternSize.height);
    private boolean mPatternWasFound = false;
    private MatOfPoint2f mCorners = new MatOfPoint2f();
    private List<Mat> mCornersBuffer = new ArrayList<>();
    private boolean mIsCalibrated = false;

    private Mat mCameraMatrix = new Mat();
    private Mat mDistortionCoefficients = new Mat();

            

Reported by PMD.

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

Line: 26

                  private final Size mPatternSize = new Size(4, 11);
    private final int mCornersSize = (int)(mPatternSize.width * mPatternSize.height);
    private boolean mPatternWasFound = false;
    private MatOfPoint2f mCorners = new MatOfPoint2f();
    private List<Mat> mCornersBuffer = new ArrayList<>();
    private boolean mIsCalibrated = false;

    private Mat mCameraMatrix = new Mat();
    private Mat mDistortionCoefficients = new Mat();

            

Reported by PMD.

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

Line: 27

                  private final int mCornersSize = (int)(mPatternSize.width * mPatternSize.height);
    private boolean mPatternWasFound = false;
    private MatOfPoint2f mCorners = new MatOfPoint2f();
    private List<Mat> mCornersBuffer = new ArrayList<>();
    private boolean mIsCalibrated = false;

    private Mat mCameraMatrix = new Mat();
    private Mat mDistortionCoefficients = new Mat();
    private int mFlags;

            

Reported by PMD.

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

Line: 27

                  private final int mCornersSize = (int)(mPatternSize.width * mPatternSize.height);
    private boolean mPatternWasFound = false;
    private MatOfPoint2f mCorners = new MatOfPoint2f();
    private List<Mat> mCornersBuffer = new ArrayList<>();
    private boolean mIsCalibrated = false;

    private Mat mCameraMatrix = new Mat();
    private Mat mDistortionCoefficients = new Mat();
    private int mFlags;

            

Reported by PMD.

Avoid using redundant field initializer for 'mIsCalibrated'
Performance

Line: 28

                  private boolean mPatternWasFound = false;
    private MatOfPoint2f mCorners = new MatOfPoint2f();
    private List<Mat> mCornersBuffer = new ArrayList<>();
    private boolean mIsCalibrated = false;

    private Mat mCameraMatrix = new Mat();
    private Mat mDistortionCoefficients = new Mat();
    private int mFlags;
    private double mRms;

            

Reported by PMD.

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

Line: 28

                  private boolean mPatternWasFound = false;
    private MatOfPoint2f mCorners = new MatOfPoint2f();
    private List<Mat> mCornersBuffer = new ArrayList<>();
    private boolean mIsCalibrated = false;

    private Mat mCameraMatrix = new Mat();
    private Mat mDistortionCoefficients = new Mat();
    private int mFlags;
    private double mRms;

            

Reported by PMD.

samples/python/turing.py
31 issues
Unable to import 'cv2'
Error

Line: 19 Column: 1

                  xrange = range

import numpy as np
import cv2 as cv
from common import draw_str
import getopt, sys
from itertools import count

help_message = '''

            

Reported by Pylint.

Reimport 'sys' (imported line 12)
Error

Line: 21 Column: 1

              import numpy as np
import cv2 as cv
from common import draw_str
import getopt, sys
from itertools import count

help_message = '''
USAGE: turing.py [-o <output.avi>]


            

Reported by Pylint.

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

Line: 16 Column: 5

              PY3 = sys.version_info[0] == 3

if PY3:
    xrange = range

import numpy as np
import cv2 as cv
from common import draw_str
import getopt, sys

            

Reported by Pylint.

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

Line: 18 Column: 1

              if PY3:
    xrange = range

import numpy as np
import cv2 as cv
from common import draw_str
import getopt, sys
from itertools import count


            

Reported by Pylint.

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

Line: 19 Column: 1

                  xrange = range

import numpy as np
import cv2 as cv
from common import draw_str
import getopt, sys
from itertools import count

help_message = '''

            

Reported by Pylint.

Import "from common import draw_str" should be placed at the top of the module
Error

Line: 20 Column: 1

              
import numpy as np
import cv2 as cv
from common import draw_str
import getopt, sys
from itertools import count

help_message = '''
USAGE: turing.py [-o <output.avi>]

            

Reported by Pylint.

Import "import getopt, sys" should be placed at the top of the module
Error

Line: 21 Column: 1

              import numpy as np
import cv2 as cv
from common import draw_str
import getopt, sys
from itertools import count

help_message = '''
USAGE: turing.py [-o <output.avi>]


            

Reported by Pylint.

Import "import getopt, sys" should be placed at the top of the module
Error

Line: 21 Column: 1

              import numpy as np
import cv2 as cv
from common import draw_str
import getopt, sys
from itertools import count

help_message = '''
USAGE: turing.py [-o <output.avi>]


            

Reported by Pylint.

Imports from package sys are not grouped
Error

Line: 21 Column: 1

              import numpy as np
import cv2 as cv
from common import draw_str
import getopt, sys
from itertools import count

help_message = '''
USAGE: turing.py [-o <output.avi>]


            

Reported by Pylint.

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

Line: 21 Column: 1

              import numpy as np
import cv2 as cv
from common import draw_str
import getopt, sys
from itertools import count

help_message = '''
USAGE: turing.py [-o <output.avi>]


            

Reported by Pylint.

samples/python/fitline.py
31 issues
Unable to import 'cv2'
Error

Line: 31 Column: 1

              PY3 = sys.version_info[0] == 3

import numpy as np
import cv2 as cv

# built-in modules
import itertools as it

# local modules

            

Reported by Pylint.

Instance of 'cycle' has no 'next' member
Error

Line: 55 Column: 21

              if PY3:
    cur_func_name = next(dist_func_names)
else:
    cur_func_name = dist_func_names.next()

def update(_=None):
    noise = cv.getTrackbarPos('noise', 'fit line')
    n = cv.getTrackbarPos('point n', 'fit line')
    r = cv.getTrackbarPos('outlier %', 'fit line') / 100.0

            

Reported by Pylint.

Instance of 'cycle' has no 'next' member
Error

Line: 95 Column: 33

                          if PY3:
                cur_func_name = next(dist_func_names)
            else:
                cur_func_name = dist_func_names.next()
        if ch == 27:
            break

    print('Done')


            

Reported by Pylint.

Using the global statement
Error

Line: 91 Column: 13

                      update()
        ch = cv.waitKey(0)
        if ch == ord('f'):
            global cur_func_name
            if PY3:
                cur_func_name = next(dist_func_names)
            else:
                cur_func_name = dist_func_names.next()
        if ch == 27:

            

Reported by Pylint.

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

Line: 30 Column: 1

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

import numpy as np
import cv2 as cv

# built-in modules
import itertools as it


            

Reported by Pylint.

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

Line: 31 Column: 1

              PY3 = sys.version_info[0] == 3

import numpy as np
import cv2 as cv

# built-in modules
import itertools as it

# local modules

            

Reported by Pylint.

Import "import itertools as it" should be placed at the top of the module
Error

Line: 34 Column: 1

              import cv2 as cv

# built-in modules
import itertools as it

# local modules
from common import draw_str



            

Reported by Pylint.

standard import "import itertools as it" should be placed before "import numpy as np"
Error

Line: 34 Column: 1

              import cv2 as cv

# built-in modules
import itertools as it

# local modules
from common import draw_str



            

Reported by Pylint.

Import "from common import draw_str" should be placed at the top of the module
Error

Line: 37 Column: 1

              import itertools as it

# local modules
from common import draw_str


w, h = 512, 256

def toint(p):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 42 Column: 1

              
w, h = 512, 256

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

def sample_line(p1, p2, n, noise=0.0):
    p1 = np.float32(p1)
    t = np.random.rand(n,1)

            

Reported by Pylint.

samples/python/tutorial_code/core/file_input_output/file_input_output.py
31 issues
Unable to import 'cv2'
Error

Line: 4 Column: 1

              from __future__ import print_function

import numpy as np
import cv2 as cv
import sys

def help(filename):
    print (
        '''

            

Reported by Pylint.

Redefining built-in 'help'
Error

Line: 7 Column: 1

              import cv2 as cv
import sys

def help(filename):
    print (
        '''
        {0} shows the usage of the OpenCV serialization functionality. \n\n
        usage:\n
            python3 {0} outputfile.yml.gz\n\n

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import print_function

import numpy as np
import cv2 as cv
import sys

def help(filename):
    print (
        '''

            

Reported by Pylint.

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

Line: 5 Column: 1

              
import numpy as np
import cv2 as cv
import sys

def help(filename):
    print (
        '''
        {0} shows the usage of the OpenCV serialization functionality. \n\n

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

              import cv2 as cv
import sys

def help(filename):
    print (
        '''
        {0} shows the usage of the OpenCV serialization functionality. \n\n
        usage:\n
            python3 {0} outputfile.yml.gz\n\n

            

Reported by Pylint.

Missing class docstring
Error

Line: 21 Column: 1

                      '''.format(filename)
    )

class MyData:
    A = 97
    X = np.pi
    name = 'mydata1234'

    def __repr__(self):

            

Reported by Pylint.

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

Line: 27 Column: 9

                  name = 'mydata1234'

    def __repr__(self):
        s = '{ name = ' + self.name + ', X = ' + str(self.X)
        s = s + ', A = ' +  str(self.A) + '}'
        return s

    ## [inside]
    def write(self, fs, name):

            

Reported by Pylint.

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

Line: 28 Column: 9

              
    def __repr__(self):
        s = '{ name = ' + self.name + ', X = ' + str(self.X)
        s = s + ', A = ' +  str(self.A) + '}'
        return s

    ## [inside]
    def write(self, fs, name):
        fs.startWriteStruct(name, cv.FileNode_MAP|cv.FileNode_FLOW)

            

Reported by Pylint.

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

Line: 32 Column: 5

                      return s

    ## [inside]
    def write(self, fs, name):
        fs.startWriteStruct(name, cv.FileNode_MAP|cv.FileNode_FLOW)
        fs.write('A', self.A)
        fs.write('X', self.X)
        fs.write('name', self.name)
        fs.endWriteStruct()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 32 Column: 5

                      return s

    ## [inside]
    def write(self, fs, name):
        fs.startWriteStruct(name, cv.FileNode_MAP|cv.FileNode_FLOW)
        fs.write('A', self.A)
        fs.write('X', self.X)
        fs.write('name', self.name)
        fs.endWriteStruct()

            

Reported by Pylint.

samples/python/camshift.py
30 issues
Unable to import 'cv2'
Error

Line: 34 Column: 1

                  xrange = range

import numpy as np
import cv2 as cv

# local module
import video
from video import presets


            

Reported by Pylint.

Redefining name 'video_src' from outer scope (line 125)
Error

Line: 42 Column: 24

              

class App(object):
    def __init__(self, video_src):
        self.cam = video.create_capture(video_src, presets['cube'])
        _ret, self.frame = self.cam.read()
        cv.namedWindow('camshift')
        cv.setMouseCallback('camshift', self.onmouse)


            

Reported by Pylint.

Unused argument 'flags'
Error

Line: 53 Column: 36

                      self.show_backproj = False
        self.track_window = None

    def onmouse(self, event, x, y, flags, param):
        if event == cv.EVENT_LBUTTONDOWN:
            self.drag_start = (x, y)
            self.track_window = None
        if self.drag_start:
            xmin = min(x, self.drag_start[0])

            

Reported by Pylint.

Unused argument 'param'
Error

Line: 53 Column: 43

                      self.show_backproj = False
        self.track_window = None

    def onmouse(self, event, x, y, flags, param):
        if event == cv.EVENT_LBUTTONDOWN:
            self.drag_start = (x, y)
            self.track_window = None
        if self.drag_start:
            xmin = min(x, self.drag_start[0])

            

Reported by Pylint.

Attribute 'hist' defined outside __init__
Error

Line: 90 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.show_hist()

                vis_roi = vis[y0:y1, x0:x1]
                cv.bitwise_not(vis_roi, vis_roi)
                vis[mask == 0] = 0

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 108 Column: 17

                                  vis[:] = prob[...,np.newaxis]
                try:
                    cv.ellipse(vis, track_box, (0, 0, 255), 2)
                except:
                    print(track_box)

            cv.imshow('camshift', vis)

            ch = cv.waitKey(5)

            

Reported by Pylint.

Reimport 'sys' (imported line 27)
Error

Line: 123 Column: 5

              
if __name__ == '__main__':
    print(__doc__)
    import sys
    try:
        video_src = sys.argv[1]
    except:
        video_src = 0
    App(video_src).run()

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 126 Column: 5

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

            

Reported by Pylint.

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

Line: 31 Column: 5

              PY3 = sys.version_info[0] == 3

if PY3:
    xrange = range

import numpy as np
import cv2 as cv

# local module

            

Reported by Pylint.

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

Line: 33 Column: 1

              if PY3:
    xrange = range

import numpy as np
import cv2 as cv

# local module
import video
from video import presets

            

Reported by Pylint.