The following issues were found

modules/core/src/opencl/runtime/generator/common.py
93 issues
No exception type(s) specified
Error

Line: 87 Column: 5

              def readFunctionFilter(fns, fileName):
    try:
        f = open(fileName, "r")
    except:
        print("ERROR: Can't open filter file: %s" % fileName)
        return 0

    count = 0
    while f:

            

Reported by Pylint.

Unused variable 'decl_args_str'
Error

Line: 174 Column: 9

                      decl_args = []
        for (i, t) in enumerate(fn['params']):
            decl_args.append(getTypeWithParam(t, 'p%d' % (i+1)))
        decl_args_str = '(' + (', '.join(decl_args)) + ')'
        print(commentStr + ('CL_RUNTIME_EXPORT %s%s (%s *%s_pfn)(%s) = %s;' % \
            ((' '.join(fn['modifiers'] + ' ') if len(fn['modifiers']) > 0 else ''),
             ' '.join(fn['ret']), ' '.join(fn['calling']), fn['name'], ', '.join(fn['params']), \
             fn['name'])))


            

Reported by Pylint.

Unused variable 'commentStr'
Error

Line: 185 Column: 9

                  print('// generated by %s' % os.path.basename(sys.argv[0]))
    print('static const struct DynamicFnEntry* %s[] = {' % (name))
    for fn in fns:
        commentStr = '' if 'enabled' in fn else '//'
        if 'enabled' in fn:
            print('    &%s_definition,' % (fn['name']))
        else:
            print('    NULL/*&%s_definition*/,' % (fn['name']))
        first = False

            

Reported by Pylint.

Unused variable 'first'
Error

Line: 190 Column: 9

                          print('    &%s_definition,' % (fn['name']))
        else:
            print('    NULL/*&%s_definition*/,' % (fn['name']))
        first = False
    print('};')

@outputToString
def generateEnums(fns, prefix='OPENCL_FN'):
    print('// generated by %s' % os.path.basename(sys.argv[0]))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import print_function
import sys, os, re

#
# Parser helpers
#

def remove_comments(s):
    def replacer(match):

            

Reported by Pylint.

Multiple imports on one line (sys, os, re)
Error

Line: 2 Column: 1

              from __future__ import print_function
import sys, os, re

#
# Parser helpers
#

def remove_comments(s):
    def replacer(match):

            

Reported by Pylint.

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

Line: 8 Column: 1

              # Parser helpers
#

def remove_comments(s):
    def replacer(match):
        s = match.group(0)
        if s.startswith('/'):
            return ""
        else:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              # Parser helpers
#

def remove_comments(s):
    def replacer(match):
        s = match.group(0)
        if s.startswith('/'):
            return ""
        else:

            

Reported by Pylint.

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

