The following issues were found

doc/pattern_tools/svgfig.py
788 issues
Unable to import '_winreg'
Error

Line: 40 Column: 9

              
if re.search("windows", platform.system(), re.I):
    try:
        import _winreg
        _default_directory = _winreg.QueryValueEx(_winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
                             r"Software\Microsoft\Windows\Current Version\Explorer\Shell Folders"), "Desktop")[0]
#   tmpdir = _winreg.QueryValueEx(_winreg.OpenKey(_winreg.HKEY_CURRENT_USER, "Environment"), "TEMP")[0]
#   if tmpdir[0:13] != "%USERPROFILE%":
#     tmpdir = os.path.expanduser("~") + tmpdir[13:]

            

Reported by Pylint.

__iter__ returns non-iterator
Error

Line: 244 Column: 9

                          self.shown = False
            self.depth_limit = depth_limit

        def __iter__(self):
            return self

        def next(self):
            if not self.shown:
                self.shown = True

            

Reported by Pylint.

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

Line: 266 Column: 20

                                  self.iterators.append(self.__class__(s, self.ti + (k,), self.depth_limit))
                self.iterators = itertools.chain(*self.iterators)

            return self.iterators.next()
    ### end nested class

    def depth_first(self, depth_limit=None):
        """Returns a depth-first generator over the SVG.  If depth_limit
        is a number, stop recursion at that depth."""

            

Reported by Pylint.

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

Line: 266 Column: 20

                                  self.iterators.append(self.__class__(s, self.ti + (k,), self.depth_limit))
                self.iterators = itertools.chain(*self.iterators)

            return self.iterators.next()
    ### end nested class

    def depth_first(self, depth_limit=None):
        """Returns a depth-first generator over the SVG.  If depth_limit
        is a number, stop recursion at that depth."""

            

Reported by Pylint.

__iter__ returns non-iterator
Error

Line: 281 Column: 5

                      is a number, stop recursion at that depth."""
        raise NotImplementedError( "Got an algorithm for breadth-first searching a tree without effectively copying the tree?")

    def __iter__(self):
        return self.depth_first()

    def items(self, sub=True, attr=True, text=True):
        """Get a recursively-generated list of tree-index, sub-element/attribute pairs.


            

Reported by Pylint.

__iter__ returns non-iterator
Error

Line: 1718 Column: 9

                              current = current.right
            return count

        def __iter__(self):
            self.current = self.left
            return self

        def next(self):
            current = self.current

            

Reported by Pylint.

'last_trial' does not support item assignment
Error

Line: 2923 Column: 25

                                  lowN = 1.*self.low / last_granularity
                    highN = 1.*self.high / last_granularity
                    if abs(lowN - round(lowN)) < _epsilon and not low_in_ticks:
                        last_trial[self.low] = format(self.low)
                    if abs(highN - round(highN)) < _epsilon and not high_in_ticks:
                        last_trial[self.high] = format(self.high)
                    return last_trial

            last_granularity = granularity

            

Reported by Pylint.

'last_trial' does not support item assignment
Error

Line: 2925 Column: 25

                                  if abs(lowN - round(lowN)) < _epsilon and not low_in_ticks:
                        last_trial[self.low] = format(self.low)
                    if abs(highN - round(highN)) < _epsilon and not high_in_ticks:
                        last_trial[self.high] = format(self.high)
                    return last_trial

            last_granularity = granularity
            last_trial = trial


            

Reported by Pylint.

Undefined variable 'ticks'
Error

