The following issues were found

samples/python/tutorial_code/imgProc/match_template/match_template.py
38 issues
Unable to import 'cv2'
Error

Line: 3 Column: 1

              from __future__ import print_function
import sys
import cv2 as cv

## [global_variables]
use_mask = False
img = None
templ = None
mask = None

            

Reported by Pylint.

Unused argument 'argv'
Error

Line: 17 Column: 10

              max_Trackbar = 5
## [global_variables]

def main(argv):

    if (len(sys.argv) < 3):
        print('Not enough parameters')
        print('Usage:\nmatch_template_demo.py <image_name> <template_name> [<mask_name>]')
        return -1

            

Reported by Pylint.

Using the global statement
Error

Line: 25 Column: 5

                      return -1

    ## [load_image]
    global img
    global templ
    img = cv.imread(sys.argv[1], cv.IMREAD_COLOR)
    templ = cv.imread(sys.argv[2], cv.IMREAD_COLOR)

    if (len(sys.argv) > 3):

            

Reported by Pylint.

Using the global statement
Error

Line: 26 Column: 5

              
    ## [load_image]
    global img
    global templ
    img = cv.imread(sys.argv[1], cv.IMREAD_COLOR)
    templ = cv.imread(sys.argv[2], cv.IMREAD_COLOR)

    if (len(sys.argv) > 3):
        global use_mask

            

Reported by Pylint.

Using the global statement
Error

Line: 31 Column: 9

                  templ = cv.imread(sys.argv[2], cv.IMREAD_COLOR)

    if (len(sys.argv) > 3):
        global use_mask
        use_mask = True
        global mask
        mask = cv.imread( sys.argv[3], cv.IMREAD_COLOR )

    if ((img is None) or (templ is None) or (use_mask and (mask is None))):

            

Reported by Pylint.

Using the global statement
Error

Line: 33 Column: 9

                  if (len(sys.argv) > 3):
        global use_mask
        use_mask = True
        global mask
        mask = cv.imread( sys.argv[3], cv.IMREAD_COLOR )

    if ((img is None) or (templ is None) or (use_mask and (mask is None))):
        print('Can\'t read one of the images')
        return -1

            

Reported by Pylint.

Using the global statement
Error

Line: 60 Column: 5

              
def MatchingMethod(param):

    global match_method
    match_method = param

    ## [copy_source]
    img_display = img.copy()
    ## [copy_source]

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 94 Column: 5

                  cv.imshow(image_window, img_display)
    cv.imshow(result_window, result)
    ## [imshow]
    pass

if __name__ == "__main__":
    main(sys.argv[1:])

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import print_function
import sys
import cv2 as cv

## [global_variables]
use_mask = False
img = None
templ = None
mask = None

            

Reported by Pylint.

Constant name "use_mask" doesn't conform to UPPER_CASE naming style
Error

Line: 6 Column: 1

              import cv2 as cv

## [global_variables]
use_mask = False
img = None
templ = None
mask = None
image_window = "Source Image"
result_window = "Result window"

            

Reported by Pylint.

modules/gapi/misc/python/samples/gaze_estimation.py
37 issues
Unable to import 'cv2'
Error

Line: 4 Column: 1

              import argparse
import time
import numpy as np
import cv2 as cv


