The following issues were found

modules/java/test/common_test/src/org/opencv/test/utils/ConvertersTest.java
59 issues
Avoid instantiating Byte objects. Call Byte.valueOf() instead
Performance

Line: 31

                      byte value1 = 2;
        byte value2 = 4;
        byte value3 = 3;
        truth.add(new Byte(value1));
        truth.add(new Byte(value2));
        truth.add(new Byte(value3));
        assertEquals(truth, bs);
    }


            

Reported by PMD.

Avoid instantiating Byte objects. Call Byte.valueOf() instead
Performance

Line: 32

                      byte value2 = 4;
        byte value3 = 3;
        truth.add(new Byte(value1));
        truth.add(new Byte(value2));
        truth.add(new Byte(value3));
        assertEquals(truth, bs);
    }

    public void testMat_to_vector_DMatch() {

            

Reported by PMD.

Avoid instantiating Byte objects. Call Byte.valueOf() instead
Performance

Line: 33

                      byte value3 = 3;
        truth.add(new Byte(value1));
        truth.add(new Byte(value2));
        truth.add(new Byte(value3));
        assertEquals(truth, bs);
    }

    public void testMat_to_vector_DMatch() {
        Mat src = new Mat(4, 1, CvType.CV_64FC4);

            

Reported by PMD.

Avoid instantiating Byte objects. Call Byte.valueOf() instead
Performance

Line: 251

                      byte value1 = 2;
        byte value2 = 4;
        byte value3 = 3;
        truth.add(new Byte(value1));
        truth.add(new Byte(value2));
        truth.add(new Byte(value3));
        assertEquals(truth, bs);
    }


            

Reported by PMD.

Avoid instantiating Byte objects. Call Byte.valueOf() instead
Performance

Line: 252

                      byte value2 = 4;
        byte value3 = 3;
        truth.add(new Byte(value1));
        truth.add(new Byte(value2));
        truth.add(new Byte(value3));
        assertEquals(truth, bs);
    }

    public void testMat_to_vector_vector_char() {

            

Reported by PMD.

Avoid instantiating Byte objects. Call Byte.valueOf() instead
Performance

Line: 253

                      byte value3 = 3;
        truth.add(new Byte(value1));
        truth.add(new Byte(value2));
        truth.add(new Byte(value3));
        assertEquals(truth, bs);
    }

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

            

Reported by PMD.

Avoid instantiating Byte objects. Call Byte.valueOf() instead
Performance

Line: 279

                      byte value2 = 2;
        byte value3 = 3;
        byte value4 = 4;
        bytes.add(new Byte(value1));
        bytes.add(new Byte(value2));
        bytes.add(new Byte(value3));
        bytes.add(new Byte(value4));

        dst = Converters.vector_char_to_Mat(bytes);

            

Reported by PMD.

Avoid instantiating Byte objects. Call Byte.valueOf() instead
Performance

Line: 280

                      byte value3 = 3;
        byte value4 = 4;
        bytes.add(new Byte(value1));
        bytes.add(new Byte(value2));
        bytes.add(new Byte(value3));
        bytes.add(new Byte(value4));

        dst = Converters.vector_char_to_Mat(bytes);
        truth = new Mat(4, 1, CvType.CV_8SC1);

            

Reported by PMD.

Avoid instantiating Byte objects. Call Byte.valueOf() instead
Performance

Line: 281

                      byte value4 = 4;
        bytes.add(new Byte(value1));
        bytes.add(new Byte(value2));
        bytes.add(new Byte(value3));
        bytes.add(new Byte(value4));

        dst = Converters.vector_char_to_Mat(bytes);
        truth = new Mat(4, 1, CvType.CV_8SC1);
        truth.put(0, 0, 1, 2, 3, 4);

            

Reported by PMD.

Avoid instantiating Byte objects. Call Byte.valueOf() instead
Performance

Line: 282

                      bytes.add(new Byte(value1));
        bytes.add(new Byte(value2));
        bytes.add(new Byte(value3));
        bytes.add(new Byte(value4));

        dst = Converters.vector_char_to_Mat(bytes);
        truth = new Mat(4, 1, CvType.CV_8SC1);
        truth.put(0, 0, 1, 2, 3, 4);
        assertMatEqual(truth, dst);

            

Reported by PMD.

samples/python/video.py
59 issues
Unable to import 'cv2'
Error

Line: 36 Column: 1

              from __future__ import print_function

import numpy as np
import cv2 as cv

import re

from numpy import pi, sin, cos


            

Reported by Pylint.

Unused argument 'params'
Error

Line: 47 Column: 1

              import common

class VideoSynthBase(object):
    def __init__(self, size=None, noise=0.0, bg = None, **params):
        self.bg = None
        self.frame_size = (640, 480)
        if bg is not None:
            self.bg = cv.imread(cv.samples.findFile(bg))
            h, w = self.bg.shape[:2]

            

Reported by Pylint.

Unused argument 'dst'
Error

Line: 65 Column: 20

                  def render(self, dst):
        pass

    def read(self, dst=None):
        w, h = self.frame_size

        if self.bg is None:
            buf = np.zeros((h, w, 3), np.uint8)
        else:

            

Reported by Pylint.

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