Line: 2960 Column: 30

                      Normally only used internally.
        """
        if len(original_ticks) < 2:
            original_ticks = ticks(self.low, self.high) # XXX ticks is undefined!
        original_ticks = original_ticks.keys()
        original_ticks.sort()

        if self.low > original_ticks[0] + _epsilon or self.high < original_ticks[-1] - _epsilon:
            raise ValueError("original_ticks {%g...%g} extend beyond [%g, %g]" % (original_ticks[0], original_ticks[-1], self.low, self.high))

            

Reported by Pylint.

Instance of 'XAxis' has no 'xmin' member
Error

Line: 3263 Column: 16

              
    def __repr__(self):
        return "<XAxis (%g, %g) at y=%g ticks=%s labels=%s %s>" % (
               self.xmin, self.xmax, self.aty, str(self.ticks), str(self.labels), self.attr) # XXX self.xmin/xmax undefd!

    def __init__(self, xmin, xmax, aty=0, ticks=-10, miniticks=True, labels=True, logbase=None,
                 arrow_start=None, arrow_end=None, exclude=None, text_attr={}, **attr):
        self.aty = aty
        tattr = dict(self.text_defaults)

            

Reported by Pylint.

modules/objc/generator/gen_objc.py
453 issues
Unable to import 'hdr_parser'
Error

Line: 1569 Column: 5

                  if hdr_parser_path.endswith(".py"):
        hdr_parser_path = os.path.dirname(hdr_parser_path)
    sys.path.append(hdr_parser_path)
    import hdr_parser

    with open(args.config) as f:
        config = json.load(f)

    ROOT_DIR = config['rootdir']; assert os.path.exists(ROOT_DIR)

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 16 Column: 1

              
try:
    from io import StringIO # Python 3
except:
    from io import BytesIO as StringIO

SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))

# list of modules

            

Reported by Pylint.

__init__ method from base class 'Exception' is not called
Error

Line: 98 Column: 5

              

class SkipSymbolException(Exception):
    def __init__(self, text):
        self.t = text
    def __str__(self):
        return self.t



            

Reported by Pylint.

Redefining name 'f' from outer scope (line 1571)
Error

Line: 105 Column: 30

              

def read_contents(fname):
    with open(fname, 'r') as f:
        data = f.read()
    return data

def mkdir_p(path):
    ''' mkdir -p '''

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 134 Column: 24

              T_OBJC_MODULE_BODY = read_contents(os.path.join(SCRIPT_DIR, 'templates/objc_module_body.template'))

class GeneralInfo():
    def __init__(self, type, decl, namespaces):
        self.symbol_id, self.namespace, self.classpath, self.classname, self.name = self.parseName(decl[0], namespaces)

        for ns_ignore in namespace_ignore_list:
            if self.symbol_id.startswith(ns_ignore + '.'):
                raise SkipSymbolException('ignored namespace ({}): {}'.format(ns_ignore, self.symbol_id))

            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 194 Column: 5

                      return result if not isCPP else get_cname(result)

class ConstInfo(GeneralInfo):
    def __init__(self, decl, addedManually=False, namespaces=[], enumType=None):
        GeneralInfo.__init__(self, "const", decl, namespaces)
        self.cname = get_cname(self.name)
        self.value = decl[1]
        self.enumType = enumType
        self.addedManually = addedManually

            

Reported by Pylint.

Redefining name 'module' from outer scope (line 1597)
Error

Line: 233 Column: 30

                      return type_dict[t]["cast_to"]
    return t

def gen_class_doc(docstring, module, members, enums):
    lines = docstring.splitlines()
    lines.insert(len(lines)-1, " *")
    if len(members) > 0:
        lines.insert(len(lines)-1, " * Member classes: " + ", ".join([("`" + m + "`") for m in members]))
        lines.insert(len(lines)-1, " *")

            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 256 Column: 5

                      return Template("PROP $ctype $name").substitute(ctype=self.ctype, name=self.name)

class ClassInfo(GeneralInfo):
    def __init__(self, decl, namespaces=[]): # [ 'class/struct cname', ': base', [modlist] ]
        GeneralInfo.__init__(self, "class", decl, namespaces)
        self.cname = self.name if not self.classname else self.classname + "_" + self.name
        self.real_cname = self.name if not self.classname else self.classname + "::" + self.name
        self.methods = []
        self.methods_suffixes = {}

            

Reported by Pylint.

Unused argument 'module'
Error

Line: 291 Column: 26

                  def __repr__(self):
        return Template("CLASS $namespace::$classpath.$name : $base").substitute(**self.__dict__)

    def getImports(self, module):
        return ["#import \"%s.h\"" % c for c in sorted([m for m in [type_dict[m]["import_module"] if m in type_dict and "import_module" in type_dict[m] else m for m in self.imports] if m != self.name])]

    def isEnum(self, c):
        return c in type_dict and type_dict[c].get("is_enum", False)


            

Reported by Pylint.

Redefining name 'module' from outer scope (line 1597)
Error

Line: 291 Column: 26

                  def __repr__(self):
        return Template("CLASS $namespace::$classpath.$name : $base").substitute(**self.__dict__)

    def getImports(self, module):
        return ["#import \"%s.h\"" % c for c in sorted([m for m in [type_dict[m]["import_module"] if m in type_dict and "import_module" in type_dict[m] else m for m in self.imports] if m != self.name])]

    def isEnum(self, c):
        return c in type_dict and type_dict[c].get("is_enum", False)


            

Reported by Pylint.

modules/core/misc/java/test/CoreTest.java
364 issues
This class has a bunch of public methods and attributes
Design

Line: 1

              package org.opencv.test.core;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.opencv.core.Core;
import org.opencv.core.Core.MinMaxLocResult;
import org.opencv.core.CvException;

            

Reported by PMD.

Avoid really long classes.
Design

Line: 24

              import org.opencv.test.OpenCVTestCase;
import org.opencv.imgproc.Imgproc;

public class CoreTest extends OpenCVTestCase {

    public void testAbsdiff() {
        Core.absdiff(gray128, gray255, dst);

        assertMatEqual(gray127, dst);

            

Reported by PMD.

Possible God Class (WMC=154, ATFD=455, TCC=0.000%)
Design

Line: 24

              import org.opencv.test.OpenCVTestCase;
import org.opencv.imgproc.Imgproc;

public class CoreTest extends OpenCVTestCase {

    public void testAbsdiff() {
        Core.absdiff(gray128, gray255, dst);

        assertMatEqual(gray127, dst);

            

Reported by PMD.

The class 'CoreTest' has a total cyclomatic complexity of 154 (highest 2).
Design

Line: 24

              import org.opencv.test.OpenCVTestCase;
import org.opencv.imgproc.Imgproc;

public class CoreTest extends OpenCVTestCase {

    public void testAbsdiff() {
        Core.absdiff(gray128, gray255, dst);

        assertMatEqual(gray127, dst);

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 24

              import org.opencv.test.OpenCVTestCase;
import org.opencv.imgproc.Imgproc;

public class CoreTest extends OpenCVTestCase {

    public void testAbsdiff() {
        Core.absdiff(gray128, gray255, dst);

        assertMatEqual(gray127, dst);

            

Reported by PMD.

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

Line: 26

              
public class CoreTest extends OpenCVTestCase {

    public void testAbsdiff() {
        Core.absdiff(gray128, gray255, dst);

        assertMatEqual(gray127, dst);
    }


            

Reported by PMD.

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

Line: 32

                      assertMatEqual(gray127, dst);
    }

    public void testAddMatMatMat() {
        Core.add(gray128, gray128, dst);

        assertMatEqual(gray255, dst);
    }


            

Reported by PMD.

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

Line: 38

                      assertMatEqual(gray255, dst);
    }

    public void testAddMatMatMatMatInt() {
        Core.add(gray0, gray1, dst, gray1, CvType.CV_32F);

        assertEquals(CvType.CV_32F, dst.depth());
        assertMatEqual(gray1_32f, dst, EPS);
    }

            

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

                      assertMatEqual(gray255, dst);
    }

    public void testAddMatMatMatMatInt() {
        Core.add(gray0, gray1, dst, gray1, CvType.CV_32F);

        assertEquals(CvType.CV_32F, dst.depth());
        assertMatEqual(gray1_32f, dst, EPS);
    }

            

Reported by PMD.

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

Line: 45

                      assertMatEqual(gray1_32f, dst, EPS);
    }

    public void testAddWeightedMatDoubleMatDoubleDoubleMat() {
        Core.addWeighted(gray1, 120.0, gray127, 1.0, 10.0, dst);

        assertMatEqual(gray255, dst);
    }


            

Reported by PMD.

modules/java/generator/gen_java.py
361 issues
Undefined variable 'unicode'
Error

Line: 18 Column: 21

                  class StringIO(io.StringIO):
        def write(self, s):
            if isinstance(s, str):
                s = unicode(s)  # noqa: F821
            return super(StringIO, self).write(s)

SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))

# list of modules + files remap

            

Reported by Pylint.

Instance of 'GeneralInfo' has no 'jname' member; maybe 'name'?
Error

Line: 179 Column: 55

                      return result

    def fullNameJAVA(self):
        result = '.'.join([self.fullParentNameJAVA(), self.jname])
        return result

    def fullNameCPP(self):
        result = self.cname
        return result

            

Reported by Pylint.

Unable to import 'hdr_parser'
Error

Line: 1408 Column: 5

                  if hdr_parser_path.endswith(".py"):
        hdr_parser_path = os.path.dirname(hdr_parser_path)
    sys.path.append(hdr_parser_path)
    import hdr_parser

    with open(args.config) as f:
        config = json.load(f)

    ROOT_DIR = config['rootdir']; assert os.path.exists(ROOT_DIR)

            

Reported by Pylint.

Redefining name 'f' from outer scope (line 1410)
Error

Line: 105 Column: 30

              func_arg_fix = {}

def read_contents(fname):
    with open(fname, 'r') as f:
        data = f.read()
    return data

def mkdir_p(path):
    ''' mkdir -p '''

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 125 Column: 24

              T_CPP_MODULE = Template(read_contents(os.path.join(SCRIPT_DIR, 'templates/cpp_module.template')))

class GeneralInfo():
    def __init__(self, type, decl, namespaces):
        self.symbol_id, self.parent_id, self.namespace, self.classpath, self.classname, self.name = self.parseName(decl[0], namespaces)
        self.cname = get_cname(self.symbol_id)

        # parse doxygen comments
        self.params={}

            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 195 Column: 5

                      return result

class ConstInfo(GeneralInfo):
    def __init__(self, decl, addedManually=False, namespaces=[], enumType=None):
        GeneralInfo.__init__(self, "const", decl, namespaces)
        self.value = decl[1]
        self.enumType = enumType
        self.addedManually = addedManually
        if self.namespace in namespaces_dict:

            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 245 Column: 5

                      return Template("PROP $ctype $name").substitute(ctype=self.ctype, name=self.name)

class ClassInfo(GeneralInfo):
    def __init__(self, decl, namespaces=[]): # [ 'class/struct cname', ': base', [modlist] ]
        GeneralInfo.__init__(self, "class", decl, namespaces)
        self.methods = []
        self.methods_suffixes = {}
        self.consts = [] # using a list to save the occurrence order
        self.private_consts = []

            

Reported by Pylint.

Redefining name 'module' from outer scope (line 1437)
Error

Line: 291 Column: 29

                  def __repr__(self):
        return Template("CLASS $namespace::$classpath.$name : $base").substitute(**self.__dict__)

    def getAllImports(self, module):
        return ["import %s;" % c for c in sorted(self.imports) if not c.startswith('org.opencv.'+module)
            and (not c.startswith('java.lang.') or c.count('.') != 2)]

    def addImports(self, ctype):
        if ctype in type_dict:

            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 392 Column: 5

                                                                                defval=self.defval)

class FuncInfo(GeneralInfo):
    def __init__(self, decl, namespaces=[]): # [ funcname, return_ctype, [modifiers], [args] ]
        GeneralInfo.__init__(self, "func", decl, namespaces)
        self.cname = get_cname(decl[0])
        self.jname = self.name
        self.isconstructor = self.name == self.classname
        if "[" in self.name:

            

Reported by Pylint.

Using a conditional statement with a constant value
Error

Line: 505 Column: 13

              
        # class props
        for p in decl[3]:
            if True: #"vector" not in p[0]:
                classinfo.props.append( ClassPropInfo(p) )
            else:
                logging.warning("Skipped property: [%s]" % name, p)

        if classinfo.base:

            

Reported by Pylint.

modules/core/misc/java/test/MatTest.java
328 issues
Do not use the short type
Performance

Line: 450

              
        // sub-Mat
        Mat sm = m.submat(2, 4, 3, 5);
        short buff00[] = new short[4];
        bytesNum = sm.get(0, 0, buff00);
        assertEquals(8, bytesNum);
        assertTrue(Arrays.equals(new short[] {230, 231, 240, 241}, buff00));
        short buff11[] = new short[]{0, 0, 0, 0};
        bytesNum = sm.get(1, 1, buff11);

            

Reported by PMD.

Do not use the short type
Performance

Line: 454

                      bytesNum = sm.get(0, 0, buff00);
        assertEquals(8, bytesNum);
        assertTrue(Arrays.equals(new short[] {230, 231, 240, 241}, buff00));
        short buff11[] = new short[]{0, 0, 0, 0};
        bytesNum = sm.get(1, 1, buff11);
        assertEquals(4, bytesNum);
        assertTrue(Arrays.equals(new short[] {340, 341, 0, 0}, buff11));

        Mat m2 = new Mat(new int[]{ 5, 6, 8 }, CvType.CV_16S);

            

Reported by PMD.

Do not use the short type
Performance

Line: 951

              
        assertEquals(elements.length * 2, bytesNum);
        Mat m1 = m.col(3);
        short buff[] = new short[3];
        bytesNum = m1.get(2, 0, buff);
        assertTrue(Arrays.equals(new short[]{10, 20, 30}, buff));
        assertArrayEquals(new double[]{40, 50, 60}, m.get(2, 4), EPS);

        try {

            

Reported by PMD.

Do not use the short type
Performance

Line: 973

              
        assertEquals(elements.length * 2, bytesNum);
        Mat m1 = m.submat(new Range[]{ Range.all(), Range.all(), new Range(3, 4)});
        short buff[] = new short[3];
        bytesNum = m1.get(new int[]{ 0, 2, 0 }, buff);
        assertTrue(Arrays.equals(new short[]{10, 20, 30}, buff));
        assertArrayEquals(new double[]{40, 50, 60}, m.get(new int[]{ 0, 2, 4 }), EPS);

        try {

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 1

              package org.opencv.test.core;

import java.util.Arrays;
import java.nio.ByteBuffer;

import org.opencv.core.Core;
import org.opencv.core.CvException;
import org.opencv.core.CvType;
import org.opencv.core.Mat;

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 17

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

public class MatTest extends OpenCVTestCase {

    public void testAdjustROI() {
        Mat roi = gray0.submat(3, 5, 7, 10);
        Mat originalroi = roi.clone();


            

Reported by PMD.

Avoid really long classes.
Design

Line: 17

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

public class MatTest extends OpenCVTestCase {

    public void testAdjustROI() {
        Mat roi = gray0.submat(3, 5, 7, 10);
        Mat originalroi = roi.clone();


            

Reported by PMD.

Possible God Class (WMC=127, ATFD=312, TCC=0.000%)
Design

Line: 17

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

public class MatTest extends OpenCVTestCase {

    public void testAdjustROI() {
        Mat roi = gray0.submat(3, 5, 7, 10);
        Mat originalroi = roi.clone();


            

Reported by PMD.

The class 'MatTest' has a total cyclomatic complexity of 127 (highest 4).
Design

Line: 17

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

public class MatTest extends OpenCVTestCase {

    public void testAdjustROI() {
        Mat roi = gray0.submat(3, 5, 7, 10);
        Mat originalroi = roi.clone();


            

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

              
public class MatTest extends OpenCVTestCase {

    public void testAdjustROI() {
        Mat roi = gray0.submat(3, 5, 7, 10);
        Mat originalroi = roi.clone();

        Mat adjusted = roi.adjustROI(2, 2, 2, 2);


            

Reported by PMD.

modules/imgproc/misc/java/test/ImgprocTest.java
283 issues
This class has a bunch of public methods and attributes
Design

Line: 1

              package org.opencv.test.imgproc;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;

            

Reported by PMD.

Avoid really long classes.
Design

Line: 24

              import org.opencv.imgproc.Imgproc;
import org.opencv.test.OpenCVTestCase;

public class ImgprocTest extends OpenCVTestCase {

    Point anchorPoint;
    private int imgprocSz;
    Size size;


            

Reported by PMD.

The class 'ImgprocTest' has a total cyclomatic complexity of 173 (highest 2).
Design

Line: 24

              import org.opencv.imgproc.Imgproc;
import org.opencv.test.OpenCVTestCase;

public class ImgprocTest extends OpenCVTestCase {

    Point anchorPoint;
    private int imgprocSz;
    Size size;


            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 24

              import org.opencv.imgproc.Imgproc;
import org.opencv.test.OpenCVTestCase;

public class ImgprocTest extends OpenCVTestCase {

    Point anchorPoint;
    private int imgprocSz;
    Size size;


            

Reported by PMD.

Possible God Class (WMC=173, ATFD=447, TCC=3.053%)
Design

Line: 24

              import org.opencv.imgproc.Imgproc;
import org.opencv.test.OpenCVTestCase;

public class ImgprocTest extends OpenCVTestCase {

    Point anchorPoint;
    private int imgprocSz;
    Size size;


            

Reported by PMD.

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

Line: 26

              
public class ImgprocTest extends OpenCVTestCase {

    Point anchorPoint;
    private int imgprocSz;
    Size size;

    @Override
    protected void setUp() throws Exception {

            

Reported by PMD.

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

Line: 27

              public class ImgprocTest extends OpenCVTestCase {

    Point anchorPoint;
    private int imgprocSz;
    Size size;

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

              
    Point anchorPoint;
    private int imgprocSz;
    Size size;

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

                  private int imgprocSz;
    Size size;

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

        imgprocSz = 2;
        anchorPoint = new Point(2, 2);

            

Reported by PMD.

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

Line: 39

                      size = new Size(3, 3);
    }

    public void testAccumulateMatMat() {
        Mat src = getMat(CvType.CV_64F, 2);
        Mat dst = getMat(CvType.CV_64F, 0);
        Mat dst2 = src.clone();

        Imgproc.accumulate(src, dst);

            

Reported by PMD.

modules/gapi/misc/python/test/test_gapi_sample_pipelines.py
273 issues
Unable to import 'cv2'
Error

Line: 4 Column: 1

              #!/usr/bin/env python

import numpy as np
import cv2 as cv
import os
import sys
import unittest

from tests_common import NewOpenCVTests

            

Reported by Pylint.

Unable to import 'tests_common'
Error

Line: 9 Column: 1

              import sys
import unittest

from tests_common import NewOpenCVTests


try:

    if sys.version_info[:2] < (3, 0):

            

Reported by Pylint.

Class 'GAdd' has no 'on' member
Error

Line: 223 Column: 21

                          # G-API
            g_in1  = cv.GMat()
            g_in2  = cv.GMat()
            g_out = GAdd.on(g_in1, g_in2, cv.CV_8UC1)

            comp = cv.GComputation(cv.GIn(g_in1, g_in2), cv.GOut(g_out))

            pkg = cv.gapi.kernels(GAddImpl)
            actual = comp.apply(cv.gin(in_mat1, in_mat2), args=cv.gapi.compile_args(pkg))

            

Reported by Pylint.

Class 'GSplit3' has no 'on' member
Error

Line: 243 Column: 35

              
            # G-API
            g_in  = cv.GMat()
            g_ch1, g_ch2, g_ch3 = GSplit3.on(g_in)

            comp = cv.GComputation(cv.GIn(g_in), cv.GOut(g_ch1, g_ch2, g_ch3))

            pkg = cv.gapi.kernels(GSplit3Impl)
            ch1, ch2, ch3 = comp.apply(cv.gin(in_mat), args=cv.gapi.compile_args(pkg))

            

Reported by Pylint.

Class 'GMean' has no 'on' member
Error

Line: 264 Column: 21

              
            # G-API
            g_in  = cv.GMat()
            g_out = GMean.on(g_in)

            comp = cv.GComputation(g_in, g_out)

            pkg    = cv.gapi.kernels(GMeanImpl)
            actual = comp.apply(cv.gin(in_mat), args=cv.gapi.compile_args(pkg))

            

Reported by Pylint.

Class 'GAddC' has no 'on' member
Error

Line: 286 Column: 21

                          # G-API
            g_in  = cv.GMat()
            g_sc  = cv.GScalar()
            g_out = GAddC.on(g_in, g_sc, cv.CV_8UC1)
            comp  = cv.GComputation(cv.GIn(g_in, g_sc), cv.GOut(g_out))

            pkg = cv.gapi.kernels(GAddCImpl)
            actual = comp.apply(cv.gin(in_mat, sc), args=cv.gapi.compile_args(pkg))


            

Reported by Pylint.

Class 'GSize' has no 'on' member
Error

Line: 304 Column: 20

              
            # G-API
            g_in = cv.GMat()
            g_sz = GSize.on(g_in)
            comp = cv.GComputation(cv.GIn(g_in), cv.GOut(g_sz))

            pkg = cv.gapi.kernels(GSizeImpl)
            actual = comp.apply(cv.gin(in_mat), args=cv.gapi.compile_args(pkg))


            

Reported by Pylint.

Class 'GSizeR' has no 'on' member
Error

Line: 321 Column: 20

              
            # G-API
            g_r  = cv.GOpaque.Rect()
            g_sz = GSizeR.on(g_r)
            comp = cv.GComputation(cv.GIn(g_r), cv.GOut(g_sz))

            pkg = cv.gapi.kernels(GSizeRImpl)
            actual = comp.apply(cv.gin(roi), args=cv.gapi.compile_args(pkg))


            

Reported by Pylint.

Class 'GBoundingRect' has no 'on' member
Error

Line: 339 Column: 21

              
            # G-API
            g_pts = cv.GArray.Point()
            g_br  = GBoundingRect.on(g_pts)
            comp  = cv.GComputation(cv.GIn(g_pts), cv.GOut(g_br))

            pkg = cv.gapi.kernels(GBoundingRectImpl)
            actual = comp.apply(cv.gin(points), args=cv.gapi.compile_args(pkg))


            

Reported by Pylint.

Class 'GGoodFeatures' has no 'on' member
Error

Line: 369 Column: 21

              
            # G-API
            g_in = cv.GMat()
            g_out = GGoodFeatures.on(g_in, max_corners, quality_lvl,
                                     min_distance, block_sz, use_harris_detector, k)

            comp = cv.GComputation(cv.GIn(g_in), cv.GOut(g_out))
            pkg = cv.gapi.kernels(GGoodFeaturesImpl)
            actual = comp.apply(cv.gin(in_mat), args=cv.gapi.compile_args(pkg))

            

Reported by Pylint.

samples/dnn/virtual_try_on.py
206 issues
Unable to import 'cv2'
Error

Line: 13 Column: 1

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

from numpy import linalg
from common import findFile
from human_parsing import parse_human


            

Reported by Pylint.

Redefining name 'out_h' from outer scope (line 443)
Error

Line: 65 Column: 15

                  out = net.forward()

    threshold = 0.1
    _, out_c, out_h, out_w = out.shape
    pose_map = np.zeros((height, width, out_c - 1))
    # last label: Background
    for i in range(0, out.shape[1] - 1):
        heatMap = out[0, i, :, :]
        keypoint = np.full((height, width), -1)

            

Reported by Pylint.

Redefining name 'out_w' from outer scope (line 449)
Error

Line: 65 Column: 22

                  out = net.forward()

    threshold = 0.1
    _, out_c, out_h, out_w = out.shape
    pose_map = np.zeros((height, width, out_c - 1))
    # last label: Background
    for i in range(0, out.shape[1] - 1):
        heatMap = out[0, i, :, :]
        keypoint = np.full((height, width), -1)

            

Reported by Pylint.

Redefining name 'segm_image' from outer scope (line 457)
Error

Line: 144 Column: 32

                      self.tom_net.setPreferableBackend(backend)
        self.tom_net.setPreferableTarget(target)

    def prepare_agnostic(self, segm_image, input_image, pose_map, height=256, width=192):
        palette = {
            'Background'   : (0, 0, 0),
            'Hat'          : (128, 0, 0),
            'Hair'         : (255, 0, 0),
            'Glove'        : (0, 85, 0),

            

Reported by Pylint.

Redefining name 'agnostic' from outer scope (line 463)
Error

Line: 194 Column: 9

                      res_shape = cv.dnn.blobFromImage(res_shape, 1.0 / 127.5, mean=(127.5, 127.5, 127.5), swapRB=True)
        res_shape = res_shape.squeeze(0)

        agnostic = np.concatenate((res_shape, img_head, pose_map), axis=0)
        agnostic = np.expand_dims(agnostic, axis=0)
        return agnostic.astype(np.float32)

    def get_warped_cloth(self, cloth_img, agnostic, height=256, width=192):
        cloth = cv.dnn.blobFromImage(cloth_img, 1.0 / 127.5, (width, height), mean=(127.5, 127.5, 127.5), swapRB=True)

            

Reported by Pylint.

Redefining name 'agnostic' from outer scope (line 463)
Error

Line: 198 Column: 43

                      agnostic = np.expand_dims(agnostic, axis=0)
        return agnostic.astype(np.float32)

    def get_warped_cloth(self, cloth_img, agnostic, height=256, width=192):
        cloth = cv.dnn.blobFromImage(cloth_img, 1.0 / 127.5, (width, height), mean=(127.5, 127.5, 127.5), swapRB=True)

        self.gmm_net.setInput(agnostic, "input.1")
        self.gmm_net.setInput(cloth, "input.18")
        theta = self.gmm_net.forward()

            

Reported by Pylint.

Redefining name 'cloth_img' from outer scope (line 454)
Error

Line: 198 Column: 32

                      agnostic = np.expand_dims(agnostic, axis=0)
        return agnostic.astype(np.float32)

    def get_warped_cloth(self, cloth_img, agnostic, height=256, width=192):
        cloth = cv.dnn.blobFromImage(cloth_img, 1.0 / 127.5, (width, height), mean=(127.5, 127.5, 127.5), swapRB=True)

        self.gmm_net.setInput(agnostic, "input.1")
        self.gmm_net.setInput(cloth, "input.18")
        theta = self.gmm_net.forward()

            

Reported by Pylint.

Redefining name 'warped_cloth' from outer scope (line 464)
Error

Line: 206 Column: 9

                      theta = self.gmm_net.forward()

        grid = self._generate_grid(theta)
        warped_cloth = self._bilinear_sampler(cloth, grid).astype(np.float32)
        return warped_cloth

    def get_tryon(self, agnostic, warp_cloth):
        inp = np.concatenate([agnostic, warp_cloth], axis=1)
        self.tom_net.setInput(inp)

            

Reported by Pylint.

Redefining name 'agnostic' from outer scope (line 463)
Error

Line: 209 Column: 25

                      warped_cloth = self._bilinear_sampler(cloth, grid).astype(np.float32)
        return warped_cloth

    def get_tryon(self, agnostic, warp_cloth):
        inp = np.concatenate([agnostic, warp_cloth], axis=1)
        self.tom_net.setInput(inp)
        out = self.tom_net.forward()

        p_rendered, m_composite = np.split(out, [3], axis=1)

            

Reported by Pylint.

Possible unbalanced tuple unpacking with sequence defined at line 785 of numpy.lib.shape_base: left side has 2 label(s), right side has 0 value(s)
Error

Line: 214 Column: 9

                      self.tom_net.setInput(inp)
        out = self.tom_net.forward()

        p_rendered, m_composite = np.split(out, [3], axis=1)
        p_rendered = np.tanh(p_rendered)
        m_composite = 1 / (1 + np.exp(-m_composite))

        p_tryon = warp_cloth * m_composite + p_rendered * (1 - m_composite)
        rgb_p_tryon = cv.cvtColor(p_tryon.squeeze(0).transpose(1, 2, 0), cv.COLOR_BGR2RGB)

            

Reported by Pylint.

modules/python/src2/hdr_parser.py
196 issues
Unused import string
Error

Line: 4 Column: 1

              #!/usr/bin/env python

from __future__ import print_function
import os, sys, re, string, io

# the list only for debugging. The real list, used in the real OpenCV build, is specified in CMakeLists.txt
opencv_hdr_list = [
"../../core/include/opencv2/core.hpp",
"../../core/include/opencv2/core/mat.hpp",

            

Reported by Pylint.

Unused import os
Error

Line: 4 Column: 1

              #!/usr/bin/env python

from __future__ import print_function
import os, sys, re, string, io

# the list only for debugging. The real list, used in the real OpenCV build, is specified in CMakeLists.txt
opencv_hdr_list = [
"../../core/include/opencv2/core.hpp",
"../../core/include/opencv2/core/mat.hpp",

            

Reported by Pylint.

Unused variable 'pos3'
Error

Line: 351 Column: 33

                              else:
                    dfpos = arg.find("CV_DEFAULT")
                    if dfpos >= 0:
                        defval, pos3 = self.get_macro_arg(arg, dfpos)
                    else:
                        dfpos = arg.find("CV_WRAP_DEFAULT")
                        if dfpos >= 0:
                            defval, pos3 = self.get_macro_arg(arg, dfpos)
                if dfpos >= 0:

            

Reported by Pylint.

TODO: normalize all type of operators
Error

Line: 481 Column: 3

                              print("Error at %d: no args in '%s'" % (self.lineno, decl_str))
                sys.exit(-1)
            decl_start = decl_str[:args_begin].strip()
            # TODO: normalize all type of operators
            if decl_start.endswith("()"):
                decl_start = decl_start[0:-2].rstrip() + " ()"

        # constructor/destructor case
        if bool(re.match(r'^(\w+::)*(?P<x>\w+)::~?(?P=x)$', decl_start)):

            

Reported by Pylint.

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

Line: 502 Column: 53

                          if rettype == classname or rettype == "~" + classname:
                rettype, funcname = "", rettype
            else:
                if bool(re.match('\w+\s+\(\*\w+\)\s*\(.*\)', decl_str)):
                    return [] # function typedef
                elif bool(re.match('\w+\s+\(\w+::\*\w+\)\s*\(.*\)', decl_str)):
                    return [] # class method typedef
                elif bool(re.match('[A-Z_]+', decl_start)):
                    return [] # it seems to be a macro instantiation

            

Reported by Pylint.

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

Line: 502 Column: 50

                          if rettype == classname or rettype == "~" + classname:
                rettype, funcname = "", rettype
            else:
                if bool(re.match('\w+\s+\(\*\w+\)\s*\(.*\)', decl_str)):
                    return [] # function typedef
                elif bool(re.match('\w+\s+\(\w+::\*\w+\)\s*\(.*\)', decl_str)):
                    return [] # class method typedef
                elif bool(re.match('[A-Z_]+', decl_start)):
                    return [] # it seems to be a macro instantiation

            

Reported by Pylint.

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

Line: 502 Column: 48

                          if rettype == classname or rettype == "~" + classname:
                rettype, funcname = "", rettype
            else:
                if bool(re.match('\w+\s+\(\*\w+\)\s*\(.*\)', decl_str)):
                    return [] # function typedef
                elif bool(re.match('\w+\s+\(\w+::\*\w+\)\s*\(.*\)', decl_str)):
                    return [] # class method typedef
                elif bool(re.match('[A-Z_]+', decl_start)):
                    return [] # it seems to be a macro instantiation

            

Reported by Pylint.

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

Line: 502 Column: 45

                          if rettype == classname or rettype == "~" + classname:
                rettype, funcname = "", rettype
            else:
                if bool(re.match('\w+\s+\(\*\w+\)\s*\(.*\)', decl_str)):
                    return [] # function typedef
                elif bool(re.match('\w+\s+\(\w+::\*\w+\)\s*\(.*\)', decl_str)):
                    return [] # class method typedef
                elif bool(re.match('[A-Z_]+', decl_start)):
                    return [] # it seems to be a macro instantiation

            

Reported by Pylint.

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

Line: 502 Column: 43

                          if rettype == classname or rettype == "~" + classname:
                rettype, funcname = "", rettype
            else:
                if bool(re.match('\w+\s+\(\*\w+\)\s*\(.*\)', decl_str)):
                    return [] # function typedef
                elif bool(re.match('\w+\s+\(\w+::\*\w+\)\s*\(.*\)', decl_str)):
                    return [] # class method typedef
                elif bool(re.match('[A-Z_]+', decl_start)):
                    return [] # it seems to be a macro instantiation

            

Reported by Pylint.

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

Line: 502 Column: 57

                          if rettype == classname or rettype == "~" + classname:
                rettype, funcname = "", rettype
            else:
                if bool(re.match('\w+\s+\(\*\w+\)\s*\(.*\)', decl_str)):
                    return [] # function typedef
                elif bool(re.match('\w+\s+\(\w+::\*\w+\)\s*\(.*\)', decl_str)):
                    return [] # class method typedef
                elif bool(re.match('[A-Z_]+', decl_start)):
                    return [] # it seems to be a macro instantiation

            

Reported by Pylint.

modules/js/generator/embindgen.py
186 issues
Unable to import 'cStringIO'
Error

Line: 77 Column: 5

              if sys.version_info[0] >= 3:
    from io import StringIO
else:
    from cStringIO import StringIO


func_table = {}

# Ignore these functions due to Embind limitations for now

            

Reported by Pylint.

Value 'white_list' is unsubscriptable
Error

Line: 748 Column: 32

                          for name, func in sorted(ns.funcs.items()):
                if name in ignore_list:
                    continue
                if not name in white_list['']:
                    continue

                ext_cnst = False
                # Check if the method is an external constructor
                for variant in func.variants:

            

Reported by Pylint.

Value 'white_list' doesn't support membership test
Error

Line: 782 Column: 28

                      # generate code for the classes and their methods
        for name, class_info in sorted(self.classes.items()):
            class_bindings = []
            if not name in white_list:
                continue

            # Generate bindings for methods
            for method_name, method in sorted(class_info.methods.items()):
                if method.cname in ignore_list:

            

Reported by Pylint.

Value 'white_list' is unsubscriptable
Error

Line: 789 Column: 39

                          for method_name, method in sorted(class_info.methods.items()):
                if method.cname in ignore_list:
                    continue
                if not method.name in white_list[method.class_name]:
                    continue
                if method.is_constructor:
                    for variant in method.variants:
                        args = []
                        for arg in variant.args:

            

Reported by Pylint.

Unable to import 'hdr_parser'
Error

Line: 903 Column: 5

                  if hdr_parser_path.endswith(".py"):
        hdr_parser_path = os.path.dirname(hdr_parser_path)
    sys.path.append(hdr_parser_path)
    import hdr_parser

    bindingsCpp = sys.argv[2]
    headers = open(sys.argv[3], 'r').read().split(';')
    coreBindings = sys.argv[4]
    whiteListFile = sys.argv[5]

            

Reported by Pylint.

Unused import function_template from wildcard import
Error

Line: 72 Column: 1

              
from __future__ import print_function
import sys, re, os
from templates import *

if sys.version_info[0] >= 3:
    from io import StringIO
else:
    from cStringIO import StringIO

            

Reported by Pylint.

Unused import map_template from wildcard import
Error

Line: 72 Column: 1

              
from __future__ import print_function
import sys, re, os
from templates import *

if sys.version_info[0] >= 3:
    from io import StringIO
else:
    from cStringIO import StringIO

            

Reported by Pylint.

Unused import vector_template from wildcard import
Error

Line: 72 Column: 1

              
from __future__ import print_function
import sys, re, os
from templates import *

if sys.version_info[0] >= 3:
    from io import StringIO
else:
    from cStringIO import StringIO

            

Reported by Pylint.

Unused import static_function_template from wildcard import
Error

Line: 72 Column: 1

              
from __future__ import print_function
import sys, re, os
from templates import *

if sys.version_info[0] >= 3:
    from io import StringIO
else:
    from cStringIO import StringIO

            

Reported by Pylint.

Unused import wrapper_function_with_def_args_template from wildcard import
Error

Line: 72 Column: 1

              
from __future__ import print_function
import sys, re, os
from templates import *

if sys.version_info[0] >= 3:
    from io import StringIO
else:
    from cStringIO import StringIO

            

Reported by Pylint.