# ------------------------Service operations------------------------
def weight_path(model_path):
    """ Get path of weights based on path to IR

            

Reported by Pylint.

Class 'GProcessPoses' has no 'on' member
Error

Line: 260 Column: 17

                  angles_r = face_outputs.at('angle_r_fc')

    # Parse poses
    heads_pos = GProcessPoses.on(angles_y, angles_p, angles_r)

    # Detect landmarks
    landmark_inputs = cv.GInferInputs()
    landmark_inputs.setInput('data', g_in)
    landmark_outputs = cv.gapi.infer('facial-landmarks', faces_rc,

            

Reported by Pylint.

Class 'GParseEyes' has no 'on' member
Error

Line: 270 Column: 43

                  landmark = landmark_outputs.at('align_fc3')

    # Parse landmarks
    left_eyes, right_eyes, mids, lmarks = GParseEyes.on(landmark, faces_rc, sz)

    # Detect eyes
    eyes_inputs = cv.GInferInputs()
    eyes_inputs.setInput('input.1', g_in)
    eyesl_outputs = cv.gapi.infer('open-closed-eye', left_eyes, eyes_inputs)

            

Reported by Pylint.

Class 'GGetStates' has no 'on' member
Error

Line: 281 Column: 26

                  eyesr = eyesr_outputs.at('19')

    # Process eyes states
    l_eye_st, r_eye_st = GGetStates.on(eyesl, eyesr)

    # Gaze estimation
    gaze_inputs = cv.GInferListInputs()
    gaze_inputs.setInput('left_eye_image', left_eyes)
    gaze_inputs.setInput('right_eye_image', right_eyes)

            

Reported by Pylint.

Unused argument 'arr_desc0'
Error

Line: 135 Column: 17

                          out_types=[cv.GArray.GMat])
class GProcessPoses:
    @staticmethod
    def outMeta(arr_desc0, arr_desc1, arr_desc2):
        return cv.empty_array_desc()


@cv.gapi.op('custom.GParseEyes',
            in_types=[cv.GArray.GMat, cv.GArray.Rect, cv.GOpaque.Size],

            

Reported by Pylint.

Unused argument 'arr_desc1'
Error

Line: 135 Column: 28

                          out_types=[cv.GArray.GMat])
class GProcessPoses:
    @staticmethod
    def outMeta(arr_desc0, arr_desc1, arr_desc2):
        return cv.empty_array_desc()


@cv.gapi.op('custom.GParseEyes',
            in_types=[cv.GArray.GMat, cv.GArray.Rect, cv.GOpaque.Size],

            

Reported by Pylint.

Unused argument 'arr_desc2'
Error

Line: 135 Column: 39

                          out_types=[cv.GArray.GMat])
class GProcessPoses:
    @staticmethod
    def outMeta(arr_desc0, arr_desc1, arr_desc2):
        return cv.empty_array_desc()


@cv.gapi.op('custom.GParseEyes',
            in_types=[cv.GArray.GMat, cv.GArray.Rect, cv.GOpaque.Size],

            

Reported by Pylint.

Unused argument 'arr_desc1'
Error

Line: 144 Column: 28

                          out_types=[cv.GArray.Rect, cv.GArray.Rect, cv.GArray.Point, cv.GArray.Point])
class GParseEyes:
    @staticmethod
    def outMeta(arr_desc0, arr_desc1, arr_desc2):
        return cv.empty_array_desc(), cv.empty_array_desc(), \
               cv.empty_array_desc(), cv.empty_array_desc()


@cv.gapi.op('custom.GGetStates',

            

Reported by Pylint.

Unused argument 'arr_desc0'
Error

Line: 144 Column: 17

                          out_types=[cv.GArray.Rect, cv.GArray.Rect, cv.GArray.Point, cv.GArray.Point])
class GParseEyes:
    @staticmethod
    def outMeta(arr_desc0, arr_desc1, arr_desc2):
        return cv.empty_array_desc(), cv.empty_array_desc(), \
               cv.empty_array_desc(), cv.empty_array_desc()


@cv.gapi.op('custom.GGetStates',

            

Reported by Pylint.

Unused argument 'arr_desc2'
Error

Line: 144 Column: 39

                          out_types=[cv.GArray.Rect, cv.GArray.Rect, cv.GArray.Point, cv.GArray.Point])
class GParseEyes:
    @staticmethod
    def outMeta(arr_desc0, arr_desc1, arr_desc2):
        return cv.empty_array_desc(), cv.empty_array_desc(), \
               cv.empty_array_desc(), cv.empty_array_desc()


@cv.gapi.op('custom.GGetStates',

            

Reported by Pylint.

modules/java/generator/android-21/java/org/opencv/android/CameraRenderer.java
37 issues
Avoid reassigning parameters such as 'width'
Design

Line: 120

                  }

    @Override
    public synchronized void setCameraPreviewSize(int width, int height) {
        Log.i(LOGTAG, "setCameraPreviewSize: "+width+"x"+height);
        if(mCamera == null) {
            Log.e(LOGTAG, "Camera isn't initialized!");
            return;
        }

            

Reported by PMD.

Avoid reassigning parameters such as 'height'
Design

Line: 120

                  }

    @Override
    public synchronized void setCameraPreviewSize(int width, int height) {
        Log.i(LOGTAG, "setCameraPreviewSize: "+width+"x"+height);
        if(mCamera == null) {
            Log.e(LOGTAG, "Camera isn't initialized!");
            return;
        }

            

Reported by PMD.

The class 'CameraRenderer' has a Modified Cyclomatic Complexity of 8 (Highest = 20).
Design

Line: 14

              
@TargetApi(15)
@SuppressWarnings("deprecation")
public class CameraRenderer extends CameraGLRendererBase {

    public static final String LOGTAG = "CameraRenderer";

    private Camera mCamera;
    private boolean mPreviewStarted = false;

            

Reported by PMD.

The class 'CameraRenderer' has a Standard Cyclomatic Complexity of 8 (Highest = 20).
Design

Line: 14

              
@TargetApi(15)
@SuppressWarnings("deprecation")
public class CameraRenderer extends CameraGLRendererBase {

    public static final String LOGTAG = "CameraRenderer";

    private Camera mCamera;
    private boolean mPreviewStarted = false;

            

Reported by PMD.

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

Line: 18

              
    public static final String LOGTAG = "CameraRenderer";

    private Camera mCamera;
    private boolean mPreviewStarted = false;

    CameraRenderer(CameraGLSurfaceView view) {
        super(view);
    }

            

Reported by PMD.

Avoid using redundant field initializer for 'mPreviewStarted'
Performance

Line: 19

                  public static final String LOGTAG = "CameraRenderer";

    private Camera mCamera;
    private boolean mPreviewStarted = false;

    CameraRenderer(CameraGLSurfaceView view) {
        super(view);
    }


            

Reported by PMD.

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

Line: 19

                  public static final String LOGTAG = "CameraRenderer";

    private Camera mCamera;
    private boolean mPreviewStarted = false;

    CameraRenderer(CameraGLSurfaceView view) {
        super(view);
    }


            

Reported by PMD.

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

Line: 32

                          mCamera.stopPreview();
            mPreviewStarted = false;
            mCamera.release();
            mCamera = null;
        }
    }

    @Override
    protected synchronized void openCamera(int id) {

            

Reported by PMD.

The method 'openCamera' has a Modified Cyclomatic Complexity of 20.
Design

Line: 37

                  }

    @Override
    protected synchronized void openCamera(int id) {
        Log.i(LOGTAG, "openCamera");
        closeCamera();
        if (id == CameraBridgeViewBase.CAMERA_ID_ANY) {
            Log.d(LOGTAG, "Trying to open camera with old open()");
            try {

            

Reported by PMD.

The method 'openCamera(int)' has an NPath complexity of 516, current threshold is 200
Design

Line: 37

                  }

    @Override
    protected synchronized void openCamera(int id) {
        Log.i(LOGTAG, "openCamera");
        closeCamera();
        if (id == CameraBridgeViewBase.CAMERA_ID_ANY) {
            Log.d(LOGTAG, "Trying to open camera with old open()");
            try {

            

Reported by PMD.

samples/java/tutorial_code/video/optical_flow/OpticalFlowDemo.java
36 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 this file");
            System.exit(-1);
        }


        // Create some random colors

            

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 this file");
            System.exit(-1);
        }


        // Create some random colors
        Scalar[] colors = new Scalar[100];

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 44

                      Mat mask = Mat.zeros(old_frame.size(), old_frame.type());

        while (true) {
            Mat frame = new Mat(), frame_gray = new Mat();
            capture.read(frame);
            if (frame.empty()) {
                break;
            }


            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 44

                      Mat mask = Mat.zeros(old_frame.size(), old_frame.type());

        while (true) {
            Mat frame = new Mat(), frame_gray = new Mat();
            capture.read(frame);
            if (frame.empty()) {
                break;
            }


            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 53

                          Imgproc.cvtColor(frame, frame_gray, Imgproc.COLOR_BGR2GRAY);

            // calculate optical flow
            MatOfByte status = new MatOfByte();
            MatOfFloat err = new MatOfFloat();
            TermCriteria criteria = new TermCriteria(TermCriteria.COUNT + TermCriteria.EPS,10,0.03);
            Video.calcOpticalFlowPyrLK(old_gray, frame_gray, p0, p1, status, err, new Size(15,15),2, criteria);

            byte StatusArr[] = status.toArray();

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 54

              
            // calculate optical flow
            MatOfByte status = new MatOfByte();
            MatOfFloat err = new MatOfFloat();
            TermCriteria criteria = new TermCriteria(TermCriteria.COUNT + TermCriteria.EPS,10,0.03);
            Video.calcOpticalFlowPyrLK(old_gray, frame_gray, p0, p1, status, err, new Size(15,15),2, criteria);

            byte StatusArr[] = status.toArray();
            Point p0Arr[] = p0.toArray();

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 55

                          // calculate optical flow
            MatOfByte status = new MatOfByte();
            MatOfFloat err = new MatOfFloat();
            TermCriteria criteria = new TermCriteria(TermCriteria.COUNT + TermCriteria.EPS,10,0.03);
            Video.calcOpticalFlowPyrLK(old_gray, frame_gray, p0, p1, status, err, new Size(15,15),2, criteria);

            byte StatusArr[] = status.toArray();
            Point p0Arr[] = p0.toArray();
            Point p1Arr[] = p1.toArray();

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 56

                          MatOfByte status = new MatOfByte();
            MatOfFloat err = new MatOfFloat();
            TermCriteria criteria = new TermCriteria(TermCriteria.COUNT + TermCriteria.EPS,10,0.03);
            Video.calcOpticalFlowPyrLK(old_gray, frame_gray, p0, p1, status, err, new Size(15,15),2, criteria);

            byte StatusArr[] = status.toArray();
            Point p0Arr[] = p0.toArray();
            Point p1Arr[] = p1.toArray();
            ArrayList<Point> good_new = new ArrayList<>();

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 61

                          byte StatusArr[] = status.toArray();
            Point p0Arr[] = p0.toArray();
            Point p1Arr[] = p1.toArray();
            ArrayList<Point> good_new = new ArrayList<>();

            for (int i = 0; i<StatusArr.length ; i++ ) {
                if (StatusArr[i] == 1) {
                    good_new.add(p1Arr[i]);
                    Imgproc.line(mask, p1Arr[i], p0Arr[i], colors[i],2);

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 64

                          ArrayList<Point> good_new = new ArrayList<>();

            for (int i = 0; i<StatusArr.length ; i++ ) {
                if (StatusArr[i] == 1) {
                    good_new.add(p1Arr[i]);
                    Imgproc.line(mask, p1Arr[i], p0Arr[i], colors[i],2);
                    Imgproc.circle(frame, p1Arr[i],5, colors[i],-1);
                }
            }

            

Reported by PMD.

samples/python/deconvolution.py
36 issues
Unable to import 'cv2'
Error

Line: 37 Column: 1

              from __future__ import print_function

import numpy as np
import cv2 as cv

# local module
from common import nothing



            

Reported by Pylint.

'A' does not support item assignment
Error

Line: 57 Column: 5

                  c, s = np.cos(angle), np.sin(angle)
    A = np.float32([[c, -s, 0], [s, c, 0]])
    sz2 = sz // 2
    A[:,2] = (sz2, sz2) - np.dot(A[:,:2], ((d-1)*0.5, 0))
    kern = cv.warpAffine(kern, A, (sz, sz), flags=cv.INTER_CUBIC)
    return kern

def defocus_kernel(d, sz=65):
    kern = np.zeros((sz, sz), np.uint8)

            

Reported by Pylint.

Value 'A' is unsubscriptable
Error

Line: 57 Column: 34

                  c, s = np.cos(angle), np.sin(angle)
    A = np.float32([[c, -s, 0], [s, c, 0]])
    sz2 = sz // 2
    A[:,2] = (sz2, sz2) - np.dot(A[:,:2], ((d-1)*0.5, 0))
    kern = cv.warpAffine(kern, A, (sz, sz), flags=cv.INTER_CUBIC)
    return kern

def defocus_kernel(d, sz=65):
    kern = np.zeros((sz, sz), np.uint8)

            

Reported by Pylint.

Unused nothing imported from common
Error

Line: 40 Column: 1

              import cv2 as cv

# local module
from common import nothing


def blur_edge(img, d=31):
    h, w  = img.shape[:2]
    img_pad = cv.copyMakeBorder(img, d, d, d, d, cv.BORDER_WRAP)

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 74 Column: 5

                  opts = dict(opts)
    try:
        fn = args[0]
    except:
        fn = 'licenseplate_motion.jpg'

    win = 'deconvolution'

    img = cv.imread(cv.samples.findFile(fn), cv.IMREAD_GRAYSCALE)

            

Reported by Pylint.

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

Line: 43 Column: 1

              from common import nothing


def blur_edge(img, d=31):
    h, w  = img.shape[:2]
    img_pad = cv.copyMakeBorder(img, d, d, d, d, cv.BORDER_WRAP)
    img_blur = cv.GaussianBlur(img_pad, (2*d+1, 2*d+1), -1)[d:-d,d:-d]
    y, x = np.indices((h, w))
    dist = np.dstack([x, w-x-1, y, h-y-1]).min(-1)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 43 Column: 1

              from common import nothing


def blur_edge(img, d=31):
    h, w  = img.shape[:2]
    img_pad = cv.copyMakeBorder(img, d, d, d, d, cv.BORDER_WRAP)
    img_blur = cv.GaussianBlur(img_pad, (2*d+1, 2*d+1), -1)[d:-d,d:-d]
    y, x = np.indices((h, w))
    dist = np.dstack([x, w-x-1, y, h-y-1]).min(-1)

            

Reported by Pylint.

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

Line: 44 Column: 8

              

def blur_edge(img, d=31):
    h, w  = img.shape[:2]
    img_pad = cv.copyMakeBorder(img, d, d, d, d, cv.BORDER_WRAP)
    img_blur = cv.GaussianBlur(img_pad, (2*d+1, 2*d+1), -1)[d:-d,d:-d]
    y, x = np.indices((h, w))
    dist = np.dstack([x, w-x-1, y, h-y-1]).min(-1)
    w = np.minimum(np.float32(dist)/d, 1.0)

            

Reported by Pylint.

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

Line: 44 Column: 5

              

def blur_edge(img, d=31):
    h, w  = img.shape[:2]
    img_pad = cv.copyMakeBorder(img, d, d, d, d, cv.BORDER_WRAP)
    img_blur = cv.GaussianBlur(img_pad, (2*d+1, 2*d+1), -1)[d:-d,d:-d]
    y, x = np.indices((h, w))
    dist = np.dstack([x, w-x-1, y, h-y-1]).min(-1)
    w = np.minimum(np.float32(dist)/d, 1.0)

            

Reported by Pylint.

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

Line: 47 Column: 5

                  h, w  = img.shape[:2]
    img_pad = cv.copyMakeBorder(img, d, d, d, d, cv.BORDER_WRAP)
    img_blur = cv.GaussianBlur(img_pad, (2*d+1, 2*d+1), -1)[d:-d,d:-d]
    y, x = np.indices((h, w))
    dist = np.dstack([x, w-x-1, y, h-y-1]).min(-1)
    w = np.minimum(np.float32(dist)/d, 1.0)
    return img*w + img_blur*(1-w)

def motion_kernel(angle, d, sz=65):

            

Reported by Pylint.

modules/ts/misc/xls-report.py
35 issues
No name 'ifilter' in module 'itertools'
Error

Line: 89 Column: 1

              
from argparse import ArgumentParser
from glob import glob
from itertools import ifilter

import xlwt

from testlog_parser import parseLogFile


            

Reported by Pylint.

Unable to import 'xlwt'
Error

Line: 91 Column: 1

              from glob import glob
from itertools import ifilter

import xlwt

from testlog_parser import parseLogFile

re_image_size = re.compile(r'^ \d+ x \d+$', re.VERBOSE)
re_data_type = re.compile(r'^ (?: 8 | 16 | 32 | 64 ) [USF] C [1234] $', re.VERBOSE)

            

Reported by Pylint.

Instance of 'dict' has no 'iteritems' member
Error

Line: 159 Column: 54

                                      Collector.__format_config_cache_key(props_key))

            else:
                same_config_props = [it[0] for it in self.__config_cache.iteritems() if it[1] == configuration]
                if len(same_config_props) > 0:
                    logging.warning('property set %s matches the same configuration %r as property set %s',
                        Collector.__format_config_cache_key(props_key),
                        configuration,
                        Collector.__format_config_cache_key(same_config_props[0]))

            

Reported by Pylint.

Instance of 'dict' has no 'iteritems' member
Error

Line: 309 Column: 37

                      module_styles = {module: xlwt.easyxf('pattern: pattern solid, fore_color {}'.format(color))
                         for module, color in module_colors.iteritems()}

        for module, tests in sorted(collector.tests.iteritems()):
            for ((test, param), configs) in sorted(tests.iteritems()):
                sheet.write(row, 0, module, module_styles.get(module, xlwt.Style.default_style))
                sheet.write(row, 1, test)

                param_list = param[1:-1].split(', ') if param.startswith('(') and param.endswith(')') else [param]

            

Reported by Pylint.

Unused glob imported from glob
Error

Line: 88 Column: 1

              import re

from argparse import ArgumentParser
from glob import glob
from itertools import ifilter

import xlwt

from testlog_parser import parseLogFile

            

Reported by Pylint.

Unused variable 'e'
Error

Line: 361 Column: 25

                                          sheet.write(row, col, speedup, good_speedup_style if speedup > 1.1 else
                                                           bad_speedup_style  if speedup < 0.9 else
                                                           speedup_style)
                        except ArithmeticError as e:
                            sheet.write(row, col, None, error_speedup_style)
                    else:
                        sheet.write(row, col, None, no_speedup_style)

                    col += 1

            

Reported by Pylint.

Module name "xls-report" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              #!/usr/bin/env python

"""
    This script can generate XLS reports from OpenCV tests' XML output files.

    To use it, first, create a directory for each machine you ran tests on.
    Each such directory will become a sheet in the report. Put each XML file
    into the corresponding directory.


            