Line: 117 Column: 13

                      self.grid_size = sx, sy = 10, 7
        white_quads = []
        black_quads = []
        for i, j in np.ndindex(sy, sx):
            q = [[j, i, 0], [j+1, i, 0], [j+1, i+1, 0], [j, i+1, 0]]
            [white_quads, black_quads][(i + j) % 2].append(q)
        self.white_quads = np.float32(white_quads)
        self.black_quads = np.float32(black_quads)


            

Reported by Pylint.

Redefining name 'img' from outer scope (line 216)
Error

Line: 131 Column: 26

                      self.dist_coef = np.float64([-0.2, 0.1, 0, 0])
        self.t = 0

    def draw_quads(self, img, quads, color = (0, 255, 0)):
        img_quads = cv.projectPoints(quads.reshape(-1, 3), self.rvec, self.tvec, self.K, self.dist_coef) [0]
        img_quads.shape = quads.shape[:2] + (2,)
        for q in img_quads:
            cv.fillConvexPoly(img, np.int32(q*4), color, cv.LINE_AA, shift=2)


            

Reported by Pylint.

Attribute 'tvec' defined outside __init__
Error

Line: 149 Column: 12

                      eye_pos = center + np.array([cos(t)*c, sin(t)*c, s]) * 15.0 + ofs
        target_pos = center + ofs

        R, self.tvec = common.lookat(eye_pos, target_pos)
        self.rvec = common.mtx2rvec(R)

        self.draw_quads(dst, self.white_quads, (245, 245, 245))
        self.draw_quads(dst, self.black_quads, (10, 10, 10))


            

Reported by Pylint.

Attribute 'rvec' defined outside __init__
Error

Line: 150 Column: 9

                      target_pos = center + ofs

        R, self.tvec = common.lookat(eye_pos, target_pos)
        self.rvec = common.mtx2rvec(R)

        self.draw_quads(dst, self.white_quads, (245, 245, 245))
        self.draw_quads(dst, self.black_quads, (10, 10, 10))



            

Reported by Pylint.

Redefining name 'cap' from outer scope (line 215)
Error

Line: 182 Column: 5

                  except ValueError: pass
    params = dict( s.split('=') for s in chunks[1:] )

    cap = None
    if source == 'synth':
        Class = classes.get(params.get('class', None), VideoSynthBase)
        try: cap = Class(**params)
        except: pass
    else:

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 186 Column: 9

                  if source == 'synth':
        Class = classes.get(params.get('class', None), VideoSynthBase)
        try: cap = Class(**params)
        except: pass
    else:
        cap = cv.VideoCapture(source)
        if 'size' in params:
            w, h = map(int, params['size'].split('x'))
            cap.set(cv.CAP_PROP_FRAME_WIDTH, w)

            

Reported by Pylint.

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

Line: 38 Column: 1

              import numpy as np
import cv2 as cv

import re

from numpy import pi, sin, cos

# local modules
from tst_scene_render import TestSceneRender

            

Reported by Pylint.

modules/ts/misc/testlog_parser.py
59 issues
Unused import re
Error

Line: 5 Column: 1

              
from __future__ import print_function
import collections
import re
import os.path
import sys
from xml.dom.minidom import parse

