The following issues were found

modules/core/misc/java/src/java/core+MatOfDMatch.java
9 issues
Overridable method 'fromArray' called during object construction
Error

Line: 37

              
    public MatOfDMatch(DMatch...ap) {
        super();
        fromArray(ap);
    }

    public void alloc(int elemNumber) {
        if(elemNumber>0)
            super.create(elemNumber, 1, CvType.makeType(_depth, _channels));

            

Reported by PMD.

No need to import a type that lives in the same package
Error

Line: 6

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

import org.opencv.core.DMatch;

public class MatOfDMatch extends Mat {
    // 32FC4
    private static final int _depth = CvType.CV_32F;
    private static final int _channels = 4;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '51'-'54').
Error

Line: 51

                          return;
        int num = a.length;
        alloc(num);
        float buff[] = new float[num * _channels];
        for(int i=0; i<num; i++) {
            DMatch m = a[i];
            buff[_channels*i+0] = m.queryIdx;
            buff[_channels*i+1] = m.trainIdx;
            buff[_channels*i+2] = m.imgIdx;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '54'-'55').
Error

Line: 54

                      float buff[] = new float[num * _channels];
        for(int i=0; i<num; i++) {
            DMatch m = a[i];
            buff[_channels*i+0] = m.queryIdx;
            buff[_channels*i+1] = m.trainIdx;
            buff[_channels*i+2] = m.imgIdx;
            buff[_channels*i+3] = m.distance;
        }
        put(0, 0, buff); //TODO: check ret val!

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '55'-'56').
Error

Line: 55

                      for(int i=0; i<num; i++) {
            DMatch m = a[i];
            buff[_channels*i+0] = m.queryIdx;
            buff[_channels*i+1] = m.trainIdx;
            buff[_channels*i+2] = m.imgIdx;
            buff[_channels*i+3] = m.distance;
        }
        put(0, 0, buff); //TODO: check ret val!
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '56'-'57').
Error

Line: 56

                          DMatch m = a[i];
            buff[_channels*i+0] = m.queryIdx;
            buff[_channels*i+1] = m.trainIdx;
            buff[_channels*i+2] = m.imgIdx;
            buff[_channels*i+3] = m.distance;
        }
        put(0, 0, buff); //TODO: check ret val!
    }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '57'-'54').
Error