Reported by Pylint.

Multiple imports on one line (os, os.path)
Error

Line: 84 Column: 1

              import fnmatch
import logging
import numbers
import os, os.path
import re

from argparse import ArgumentParser
from glob import glob
from itertools import ifilter

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 112 Column: 1

              header_style = xlwt.easyxf('font: bold true; alignment: horizontal centre, vertical top, wrap True')
subheader_style = xlwt.easyxf('alignment: horizontal centre, vertical top')

class Collector(object):
    def __init__(self, config_match_func, include_unmatched):
        self.__config_cache = {}
        self.config_match_func = config_match_func
        self.include_unmatched = include_unmatched
        self.tests = {}

            

Reported by Pylint.

Missing class docstring
Error

Line: 112 Column: 1

              header_style = xlwt.easyxf('font: bold true; alignment: horizontal centre, vertical top, wrap True')
subheader_style = xlwt.easyxf('alignment: horizontal centre, vertical top')

class Collector(object):
    def __init__(self, config_match_func, include_unmatched):
        self.__config_cache = {}
        self.config_match_func = config_match_func
        self.include_unmatched = include_unmatched
        self.tests = {}

            

Reported by Pylint.

modules/video/misc/java/test/VideoTest.java
35 issues
This class has too many methods, consider refactoring it.
Design