if sys.version_info > (3,):

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 43 Column: 1

                          if prop.hasAttribute("name") and prop.hasAttribute("value")
        }
        self.metrix = {}
        self.parseLongMetric(xmlnode, "bytesIn");
        self.parseLongMetric(xmlnode, "bytesOut");
        self.parseIntMetric(xmlnode, "samples");
        self.parseIntMetric(xmlnode, "outliers");
        self.parseFloatMetric(xmlnode, "frequency", 1);
        self.parseLongMetric(xmlnode, "min");

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 44 Column: 1

                      }
        self.metrix = {}
        self.parseLongMetric(xmlnode, "bytesIn");
        self.parseLongMetric(xmlnode, "bytesOut");
        self.parseIntMetric(xmlnode, "samples");
        self.parseIntMetric(xmlnode, "outliers");
        self.parseFloatMetric(xmlnode, "frequency", 1);
        self.parseLongMetric(xmlnode, "min");
        self.parseLongMetric(xmlnode, "median");

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 45 Column: 1

                      self.metrix = {}
        self.parseLongMetric(xmlnode, "bytesIn");
        self.parseLongMetric(xmlnode, "bytesOut");
        self.parseIntMetric(xmlnode, "samples");
        self.parseIntMetric(xmlnode, "outliers");
        self.parseFloatMetric(xmlnode, "frequency", 1);
        self.parseLongMetric(xmlnode, "min");
        self.parseLongMetric(xmlnode, "median");
        self.parseLongMetric(xmlnode, "gmean");

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 46 Column: 1

                      self.parseLongMetric(xmlnode, "bytesIn");
        self.parseLongMetric(xmlnode, "bytesOut");
        self.parseIntMetric(xmlnode, "samples");
        self.parseIntMetric(xmlnode, "outliers");
        self.parseFloatMetric(xmlnode, "frequency", 1);
        self.parseLongMetric(xmlnode, "min");
        self.parseLongMetric(xmlnode, "median");
        self.parseLongMetric(xmlnode, "gmean");
        self.parseLongMetric(xmlnode, "mean");

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 47 Column: 1

                      self.parseLongMetric(xmlnode, "bytesOut");
        self.parseIntMetric(xmlnode, "samples");
        self.parseIntMetric(xmlnode, "outliers");
        self.parseFloatMetric(xmlnode, "frequency", 1);
        self.parseLongMetric(xmlnode, "min");
        self.parseLongMetric(xmlnode, "median");
        self.parseLongMetric(xmlnode, "gmean");
        self.parseLongMetric(xmlnode, "mean");
        self.parseLongMetric(xmlnode, "stddev");

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 48 Column: 1

                      self.parseIntMetric(xmlnode, "samples");
        self.parseIntMetric(xmlnode, "outliers");
        self.parseFloatMetric(xmlnode, "frequency", 1);
        self.parseLongMetric(xmlnode, "min");
        self.parseLongMetric(xmlnode, "median");
        self.parseLongMetric(xmlnode, "gmean");
        self.parseLongMetric(xmlnode, "mean");
        self.parseLongMetric(xmlnode, "stddev");
        self.parseFloatMetric(xmlnode, "gstddev");

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 49 Column: 1

                      self.parseIntMetric(xmlnode, "outliers");
        self.parseFloatMetric(xmlnode, "frequency", 1);
        self.parseLongMetric(xmlnode, "min");
        self.parseLongMetric(xmlnode, "median");
        self.parseLongMetric(xmlnode, "gmean");
        self.parseLongMetric(xmlnode, "mean");
        self.parseLongMetric(xmlnode, "stddev");
        self.parseFloatMetric(xmlnode, "gstddev");
        self.parseFloatMetric(xmlnode, "time");

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 50 Column: 1

                      self.parseFloatMetric(xmlnode, "frequency", 1);
        self.parseLongMetric(xmlnode, "min");
        self.parseLongMetric(xmlnode, "median");
        self.parseLongMetric(xmlnode, "gmean");
        self.parseLongMetric(xmlnode, "mean");
        self.parseLongMetric(xmlnode, "stddev");
        self.parseFloatMetric(xmlnode, "gstddev");
        self.parseFloatMetric(xmlnode, "time");
        self.parseLongMetric(xmlnode, "total_memory_usage");

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 51 Column: 1

                      self.parseLongMetric(xmlnode, "min");
        self.parseLongMetric(xmlnode, "median");
        self.parseLongMetric(xmlnode, "gmean");
        self.parseLongMetric(xmlnode, "mean");
        self.parseLongMetric(xmlnode, "stddev");
        self.parseFloatMetric(xmlnode, "gstddev");
        self.parseFloatMetric(xmlnode, "time");
        self.parseLongMetric(xmlnode, "total_memory_usage");


            

Reported by Pylint.

platforms/winpack_dldt/2020.1/sysroot.config.py
58 issues
Undefined variable 'prepare_dir'
Error

Line: 1 Column: 19

              sysroot_bin_dir = prepare_dir(self.sysrootdir / 'bin')
copytree(self.build_dir / 'install', self.sysrootdir / 'ngraph')
#rm_one(self.sysrootdir / 'ngraph' / 'lib' / 'ngraph.dll')

build_config = 'Release' if not self.config.build_debug else 'Debug'
build_bin_dir = self.build_dir / 'bin' / 'intel64' / build_config

def copy_bin(name):
    global build_bin_dir, sysroot_bin_dir

            

Reported by Pylint.

Undefined variable 'self'
Error

Line: 1 Column: 31

              sysroot_bin_dir = prepare_dir(self.sysrootdir / 'bin')
copytree(self.build_dir / 'install', self.sysrootdir / 'ngraph')
#rm_one(self.sysrootdir / 'ngraph' / 'lib' / 'ngraph.dll')

build_config = 'Release' if not self.config.build_debug else 'Debug'
build_bin_dir = self.build_dir / 'bin' / 'intel64' / build_config

def copy_bin(name):
    global build_bin_dir, sysroot_bin_dir

            

Reported by Pylint.

Undefined variable 'self'
Error

Line: 2 Column: 10

              sysroot_bin_dir = prepare_dir(self.sysrootdir / 'bin')
copytree(self.build_dir / 'install', self.sysrootdir / 'ngraph')
#rm_one(self.sysrootdir / 'ngraph' / 'lib' / 'ngraph.dll')

build_config = 'Release' if not self.config.build_debug else 'Debug'
build_bin_dir = self.build_dir / 'bin' / 'intel64' / build_config

def copy_bin(name):
    global build_bin_dir, sysroot_bin_dir

            

Reported by Pylint.

Undefined variable 'self'
Error

Line: 2 Column: 38

              sysroot_bin_dir = prepare_dir(self.sysrootdir / 'bin')
copytree(self.build_dir / 'install', self.sysrootdir / 'ngraph')
#rm_one(self.sysrootdir / 'ngraph' / 'lib' / 'ngraph.dll')

build_config = 'Release' if not self.config.build_debug else 'Debug'
build_bin_dir = self.build_dir / 'bin' / 'intel64' / build_config

def copy_bin(name):
    global build_bin_dir, sysroot_bin_dir

            

Reported by Pylint.

Undefined variable 'copytree'
Error

Line: 2 Column: 1

              sysroot_bin_dir = prepare_dir(self.sysrootdir / 'bin')
copytree(self.build_dir / 'install', self.sysrootdir / 'ngraph')
#rm_one(self.sysrootdir / 'ngraph' / 'lib' / 'ngraph.dll')

