The following issues were found

samples/java/tutorial_code/ImgTrans/remap/RemapDemo.java
16 issues
System.err.println is used
Design

Line: 62

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

        //! [Create]

            

Reported by PMD.

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

Line: 9

              import org.opencv.imgproc.Imgproc;

class Remap {
    private Mat mapX = new Mat();
    private Mat mapY = new Mat();
    private Mat dst = new Mat();
    private int ind = 0;

    //! [Update]

            

Reported by PMD.

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

Line: 10

              
class Remap {
    private Mat mapX = new Mat();
    private Mat mapY = new Mat();
    private Mat dst = new Mat();
    private int ind = 0;

    //! [Update]
    private void updateMap() {

            

Reported by PMD.

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

Line: 11

              class Remap {
    private Mat mapX = new Mat();
    private Mat mapY = new Mat();
    private Mat dst = new Mat();
    private int ind = 0;

    //! [Update]
    private void updateMap() {
        float buffX[] = new float[(int) (mapX.total() * mapX.channels())];

            

Reported by PMD.

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

Line: 11

              class Remap {
    private Mat mapX = new Mat();
    private Mat mapY = new Mat();
    private Mat dst = new Mat();
    private int ind = 0;

    //! [Update]
    private void updateMap() {
        float buffX[] = new float[(int) (mapX.total() * mapX.channels())];

            

Reported by PMD.

Avoid using redundant field initializer for 'ind'
Performance

Line: 12

                  private Mat mapX = new Mat();
    private Mat mapY = new Mat();
    private Mat dst = new Mat();
    private int ind = 0;

    //! [Update]
    private void updateMap() {
        float buffX[] = new float[(int) (mapX.total() * mapX.channels())];
        mapX.get(0, 0, buffX);

            

Reported by PMD.

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

Line: 12

                  private Mat mapX = new Mat();
    private Mat mapY = new Mat();
    private Mat dst = new Mat();
    private int ind = 0;

    //! [Update]
    private void updateMap() {
        float buffX[] = new float[(int) (mapX.total() * mapX.channels())];
        mapX.get(0, 0, buffX);

            

Reported by PMD.

The method 'updateMap()' has a cyclomatic complexity of 11.
Design

Line: 15

                  private int ind = 0;

    //! [Update]
    private void updateMap() {
        float buffX[] = new float[(int) (mapX.total() * mapX.channels())];
        mapX.get(0, 0, buffX);

        float buffY[] = new float[(int) (mapY.total() * mapY.channels())];
        mapY.get(0, 0, buffY);

            

Reported by PMD.

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

Line: 61

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


            

Reported by PMD.

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

Line: 63

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

        //! [Create]
        mapX = new Mat(src.size(), CvType.CV_32F);

            

Reported by PMD.

doc/tools/doxygen_scan.py
16 issues
Unused import traceback
Error

Line: 1 Column: 1

              import traceback

class Symbol(object):
    def __init__(self, anchor, type, cppname):
        self.anchor = anchor
        self.type = type
        self.cppname = cppname
        #if anchor == 'ga586ebfb0a7fb604b35a23d85391329be':
        #    print(repr(self))

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 4 Column: 32

              import traceback

class Symbol(object):
    def __init__(self, anchor, type, cppname):
        self.anchor = anchor
        self.type = type
        self.cppname = cppname
        #if anchor == 'ga586ebfb0a7fb604b35a23d85391329be':
        #    print(repr(self))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import traceback

class Symbol(object):
    def __init__(self, anchor, type, cppname):
        self.anchor = anchor
        self.type = type
        self.cppname = cppname
        #if anchor == 'ga586ebfb0a7fb604b35a23d85391329be':
        #    print(repr(self))

            

Reported by Pylint.

Class 'Symbol' inherits from object, can be safely removed from bases in python3
Error

Line: 3 Column: 1

              import traceback

class Symbol(object):
    def __init__(self, anchor, type, cppname):
        self.anchor = anchor
        self.type = type
        self.cppname = cppname
        #if anchor == 'ga586ebfb0a7fb604b35a23d85391329be':
        #    print(repr(self))

            

Reported by Pylint.

Missing class docstring
Error

Line: 3 Column: 1

              import traceback

class Symbol(object):
    def __init__(self, anchor, type, cppname):
        self.anchor = anchor
        self.type = type
        self.cppname = cppname
        #if anchor == 'ga586ebfb0a7fb604b35a23d85391329be':
        #    print(repr(self))

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 3 Column: 1

              import traceback

class Symbol(object):
    def __init__(self, anchor, type, cppname):
        self.anchor = anchor
        self.type = type
        self.cppname = cppname
        #if anchor == 'ga586ebfb0a7fb604b35a23d85391329be':
        #    print(repr(self))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 1

                  def __repr__(self):
        return '%s:%s@%s' % (self.type, self.cppname, self.anchor)

def add_to_file(files_dict, file, anchor):
    anchors = files_dict.setdefault(file, [])
    anchors.append(anchor)


def scan_namespace_constants(ns, ns_name, files_dict):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 1

                  anchors.append(anchor)


def scan_namespace_constants(ns, ns_name, files_dict):
    constants = ns.findall("./member[@kind='enumvalue']")
    for c in constants:
        c_name = c.find("./name").text
        name = ns_name + '::' + c_name
        file = c.find("./anchorfile").text

            

Reported by Pylint.

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

Line: 20 Column: 1

                  anchors.append(anchor)


def scan_namespace_constants(ns, ns_name, files_dict):
    constants = ns.findall("./member[@kind='enumvalue']")
    for c in constants:
        c_name = c.find("./name").text
        name = ns_name + '::' + c_name
        file = c.find("./anchorfile").text

            

Reported by Pylint.

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

Line: 22 Column: 9

              
def scan_namespace_constants(ns, ns_name, files_dict):
    constants = ns.findall("./member[@kind='enumvalue']")
    for c in constants:
        c_name = c.find("./name").text
        name = ns_name + '::' + c_name
        file = c.find("./anchorfile").text
        anchor = c.find("./anchor").text
        #print('    CONST: {} => {}#{}'.format(name, file, anchor))

            

Reported by Pylint.

samples/java/tutorial_code/video/meanshift/MeanshiftDemo.java
15 issues
System.out.println is used
Design

Line: 14

                      String filename = args[0];
        VideoCapture capture = new VideoCapture(filename);
        if (!capture.isOpened()) {
            System.out.println("Unable to open file!");
            System.exit(-1);
        }
        Mat frame = new Mat(), hsv_roi = new Mat(), mask = new Mat(), roi;

        // take the first frame of the video

            

Reported by PMD.

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

Line: 15

                      VideoCapture capture = new VideoCapture(filename);
        if (!capture.isOpened()) {
            System.out.println("Unable to open file!");
            System.exit(-1);
        }
        Mat frame = new Mat(), hsv_roi = new Mat(), mask = new Mat(), roi;

        // take the first frame of the video
        capture.read(frame);

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 41

                      TermCriteria term_crit = new TermCriteria(TermCriteria.EPS | TermCriteria.COUNT, 10, 1);

        while (true) {
            Mat hsv = new Mat() , dst = new Mat();
            capture.read(frame);
            if (frame.empty()) {
                break;
            }
            Imgproc.cvtColor(frame, hsv, Imgproc.COLOR_BGR2HSV);

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 41

                      TermCriteria term_crit = new TermCriteria(TermCriteria.EPS | TermCriteria.COUNT, 10, 1);

        while (true) {
            Mat hsv = new Mat() , dst = new Mat();
            capture.read(frame);
            if (frame.empty()) {
                break;
            }
            Imgproc.cvtColor(frame, hsv, Imgproc.COLOR_BGR2HSV);

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 53

                          Video.meanShift(dst, track_window, term_crit);

            // Draw it on image
            Imgproc.rectangle(frame, track_window, new Scalar(255, 0, 0), 2);
            HighGui.imshow("img2", frame);

            int keyboard = HighGui.waitKey(30);
            if (keyboard == 'q' || keyboard == 27) {
                break;

            

Reported by PMD.

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

Line: 61

                              break;
            }
        }
        System.exit(0);
    }
}

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

            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 65

                  }
}

public class MeanshiftDemo {
    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        new Meanshift().run(args);
    }
}

            

Reported by PMD.

Avoid unused imports such as 'org.opencv.core'
Design

Line: 2

              import java.util.Arrays;
import org.opencv.core.*;
import org.opencv.highgui.HighGui;
import org.opencv.imgproc.Imgproc;
import org.opencv.video.Video;
import org.opencv.videoio.VideoCapture;


class Meanshift {

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 10

              

class Meanshift {
    public void run(String[] args) {
        String filename = args[0];
        VideoCapture capture = new VideoCapture(filename);
        if (!capture.isOpened()) {
            System.out.println("Unable to open file!");
            System.exit(-1);

            

Reported by PMD.

Use one line for each declaration, it enhances code readability.
Design

Line: 17

                          System.out.println("Unable to open file!");
            System.exit(-1);
        }
        Mat frame = new Mat(), hsv_roi = new Mat(), mask = new Mat(), roi;

        // take the first frame of the video
        capture.read(frame);

        //setup initial location of window

            

Reported by PMD.

modules/features2d/misc/java/test/SURFFeatureDetectorTest.java
15 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 22

              
public class SURFFeatureDetectorTest extends OpenCVTestCase {

    Feature2D detector;
    int matSize;
    KeyPoint[] truth;

    private Mat getMaskImg() {
        Mat mask = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255));

            

Reported by PMD.

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

Line: 23

              public class SURFFeatureDetectorTest extends OpenCVTestCase {

    Feature2D detector;
    int matSize;
    KeyPoint[] truth;

    private Mat getMaskImg() {
        Mat mask = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255));
        Mat right = mask.submat(0, matSize, matSize / 2, matSize);

            

Reported by PMD.

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

Line: 24

              
    Feature2D detector;
    int matSize;
    KeyPoint[] truth;

    private Mat getMaskImg() {
        Mat mask = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255));
        Mat right = mask.submat(0, matSize, matSize / 2, matSize);
        right.setTo(new Scalar(0));

            

Reported by PMD.

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

Line: 53

                      });
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        detector = createClassInstance(XFEATURES2D+"SURF", DEFAULT_FACTORY, null, null);
        matSize = 100;
        truth = new KeyPoint[] {

            

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

                          };
    }

    public void testCreate() {
        assertNotNull(detector);
    }

    public void testDetectListOfMatListOfListOfKeyPoint() {


            

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

                      assertNotNull(detector);
    }

    public void testDetectListOfMatListOfListOfKeyPoint() {

        setProperty(detector, "hessianThreshold", "double", 8000);
        setProperty(detector, "nOctaves", "int", 3);
        setProperty(detector, "nOctaveLayers", "int", 4);
        setProperty(detector, "upright", "boolean", false);

            

Reported by PMD.

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

Line: 70

                      assertNotNull(detector);
    }

    public void testDetectListOfMatListOfListOfKeyPoint() {

        setProperty(detector, "hessianThreshold", "double", 8000);
        setProperty(detector, "nOctaves", "int", 3);
        setProperty(detector, "nOctaveLayers", "int", 4);
        setProperty(detector, "upright", "boolean", false);

            

Reported by PMD.

The String literal 'int' appears 6 times in this file; the first occurrence is on line 73
Error

Line: 73

                  public void testDetectListOfMatListOfListOfKeyPoint() {

        setProperty(detector, "hessianThreshold", "double", 8000);
        setProperty(detector, "nOctaves", "int", 3);
        setProperty(detector, "nOctaveLayers", "int", 4);
        setProperty(detector, "upright", "boolean", false);

        List<MatOfKeyPoint> keypoints = new ArrayList<MatOfKeyPoint>();
        Mat cross = getTestImg();

            

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

                      }
    }

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

    public void testDetectMatListOfKeyPoint() {


            

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

                      fail("Not yet implemented");
    }

    public void testDetectMatListOfKeyPoint() {

        setProperty(detector, "hessianThreshold", "double", 8000);
        setProperty(detector, "nOctaves", "int", 3);
        setProperty(detector, "nOctaveLayers", "int", 4);
        setProperty(detector, "upright", "boolean", false);

            

Reported by PMD.

samples/python/tutorial_code/Histograms_Matching/back_projection/calcBackProject_Demo1.py
15 issues
Unable to import 'cv2'
Error

Line: 3 Column: 1

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

def Hist_and_Backproj(val):
    ## [initialize]
    bins = val

            

Reported by Pylint.

Redefining name 'bins' from outer scope (line 63)
Error

Line: 9 Column: 5

              
def Hist_and_Backproj(val):
    ## [initialize]
    bins = val
    histSize = max(bins, 2)
    ranges = [0, 180] # hue_range
    ## [initialize]

    ## [Get the Histogram and normalize it]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

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

def Hist_and_Backproj(val):
    ## [initialize]
    bins = val

            

Reported by Pylint.

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

Line: 1 Column: 1

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

def Hist_and_Backproj(val):
    ## [initialize]
    bins = val

            

Reported by Pylint.

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

Line: 5 Column: 1

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

def Hist_and_Backproj(val):
    ## [initialize]
    bins = val
    histSize = max(bins, 2)

            

Reported by Pylint.

Function name "Hist_and_Backproj" doesn't conform to snake_case naming style
Error

Line: 7 Column: 1

              import numpy as np
import argparse

def Hist_and_Backproj(val):
    ## [initialize]
    bins = val
    histSize = max(bins, 2)
    ranges = [0, 180] # hue_range
    ## [initialize]

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

              import numpy as np
import argparse

def Hist_and_Backproj(val):
    ## [initialize]
    bins = val
    histSize = max(bins, 2)
    ranges = [0, 180] # hue_range
    ## [initialize]

            

Reported by Pylint.

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

Line: 10 Column: 5

              def Hist_and_Backproj(val):
    ## [initialize]
    bins = val
    histSize = max(bins, 2)
    ranges = [0, 180] # hue_range
    ## [initialize]

    ## [Get the Histogram and normalize it]
    hist = cv.calcHist([hue], [0], None, [histSize], ranges, accumulate=False)

            

Reported by Pylint.

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

Line: 28 Column: 5

                  ## [Draw the backproj]

    ## [Draw the histogram]
    w = 400
    h = 400
    bin_w = int(round(w / histSize))
    histImg = np.zeros((h, w, 3), dtype=np.uint8)

    for i in range(bins):

            

Reported by Pylint.

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

Line: 29 Column: 5

              
    ## [Draw the histogram]
    w = 400
    h = 400
    bin_w = int(round(w / histSize))
    histImg = np.zeros((h, w, 3), dtype=np.uint8)

    for i in range(bins):
        cv.rectangle(histImg, (i*bin_w, h), ( (i+1)*bin_w, h - int(np.round( hist[i]*h/255.0 )) ), (0, 0, 255), cv.FILLED)

            

Reported by Pylint.

samples/python/tutorial_code/dnn/dnn_conversion/pytorch/segmentation/py_to_py_fcn_resnet50.py
15 issues
Unable to import 'torchvision'
Error

Line: 1 Column: 1

              from torchvision import models

from ..pytorch_model import (
    PyTorchModelPreparer,
    PyTorchModelProcessor,
    PyTorchDnnModelProcessor
)
from ...common.utils import set_pytorch_env, create_parser


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 3 Column: 1

              from torchvision import models

from ..pytorch_model import (
    PyTorchModelPreparer,
    PyTorchModelProcessor,
    PyTorchDnnModelProcessor
)
from ...common.utils import set_pytorch_env, create_parser


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

                  PyTorchModelProcessor,
    PyTorchDnnModelProcessor
)
from ...common.utils import set_pytorch_env, create_parser


class PyTorchFcnResNet50(PyTorchModelPreparer):
    def __init__(self, model_name, original_model):
        super(PyTorchFcnResNet50, self).__init__(model_name, original_model)

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 29 Column: 9

                  model_dict = resnets.get_prepared_models()

    if cmd_args.is_evaluate:
        from ...common.test_config import TestConfig
        from ...common.accuracy_eval import PASCALDataFetch
        from ...common.test.voc_segm_test import test_segm_models

        eval_params = TestConfig()


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 30 Column: 9

              
    if cmd_args.is_evaluate:
        from ...common.test_config import TestConfig
        from ...common.accuracy_eval import PASCALDataFetch
        from ...common.test.voc_segm_test import test_segm_models

        eval_params = TestConfig()

        model_names = list(model_dict.keys())

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 31 Column: 9

                  if cmd_args.is_evaluate:
        from ...common.test_config import TestConfig
        from ...common.accuracy_eval import PASCALDataFetch
        from ...common.test.voc_segm_test import test_segm_models

        eval_params = TestConfig()

        model_names = list(model_dict.keys())
        original_model_name = model_names[0]

            

Reported by Pylint.

Useless super delegation in method '__init__'
Error

Line: 12 Column: 5

              

class PyTorchFcnResNet50(PyTorchModelPreparer):
    def __init__(self, model_name, original_model):
        super(PyTorchFcnResNet50, self).__init__(model_name, original_model)


def main():
    parser = create_parser()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from torchvision import models

from ..pytorch_model import (
    PyTorchModelPreparer,
    PyTorchModelProcessor,
    PyTorchDnnModelProcessor
)
from ...common.utils import set_pytorch_env, create_parser


            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 11 Column: 1

              from ...common.utils import set_pytorch_env, create_parser


class PyTorchFcnResNet50(PyTorchModelPreparer):
    def __init__(self, model_name, original_model):
        super(PyTorchFcnResNet50, self).__init__(model_name, original_model)


def main():

            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              from ...common.utils import set_pytorch_env, create_parser


class PyTorchFcnResNet50(PyTorchModelPreparer):
    def __init__(self, model_name, original_model):
        super(PyTorchFcnResNet50, self).__init__(model_name, original_model)


def main():

            

Reported by Pylint.

samples/python/color_histogram.py
15 issues
Unable to import 'cv2'
Error

Line: 15 Column: 1

              from __future__ import print_function

import numpy as np
import cv2 as cv

# built-in modules
import sys

# local modules

            

Reported by Pylint.

Attribute 'hist_scale' defined outside __init__
Error

Line: 26 Column: 9

              class App():

    def set_scale(self, val):
        self.hist_scale = val

    def run(self):
        hsv_map = np.zeros((180, 256, 3), np.uint8)
        h, s = np.indices(hsv_map.shape[:2])
        hsv_map[:,:,0] = h

            

Reported by Pylint.

Attribute 'hist_scale' defined outside __init__
Error

Line: 38 Column: 9

                      cv.imshow('hsv_map', hsv_map)

        cv.namedWindow('hist', 0)
        self.hist_scale = 10

        cv.createTrackbar('scale', 'hist', self.hist_scale, 32, self.set_scale)

        try:
            fn = sys.argv[1]

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 44 Column: 9

              
        try:
            fn = sys.argv[1]
        except:
            fn = 0
        cam = video.create_capture(fn, fallback='synth:bg=baboon.jpg:class=chess:noise=0.05')

        while True:
            _flag, frame = cam.read()

            

Reported by Pylint.

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

Line: 18 Column: 1

              import cv2 as cv

# built-in modules
import sys

# local modules
import video

class App():

            

Reported by Pylint.

Missing class docstring
Error

Line: 23 Column: 1

              # local modules
import video

class App():

    def set_scale(self, val):
        self.hist_scale = val

    def run(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 25 Column: 5

              
class App():

    def set_scale(self, val):
        self.hist_scale = val

    def run(self):
        hsv_map = np.zeros((180, 256, 3), np.uint8)
        h, s = np.indices(hsv_map.shape[:2])

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 5

                  def set_scale(self, val):
        self.hist_scale = val

    def run(self):
        hsv_map = np.zeros((180, 256, 3), np.uint8)
        h, s = np.indices(hsv_map.shape[:2])
        hsv_map[:,:,0] = h
        hsv_map[:,:,1] = s
        hsv_map[:,:,2] = 255

            

Reported by Pylint.

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

Line: 30 Column: 12

              
    def run(self):
        hsv_map = np.zeros((180, 256, 3), np.uint8)
        h, s = np.indices(hsv_map.shape[:2])
        hsv_map[:,:,0] = h
        hsv_map[:,:,1] = s
        hsv_map[:,:,2] = 255
        hsv_map = cv.cvtColor(hsv_map, cv.COLOR_HSV2BGR)
        cv.imshow('hsv_map', hsv_map)

            

Reported by Pylint.

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

Line: 30 Column: 9

              
    def run(self):
        hsv_map = np.zeros((180, 256, 3), np.uint8)
        h, s = np.indices(hsv_map.shape[:2])
        hsv_map[:,:,0] = h
        hsv_map[:,:,1] = s
        hsv_map[:,:,2] = 255
        hsv_map = cv.cvtColor(hsv_map, cv.COLOR_HSV2BGR)
        cv.imshow('hsv_map', hsv_map)

            

Reported by Pylint.

samples/java/tutorial_code/core/discrete_fourier_transform/DiscreteFourierTransform.java
15 issues
System.out.println is used
Design

Line: 10

              
class DiscreteFourierTransformRun{
    private void help() {
        System.out.println("" +
                "This program demonstrated the use of the discrete Fourier transform (DFT). \n" +
                "The dft of an image is taken and it's power spectrum is displayed.\n" +
                "Usage:\n" +
                "./DiscreteFourierTransform [image_name -- default ../data/lena.jpg]");
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 25

              
        Mat I = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE);
        if( I.empty() ) {
            System.out.println("Error opening image");
            System.exit(-1);
        }

        //! [expand]
        Mat padded = new Mat();                     //expand input image to optimal size

            

Reported by PMD.

Do not add empty strings
Performance

Line: 10

              
class DiscreteFourierTransformRun{
    private void help() {
        System.out.println("" +
                "This program demonstrated the use of the discrete Fourier transform (DFT). \n" +
                "The dft of an image is taken and it's power spectrum is displayed.\n" +
                "Usage:\n" +
                "./DiscreteFourierTransform [image_name -- default ../data/lena.jpg]");
    }

            

Reported by PMD.

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

Line: 24

                      String filename = ((args.length > 0) ? args[0] : "../data/lena.jpg");

        Mat I = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE);
        if( I.empty() ) {
            System.out.println("Error opening image");
            System.exit(-1);
        }

        //! [expand]

            

Reported by PMD.

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

Line: 26

                      Mat I = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE);
        if( I.empty() ) {
            System.out.println("Error opening image");
            System.exit(-1);
        }

        //! [expand]
        Mat padded = new Mat();                     //expand input image to optimal size
        int m = Core.getOptimalDFTSize( I.rows() );

            

Reported by PMD.

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

Line: 31

              
        //! [expand]
        Mat padded = new Mat();                     //expand input image to optimal size
        int m = Core.getOptimalDFTSize( I.rows() );
        int n = Core.getOptimalDFTSize( I.cols() ); // on the border add zero values
        Core.copyMakeBorder(I, padded, 0, m - I.rows(), 0, n - I.cols(), Core.BORDER_CONSTANT, Scalar.all(0));
        //! [expand]

        //! [complex_and_real]

            

Reported by PMD.

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

Line: 32

                      //! [expand]
        Mat padded = new Mat();                     //expand input image to optimal size
        int m = Core.getOptimalDFTSize( I.rows() );
        int n = Core.getOptimalDFTSize( I.cols() ); // on the border add zero values
        Core.copyMakeBorder(I, padded, 0, m - I.rows(), 0, n - I.cols(), Core.BORDER_CONSTANT, Scalar.all(0));
        //! [expand]

        //! [complex_and_real]
        List<Mat> planes = new ArrayList<Mat>();

            

Reported by PMD.

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

Line: 33

                      Mat padded = new Mat();                     //expand input image to optimal size
        int m = Core.getOptimalDFTSize( I.rows() );
        int n = Core.getOptimalDFTSize( I.cols() ); // on the border add zero values
        Core.copyMakeBorder(I, padded, 0, m - I.rows(), 0, n - I.cols(), Core.BORDER_CONSTANT, Scalar.all(0));
        //! [expand]

        //! [complex_and_real]
        List<Mat> planes = new ArrayList<Mat>();
        padded.convertTo(padded, CvType.CV_32F);

            

Reported by PMD.

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

Line: 33

                      Mat padded = new Mat();                     //expand input image to optimal size
        int m = Core.getOptimalDFTSize( I.rows() );
        int n = Core.getOptimalDFTSize( I.cols() ); // on the border add zero values
        Core.copyMakeBorder(I, padded, 0, m - I.rows(), 0, n - I.cols(), Core.BORDER_CONSTANT, Scalar.all(0));
        //! [expand]

        //! [complex_and_real]
        List<Mat> planes = new ArrayList<Mat>();
        padded.convertTo(padded, CvType.CV_32F);

            

Reported by PMD.

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

Line: 59

                      //! [magnitude]

        //! [log]
        Mat matOfOnes = Mat.ones(magI.size(), magI.type());
        Core.add(matOfOnes, magI, magI);         // switch to logarithmic scale
        Core.log(magI, magI);
        //! [log]

        //! [crop_rearrange]

            

Reported by PMD.

samples/python/dft.py
15 issues
Unable to import 'cv2'
Error

Line: 15 Column: 1

              from __future__ import print_function

import numpy as np
import cv2 as cv

import sys


def shift_dft(src, dst=None):

            

Reported by Pylint.

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

Line: 17 Column: 1

              import numpy as np
import cv2 as cv

import sys


def shift_dft(src, dst=None):
    '''
        Rearrange the quadrants of Fourier image so that the origin is at

            

Reported by Pylint.

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

Line: 40 Column: 8

                  else:
        ret = dst

    h, w = src.shape[:2]

    cx1 = cx2 = w // 2
    cy1 = cy2 = h // 2

    # if the size is odd, then adjust the bottom/right quadrants

            

Reported by Pylint.

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

Line: 40 Column: 5

                  else:
        ret = dst

    h, w = src.shape[:2]

    cx1 = cx2 = w // 2
    cy1 = cy2 = h // 2

    # if the size is odd, then adjust the bottom/right quadrants

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 67 Column: 1

                  return dst


def main():
    if len(sys.argv) > 1:
        fname = sys.argv[1]
    else:
        fname = 'baboon.jpg'
        print("usage : python dft.py <image_file>")

            

Reported by Pylint.

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

Line: 74 Column: 5

                      fname = 'baboon.jpg'
        print("usage : python dft.py <image_file>")

    im = cv.imread(cv.samples.findFile(fname))

    # convert to grayscale
    im = cv.cvtColor(im, cv.COLOR_BGR2GRAY)
    h, w = im.shape[:2]


            

Reported by Pylint.

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

Line: 77 Column: 5

                  im = cv.imread(cv.samples.findFile(fname))

    # convert to grayscale
    im = cv.cvtColor(im, cv.COLOR_BGR2GRAY)
    h, w = im.shape[:2]

    realInput = im.astype(np.float64)

    # perform an optimally sized dft

            

Reported by Pylint.

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

Line: 78 Column: 5

              
    # convert to grayscale
    im = cv.cvtColor(im, cv.COLOR_BGR2GRAY)
    h, w = im.shape[:2]

    realInput = im.astype(np.float64)

    # perform an optimally sized dft
    dft_M = cv.getOptimalDFTSize(w)

            

Reported by Pylint.

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

Line: 78 Column: 8

              
    # convert to grayscale
    im = cv.cvtColor(im, cv.COLOR_BGR2GRAY)
    h, w = im.shape[:2]

    realInput = im.astype(np.float64)

    # perform an optimally sized dft
    dft_M = cv.getOptimalDFTSize(w)

            

Reported by Pylint.

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

Line: 80 Column: 5

                  im = cv.cvtColor(im, cv.COLOR_BGR2GRAY)
    h, w = im.shape[:2]

    realInput = im.astype(np.float64)

    # perform an optimally sized dft
    dft_M = cv.getOptimalDFTSize(w)
    dft_N = cv.getOptimalDFTSize(h)


            

Reported by Pylint.

modules/js/src/make_umd.py
15 issues
Unused import shutil
Error

Line: 69 Column: 1

              # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###############################################################################
import os, sys, re, json, shutil
from subprocess import Popen, PIPE, STDOUT

PY3 = sys.version_info >= (3, 0)

def make_umd(opencvjs, cvjs):

            

Reported by Pylint.

Unused import json
Error

Line: 69 Column: 1

              # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###############################################################################
import os, sys, re, json, shutil
from subprocess import Popen, PIPE, STDOUT

PY3 = sys.version_info >= (3, 0)

def make_umd(opencvjs, cvjs):

            

Reported by Pylint.

Unused import re
Error

Line: 69 Column: 1

              # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###############################################################################
import os, sys, re, json, shutil
from subprocess import Popen, PIPE, STDOUT

PY3 = sys.version_info >= (3, 0)

def make_umd(opencvjs, cvjs):

            

Reported by Pylint.

Unused Popen imported from subprocess
Error

Line: 70 Column: 1

              # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###############################################################################
import os, sys, re, json, shutil
from subprocess import Popen, PIPE, STDOUT

PY3 = sys.version_info >= (3, 0)

def make_umd(opencvjs, cvjs):
    with open(opencvjs, 'r+b') as src:

            

Reported by Pylint.

Unused PIPE imported from subprocess
Error

Line: 70 Column: 1

              # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###############################################################################
import os, sys, re, json, shutil
from subprocess import Popen, PIPE, STDOUT

PY3 = sys.version_info >= (3, 0)

def make_umd(opencvjs, cvjs):
    with open(opencvjs, 'r+b') as src:

            

Reported by Pylint.

Unused STDOUT imported from subprocess
Error

Line: 70 Column: 1

              # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###############################################################################
import os, sys, re, json, shutil
from subprocess import Popen, PIPE, STDOUT

PY3 = sys.version_info >= (3, 0)

def make_umd(opencvjs, cvjs):
    with open(opencvjs, 'r+b') as src:

            

Reported by Pylint.

Redefining name 'opencvjs' from outer scope (line 114)
Error

Line: 74 Column: 14

              
PY3 = sys.version_info >= (3, 0)

def make_umd(opencvjs, cvjs):
    with open(opencvjs, 'r+b') as src:
        content = src.read()
    if PY3:  # content is bytes
        content = content.decode('utf-8')
    with open(cvjs, 'w+b') as dst:

            

Reported by Pylint.

Redefining name 'cvjs' from outer scope (line 115)
Error

Line: 74 Column: 24

              
PY3 = sys.version_info >= (3, 0)

def make_umd(opencvjs, cvjs):
    with open(opencvjs, 'r+b') as src:
        content = src.read()
    if PY3:  # content is bytes
        content = content.decode('utf-8')
    with open(cvjs, 'w+b') as dst:

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 119 Column: 1

                      if not os.path.isfile(opencvjs):
            print('opencv.js file not found! Have you compiled the opencv_js module?')
            exit()
        make_umd(opencvjs, cvjs);

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              ###############################################################################
#
#  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
#
#  By downloading, copying, installing or using the software you agree to this license.
#  If you do not agree to this license, do not download, install,
#  copy or use the software.
#
#

            

Reported by Pylint.