Line: 13

              import org.opencv.test.OpenCVTestCase;
import org.opencv.video.Video;

public class VideoTest extends OpenCVTestCase {

    private MatOfFloat err = null;
    private int h;
    private MatOfPoint2f nextPts = null;
    private MatOfPoint2f prevPts = null;

            

Reported by PMD.

Avoid using redundant field initializer for 'err'
Performance

Line: 15

              
public class VideoTest extends OpenCVTestCase {

    private MatOfFloat err = null;
    private int h;
    private MatOfPoint2f nextPts = null;
    private MatOfPoint2f prevPts = null;

    private int shift1;

            

Reported by PMD.

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

Line: 15

              
public class VideoTest extends OpenCVTestCase {

    private MatOfFloat err = null;
    private int h;
    private MatOfPoint2f nextPts = null;
    private MatOfPoint2f prevPts = null;

    private int shift1;

            

Reported by PMD.

Perhaps 'h' could be replaced by a local variable.
Design

Line: 16

              public class VideoTest extends OpenCVTestCase {

    private MatOfFloat err = null;
    private int h;
    private MatOfPoint2f nextPts = null;
    private MatOfPoint2f prevPts = null;

    private int shift1;
    private int shift2;

            

Reported by PMD.

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

Line: 16

              public class VideoTest extends OpenCVTestCase {