build_config = 'Release' if not self.config.build_debug else 'Debug'
build_bin_dir = self.build_dir / 'bin' / 'intel64' / build_config

def copy_bin(name):
    global build_bin_dir, sysroot_bin_dir

            

Reported by Pylint.

Undefined variable 'self'
Error

Line: 5 Column: 33

              copytree(self.build_dir / 'install', self.sysrootdir / 'ngraph')
#rm_one(self.sysrootdir / 'ngraph' / 'lib' / 'ngraph.dll')

build_config = 'Release' if not self.config.build_debug else 'Debug'
build_bin_dir = self.build_dir / 'bin' / 'intel64' / build_config

def copy_bin(name):
    global build_bin_dir, sysroot_bin_dir
    copytree(build_bin_dir / name, sysroot_bin_dir / name)

            

Reported by Pylint.

Undefined variable 'self'
Error

Line: 6 Column: 17

              #rm_one(self.sysrootdir / 'ngraph' / 'lib' / 'ngraph.dll')

build_config = 'Release' if not self.config.build_debug else 'Debug'
build_bin_dir = self.build_dir / 'bin' / 'intel64' / build_config

def copy_bin(name):
    global build_bin_dir, sysroot_bin_dir
    copytree(build_bin_dir / name, sysroot_bin_dir / name)


            

Reported by Pylint.

Undefined variable 'copytree'
Error

Line: 10 Column: 5

              
def copy_bin(name):
    global build_bin_dir, sysroot_bin_dir
    copytree(build_bin_dir / name, sysroot_bin_dir / name)

dll_suffix = 'd' if self.config.build_debug else ''
def copy_dll(name):
    global copy_bin, dll_suffix
    copy_bin(name + dll_suffix + '.dll')

            

Reported by Pylint.

Undefined variable 'self'
Error

Line: 12 Column: 21

                  global build_bin_dir, sysroot_bin_dir
    copytree(build_bin_dir / name, sysroot_bin_dir / name)

dll_suffix = 'd' if self.config.build_debug else ''
def copy_dll(name):
    global copy_bin, dll_suffix
    copy_bin(name + dll_suffix + '.dll')
    copy_bin(name + dll_suffix + '.pdb')


            

Reported by Pylint.

Undefined variable 'self'
Error

Line: 28 Column: 10

              copy_dll('myriadPlugin')
copy_dll('ngraph')
copy_bin('plugins.xml')
copytree(self.build_dir / 'bin' / 'intel64' / 'pcie-ma248x.elf', sysroot_bin_dir / 'pcie-ma248x.elf')
copytree(self.build_dir / 'bin' / 'intel64' / 'usb-ma2x8x.mvcmd', sysroot_bin_dir / 'usb-ma2x8x.mvcmd')
copytree(self.build_dir / 'bin' / 'intel64' / 'usb-ma2450.mvcmd', sysroot_bin_dir / 'usb-ma2450.mvcmd')

copytree(self.srcdir / 'inference-engine' / 'temp' / 'tbb' / 'bin', sysroot_bin_dir)
copytree(self.srcdir / 'inference-engine' / 'temp' / 'tbb', self.sysrootdir / 'tbb')

            

Reported by Pylint.

modules/dnn/test/imagenet_cls_test_alexnet.py
58 issues
Consider explicitly re-raising using the 'from' keyword
Error

Line: 12 Column: 5

              try:
    import caffe
except ImportError:
    raise ImportError('Can\'t find Caffe Python module. If you\'ve built it from sources without installation, '
                      'configure environment variable PYTHONPATH to "git/caffe/python" directory')
try:
    import cv2 as cv