Line: 57

                          buff[_channels*i+0] = m.queryIdx;
            buff[_channels*i+1] = m.trainIdx;
            buff[_channels*i+2] = m.imgIdx;
            buff[_channels*i+3] = m.distance;
        }
        put(0, 0, buff); //TODO: check ret val!
    }

    public DMatch[] toArray() {

            

Reported by PMD.

Found 'DD'-anomaly for variable 'a' (lines '64'-'70').
Error

Line: 64

              
    public DMatch[] toArray() {
        int num = (int) total();
        DMatch[] a = new DMatch[num];
        if(num == 0)
            return a;
        float buff[] = new float[num * _channels];
        get(0, 0, buff); //TODO: check ret val!
        for(int i=0; i<num; i++)

            

Reported by PMD.

Found 'DD'-anomaly for variable 'a' (lines '70'-'70').
Error

Line: 70

                      float buff[] = new float[num * _channels];
        get(0, 0, buff); //TODO: check ret val!
        for(int i=0; i<num; i++)
            a[i] = new DMatch((int) buff[_channels*i+0], (int) buff[_channels*i+1], (int) buff[_channels*i+2], buff[_channels*i+3]);
        return a;
    }

    public void fromList(List<DMatch> ldm) {
        DMatch adm[] = ldm.toArray(new DMatch[0]);

            

Reported by PMD.

samples/python/tutorial_code/features2D/feature_flann_matcher/SURF_FLANN_matching_Demo.py
9 issues
Unable to import 'cv2'
Error

Line: 2 Column: 1

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

parser = argparse.ArgumentParser(description='Code for Feature Matching with FLANN tutorial.')
parser.add_argument('--input1', help='Path to input image 1.', default='box.png')
parser.add_argument('--input2', help='Path to input image 2.', default='box_in_scene.png')
args = parser.parse_args()

            

Reported by Pylint.

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

Line: 1 Column: 1

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

parser = argparse.ArgumentParser(description='Code for Feature Matching with FLANN tutorial.')
parser.add_argument('--input1', help='Path to input image 1.', default='box.png')
parser.add_argument('--input2', help='Path to input image 2.', default='box_in_scene.png')
args = parser.parse_args()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

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

parser = argparse.ArgumentParser(description='Code for Feature Matching with FLANN tutorial.')
parser.add_argument('--input1', help='Path to input image 1.', default='box.png')
parser.add_argument('--input2', help='Path to input image 2.', default='box_in_scene.png')
args = parser.parse_args()

            

Reported by Pylint.

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

Line: 4 Column: 1

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

parser = argparse.ArgumentParser(description='Code for Feature Matching with FLANN tutorial.')
parser.add_argument('--input1', help='Path to input image 1.', default='box.png')
parser.add_argument('--input2', help='Path to input image 2.', default='box_in_scene.png')
args = parser.parse_args()

            

Reported by Pylint.

Consider using sys.exit()
Error

Line: 15 Column: 5

              img2 = cv.imread(cv.samples.findFile(args.input2), cv.IMREAD_GRAYSCALE)
if img1 is None or img2 is None:
    print('Could not open or find the images!')
    exit(0)

#-- Step 1: Detect the keypoints using SURF Detector, compute the descriptors
minHessian = 400
detector = cv.xfeatures2d_SURF.create(hessianThreshold=minHessian)
keypoints1, descriptors1 = detector.detectAndCompute(img1, None)

            

Reported by Pylint.

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

Line: 18 Column: 1

                  exit(0)

#-- Step 1: Detect the keypoints using SURF Detector, compute the descriptors
minHessian = 400
detector = cv.xfeatures2d_SURF.create(hessianThreshold=minHessian)
keypoints1, descriptors1 = detector.detectAndCompute(img1, None)
keypoints2, descriptors2 = detector.detectAndCompute(img2, None)

#-- Step 2: Matching descriptor vectors with a FLANN based matcher

            

Reported by Pylint.

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

Line: 29 Column: 1

              knn_matches = matcher.knnMatch(descriptors1, descriptors2, 2)

#-- Filter matches using the Lowe's ratio test
ratio_thresh = 0.7
good_matches = []
for m,n in knn_matches:
    if m.distance < ratio_thresh * n.distance:
        good_matches.append(m)


            

Reported by Pylint.

Line too long (107/100)
Error

Line: 36 Column: 1

                      good_matches.append(m)

#-- Draw matches
img_matches = np.empty((max(img1.shape[0], img2.shape[0]), img1.shape[1]+img2.shape[1], 3), dtype=np.uint8)
cv.drawMatches(img1, keypoints1, img2, keypoints2, good_matches, img_matches, flags=cv.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS)

#-- Show detected matches
cv.imshow('Good Matches', img_matches)


            

Reported by Pylint.

Line too long (127/100)
Error

Line: 37 Column: 1

              
#-- Draw matches
img_matches = np.empty((max(img1.shape[0], img2.shape[0]), img1.shape[1]+img2.shape[1], 3), dtype=np.uint8)
cv.drawMatches(img1, keypoints1, img2, keypoints2, good_matches, img_matches, flags=cv.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS)

#-- Show detected matches
cv.imshow('Good Matches', img_matches)

cv.waitKey()

            

Reported by Pylint.

modules/core/misc/java/src/java/core+KeyPoint.java
8 issues
No need to import a type that lives in the same package
Error

Line: 3

              package org.opencv.core;

import org.opencv.core.Point;

//javadoc: KeyPoint
public class KeyPoint {

    /**
     * Coordinates of the keypoint.

            

Reported by PMD.

The class 'KeyPoint' is suspected to be a Data Class (WOC=14.286%, NOPA=6, NOAM=0, WMC=7)
Design

Line: 6

              import org.opencv.core.Point;

//javadoc: KeyPoint
public class KeyPoint {

    /**
     * Coordinates of the keypoint.
     */
    public Point pt;

            

Reported by PMD.

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

Line: 11

                  /**
     * Coordinates of the keypoint.
     */
    public Point pt;
    /**
     * Diameter of the useful keypoint adjacent area.
     */
    public float size;
    /**

            

Reported by PMD.

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

Line: 15

                  /**
     * Diameter of the useful keypoint adjacent area.
     */
    public float size;
    /**
     * Computed orientation of the keypoint (-1 if not applicable).
     */
    public float angle;
    /**

            

Reported by PMD.

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

Line: 19

                  /**
     * Computed orientation of the keypoint (-1 if not applicable).
     */
    public float angle;
    /**
     * The response, by which the strongest keypoints have been selected. Can
     * be used for further sorting or subsampling.
     */
    public float response;

            

Reported by PMD.

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

Line: 24

                   * The response, by which the strongest keypoints have been selected. Can
     * be used for further sorting or subsampling.
     */
    public float response;
    /**
     * Octave (pyramid layer), from which the keypoint has been extracted.
     */
    public int octave;
    /**

            

Reported by PMD.

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

Line: 28

                  /**
     * Octave (pyramid layer), from which the keypoint has been extracted.
     */
    public int octave;
    /**
     * Object ID, that can be used to cluster keypoints by an object they
     * belong to.
     */
    public int class_id;

            

Reported by PMD.

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

Line: 33

                   * Object ID, that can be used to cluster keypoints by an object they
     * belong to.
     */
    public int class_id;

    // javadoc:KeyPoint::KeyPoint(x,y,_size,_angle,_response,_octave,_class_id)
    public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id) {
        pt = new Point(x, y);
        size = _size;

            

Reported by PMD.

samples/python/tutorial_code/features2D/akaze_matching/AKAZE_match.py
8 issues
Unable to import 'cv2'
Error

Line: 2 Column: 1

              from __future__ import print_function
import cv2 as cv
import numpy as np
import argparse
from math import sqrt

## [load]
parser = argparse.ArgumentParser(description='Code for AKAZE local features matching tutorial.')
parser.add_argument('--input1', help='Path to input image 1.', default='graf1.png')

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import print_function
import cv2 as cv
import numpy as np
import argparse
from math import sqrt

## [load]
parser = argparse.ArgumentParser(description='Code for AKAZE local features matching tutorial.')
parser.add_argument('--input1', help='Path to input image 1.', default='graf1.png')

            

Reported by Pylint.

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

Line: 1 Column: 1

              from __future__ import print_function
import cv2 as cv
import numpy as np
import argparse
from math import sqrt

## [load]
parser = argparse.ArgumentParser(description='Code for AKAZE local features matching tutorial.')
parser.add_argument('--input1', help='Path to input image 1.', default='graf1.png')

            

Reported by Pylint.

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

Line: 4 Column: 1

              from __future__ import print_function
import cv2 as cv
import numpy as np
import argparse
from math import sqrt

## [load]
parser = argparse.ArgumentParser(description='Code for AKAZE local features matching tutorial.')
parser.add_argument('--input1', help='Path to input image 1.', default='graf1.png')

            

Reported by Pylint.

standard import "from math import sqrt" should be placed before "import cv2 as cv"
Error

Line: 5 Column: 1

              import cv2 as cv
import numpy as np
import argparse
from math import sqrt

## [load]
parser = argparse.ArgumentParser(description='Code for AKAZE local features matching tutorial.')
parser.add_argument('--input1', help='Path to input image 1.', default='graf1.png')
parser.add_argument('--input2', help='Path to input image 2.', default='graf3.png')

            

Reported by Pylint.

Consider using sys.exit()
Error

Line: 18 Column: 5

              img2 = cv.imread(cv.samples.findFile(args.input2), cv.IMREAD_GRAYSCALE)
if img1 is None or img2 is None:
    print('Could not open or find the images!')
    exit(0)

fs = cv.FileStorage(cv.samples.findFile(args.homography), cv.FILE_STORAGE_READ)
homography = fs.getFirstTopLevelNode().mat()
## [load]


            

Reported by Pylint.

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

Line: 38 Column: 1

              ## [ratio test filtering]
matched1 = []
matched2 = []
nn_match_ratio = 0.8 # Nearest neighbor matching ratio
for m, n in nn_matches:
    if m.distance < nn_match_ratio * n.distance:
        matched1.append(kpts1[m.queryIdx])
        matched2.append(kpts2[m.trainIdx])
## [ratio test filtering]

            

Reported by Pylint.

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

Line: 49 Column: 1

              inliers1 = []
inliers2 = []
good_matches = []
inlier_threshold = 2.5 # Distance threshold to identify inliers with homography check
for i, m in enumerate(matched1):
    col = np.ones((3,1), dtype=np.float64)
    col[0:2,0] = m.pt

    col = np.dot(homography, col)

            

Reported by Pylint.

samples/python/tutorial_code/imgProc/morph_lines_detection/morph_lines_detection.py
8 issues
Unable to import 'cv2'
Error

Line: 7 Column: 1

              """
import numpy as np
import sys
import cv2 as cv


def show_wait_destroy(winname, img):
    cv.imshow(winname, img)
    cv.moveWindow(winname, 500, 0)

            

Reported by Pylint.

String statement has no effect
Error

Line: 100 Column: 5

                  vertical = cv.bitwise_not(vertical)
    show_wait_destroy("vertical_bit", vertical)

    '''
    Extract edges and smooth image according to the logic
    1. extract edges
    2. dilate(edges)
    3. src.copyTo(smooth)
    4. blur smooth img

            

Reported by Pylint.

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

Line: 6 Column: 1

              @brief Use morphology transformations for extracting horizontal and vertical lines sample code
"""
import numpy as np
import sys
import cv2 as cv


def show_wait_destroy(winname, img):
    cv.imshow(winname, img)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              import cv2 as cv


def show_wait_destroy(winname, img):
    cv.imshow(winname, img)
    cv.moveWindow(winname, 500, 0)
    cv.waitKey(0)
    cv.destroyWindow(winname)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

                  cv.destroyWindow(winname)


def main(argv):
    # [load_image]
    # Check number of arguments
    if len(argv) < 1:
        print ('Not enough parameters')
        print ('Usage:\nmorph_lines_detection.py < path_to_image >')

            

Reported by Pylint.

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

Line: 51 Column: 5

                  # [bin]
    # Apply adaptiveThreshold at the bitwise_not of gray, notice the ~ symbol
    gray = cv.bitwise_not(gray)
    bw = cv.adaptiveThreshold(gray, 255, cv.ADAPTIVE_THRESH_MEAN_C, \
                                cv.THRESH_BINARY, 15, -2)
    # Show binary image
    show_wait_destroy("binary", bw)
    # [bin]


            

Reported by Pylint.

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

Line: 69 Column: 5

                  horizontal_size = cols // 30

    # Create structure element for extracting horizontal lines through morphology operations
    horizontalStructure = cv.getStructuringElement(cv.MORPH_RECT, (horizontal_size, 1))

    # Apply morphology operations
    horizontal = cv.erode(horizontal, horizontalStructure)
    horizontal = cv.dilate(horizontal, horizontalStructure)


            

Reported by Pylint.

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

Line: 85 Column: 5

                  verticalsize = rows // 30

    # Create structure element for extracting vertical lines through morphology operations
    verticalStructure = cv.getStructuringElement(cv.MORPH_RECT, (1, verticalsize))

    # Apply morphology operations
    vertical = cv.erode(vertical, verticalStructure)
    vertical = cv.dilate(vertical, verticalStructure)


            

Reported by Pylint.

samples/dnn/dnn_model_runner/dnn_conversion/common/abstract_model.py
8 issues
Missing module docstring
Error

Line: 1 Column: 1

              from abc import ABC, ABCMeta, abstractmethod


class AbstractModel(ABC):

    @abstractmethod
    def get_prepared_models(self):
        pass


            

Reported by Pylint.

Missing class docstring
Error

Line: 4 Column: 1

              from abc import ABC, ABCMeta, abstractmethod


class AbstractModel(ABC):

    @abstractmethod
    def get_prepared_models(self):
        pass


            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 4 Column: 1

              from abc import ABC, ABCMeta, abstractmethod


class AbstractModel(ABC):

    @abstractmethod
    def get_prepared_models(self):
        pass


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 5

              class AbstractModel(ABC):

    @abstractmethod
    def get_prepared_models(self):
        pass


class Framework(object):
    in_blob_name = ''

            

Reported by Pylint.

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

Line: 11 Column: 1

                      pass


class Framework(object):
    in_blob_name = ''
    out_blob_name = ''

    __metaclass__ = ABCMeta


            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

                      pass


class Framework(object):
    in_blob_name = ''
    out_blob_name = ''

    __metaclass__ = ABCMeta


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 5

                  __metaclass__ = ABCMeta

    @abstractmethod
    def get_name(self):
        pass

    @abstractmethod
    def get_output(self, input_blob):
        pass

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 5

                      pass

    @abstractmethod
    def get_output(self, input_blob):
        pass

            

Reported by Pylint.

samples/android/tutorial-4-opencl/src/org/opencv/samples/tutorial4/Tutorial4Activity.java
8 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 15

              
public class Tutorial4Activity extends Activity {

    private MyGLSurfaceView mView;
    private TextView mProcMode;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

            

Reported by PMD.

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

Line: 16

              public class Tutorial4Activity extends Activity {

    private MyGLSurfaceView mView;
    private TextView mProcMode;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 22

                  public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
                WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 24

                      requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
                WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        //mView = new MyGLSurfaceView(this, null);
        //setContentView(mView);

            

Reported by PMD.

Avoid unused local variables such as 'tv'.
Design

Line: 33

                      setContentView(R.layout.activity);
        mView = (MyGLSurfaceView) findViewById(R.id.my_gl_surface_view);
        mView.setCameraTextureListener(mView);
        TextView tv = (TextView)findViewById(R.id.fps_text_view);
        mProcMode = (TextView)findViewById(R.id.proc_mode_text_view);
        runOnUiThread(new Runnable() {
            public void run() {
                mProcMode.setText("Processing mode: No processing");
            }

            

Reported by PMD.

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

Line: 59

                  @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'tv' (lines '33'-'42').
Error

Line: 33

                      setContentView(R.layout.activity);
        mView = (MyGLSurfaceView) findViewById(R.id.my_gl_surface_view);
        mView.setCameraTextureListener(mView);
        TextView tv = (TextView)findViewById(R.id.fps_text_view);
        mProcMode = (TextView)findViewById(R.id.proc_mode_text_view);
        runOnUiThread(new Runnable() {
            public void run() {
                mProcMode.setText("Processing mode: No processing");
            }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'tv' (lines '33'-'42').
Error

Line: 33

                      setContentView(R.layout.activity);
        mView = (MyGLSurfaceView) findViewById(R.id.my_gl_surface_view);
        mView.setCameraTextureListener(mView);
        TextView tv = (TextView)findViewById(R.id.fps_text_view);
        mProcMode = (TextView)findViewById(R.id.proc_mode_text_view);
        runOnUiThread(new Runnable() {
            public void run() {
                mProcMode.setText("Processing mode: No processing");
            }

            

Reported by PMD.

samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CalibrationResult.java
8 issues
This abstract class does not have any abstract methods
Design

Line: 10

              import android.content.SharedPreferences;
import android.util.Log;

public abstract class CalibrationResult {
    private static final String TAG = "OCV::CalibrationResult";

    private static final int CAMERA_MATRIX_ROWS = 3;
    private static final int CAMERA_MATRIX_COLS = 3;
    private static final int DISTORTION_COEFFICIENTS_SIZE = 5;

            

Reported by PMD.

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

Line: 19

              
    public static void save(Activity activity, Mat cameraMatrix, Mat distortionCoefficients) {
        SharedPreferences sharedPref = activity.getPreferences(Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPref.edit();

        double[] cameraMatrixArray = new double[CAMERA_MATRIX_ROWS * CAMERA_MATRIX_COLS];
        cameraMatrix.get(0,  0, cameraMatrixArray);
        for (int i = 0; i < CAMERA_MATRIX_ROWS; i++) {
            for (int j = 0; j < CAMERA_MATRIX_COLS; j++) {

            

Reported by PMD.

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

Line: 37

                          editor.putFloat(Integer.toString(i), (float)distortionCoefficientsArray[i-shift]);
        }

        editor.apply();
        Log.i(TAG, "Saved camera matrix: " + cameraMatrix.dump());
        Log.i(TAG, "Saved distortion coefficients: " + distortionCoefficients.dump());
    }

    public static boolean tryLoad(Activity activity, Mat cameraMatrix, Mat distortionCoefficients) {

            

Reported by PMD.

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

Line: 44

              
    public static boolean tryLoad(Activity activity, Mat cameraMatrix, Mat distortionCoefficients) {
        SharedPreferences sharedPref = activity.getPreferences(Context.MODE_PRIVATE);
        if (sharedPref.getFloat("0", -1) == -1) {
            Log.i(TAG, "No previous calibration results found");
            return false;
        }

        double[] cameraMatrixArray = new double[CAMERA_MATRIX_ROWS * CAMERA_MATRIX_COLS];

            

Reported by PMD.

Found 'DD'-anomaly for variable 'cameraMatrixArray' (lines '49'-'53').
Error

Line: 49

                          return false;
        }

        double[] cameraMatrixArray = new double[CAMERA_MATRIX_ROWS * CAMERA_MATRIX_COLS];
        for (int i = 0; i < CAMERA_MATRIX_ROWS; i++) {
            for (int j = 0; j < CAMERA_MATRIX_COLS; j++) {
                int id = i * CAMERA_MATRIX_ROWS + j;
                cameraMatrixArray[id] = sharedPref.getFloat(Integer.toString(id), -1);
            }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'cameraMatrixArray' (lines '53'-'53').
Error

Line: 53

                      for (int i = 0; i < CAMERA_MATRIX_ROWS; i++) {
            for (int j = 0; j < CAMERA_MATRIX_COLS; j++) {
                int id = i * CAMERA_MATRIX_ROWS + j;
                cameraMatrixArray[id] = sharedPref.getFloat(Integer.toString(id), -1);
            }
        }
        cameraMatrix.put(0, 0, cameraMatrixArray);
        Log.i(TAG, "Loaded camera matrix: " + cameraMatrix.dump());


            

Reported by PMD.

Found 'DD'-anomaly for variable 'distortionCoefficientsArray' (lines '59'-'62').
Error

Line: 59

                      cameraMatrix.put(0, 0, cameraMatrixArray);
        Log.i(TAG, "Loaded camera matrix: " + cameraMatrix.dump());

        double[] distortionCoefficientsArray = new double[DISTORTION_COEFFICIENTS_SIZE];
        int shift = CAMERA_MATRIX_ROWS * CAMERA_MATRIX_COLS;
        for (int i = shift; i < DISTORTION_COEFFICIENTS_SIZE + shift; i++) {
            distortionCoefficientsArray[i - shift] = sharedPref.getFloat(Integer.toString(i), -1);
        }
        distortionCoefficients.put(0, 0, distortionCoefficientsArray);

            

Reported by PMD.

Found 'DD'-anomaly for variable 'distortionCoefficientsArray' (lines '62'-'62').
Error

Line: 62

                      double[] distortionCoefficientsArray = new double[DISTORTION_COEFFICIENTS_SIZE];
        int shift = CAMERA_MATRIX_ROWS * CAMERA_MATRIX_COLS;
        for (int i = shift; i < DISTORTION_COEFFICIENTS_SIZE + shift; i++) {
            distortionCoefficientsArray[i - shift] = sharedPref.getFloat(Integer.toString(i), -1);
        }
        distortionCoefficients.put(0, 0, distortionCoefficientsArray);
        Log.i(TAG, "Loaded distortion coefficients: " + distortionCoefficients.dump());

        return true;

            

Reported by PMD.

samples/python/edge.py
8 issues
Unable to import 'cv2'
Error

Line: 16 Column: 1

              # Python 2/3 compatibility
from __future__ import print_function

import cv2 as cv
import numpy as np

# relative module
import video


            

Reported by Pylint.

No exception type(s) specified
Error

Line: 29 Column: 5

              def main():
    try:
        fn = sys.argv[1]
    except:
        fn = 0

    def nothing(*arg):
        pass


            

Reported by Pylint.

Unused argument 'arg'
Error

Line: 32 Column: 1

                  except:
        fn = 0

    def nothing(*arg):
        pass

    cv.namedWindow('edge')
    cv.createTrackbar('thrs1', 'edge', 2000, 5000, nothing)
    cv.createTrackbar('thrs2', 'edge', 4000, 5000, nothing)

            

Reported by Pylint.

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

Line: 23 Column: 1

              import video

# built-in module
import sys


def main():
    try:
        fn = sys.argv[1]

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 1

              import sys


def main():
    try:
        fn = sys.argv[1]
    except:
        fn = 0


            

Reported by Pylint.

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

Line: 28 Column: 9

              
def main():
    try:
        fn = sys.argv[1]
    except:
        fn = 0

    def nothing(*arg):
        pass

            

Reported by Pylint.

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

Line: 30 Column: 9

                  try:
        fn = sys.argv[1]
    except:
        fn = 0

    def nothing(*arg):
        pass

    cv.namedWindow('edge')

            

Reported by Pylint.

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

Line: 50 Column: 9

                      vis = np.uint8(vis/2.)
        vis[edge != 0] = (0, 255, 0)
        cv.imshow('edge', vis)
        ch = cv.waitKey(5)
        if ch == 27:
            break

    print('Done')


            

Reported by Pylint.

samples/python/tutorial_code/Histograms_Matching/histogram_comparison/compareHist_Demo.py
8 issues
Unable to import 'cv2'
Error

Line: 3 Column: 1

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

## [Load three images with different environment settings]
parser = argparse.ArgumentParser(description='Code for Histogram Comparison tutorial.')
parser.add_argument('--input1', help='Path to input image 1.')

            

Reported by Pylint.

Unused numpy imported as np
Error

Line: 4 Column: 1

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

## [Load three images with different environment settings]
parser = argparse.ArgumentParser(description='Code for Histogram Comparison tutorial.')
parser.add_argument('--input1', help='Path to input image 1.')

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

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

## [Load three images with different environment settings]
parser = argparse.ArgumentParser(description='Code for Histogram Comparison tutorial.')
parser.add_argument('--input1', help='Path to input image 1.')

            

Reported by Pylint.

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

Line: 1 Column: 1

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

## [Load three images with different environment settings]
parser = argparse.ArgumentParser(description='Code for Histogram Comparison tutorial.')
parser.add_argument('--input1', help='Path to input image 1.')

            

Reported by Pylint.

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

Line: 5 Column: 1

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

## [Load three images with different environment settings]
parser = argparse.ArgumentParser(description='Code for Histogram Comparison tutorial.')
parser.add_argument('--input1', help='Path to input image 1.')
parser.add_argument('--input2', help='Path to input image 2.')

            

Reported by Pylint.

Consider using sys.exit()
Error

Line: 19 Column: 5

              src_test2 = cv.imread(args.input3)
if src_base is None or src_test1 is None or src_test2 is None:
    print('Could not open or find the images!')
    exit(0)
## [Load three images with different environment settings]

## [Convert to HSV]
hsv_base = cv.cvtColor(src_base, cv.COLOR_BGR2HSV)
hsv_test1 = cv.cvtColor(src_test1, cv.COLOR_BGR2HSV)

            

Reported by Pylint.

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

Line: 33 Column: 1

              ## [Convert to HSV half]

## [Using 50 bins for hue and 60 for saturation]
h_bins = 50
s_bins = 60
histSize = [h_bins, s_bins]

# hue varies from 0 to 179, saturation from 0 to 255
h_ranges = [0, 180]

            

Reported by Pylint.

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

Line: 34 Column: 1

              
## [Using 50 bins for hue and 60 for saturation]
h_bins = 50
s_bins = 60
histSize = [h_bins, s_bins]

# hue varies from 0 to 179, saturation from 0 to 255
h_ranges = [0, 180]
s_ranges = [0, 256]

            

Reported by Pylint.