    private MatOfFloat err = null;
    private int h;
    private MatOfPoint2f nextPts = null;
    private MatOfPoint2f prevPts = null;

    private int shift1;
    private int shift2;

            

Reported by PMD.

Avoid using redundant field initializer for 'nextPts'
Performance

Line: 17

              
    private MatOfFloat err = null;
    private int h;
    private MatOfPoint2f nextPts = null;
    private MatOfPoint2f prevPts = null;

    private int shift1;
    private int shift2;


            

Reported by PMD.

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

Line: 17

              
    private MatOfFloat err = null;
    private int h;
    private MatOfPoint2f nextPts = null;
    private MatOfPoint2f prevPts = null;

    private int shift1;
    private int shift2;


            

Reported by PMD.

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

Line: 18

                  private MatOfFloat err = null;
    private int h;
    private MatOfPoint2f nextPts = null;
    private MatOfPoint2f prevPts = null;

    private int shift1;
    private int shift2;

    private MatOfByte status = null;

            

Reported by PMD.

Avoid using redundant field initializer for 'prevPts'
Performance

Line: 18

                  private MatOfFloat err = null;
    private int h;
    private MatOfPoint2f nextPts = null;
    private MatOfPoint2f prevPts = null;

    private int shift1;
    private int shift2;

    private MatOfByte status = null;

            

Reported by PMD.

Perhaps 'shift1' could be replaced by a local variable.
Design

Line: 20