except ImportError:
    raise ImportError('Can\'t find OpenCV Python module. If you\'ve built it from sources without installation, '

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 17 Column: 5

              try:
    import cv2 as cv
except ImportError:
    raise ImportError('Can\'t find OpenCV Python module. If you\'ve built it from sources without installation, '
                      'configure environment variable PYTHONPATH to "opencv_build_dir/lib" directory (with "python3" subdirectory if required)')

try:
    xrange          # Python 2
except NameError:

            

Reported by Pylint.

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

Line: 80 Column: 5

              

class MeanChannelsFetch(MeanBlobFetch):
    def __init__(self, frame_size, imgs_dir):
        self.imgs_dir = imgs_dir
        self.frame_size = frame_size
        self.mean_blob = np.ones((3, self.frame_size, self.frame_size)).astype(np.float32)
        self.mean_blob[0] *= 104
        self.mean_blob[1] *= 117

            

Reported by Pylint.

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

Line: 90 Column: 5

              

class MeanValueFetch(MeanBlobFetch):
    def __init__(self, frame_size, imgs_dir, bgr_to_rgb):
        self.imgs_dir = imgs_dir
        self.frame_size = frame_size
        self.mean_blob = np.ones((3, self.frame_size, self.frame_size)).astype(np.float32)
        self.mean_blob *= 117
        self.bgr_to_rgb = bgr_to_rgb

            

Reported by Pylint.

Redefining name 'data_fetcher' from outer scope (line 241)
Error

Line: 177 Column: 35

                              result[l.split()[0]] = int(l.split()[1])
        return result

    def process(self, frameworks, data_fetcher):
        sorted_imgs_names = sorted(self.img_classes.keys())
        correct_answers = [0] * len(frameworks)
        samples_handled = 0
        blobs_l1_diff = [0] * len(frameworks)
        blobs_l1_diff_count = [0] * len(frameworks)

            

Reported by Pylint.

Redefining name 'frameworks' from outer scope (line 243)
Error

Line: 177 Column: 23

                              result[l.split()[0]] = int(l.split()[1])
        return result

    def process(self, frameworks, data_fetcher):
        sorted_imgs_names = sorted(self.img_classes.keys())
        correct_answers = [0] * len(frameworks)
        samples_handled = 0
        blobs_l1_diff = [0] * len(frameworks)
        blobs_l1_diff_count = [0] * len(frameworks)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import print_function
from abc import ABCMeta, abstractmethod
import numpy as np
import sys
import os
import argparse
import time

try:

            

Reported by Pylint.

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

Line: 4 Column: 1

              from __future__ import print_function
from abc import ABCMeta, abstractmethod
import numpy as np
import sys
import os
import argparse
import time

try:

            

Reported by Pylint.

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

Line: 5 Column: 1

              from abc import ABCMeta, abstractmethod
import numpy as np
import sys
import os
import argparse
import time

try:
    import caffe

            

Reported by Pylint.

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

Line: 6 Column: 1

              import numpy as np
import sys
import os
import argparse
import time

try:
    import caffe
except ImportError:

            

Reported by Pylint.

samples/python/tutorial_code/imgProc/threshold_inRange/threshold_inRange.py
58 issues
Unable to import 'cv2'
Error

Line: 2 Column: 1

              from __future__ import print_function
import cv2 as cv
import argparse

max_value = 255
max_value_H = 360//2
low_H = 0
low_S = 0
low_V = 0

            

Reported by Pylint.

Using the global statement
Error

Line: 24 Column: 5

              
## [low]
def on_low_H_thresh_trackbar(val):
    global low_H
    global high_H
    low_H = val
    low_H = min(high_H-1, low_H)
    cv.setTrackbarPos(low_H_name, window_detection_name, low_H)
## [low]

            

Reported by Pylint.

Using the global statement
Error

Line: 25 Column: 5

              ## [low]
def on_low_H_thresh_trackbar(val):
    global low_H
    global high_H
    low_H = val
    low_H = min(high_H-1, low_H)
    cv.setTrackbarPos(low_H_name, window_detection_name, low_H)
## [low]


            

Reported by Pylint.

Using the global statement
Error

Line: 33 Column: 5

              
## [high]
def on_high_H_thresh_trackbar(val):
    global low_H
    global high_H
    high_H = val
    high_H = max(high_H, low_H+1)
    cv.setTrackbarPos(high_H_name, window_detection_name, high_H)
## [high]

            

Reported by Pylint.

Using the global statement
Error

Line: 34 Column: 5

              ## [high]
def on_high_H_thresh_trackbar(val):
    global low_H
    global high_H
    high_H = val
    high_H = max(high_H, low_H+1)
    cv.setTrackbarPos(high_H_name, window_detection_name, high_H)
## [high]


            

Reported by Pylint.

Using the global statement
Error

Line: 41 Column: 5

              ## [high]

def on_low_S_thresh_trackbar(val):
    global low_S
    global high_S
    low_S = val
    low_S = min(high_S-1, low_S)
    cv.setTrackbarPos(low_S_name, window_detection_name, low_S)


            

Reported by Pylint.

Using the global statement
Error

Line: 42 Column: 5

              
def on_low_S_thresh_trackbar(val):
    global low_S
    global high_S
    low_S = val
    low_S = min(high_S-1, low_S)
    cv.setTrackbarPos(low_S_name, window_detection_name, low_S)

def on_high_S_thresh_trackbar(val):

            

Reported by Pylint.

Using the global statement
Error

Line: 48 Column: 5

                  cv.setTrackbarPos(low_S_name, window_detection_name, low_S)

def on_high_S_thresh_trackbar(val):
    global low_S
    global high_S
    high_S = val
    high_S = max(high_S, low_S+1)
    cv.setTrackbarPos(high_S_name, window_detection_name, high_S)


            

Reported by Pylint.

Using the global statement
Error

Line: 49 Column: 5

              
def on_high_S_thresh_trackbar(val):
    global low_S
    global high_S
    high_S = val
    high_S = max(high_S, low_S+1)
    cv.setTrackbarPos(high_S_name, window_detection_name, high_S)

def on_low_V_thresh_trackbar(val):

            

Reported by Pylint.

Using the global statement
Error

Line: 55 Column: 5

                  cv.setTrackbarPos(high_S_name, window_detection_name, high_S)

def on_low_V_thresh_trackbar(val):
    global low_V
    global high_V
    low_V = val
    low_V = min(high_V-1, low_V)
    cv.setTrackbarPos(low_V_name, window_detection_name, low_V)


            

Reported by Pylint.

modules/java/generator/android/java/org/opencv/android/CameraBridgeViewBase.java
57 issues
Overridable method 'enableFpsMeter' called during object construction
Error

Line: 76

              
        TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
        if (styledAttrs.getBoolean(R.styleable.CameraBridgeViewBase_show_fps, false))
            enableFpsMeter();

        mCameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);

        getHolder().addCallback(this);
        mMaxWidth = MAX_UNSPECIFIED;

            