Line: 10 Column: 9

              
def remove_comments(s):
    def replacer(match):
        s = match.group(0)
        if s.startswith('/'):
            return ""
        else:
            return s
    pattern = re.compile(

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 11 Column: 9

              def remove_comments(s):
    def replacer(match):
        s = match.group(0)
        if s.startswith('/'):
            return ""
        else:
            return s
    pattern = re.compile(
        r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',

            

Reported by Pylint.

modules/dnn/misc/face_detector_accuracy.py
90 issues
Unable to import 'cv2'
Error

Line: 8 Column: 1

              import json
from fnmatch import fnmatch
from math import pi
import cv2 as cv
import argparse
import os
import sys
from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval

            

Reported by Pylint.

Unable to import 'pycocotools.coco'
Error

Line: 12 Column: 1

              import argparse
import os
import sys
from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval

parser = argparse.ArgumentParser(
        description='Evaluate OpenCV face detection algorithms '
                    'using COCO evaluation tool, http://cocodataset.org/#detections-eval')

            

Reported by Pylint.

Unable to import 'pycocotools.cocoeval'
Error

Line: 13 Column: 1

              import os
import sys
from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval

parser = argparse.ArgumentParser(
        description='Evaluate OpenCV face detection algorithms '
                    'using COCO evaluation tool, http://cocodataset.org/#detections-eval')
parser.add_argument('--proto', help='Path to .prototxt of Caffe model or .pbtxt of TensorFlow graph')

            

Reported by Pylint.

Reimport 'os' (imported line 4)
Error

Line: 10 Column: 1

              from math import pi
import cv2 as cv
import argparse
import os
import sys
from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval

parser = argparse.ArgumentParser(

            

Reported by Pylint.

Redefining name 'imageId' from outer scope (line 181)
Error

Line: 50 Column: 5

              
def addImage(imagePath):
    assert('images' in  dataset)
    imageId = len(dataset['images'])
    dataset['images'].append({
        'id': int(imageId),
        'file_name': imagePath
    })
    return imageId

            

Reported by Pylint.

Redefining name 'imageId' from outer scope (line 181)
Error

Line: 57 Column: 13

                  })
    return imageId

def addBBox(imageId, left, top, width, height):
    assert('annotations' in  dataset)
    dataset['annotations'].append({
        'id': len(dataset['annotations']),
        'image_id': int(imageId),
        'category_id': 0,  # Face

            

Reported by Pylint.

Redefining name 'detections' from outer scope (line 141)
Error

Line: 68 Column: 18

                      'area': float(width * height)
    })

def addDetection(detections, imageId, left, top, width, height, score):
    detections.append({
      'image_id': int(imageId),
      'category_id': 0,  # Face
      'bbox': [int(left), int(top), int(width), int(height)],
      'score': float(score)

            

Reported by Pylint.

Redefining name 'imageId' from outer scope (line 181)
Error

Line: 68 Column: 30

                      'area': float(width * height)
    })

def addDetection(detections, imageId, left, top, width, height, score):
    detections.append({
      'image_id': int(imageId),
      'category_id': 0,  # Face
      'bbox': [int(left), int(top), int(width), int(height)],
      'score': float(score)

            

Reported by Pylint.

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

Line: 80 Column: 62

              def fddb_dataset(annotations, images):
    for d in os.listdir(annotations):
        if fnmatch(d, 'FDDB-fold-*-ellipseList.txt'):
            with open(os.path.join(annotations, d), 'rt') as f:
                lines = [line.rstrip('\n') for line in f]
                lineId = 0
                while lineId < len(lines):
                    # Image
                    imgPath = lines[lineId]

            

Reported by Pylint.

Redefining name 'imageId' from outer scope (line 181)
Error

Line: 87 Column: 21

                                  # Image
                    imgPath = lines[lineId]
                    lineId += 1
                    imageId = addImage(os.path.join(images, imgPath) + '.jpg')

                    img = cv.imread(os.path.join(images, imgPath) + '.jpg')

                    # Faces
                    numFaces = int(lines[lineId])

            

Reported by Pylint.

samples/python/mosse.py
89 issues
Unable to import 'cv2'
Error

Line: 33 Column: 1

                  xrange = range

import numpy as np
import cv2 as cv
from common import draw_str, RectSelector
import video

def rnd_warp(a):
    h, w = a.shape[:2]

            

Reported by Pylint.

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

Line: 148 Column: 24

                      self.H[...,1] *= -1

class App:
    def __init__(self, video_src, paused = False):
        self.cap = video.create_capture(video_src)
        _, self.frame = self.cap.read()
        cv.imshow('frame', self.frame)
        self.rect_sel = RectSelector('frame', self.onrect)
        self.trackers = []

            

Reported by Pylint.

Reimport 'sys' (imported line 26)
Error

Line: 190 Column: 5

              
if __name__ == '__main__':
    print (__doc__)
    import sys, getopt
    opts, args = getopt.getopt(sys.argv[1:], '', ['pause'])
    opts = dict(opts)
    try:
        video_src = args[0]
    except:

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 195 Column: 5

                  opts = dict(opts)
    try:
        video_src = args[0]
    except:
        video_src = '0'

    App(video_src, paused = '--pause' in opts).run()

            

Reported by Pylint.

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

Line: 30 Column: 5

              PY3 = sys.version_info[0] == 3

if PY3:
    xrange = range

import numpy as np
import cv2 as cv
from common import draw_str, RectSelector
import video

            

Reported by Pylint.

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

Line: 32 Column: 1

              if PY3:
    xrange = range

import numpy as np
import cv2 as cv
from common import draw_str, RectSelector
import video

def rnd_warp(a):

            

Reported by Pylint.

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

Line: 33 Column: 1

                  xrange = range

import numpy as np
import cv2 as cv
from common import draw_str, RectSelector
import video

def rnd_warp(a):
    h, w = a.shape[:2]

            

Reported by Pylint.

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

Line: 34 Column: 1

              
import numpy as np
import cv2 as cv
from common import draw_str, RectSelector
import video

def rnd_warp(a):
    h, w = a.shape[:2]
    T = np.zeros((2, 3))

            

Reported by Pylint.

Import "import video" should be placed at the top of the module
Error

Line: 35 Column: 1

              import numpy as np
import cv2 as cv
from common import draw_str, RectSelector
import video

def rnd_warp(a):
    h, w = a.shape[:2]
    T = np.zeros((2, 3))
    coef = 0.2

            

Reported by Pylint.

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

Line: 37 Column: 1

              from common import draw_str, RectSelector
import video

def rnd_warp(a):
    h, w = a.shape[:2]
    T = np.zeros((2, 3))
    coef = 0.2
    ang = (np.random.rand()-0.5)*coef
    c, s = np.cos(ang), np.sin(ang)

            

Reported by Pylint.

samples/dnn/tf_text_graph_common.py
89 issues
No exception type(s) specified
Error

Line: 221 Column: 33

                                          if isinstance(v, str) and not v.startswith('DT_'):
                                try:
                                    float(v)
                                except:
                                    isString = True

                            if isinstance(v, bool):
                                printed = 'true' if v else 'false'
                            elif v == 'true' or v == 'false':

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 318 Column: 5

                      import cv2 as cv

        cv.dnn.writeTextGraph(modelPath, outputPath)
    except:
        import tensorflow as tf
        from tensorflow.tools.graph_transforms import TransformGraph

        with tf.gfile.FastGFile(modelPath, 'rb') as f:
            graph_def = tf.GraphDef()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              def tokenize(s):
    tokens = []
    token = ""
    isString = False
    isComment = False
    for symbol in s:
        isComment = (isComment and symbol != '\n') or (not isString and symbol == '#')
        if isComment:
            continue

            

Reported by Pylint.

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

Line: 1 Column: 1

              def tokenize(s):
    tokens = []
    token = ""
    isString = False
    isComment = False
    for symbol in s:
        isComment = (isComment and symbol != '\n') or (not isString and symbol == '#')
        if isComment:
            continue

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 1 Column: 1

              def tokenize(s):
    tokens = []
    token = ""
    isString = False
    isComment = False
    for symbol in s:
        isComment = (isComment and symbol != '\n') or (not isString and symbol == '#')
        if isComment:
            continue

            

Reported by Pylint.

Possible hardcoded password: ''
Security

Line: 3
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b105_hardcoded_password_string.html

              def tokenize(s):
    tokens = []
    token = ""
    isString = False
    isComment = False
    for symbol in s:
        isComment = (isComment and symbol != '\n') or (not isString and symbol == '#')
        if isComment:
            continue

            

Reported by Bandit.

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

Line: 4 Column: 5

              def tokenize(s):
    tokens = []
    token = ""
    isString = False
    isComment = False
    for symbol in s:
        isComment = (isComment and symbol != '\n') or (not isString and symbol == '#')
        if isComment:
            continue

            

Reported by Pylint.

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

Line: 5 Column: 5

                  tokens = []
    token = ""
    isString = False
    isComment = False
    for symbol in s:
        isComment = (isComment and symbol != '\n') or (not isString and symbol == '#')
        if isComment:
            continue


            

Reported by Pylint.

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

Line: 7 Column: 9

                  isString = False
    isComment = False
    for symbol in s:
        isComment = (isComment and symbol != '\n') or (not isString and symbol == '#')
        if isComment:
            continue

        if symbol == ' ' or symbol == '\t' or symbol == '\r' or symbol == '\'' or \
           symbol == '\n' or symbol == ':' or symbol == '\"' or symbol == ';' or \

            

Reported by Pylint.

Consider merging these comparisons with "in" to 'symbol in (\' \', \'\\t\', \'\\r\', "\'", \'\\n\', \':\', \'"\', \';\', \',\')'
Error

Line: 11 Column: 12

                      if isComment:
            continue

        if symbol == ' ' or symbol == '\t' or symbol == '\r' or symbol == '\'' or \
           symbol == '\n' or symbol == ':' or symbol == '\"' or symbol == ';' or \
           symbol == ',':

            if (symbol == '\"' or symbol == '\'') and isString:
                tokens.append(token)

            

Reported by Pylint.

samples/dnn/tf_text_graph_ssd.py
89 issues
Unused import addSoftMax from wildcard import
Error

Line: 15 Column: 1

              import argparse
import re
from math import sqrt
from tf_text_graph_common import *

class SSDAnchorGenerator:
    def __init__(self, min_scale, max_scale, num_layers, aspect_ratios,
                 reduce_boxes_in_lowest_layer, image_width, image_height):
        self.min_scale = min_scale

            

Reported by Pylint.

Unused import GraphDef from wildcard import
Error

Line: 15 Column: 1

              import argparse
import re
from math import sqrt
from tf_text_graph_common import *

class SSDAnchorGenerator:
    def __init__(self, min_scale, max_scale, num_layers, aspect_ratios,
                 reduce_boxes_in_lowest_layer, image_width, image_height):
        self.min_scale = min_scale

            

Reported by Pylint.

Unused import parseMessage from wildcard import
Error

Line: 15 Column: 1

              import argparse
import re
from math import sqrt
from tf_text_graph_common import *

class SSDAnchorGenerator:
    def __init__(self, min_scale, max_scale, num_layers, aspect_ratios,
                 reduce_boxes_in_lowest_layer, image_width, image_height):
        self.min_scale = min_scale

            

Reported by Pylint.

Unused import listToTensor from wildcard import
Error

Line: 15 Column: 1

              import argparse
import re
from math import sqrt
from tf_text_graph_common import *

class SSDAnchorGenerator:
    def __init__(self, min_scale, max_scale, num_layers, aspect_ratios,
                 reduce_boxes_in_lowest_layer, image_width, image_height):
        self.min_scale = min_scale

            

Reported by Pylint.

Wildcard import tf_text_graph_common
Error

Line: 15 Column: 1

              import argparse
import re
from math import sqrt
from tf_text_graph_common import *

class SSDAnchorGenerator:
    def __init__(self, min_scale, max_scale, num_layers, aspect_ratios,
                 reduce_boxes_in_lowest_layer, image_width, image_height):
        self.min_scale = min_scale

            

Reported by Pylint.

Unused import addSlice from wildcard import
Error

Line: 15 Column: 1

              import argparse
import re
from math import sqrt
from tf_text_graph_common import *

class SSDAnchorGenerator:
    def __init__(self, min_scale, max_scale, num_layers, aspect_ratios,
                 reduce_boxes_in_lowest_layer, image_width, image_height):
        self.min_scale = min_scale

            

Reported by Pylint.

Unused import tokenize from wildcard import
Error

Line: 15 Column: 1

              import argparse
import re
from math import sqrt
from tf_text_graph_common import *

class SSDAnchorGenerator:
    def __init__(self, min_scale, max_scale, num_layers, aspect_ratios,
                 reduce_boxes_in_lowest_layer, image_width, image_height):
        self.min_scale = min_scale

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 240 Column: 5

                      input_shape = graph_def.node[0].attr['shape']['shape'][0]['dim']
        input_shape[1]['size'] = image_height
        input_shape[2]['size'] = image_width
    except:
        print("Input shapes are undefined")
    # assert(graph_def.node[1].op == 'Conv2D')
    weights = graph_def.node[1].input[-1]
    for i in range(len(graph_def.node[1].input)):
        graph_def.node[1].input.pop()

            

Reported by Pylint.

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

Line: 295 Column: 35

              
    num_matched_layers = 0
    for node in graph_def.node:
        if re.match('BoxPredictor_\d/BoxEncodingPredictor/convolution', node.name) or \
           re.match('BoxPredictor_\d/BoxEncodingPredictor/Conv2D', node.name) or \
           re.match('WeightSharedConvolutionalBoxPredictor(_\d)*/BoxPredictor/Conv2D', node.name):
            node.addAttr('loc_pred_transposed', True)
            num_matched_layers += 1
    assert(num_matched_layers == num_layers)

            

Reported by Pylint.

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

Line: 296 Column: 35

                  num_matched_layers = 0
    for node in graph_def.node:
        if re.match('BoxPredictor_\d/BoxEncodingPredictor/convolution', node.name) or \
           re.match('BoxPredictor_\d/BoxEncodingPredictor/Conv2D', node.name) or \
           re.match('WeightSharedConvolutionalBoxPredictor(_\d)*/BoxPredictor/Conv2D', node.name):
            node.addAttr('loc_pred_transposed', True)
            num_matched_layers += 1
    assert(num_matched_layers == num_layers)


            

Reported by Pylint.

modules/gapi/misc/python/test/test_gapi_infer.py
87 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.

method already defined line 208
Error

Line: 267 Column: 9

                                                        cv.NORM_INF))


        def test_person_detection_retail_0013(self):
            # NB: Check IE
            if not cv.dnn.DNN_TARGET_CPU in cv.dnn.getAvailableTargets(cv.dnn.DNN_BACKEND_INFERENCE_ENGINE):
                return

            root_path    = '/omz_intel_models/intel/person-detection-retail-0013/FP32/person-detection-retail-0013'

            

Reported by Pylint.

Method has no argument
Error

Line: 334 Column: 9

                      def setUp(self):
            self.skipTest('Skip tests: ' + message)

        def test_skip():
            pass

    pass



            

Reported by Pylint.

Unused variable 'class_id'
Error

Line: 231 Column: 32

                              h, w = size
                bboxes = []
                detections = detections.reshape(-1, 7)
                for sample_id, class_id, confidence, xmin, ymin, xmax, ymax in detections:
                    if confidence >= 0.5:
                        x      = int(xmin * w)
                        y      = int(ymin * h)
                        width  = int(xmax * w - x)
                        height = int(ymax * h - y)

            

Reported by Pylint.

Unused variable 'sample_id'
Error

Line: 231 Column: 21

                              h, w = size
                bboxes = []
                detections = detections.reshape(-1, 7)
                for sample_id, class_id, confidence, xmin, ymin, xmax, ymax in detections:
                    if confidence >= 0.5:
                        x      = int(xmin * w)
                        y      = int(ymin * h)
                        width  = int(xmax * w - x)
                        height = int(ymax * h - y)

            

Reported by Pylint.

Unused variable 'class_id'
Error

Line: 290 Column: 32

                              h, w = size
                bboxes = []
                detections = detections.reshape(-1, 7)
                for sample_id, class_id, confidence, xmin, ymin, xmax, ymax in detections:
                    if confidence >= 0.5:
                        x      = int(xmin * w)
                        y      = int(ymin * h)
                        width  = int(xmax * w - x)
                        height = int(ymax * h - y)

            

Reported by Pylint.

Unused variable 'sample_id'
Error

Line: 290 Column: 21

                              h, w = size
                bboxes = []
                detections = detections.reshape(-1, 7)
                for sample_id, class_id, confidence, xmin, ymin, xmax, ymax in detections:
                    if confidence >= 0.5:
                        x      = int(xmin * w)
                        y      = int(ymin * h)
                        width  = int(xmax * w - x)
                        height = int(ymax * h - y)

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 337 Column: 5

                      def test_skip():
            pass

    pass


if __name__ == '__main__':
    NewOpenCVTests.bootstrap()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 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.

modules/java/generator/src/java/org/opencv/utils/Converters.java
86 issues
This class has a bunch of public methods and attributes
Design

Line: 1

              package org.opencv.utils;

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

import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.MatOfByte;
import org.opencv.core.MatOfDMatch;

            

Reported by PMD.

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

Line: 23

              import org.opencv.core.DMatch;
import org.opencv.core.KeyPoint;

public class Converters {

    public static Mat vector_Point_to_Mat(List<Point> pts) {
        return vector_Point_to_Mat(pts, CvType.CV_32S);
    }


            

Reported by PMD.

Possible God Class (WMC=230, ATFD=115, TCC=0.000%)
Design

Line: 23

              import org.opencv.core.DMatch;
import org.opencv.core.KeyPoint;

public class Converters {

    public static Mat vector_Point_to_Mat(List<Point> pts) {
        return vector_Point_to_Mat(pts, CvType.CV_32S);
    }


            

Reported by PMD.

The class 'Converters' has a total cyclomatic complexity of 230 (highest 12).
Design

Line: 23

              import org.opencv.core.DMatch;
import org.opencv.core.KeyPoint;

public class Converters {

    public static Mat vector_Point_to_Mat(List<Point> pts) {
        return vector_Point_to_Mat(pts, CvType.CV_32S);
    }


            

Reported by PMD.

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

Line: 23

              import org.opencv.core.DMatch;
import org.opencv.core.KeyPoint;

public class Converters {

    public static Mat vector_Point_to_Mat(List<Point> pts) {
        return vector_Point_to_Mat(pts, CvType.CV_32S);
    }


            

Reported by PMD.

The method 'vector_Point_to_Mat(List, int)' has a cyclomatic complexity of 10.
Design

Line: 37

                      return vector_Point_to_Mat(pts, CvType.CV_64F);
    }

    public static Mat vector_Point_to_Mat(List<Point> pts, int typeDepth) {
        Mat res;
        int count = (pts != null) ? pts.size() : 0;
        if (count > 0) {
            switch (typeDepth) {
            case CvType.CV_32S: {

            

Reported by PMD.

The method 'vector_Point3_to_Mat(List, int)' has a cyclomatic complexity of 10.
Design

Line: 99

                      return vector_Point3_to_Mat(pts, CvType.CV_64F);
    }

    public static Mat vector_Point3_to_Mat(List<Point3> pts, int typeDepth) {
        Mat res;
        int count = (pts != null) ? pts.size() : 0;
        if (count > 0) {
            switch (typeDepth) {
            case CvType.CV_32S: {

            

Reported by PMD.

The method 'Mat_to_vector_Point(Mat, List)' has a cyclomatic complexity of 12.
Design

Line: 160

                      Mat_to_vector_Point(m, pts);
    }

    public static void Mat_to_vector_Point(Mat m, List<Point> pts) {
        if (pts == null)
            throw new IllegalArgumentException("Output List can't be null");
        int count = m.rows();
        int type = m.type();
        if (m.cols() != 1)

            

Reported by PMD.

The String literal 'Output List can't be null' appears 12 times in this file; the first occurrence is on line 162
Error

Line: 162

              
    public static void Mat_to_vector_Point(Mat m, List<Point> pts) {
        if (pts == null)
            throw new IllegalArgumentException("Output List can't be null");
        int count = m.rows();
        int type = m.type();
        if (m.cols() != 1)
            throw new IllegalArgumentException("Input Mat should have one column\n" + m);


            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 165

                          throw new IllegalArgumentException("Output List can't be null");
        int count = m.rows();
        int type = m.type();
        if (m.cols() != 1)
            throw new IllegalArgumentException("Input Mat should have one column\n" + m);

        pts.clear();
        if (type == CvType.CV_32SC2) {
            int[] buff = new int[2 * count];

            

Reported by PMD.

modules/java/generator/android/java/org/opencv/android/AsyncServiceHelper.java
86 issues
The class 'AsyncServiceHelper' has a Standard Cyclomatic Complexity of 6 (Highest = 20).
Design

Line: 18

              import android.os.RemoteException;
import android.util.Log;

class AsyncServiceHelper
{
    public static boolean initOpenCV(String Version, final Context AppContext,
            final LoaderCallbackInterface Callback)
    {
        AsyncServiceHelper helper = new AsyncServiceHelper(Version, AppContext, Callback);

            

Reported by PMD.

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

Line: 18

              import android.os.RemoteException;
import android.util.Log;

class AsyncServiceHelper
{
    public static boolean initOpenCV(String Version, final Context AppContext,
            final LoaderCallbackInterface Callback)
    {
        AsyncServiceHelper helper = new AsyncServiceHelper(Version, AppContext, Callback);

            

Reported by PMD.

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

Line: 47

              
    protected static final String TAG = "OpenCVManager/Helper";
    protected static final int MINIMUM_ENGINE_VERSION = 2;
    protected OpenCVEngineInterface mEngineService;
    protected LoaderCallbackInterface mUserAppCallback;
    protected String mOpenCVersion;
    protected Context mAppContext;
    protected static boolean mServiceInstallationProgress = false;
    protected static boolean mLibraryInstallationProgress = false;

            

Reported by PMD.

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

Line: 48

                  protected static final String TAG = "OpenCVManager/Helper";
    protected static final int MINIMUM_ENGINE_VERSION = 2;
    protected OpenCVEngineInterface mEngineService;
    protected LoaderCallbackInterface mUserAppCallback;
    protected String mOpenCVersion;
    protected Context mAppContext;
    protected static boolean mServiceInstallationProgress = false;
    protected static boolean mLibraryInstallationProgress = false;


            

Reported by PMD.

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

Line: 49

                  protected static final int MINIMUM_ENGINE_VERSION = 2;
    protected OpenCVEngineInterface mEngineService;
    protected LoaderCallbackInterface mUserAppCallback;
    protected String mOpenCVersion;
    protected Context mAppContext;
    protected static boolean mServiceInstallationProgress = false;
    protected static boolean mLibraryInstallationProgress = false;

    protected static boolean InstallServiceQuiet(Context context)

            

Reported by PMD.

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

Line: 50

                  protected OpenCVEngineInterface mEngineService;
    protected LoaderCallbackInterface mUserAppCallback;
    protected String mOpenCVersion;
    protected Context mAppContext;
    protected static boolean mServiceInstallationProgress = false;
    protected static boolean mLibraryInstallationProgress = false;

    protected static boolean InstallServiceQuiet(Context context)
    {

            

Reported by PMD.

Avoid using redundant field initializer for 'mServiceInstallationProgress'
Performance

Line: 51

                  protected LoaderCallbackInterface mUserAppCallback;
    protected String mOpenCVersion;
    protected Context mAppContext;
    protected static boolean mServiceInstallationProgress = false;
    protected static boolean mLibraryInstallationProgress = false;

    protected static boolean InstallServiceQuiet(Context context)
    {
        boolean result = true;

            

Reported by PMD.

Avoid using redundant field initializer for 'mLibraryInstallationProgress'
Performance

Line: 52

                  protected String mOpenCVersion;
    protected Context mAppContext;
    protected static boolean mServiceInstallationProgress = false;
    protected static boolean mLibraryInstallationProgress = false;

    protected static boolean InstallServiceQuiet(Context context)
    {
        boolean result = true;
        try

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 63

                          intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        }
        catch(Exception e)
        {
            result = false;
        }

        return result;

            

Reported by PMD.

The method 'InstallService' has a Modified Cyclomatic Complexity of 11.
Design

Line: 71

                      return result;
    }

    protected static void InstallService(final Context AppContext, final LoaderCallbackInterface Callback)
    {
        if (!mServiceInstallationProgress)
        {
                Log.d(TAG, "Request new service installation");
                InstallCallbackInterface InstallQuery = new InstallCallbackInterface() {

            

Reported by PMD.

samples/java/tutorial_code/ml/non_linear_svms/NonLinearSVMsDemo.java
84 issues
System.out.println is used
Design

Line: 23

                      // Load the native OpenCV library
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        System.out.println("\n--------------------------------------------------------------------------");
        System.out.println("This program shows Support Vector Machines for Non-Linearly Separable Data. ");
        System.out.println("--------------------------------------------------------------------------\n");

        // Data for visual representation
        int width = 512, height = 512;

            

Reported by PMD.

System.out.println is used
Design

Line: 24

                      System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        System.out.println("\n--------------------------------------------------------------------------");
        System.out.println("This program shows Support Vector Machines for Non-Linearly Separable Data. ");
        System.out.println("--------------------------------------------------------------------------\n");

        // Data for visual representation
        int width = 512, height = 512;
        Mat I = Mat.zeros(height, width, CvType.CV_8UC3);

            

Reported by PMD.

System.out.println is used
Design

Line: 25

              
        System.out.println("\n--------------------------------------------------------------------------");
        System.out.println("This program shows Support Vector Machines for Non-Linearly Separable Data. ");
        System.out.println("--------------------------------------------------------------------------\n");

        // Data for visual representation
        int width = 512, height = 512;
        Mat I = Mat.zeros(height, width, CvType.CV_8UC3);


            

Reported by PMD.

System.out.println is used
Design

Line: 107

                      labels.rowRange(NTRAINING_SAMPLES, 2 * NTRAINING_SAMPLES).setTo(new Scalar(2)); // Class 2

        // ------------------------ 2. Set up the support vector machines parameters--------------------
        System.out.println("Starting training process");
        //! [init]
        SVM svm = SVM.create();
        svm.setType(SVM.C_SVC);
        svm.setC(0.1);
        svm.setKernel(SVM.LINEAR);

            

Reported by PMD.

System.out.println is used
Design

Line: 120

                      //! [train]
        svm.train(trainData, Ml.ROW_SAMPLE, labels);
        //! [train]
        System.out.println("Finished training process");

        // ------------------------ 4. Show the decision regions----------------------------------------
        //! [show]
        byte[] IData = new byte[(int) (I.total() * I.channels())];
        Mat sampleMat = new Mat(1, 2, CvType.CV_32F);

            

Reported by PMD.

The class 'NonLinearSVMsDemo' has a Standard Cyclomatic Complexity of 15 (Highest = 14).
Design

Line: 15

              import org.opencv.ml.Ml;
import org.opencv.ml.SVM;

public class NonLinearSVMsDemo {
    public static final int NTRAINING_SAMPLES = 100;
    public static final float FRAC_LINEAR_SEP = 0.9f;

    public static void main(String[] args) {
        // Load the native OpenCV library

            

Reported by PMD.

The class 'NonLinearSVMsDemo' has a Modified Cyclomatic Complexity of 15 (Highest = 14).
Design

Line: 15

              import org.opencv.ml.Ml;
import org.opencv.ml.SVM;

public class NonLinearSVMsDemo {
    public static final int NTRAINING_SAMPLES = 100;
    public static final float FRAC_LINEAR_SEP = 0.9f;

    public static void main(String[] args) {
        // Load the native OpenCV library

            

Reported by PMD.

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

Line: 15

              import org.opencv.ml.Ml;
import org.opencv.ml.SVM;

public class NonLinearSVMsDemo {
    public static final int NTRAINING_SAMPLES = 100;
    public static final float FRAC_LINEAR_SEP = 0.9f;

    public static void main(String[] args) {
        // Load the native OpenCV library

            

Reported by PMD.

The method 'main(String)' has a cyclomatic complexity of 14.
Design

Line: 19

                  public static final int NTRAINING_SAMPLES = 100;
    public static final float FRAC_LINEAR_SEP = 0.9f;

    public static void main(String[] args) {
        // Load the native OpenCV library
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        System.out.println("\n--------------------------------------------------------------------------");
        System.out.println("This program shows Support Vector Machines for Non-Linearly Separable Data. ");

            

Reported by PMD.

Avoid really long methods.
Design

Line: 19

                  public static final int NTRAINING_SAMPLES = 100;
    public static final float FRAC_LINEAR_SEP = 0.9f;

    public static void main(String[] args) {
        // Load the native OpenCV library
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        System.out.println("\n--------------------------------------------------------------------------");
        System.out.println("This program shows Support Vector Machines for Non-Linearly Separable Data. ");

            

Reported by PMD.

modules/ts/misc/run_utils.py
83 issues
Module 'platform' has no 'linux_distribution' member
Error

Line: 74 Column: 18

                      if wv[0]:
            return "Windows" + wv[0]
        else:
            lv = platform.linux_distribution()
            if lv[0]:
                return lv[0] + lv[1]
    return None



            

Reported by Pylint.

Instance of 'CMakeCache' has no 'opencv_build' member
Error

Line: 130 Column: 51

                      if not self.tests_dir:
            self.tests_dir = path
        else:
            rel = os.path.relpath(self.tests_dir, self.opencv_build)
            self.tests_dir = os.path.join(path, rel)
        self.tests_dir = os.path.normpath(self.tests_dir)

        # fix VS test binary path (add Debug or Release)
        if "Visual Studio" in self.cmake_generator:

            

Reported by Pylint.

Instance of 'CMakeCache' has no 'cmake_generator' member
Error

Line: 135 Column: 31

                      self.tests_dir = os.path.normpath(self.tests_dir)

        # fix VS test binary path (add Debug or Release)
        if "Visual Studio" in self.cmake_generator:
            self.tests_dir = os.path.join(self.tests_dir, self.build_type)

        for module, path in module_paths.items():
            rel = os.path.relpath(path, self.opencv_home)
            if ".." not in rel:

            

Reported by Pylint.

Instance of 'CMakeCache' has no 'opencv_home' member
Error

Line: 139 Column: 41

                          self.tests_dir = os.path.join(self.tests_dir, self.build_type)

        for module, path in module_paths.items():
            rel = os.path.relpath(path, self.opencv_home)
            if ".." not in rel:
                self.main_modules.append(module)

    def setDefaultAttrs(self):
        for p in parse_patterns:

            

Reported by Pylint.

Instance of 'CMakeCache' has no 'java_test_dir' member
Error

Line: 164 Column: 78

                      return name in self.main_modules + ['python2', 'python3']

    def withJava(self):
        return self.ant_executable and self.java_test_dir and os.path.exists(self.java_test_dir)

    def withPython2(self):
        return self.python2 == 'ON'

    def withPython3(self):

            

Reported by Pylint.

Instance of 'CMakeCache' has no 'java_test_dir' member
Error

Line: 164 Column: 40

                      return name in self.main_modules + ['python2', 'python3']

    def withJava(self):
        return self.ant_executable and self.java_test_dir and os.path.exists(self.java_test_dir)

    def withPython2(self):
        return self.python2 == 'ON'

    def withPython3(self):

            

Reported by Pylint.

Instance of 'CMakeCache' has no 'ant_executable' member
Error

Line: 164 Column: 16

                      return name in self.main_modules + ['python2', 'python3']

    def withJava(self):
        return self.ant_executable and self.java_test_dir and os.path.exists(self.java_test_dir)

    def withPython2(self):
        return self.python2 == 'ON'

    def withPython3(self):

            

Reported by Pylint.

Instance of 'CMakeCache' has no 'python2' member
Error

Line: 167 Column: 16

                      return self.ant_executable and self.java_test_dir and os.path.exists(self.java_test_dir)

    def withPython2(self):
        return self.python2 == 'ON'

    def withPython3(self):
        return self.python3 == 'ON'

    def getOS(self):

            

Reported by Pylint.

Instance of 'CMakeCache' has no 'python3' member
Error

Line: 170 Column: 16

                      return self.python2 == 'ON'

    def withPython3(self):
        return self.python3 == 'ON'

    def getOS(self):
        if self.android_executable:
            return "android"
        else:

            

Reported by Pylint.

Instance of 'CMakeCache' has no 'android_executable' member
Error

Line: 173 Column: 12

                      return self.python3 == 'ON'

    def getOS(self):
        if self.android_executable:
            return "android"
        else:
            return hostos



            

Reported by Pylint.