                  private MatOfPoint2f nextPts = null;
    private MatOfPoint2f prevPts = null;

    private int shift1;
    private int shift2;

    private MatOfByte status = null;
    private Mat subLena1 = null;
    private Mat subLena2 = null;

            

Reported by PMD.

modules/calib3d/misc/java/test/StereoSGBMTest.java
35 issues
This class has too many methods, consider refactoring it.
Design

Line: 5

              
import org.opencv.test.OpenCVTestCase;

public class StereoSGBMTest extends OpenCVTestCase {

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


            

Reported by PMD.

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

Line: 7

              
public class StereoSGBMTest extends OpenCVTestCase {

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

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

            

Reported by PMD.

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

Line: 8

              public class StereoSGBMTest extends OpenCVTestCase {

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

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

            

Reported by PMD.

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

Line: 11

                      fail("Not yet implemented");
    }

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

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

            

Reported by PMD.

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

Line: 15

                      fail("Not yet implemented");
    }

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

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

            

Reported by PMD.

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

Line: 19

                      fail("Not yet implemented");
    }

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

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

            

Reported by PMD.

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

Line: 23

                      fail("Not yet implemented");
    }

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

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

            

Reported by PMD.

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

Line: 27

                      fail("Not yet implemented");
    }

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

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

            

Reported by PMD.

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

Line: 31