Reported by PMD.

Possible God Class (WMC=63, ATFD=92, TCC=19.565%)
Design

Line: 30

               * frame to the screen.
 * The clients shall implement CvCameraViewListener.
 */
public abstract class CameraBridgeViewBase extends SurfaceView implements SurfaceHolder.Callback {

    private static final String TAG = "CameraBridge";
    protected static final int MAX_UNSPECIFIED = -1;
    private static final int STOPPED = 0;
    private static final int STARTED = 1;

            

Reported by PMD.

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

Line: 30

               * frame to the screen.
 * The clients shall implement CvCameraViewListener.
 */
public abstract class CameraBridgeViewBase extends SurfaceView implements SurfaceHolder.Callback {

    private static final String TAG = "CameraBridge";
    protected static final int MAX_UNSPECIFIED = -1;
    private static final int STOPPED = 0;
    private static final int STARTED = 1;

            

Reported by PMD.

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

Line: 37

                  private static final int STOPPED = 0;
    private static final int STARTED = 1;

    private int mState = STOPPED;
    private Bitmap mCacheBitmap;
    private CvCameraViewListener2 mListener;
    private boolean mSurfaceExist;
    private final Object mSyncObject = new Object();


            

Reported by PMD.

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

Line: 38

                  private static final int STARTED = 1;

    private int mState = STOPPED;
    private Bitmap mCacheBitmap;
    private CvCameraViewListener2 mListener;
    private boolean mSurfaceExist;
    private final Object mSyncObject = new Object();

    protected int mFrameWidth;

            

Reported by PMD.

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

Line: 39

              
    private int mState = STOPPED;
    private Bitmap mCacheBitmap;
    private CvCameraViewListener2 mListener;
    private boolean mSurfaceExist;
    private final Object mSyncObject = new Object();

    protected int mFrameWidth;
    protected int mFrameHeight;

            

Reported by PMD.

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

Line: 40

                  private int mState = STOPPED;
    private Bitmap mCacheBitmap;
    private CvCameraViewListener2 mListener;
    private boolean mSurfaceExist;
    private final Object mSyncObject = new Object();

    protected int mFrameWidth;
    protected int mFrameHeight;
    protected int mMaxHeight;

            

Reported by PMD.

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

Line: 41

                  private Bitmap mCacheBitmap;
    private CvCameraViewListener2 mListener;
    private boolean mSurfaceExist;
    private final Object mSyncObject = new Object();

    protected int mFrameWidth;
    protected int mFrameHeight;
    protected int mMaxHeight;
    protected int mMaxWidth;

            

Reported by PMD.

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

Line: 43

                  private boolean mSurfaceExist;
    private final Object mSyncObject = new Object();

    protected int mFrameWidth;
    protected int mFrameHeight;
    protected int mMaxHeight;
    protected int mMaxWidth;
    protected float mScale = 0;
    protected int mPreviewFormat = RGBA;

            

Reported by PMD.

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

Line: 44

                  private final Object mSyncObject = new Object();

    protected int mFrameWidth;
    protected int mFrameHeight;
    protected int mMaxHeight;
    protected int mMaxWidth;
    protected float mScale = 0;
    protected int mPreviewFormat = RGBA;
    protected int mCameraIndex = CAMERA_ID_ANY;

            

Reported by PMD.

modules/java/check-tests.py
57 issues
Anomalous backslash in string: '\w'. String constant might be missing an r prefix.
Error

Line: 13 Column: 6

              )

funcs_ignore_list = (
    '\w+--HashCode',
    'Mat--MatLong',
    '\w+--Equals',
    'Core--MinMaxLocResult',
)


            

Reported by Pylint.

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

Line: 15 Column: 6

              funcs_ignore_list = (
    '\w+--HashCode',
    'Mat--MatLong',
    '\w+--Equals',
    'Core--MinMaxLocResult',
)

class JavaParser:
    def __init__(self):

            

Reported by Pylint.

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

Line: 29 Column: 40

                      self.mwhere = {}
        self.twhere = {}
        self.empty_stubs_cnt = 0
        self.r1 = re.compile("\s*public\s+(?:static\s+)?(\w+)\(([^)]*)\)") # c-tor
        self.r2 = re.compile("\s*(?:(?:public|static|final)\s+){1,3}\S+\s+(\w+)\(([^)]*)\)")
        self.r3 = re.compile('\s*fail\("Not yet implemented"\);') # empty test stub


    def dict2set(self, d):

            

Reported by Pylint.

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

Line: 29 Column: 52

                      self.mwhere = {}
        self.twhere = {}
        self.empty_stubs_cnt = 0
        self.r1 = re.compile("\s*public\s+(?:static\s+)?(\w+)\(([^)]*)\)") # c-tor
        self.r2 = re.compile("\s*(?:(?:public|static|final)\s+){1,3}\S+\s+(\w+)\(([^)]*)\)")
        self.r3 = re.compile('\s*fail\("Not yet implemented"\);') # empty test stub


    def dict2set(self, d):

            

Reported by Pylint.

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

Line: 29 Column: 31

                      self.mwhere = {}
        self.twhere = {}
        self.empty_stubs_cnt = 0
        self.r1 = re.compile("\s*public\s+(?:static\s+)?(\w+)\(([^)]*)\)") # c-tor
        self.r2 = re.compile("\s*(?:(?:public|static|final)\s+){1,3}\S+\s+(\w+)\(([^)]*)\)")
        self.r3 = re.compile('\s*fail\("Not yet implemented"\);') # empty test stub


    def dict2set(self, d):

            

Reported by Pylint.

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

Line: 29 Column: 62

                      self.mwhere = {}
        self.twhere = {}
        self.empty_stubs_cnt = 0
        self.r1 = re.compile("\s*public\s+(?:static\s+)?(\w+)\(([^)]*)\)") # c-tor
        self.r2 = re.compile("\s*(?:(?:public|static|final)\s+){1,3}\S+\s+(\w+)\(([^)]*)\)")
        self.r3 = re.compile('\s*fail\("Not yet implemented"\);') # empty test stub


    def dict2set(self, d):

            

Reported by Pylint.

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

Line: 29 Column: 58

                      self.mwhere = {}
        self.twhere = {}
        self.empty_stubs_cnt = 0
        self.r1 = re.compile("\s*public\s+(?:static\s+)?(\w+)\(([^)]*)\)") # c-tor
        self.r2 = re.compile("\s*(?:(?:public|static|final)\s+){1,3}\S+\s+(\w+)\(([^)]*)\)")
        self.r3 = re.compile('\s*fail\("Not yet implemented"\);') # empty test stub


    def dict2set(self, d):

            

Reported by Pylint.

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

Line: 29 Column: 71

                      self.mwhere = {}
        self.twhere = {}
        self.empty_stubs_cnt = 0
        self.r1 = re.compile("\s*public\s+(?:static\s+)?(\w+)\(([^)]*)\)") # c-tor
        self.r2 = re.compile("\s*(?:(?:public|static|final)\s+){1,3}\S+\s+(\w+)\(([^)]*)\)")
        self.r3 = re.compile('\s*fail\("Not yet implemented"\);') # empty test stub


    def dict2set(self, d):

            

Reported by Pylint.

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

Line: 30 Column: 60

                      self.twhere = {}
        self.empty_stubs_cnt = 0
        self.r1 = re.compile("\s*public\s+(?:static\s+)?(\w+)\(([^)]*)\)") # c-tor
        self.r2 = re.compile("\s*(?:(?:public|static|final)\s+){1,3}\S+\s+(\w+)\(([^)]*)\)")
        self.r3 = re.compile('\s*fail\("Not yet implemented"\);') # empty test stub


    def dict2set(self, d):
        s = set()

            

Reported by Pylint.

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

Line: 30 Column: 89

                      self.twhere = {}
        self.empty_stubs_cnt = 0
        self.r1 = re.compile("\s*public\s+(?:static\s+)?(\w+)\(([^)]*)\)") # c-tor
        self.r2 = re.compile("\s*(?:(?:public|static|final)\s+){1,3}\S+\s+(\w+)\(([^)]*)\)")
        self.r3 = re.compile('\s*fail\("Not yet implemented"\);') # empty test stub


    def dict2set(self, d):
        s = set()

            

Reported by Pylint.

platforms/osx/build_framework.py
56 issues
Unable to import 'cv_build_utils'
Error

Line: 13 Column: 1

              sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios'))
from build_framework import Builder
sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../apple'))
from cv_build_utils import print_error, get_cmake_version

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

class OSXBuilder(Builder):


            

Reported by Pylint.

Unused import traceback
Error

Line: 7 Column: 1