                      fail("Not yet implemented");
    }

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

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

            

Reported by PMD.

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

Line: 35

                      fail("Not yet implemented");
    }

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

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

            

Reported by PMD.

samples/python/demo.py
35 issues
subprocess call with shell=True identified, security issue.
Security injection

Line: 182
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

                  def on_run(self, *args):
        cmd = self.cmd_entry.get()
        print('running:', cmd)
        Popen(sys.executable + ' ' + cmd, shell=True)

    def run(self):
        tk.mainloop()



            

Reported by Bandit.

Undefined variable 'execfile'
Error

Line: 131 Column: 17

                          else:
                # Python 2
                module_globals = {}
                execfile(fn, module_globals)  # noqa: F821
                descr = module_globals.get('__doc__', 'no-description')
        except Exception as e:
            descr = str(e)

        self.linker.reset()

            

Reported by Pylint.

Unused argument 'event'
Error

Line: 52 Column: 22

                      self.links[tag] = action
        return "link", tag

    def _enter(self, event):
        self.text.config(cursor="hand2")
    def _leave(self, event):
        self.text.config(cursor="")
    def _click(self, event):
        for tag in self.text.tag_names(tk.CURRENT):

            

Reported by Pylint.

Unused argument 'event'
Error

Line: 54 Column: 22

              
    def _enter(self, event):
        self.text.config(cursor="hand2")
    def _leave(self, event):
        self.text.config(cursor="")
    def _click(self, event):
        for tag in self.text.tag_names(tk.CURRENT):
            if tag.startswith("link-"):
                proc = self.links[tag]

            

Reported by Pylint.

Unused argument 'event'
Error

Line: 56 Column: 22

                      self.text.config(cursor="hand2")
    def _leave(self, event):
        self.text.config(cursor="")
    def _click(self, event):
        for tag in self.text.tag_names(tk.CURRENT):
            if tag.startswith("link-"):
                proc = self.links[tag]
                if callable(proc):
                    proc()

            

Reported by Pylint.

Unused argument 'evt'
Error

Line: 114 Column: 30

                      print(url)
        webbrowser.open(url)

    def on_demo_select(self, evt):
        name = self.demos_lb.get( self.demos_lb.curselection()[0] )
        fn = self.samples[name]

        descr = ""
        try:

            

Reported by Pylint.

Use of exec detected.
Security

Line: 126
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html

                              module_locals = {}
                with open(fn, 'r') as f:
                    module_code = f.read()
                exec(compile(module_code, fn, 'exec'), module_globals, module_locals)
                descr = module_locals.get('__doc__', 'no-description')
            else:
                # Python 2
                module_globals = {}
                execfile(fn, module_globals)  # noqa: F821

            

Reported by Bandit.

Use of exec
Error

Line: 126 Column: 17