              """

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

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

            

Reported by Pylint.

Module import itself
Error

Line: 11 Column: 1

              
# import common code
sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios'))
from build_framework import Builder
sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../apple'))
from cv_build_utils import print_error, get_cmake_version

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


            

Reported by Pylint.

Unused argument 'target'
Error

Line: 29 Column: 34

                      else:
            return 'osx'

    def getToolchain(self, arch, target):
        return None

    def getBuildCommand(self, arch, target):
        buildcmd = [
            "xcodebuild",

            

Reported by Pylint.

Unused argument 'arch'
Error

Line: 29 Column: 28

                      else:
            return 'osx'

    def getToolchain(self, arch, target):
        return None

    def getBuildCommand(self, arch, target):
        buildcmd = [
            "xcodebuild",

            

Reported by Pylint.

TODO: When we can make breaking changes, we should make the out argument explicit and required like in build_xcframework.py.
Error

Line: 61 Column: 3

              if __name__ == "__main__":
    folder = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../.."))
    parser = argparse.ArgumentParser(description='The script builds OpenCV.framework for OSX.')
    # TODO: When we can make breaking changes, we should make the out argument explicit and required like in build_xcframework.py.
    parser.add_argument('out', metavar='OUTDIR', help='folder to put built framework')
    parser.add_argument('--opencv', metavar='DIR', default=folder, help='folder with opencv repository (default is "../.." relative to script location)')
    parser.add_argument('--contrib', metavar='DIR', default=None, help='folder with opencv_contrib repository (default is "None" - build only main framework)')
    parser.add_argument('--without', metavar='MODULE', default=[], action='append', help='OpenCV modules to exclude from the framework. To exclude multiple, specify this flag again, e.g. "--without video --without objc"')
    parser.add_argument('--disable', metavar='FEATURE', default=[], action='append', help='OpenCV features to disable (add WITH_*=OFF). To disable multiple, specify this flag again, e.g. "--disable tbb --disable openmp"')

            

Reported by Pylint.

TODO: To avoid breaking existing CI, catalyst_archs has no defaults. When we can make a breaking change, this should specify a default arch.
Error

Line: 105 Column: 3

                  catalyst_archs = None
    if args.catalyst_archs:
        catalyst_archs = args.catalyst_archs.split(',')
    # TODO: To avoid breaking existing CI, catalyst_archs has no defaults. When we can make a breaking change, this should specify a default arch.
    print('Using Catalyst ARCHS=' + str(catalyst_archs))

    # Prevent the build from happening if the same architecture is specified for multiple platforms.
    # When `lipo` is run to stitch the frameworks together into a fat framework, it'll fail, so it's
    # better to stop here while we're ahead.

            

Reported by Pylint.

Expression "(targets.append((catalyst_archs, 'Catalyst')), )" is assigned to nothing
Error

Line: 129 Column: 9

                  if macos_archs:
        targets.append((macos_archs, "MacOSX"))
    if catalyst_archs:
        targets.append((catalyst_archs, "Catalyst")),

    b = OSXBuilder(args.opencv, args.contrib, args.dynamic, True, args.without, args.disable, args.enablenonfree, targets, args.debug, args.debug_info, args.framework_name, args.run_tests, args.build_docs, args.swiftdisabled)
    b.build(args.out)

            

Reported by Pylint.

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

Line: 7 Column: 1

              """

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

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

            

Reported by Pylint.

Import "from build_framework import Builder" should be placed at the top of the module
Error

Line: 11 Column: 1

              
# import common code
sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios'))
from build_framework import Builder
sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../apple'))
from cv_build_utils import print_error, get_cmake_version

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


            

Reported by Pylint.

modules/ts/misc/perf_tests_timing.py
56 issues
Instance of 'dict' has no 'iterkeys' member
Error

Line: 81 Column: 32

                          suit_time = 0
            suit_num = 0
            fails_num = 0
            for name in sorted(test_cases.iterkeys(), key=alphanum_keyselector):
                cases = test_cases[name]

                groupName = next(c for c in cases if c).shortName()
                if groupName != prevGroupName:
                    if prevGroupName != None:

            

Reported by Pylint.

Unused import tblRow from wildcard import
Error

Line: 5 Column: 1

              
from __future__ import print_function
import testlog_parser, sys, os, xml, glob, re
from table_formatter import *
from optparse import OptionParser
from operator import itemgetter, attrgetter
from summary import getSetName, alphanum_keyselector
import re


            

Reported by Pylint.

Unused import htmlEncode from wildcard import
Error

Line: 5 Column: 1

              
from __future__ import print_function
import testlog_parser, sys, os, xml, glob, re
from table_formatter import *
from optparse import OptionParser
from operator import itemgetter, attrgetter
from summary import getSetName, alphanum_keyselector
import re


            

Reported by Pylint.

Unused import htmlPrintHeader from wildcard import
Error

Line: 5 Column: 1

              
from __future__ import print_function
import testlog_parser, sys, os, xml, glob, re
from table_formatter import *
from optparse import OptionParser
from operator import itemgetter, attrgetter
from summary import getSetName, alphanum_keyselector
import re


            

Reported by Pylint.

Unused import val from wildcard import
Error

Line: 5 Column: 1

              
from __future__ import print_function
import testlog_parser, sys, os, xml, glob, re
from table_formatter import *
from optparse import OptionParser
from operator import itemgetter, attrgetter
from summary import getSetName, alphanum_keyselector
import re


            

Reported by Pylint.

Unused import getColorizer from wildcard import
Error

Line: 5 Column: 1

              
from __future__ import print_function
import testlog_parser, sys, os, xml, glob, re
from table_formatter import *
from optparse import OptionParser
from operator import itemgetter, attrgetter
from summary import getSetName, alphanum_keyselector
import re


            

Reported by Pylint.

Unused import getStdoutFilename from wildcard import
Error

Line: 5 Column: 1

              
from __future__ import print_function
import testlog_parser, sys, os, xml, glob, re
from table_formatter import *
from optparse import OptionParser
from operator import itemgetter, attrgetter
from summary import getSetName, alphanum_keyselector
import re


            

Reported by Pylint.

Unused import escape from wildcard import
Error

Line: 5 Column: 1

              
from __future__ import print_function
import testlog_parser, sys, os, xml, glob, re
from table_formatter import *
from optparse import OptionParser
from operator import itemgetter, attrgetter
from summary import getSetName, alphanum_keyselector
import re


            

Reported by Pylint.

Wildcard import table_formatter
Error

Line: 5 Column: 1

              
from __future__ import print_function
import testlog_parser, sys, os, xml, glob, re
from table_formatter import *
from optparse import OptionParser
from operator import itemgetter, attrgetter
from summary import getSetName, alphanum_keyselector
import re


            

Reported by Pylint.

Unused import math from wildcard import
Error

Line: 5 Column: 1

              
from __future__ import print_function
import testlog_parser, sys, os, xml, glob, re
from table_formatter import *
from optparse import OptionParser
from operator import itemgetter, attrgetter
from summary import getSetName, alphanum_keyselector
import re


            

Reported by Pylint.