                              module_locals = {}
                with open(fn, 'r') as f:
                    module_code = f.read()
                exec(compile(module_code, fn, 'exec'), module_globals, module_locals)
                descr = module_locals.get('__doc__', 'no-description')
            else:
                # Python 2
                module_globals = {}
                execfile(fn, module_globals)  # noqa: F821

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 133 Column: 16

                              module_globals = {}
                execfile(fn, module_globals)  # noqa: F821
                descr = module_globals.get('__doc__', 'no-description')
        except Exception as e:
            descr = str(e)

        self.linker.reset()
        self.text.config(state='normal')
        self.text.delete(1.0, tk.END)

            

Reported by Pylint.

Unused argument 'args'
Error

Line: 179 Column: 1

                          else:
                text.tag_add(tag_proc, match_index, end_index)

    def on_run(self, *args):
        cmd = self.cmd_entry.get()
        print('running:', cmd)
        Popen(sys.executable + ' ' + cmd, shell=True)

    def run(self):

            

Reported by Pylint.

doc/tools/html_functions.py
35 issues
Assigning result of a function call, where the function has no return
Error

Line: 88 Column: 5

              def insert_python_fn_signature(soup, table, variants, symbol):
    description = create_python_fn_description(soup, variants)
    description['class'] = 'python_language'
    soup = insert_or_replace(table, description, 'table', 'python_language')
    return soup


def create_python_fn_description(soup, variants):
    language = 'Python:'

            

Reported by Pylint.

Unused import bs4
Error

Line: 11 Column: 5

              import traceback

try:
    import bs4
    from bs4 import BeautifulSoup
except ImportError:
    raise ImportError('Error: '
                      'Install BeautifulSoup (bs4) for adding'
                      ' Python & Java signatures documentation')

            

Reported by Pylint.

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

Line: 14 Column: 5

                  import bs4
    from bs4 import BeautifulSoup
except ImportError:
    raise ImportError('Error: '
                      'Install BeautifulSoup (bs4) for adding'
                      ' Python & Java signatures documentation')

def load_html_file(file_dir):
    """ Uses BeautifulSoup to load an html """

            

Reported by Pylint.

Use lazy % formatting in logging functions
Error

Line: 47 Column: 13

                      anchor = e['id']
        if anchor in symbols_dict:
            s = symbols_dict[anchor]
            logging.info('Process: %r' % s)
            if s.type == 'fn' or s.type == 'method':
                process_fn(soup, e, python_signatures[s.cppname], s)
            elif s.type == 'const':
                process_const(soup, e, python_signatures[s.cppname], s)
            else:

            

Reported by Pylint.

Unnecessary semicolon
Error

Line: 53 Column: 1

                          elif s.type == 'const':
                process_const(soup, e, python_signatures[s.cppname], s)
            else:
                logging.error('unsupported type: %s' % s);

    update_html(filepath, soup)


def process_fn(soup, anchor, python_signature, symbol):

            

Reported by Pylint.

Use lazy % formatting in logging functions
Error

Line: 53 Column: 17

                          elif s.type == 'const':
                process_const(soup, e, python_signatures[s.cppname], s)
            else:
                logging.error('unsupported type: %s' % s);

    update_html(filepath, soup)


def process_fn(soup, anchor, python_signature, symbol):

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 62 Column: 5

                  try:
        r = anchor.find_next_sibling(class_='memitem').find(class_='memproto').find('table')
        insert_python_fn_signature(soup, r, python_signature, symbol)
    except:
        logging.error("Can't process: %s" % symbol)
        traceback.print_exc()
        pprint(anchor)



            

Reported by Pylint.

Use lazy % formatting in logging functions
Error

Line: 63 Column: 9

                      r = anchor.find_next_sibling(class_='memitem').find(class_='memproto').find('table')
        insert_python_fn_signature(soup, r, python_signature, symbol)
    except:
        logging.error("Can't process: %s" % symbol)
        traceback.print_exc()
        pprint(anchor)


def process_const(soup, anchor, python_signature, symbol):

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 79 Column: 5

                      else:
            old.replace_with(description)
        #pprint(anchor.parent)
    except:
        logging.error("Can't process: %s" % symbol)
        traceback.print_exc()
        pprint(anchor)



            

Reported by Pylint.

Use lazy % formatting in logging functions
Error

Line: 80 Column: 9

                          old.replace_with(description)
        #pprint(anchor.parent)
    except:
        logging.error("Can't process: %s" % symbol)
        traceback.print_exc()
        pprint(anchor)


def insert_python_fn_signature(soup, table, variants, symbol):

            

Reported by Pylint.