The following issues were found

modules/python/test/test_houghlines.py
14 issues
Unable to import 'cv2'
Error

Line: 10 Column: 1

              # Python 2/3 compatibility
from __future__ import print_function

import cv2 as cv
import numpy as np
import sys
import math

from tests_common import NewOpenCVTests

            

Reported by Pylint.

Unused import sys
Error

Line: 12 Column: 1

              
import cv2 as cv
import numpy as np
import sys
import math

from tests_common import NewOpenCVTests

def linesDiff(line1, line2):

            

Reported by Pylint.

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

Line: 12 Column: 1

              
import cv2 as cv
import numpy as np
import sys
import math

from tests_common import NewOpenCVTests

def linesDiff(line1, line2):

            

Reported by Pylint.

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

Line: 13 Column: 1

              import cv2 as cv
import numpy as np
import sys
import math

from tests_common import NewOpenCVTests

def linesDiff(line1, line2):


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

              
from tests_common import NewOpenCVTests

def linesDiff(line1, line2):

    norm1 = cv.norm(line1 - line2, cv.NORM_L2)
    line3 = line1[2:4] + line1[0:2]
    norm2 = cv.norm(line3 - line2, cv.NORM_L2)


            

Reported by Pylint.

Function name "linesDiff" doesn't conform to snake_case naming style
Error

Line: 17 Column: 1

              
from tests_common import NewOpenCVTests

def linesDiff(line1, line2):

    norm1 = cv.norm(line1 - line2, cv.NORM_L2)
    line3 = line1[2:4] + line1[0:2]
    norm2 = cv.norm(line3 - line2, cv.NORM_L2)


            

Reported by Pylint.

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

Line: 25 Column: 1

              
    return min(norm1, norm2)

class houghlines_test(NewOpenCVTests):

    def test_houghlines(self):

        fn = "/samples/data/pic1.png"


            

Reported by Pylint.

Missing class docstring
Error

Line: 25 Column: 1

              
    return min(norm1, norm2)

class houghlines_test(NewOpenCVTests):

    def test_houghlines(self):

        fn = "/samples/data/pic1.png"


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 5

              
class houghlines_test(NewOpenCVTests):

    def test_houghlines(self):

        fn = "/samples/data/pic1.png"

        src = self.get_sample(fn)
        dst = cv.Canny(src, 50, 200)

            

Reported by Pylint.

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

Line: 29 Column: 9

              
    def test_houghlines(self):

        fn = "/samples/data/pic1.png"

        src = self.get_sample(fn)
        dst = cv.Canny(src, 50, 200)

        lines = cv.HoughLinesP(dst, 1, math.pi/180.0, 40, np.array([]), 50, 10)[:,0,:]

            

Reported by Pylint.

samples/java/tutorial_code/ml/introduction_to_pca/IntroductionToPCADemo.java
14 issues
System.err.println is used
Design

Line: 94

              
        // Check if image is loaded successfully
        if (src.empty()) {
            System.err.println("Cannot read image: " + filename);
            System.exit(0);
        }

        Mat srcOriginal = src.clone();
        HighGui.imshow("src", srcOriginal);

            

Reported by PMD.

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

Line: 43

                      List<Point> pts = ptsMat.toList();
        //! [pca]
        // Construct a buffer used by the pca analysis
        int sz = pts.size();
        Mat dataPts = new Mat(sz, 2, CvType.CV_64F);
        double[] dataPtsData = new double[(int) (dataPts.total() * dataPts.channels())];
        for (int i = 0; i < dataPts.rows(); i++) {
            dataPtsData[i * dataPts.cols()] = pts.get(i).x;
            dataPtsData[i * dataPts.cols() + 1] = pts.get(i).y;

            

Reported by PMD.

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

Line: 47

                      Mat dataPts = new Mat(sz, 2, CvType.CV_64F);
        double[] dataPtsData = new double[(int) (dataPts.total() * dataPts.channels())];
        for (int i = 0; i < dataPts.rows(); i++) {
            dataPtsData[i * dataPts.cols()] = pts.get(i).x;
            dataPtsData[i * dataPts.cols() + 1] = pts.get(i).y;
        }
        dataPts.put(0, 0, dataPtsData);

        // Perform PCA analysis

            

Reported by PMD.

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

Line: 48

                      double[] dataPtsData = new double[(int) (dataPts.total() * dataPts.channels())];
        for (int i = 0; i < dataPts.rows(); i++) {
            dataPtsData[i * dataPts.cols()] = pts.get(i).x;
            dataPtsData[i * dataPts.cols() + 1] = pts.get(i).y;
        }
        dataPts.put(0, 0, dataPtsData);

        // Perform PCA analysis
        Mat mean = new Mat();

            

Reported by PMD.

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

Line: 93

                      Mat src = Imgcodecs.imread(filename);

        // Check if image is loaded successfully
        if (src.empty()) {
            System.err.println("Cannot read image: " + filename);
            System.exit(0);
        }

        Mat srcOriginal = src.clone();

            

Reported by PMD.

System.exit() should not be used in J2EE/JEE apps
Error

Line: 95

                      // Check if image is loaded successfully
        if (src.empty()) {
            System.err.println("Cannot read image: " + filename);
            System.exit(0);
        }

        Mat srcOriginal = src.clone();
        HighGui.imshow("src", srcOriginal);


            

Reported by PMD.

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

Line: 98

                          System.exit(0);
        }

        Mat srcOriginal = src.clone();
        HighGui.imshow("src", srcOriginal);

        // Convert image to grayscale
        Mat gray = new Mat();
        Imgproc.cvtColor(src, gray, Imgproc.COLOR_BGR2GRAY);

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 124

                              continue;

            // Draw each contour only for visualisation purposes
            Imgproc.drawContours(src, contours, i, new Scalar(0, 0, 255), 2);
            // Find the orientation of each shape
            getOrientation(contours.get(i), src);
        }
        //! [contours]


            

Reported by PMD.

System.exit() should not be used in J2EE/JEE apps
Error

Line: 133

                      HighGui.imshow("output", src);

        HighGui.waitKey();
        System.exit(0);
    }
}

public class IntroductionToPCADemo {
    public static void main(String[] args) {

            

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

                  }
}

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

        new IntroductionToPCA().run(args);

            

Reported by PMD.

samples/python/tutorial_code/imgProc/threshold/threshold.py
14 issues
Unable to import 'cv2'
Error

Line: 2 Column: 1

              from __future__ import print_function
import cv2 as cv
import argparse

max_value = 255
max_type = 4
max_binary_value = 255
trackbar_type = 'Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted'
trackbar_value = 'Value'

            

Reported by Pylint.

Unused argument 'val'
Error

Line: 13 Column: 20

              window_name = 'Threshold Demo'

## [Threshold_Demo]
def Threshold_Demo(val):
    #0: Binary
    #1: Binary Inverted
    #2: Threshold Truncated
    #3: Threshold to Zero
    #4: Threshold to Zero Inverted

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import print_function
import cv2 as cv
import argparse

max_value = 255
max_type = 4
max_binary_value = 255
trackbar_type = 'Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted'
trackbar_value = 'Value'

            

Reported by Pylint.

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

Line: 3 Column: 1

              from __future__ import print_function
import cv2 as cv
import argparse

max_value = 255
max_type = 4
max_binary_value = 255
trackbar_type = 'Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted'
trackbar_value = 'Value'

            

Reported by Pylint.

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

Line: 5 Column: 1

              import cv2 as cv
import argparse

max_value = 255
max_type = 4
max_binary_value = 255
trackbar_type = 'Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted'
trackbar_value = 'Value'
window_name = 'Threshold Demo'

            

Reported by Pylint.

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

Line: 6 Column: 1

              import argparse

max_value = 255
max_type = 4
max_binary_value = 255
trackbar_type = 'Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted'
trackbar_value = 'Value'
window_name = 'Threshold Demo'


            

Reported by Pylint.

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

Line: 7 Column: 1

              
max_value = 255
max_type = 4
max_binary_value = 255
trackbar_type = 'Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted'
trackbar_value = 'Value'
window_name = 'Threshold Demo'

## [Threshold_Demo]

            

Reported by Pylint.

Line too long (110/100)
Error

Line: 8 Column: 1

              max_value = 255
max_type = 4
max_binary_value = 255
trackbar_type = 'Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted'
trackbar_value = 'Value'
window_name = 'Threshold Demo'

## [Threshold_Demo]
def Threshold_Demo(val):

            

Reported by Pylint.

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

Line: 8 Column: 1

              max_value = 255
max_type = 4
max_binary_value = 255
trackbar_type = 'Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted'
trackbar_value = 'Value'
window_name = 'Threshold Demo'

## [Threshold_Demo]
def Threshold_Demo(val):

            

Reported by Pylint.

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

Line: 9 Column: 1

              max_type = 4
max_binary_value = 255
trackbar_type = 'Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted'
trackbar_value = 'Value'
window_name = 'Threshold Demo'

## [Threshold_Demo]
def Threshold_Demo(val):
    #0: Binary

            

Reported by Pylint.

samples/dnn/dnn_model_runner/dnn_conversion/tf/classification/py_to_py_cls.py
13 issues
Unable to import 'tensorflow.keras.applications'
Error

Line: 1 Column: 1

              from tensorflow.keras.applications import (
    VGG16, vgg16,
    VGG19, vgg19,

    ResNet50, resnet,
    ResNet101,
    ResNet152,

    DenseNet121, densenet,

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 25 Column: 1

                  Xception, xception
)

from ..tf_model import TFModelPreparer
from ..tf_model import (
    TFModelProcessor,
    TFDnnModelProcessor
)
from ...common.evaluation.classification.cls_data_fetcher import TFPreprocessedFetch

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 26 Column: 1

              )

from ..tf_model import TFModelPreparer
from ..tf_model import (
    TFModelProcessor,
    TFDnnModelProcessor
)
from ...common.evaluation.classification.cls_data_fetcher import TFPreprocessedFetch
from ...common.test.cls_model_test_pipeline import ClsModelTestPipeline

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 30 Column: 1

                  TFModelProcessor,
    TFDnnModelProcessor
)
from ...common.evaluation.classification.cls_data_fetcher import TFPreprocessedFetch
from ...common.test.cls_model_test_pipeline import ClsModelTestPipeline
from ...common.test.configs.default_preprocess_config import (
    tf_input_blob,
    pytorch_input_blob,
    tf_model_blob_caffe_mode

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 31 Column: 1

                  TFDnnModelProcessor
)
from ...common.evaluation.classification.cls_data_fetcher import TFPreprocessedFetch
from ...common.test.cls_model_test_pipeline import ClsModelTestPipeline
from ...common.test.configs.default_preprocess_config import (
    tf_input_blob,
    pytorch_input_blob,
    tf_model_blob_caffe_mode
)

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 32 Column: 1

              )
from ...common.evaluation.classification.cls_data_fetcher import TFPreprocessedFetch
from ...common.test.cls_model_test_pipeline import ClsModelTestPipeline
from ...common.test.configs.default_preprocess_config import (
    tf_input_blob,
    pytorch_input_blob,
    tf_model_blob_caffe_mode
)
from ...common.utils import set_tf_env, create_extended_parser

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 37 Column: 1

                  pytorch_input_blob,
    tf_model_blob_caffe_mode
)
from ...common.utils import set_tf_env, create_extended_parser

model_dict = {
    "vgg16": [VGG16, vgg16, tf_model_blob_caffe_mode],
    "vgg19": [VGG19, vgg19, tf_model_blob_caffe_mode],


            

Reported by Pylint.

Useless super delegation in method '__init__'
Error

Line: 69 Column: 5

              

class TFClsModel(TFModelPreparer):
    def __init__(self, model_name, original_model):
        super(TFClsModel, self).__init__(model_name, original_model)


def main():
    set_tf_env()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from tensorflow.keras.applications import (
    VGG16, vgg16,
    VGG19, vgg19,

    ResNet50, resnet,
    ResNet101,
    ResNet152,

    DenseNet121, densenet,

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 68 Column: 1

              DEFAULT_BLOB_PARAMS_ID = 2


class TFClsModel(TFModelPreparer):
    def __init__(self, model_name, original_model):
        super(TFClsModel, self).__init__(model_name, original_model)


def main():

            

Reported by Pylint.

samples/dnn/dnn_model_runner/dnn_conversion/pytorch/classification/py_to_py_cls.py
13 issues
Unable to import 'torchvision'
Error

Line: 1 Column: 1

              from torchvision import models

from ..pytorch_model import (
    PyTorchModelPreparer,
    PyTorchModelProcessor,
    PyTorchDnnModelProcessor
)
from ...common.evaluation.classification.cls_data_fetcher import PyTorchPreprocessedFetch
from ...common.test.cls_model_test_pipeline import ClsModelTestPipeline

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 3 Column: 1

              from torchvision import models

from ..pytorch_model import (
    PyTorchModelPreparer,
    PyTorchModelProcessor,
    PyTorchDnnModelProcessor
)
from ...common.evaluation.classification.cls_data_fetcher import PyTorchPreprocessedFetch
from ...common.test.cls_model_test_pipeline import ClsModelTestPipeline

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

                  PyTorchModelProcessor,
    PyTorchDnnModelProcessor
)
from ...common.evaluation.classification.cls_data_fetcher import PyTorchPreprocessedFetch
from ...common.test.cls_model_test_pipeline import ClsModelTestPipeline
from ...common.test.configs.default_preprocess_config import pytorch_resize_input_blob
from ...common.test.configs.test_config import TestClsConfig
from ...common.utils import set_pytorch_env, create_extended_parser


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

                  PyTorchDnnModelProcessor
)
from ...common.evaluation.classification.cls_data_fetcher import PyTorchPreprocessedFetch
from ...common.test.cls_model_test_pipeline import ClsModelTestPipeline
from ...common.test.configs.default_preprocess_config import pytorch_resize_input_blob
from ...common.test.configs.test_config import TestClsConfig
from ...common.utils import set_pytorch_env, create_extended_parser

model_dict = {

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 10 Column: 1

              )
from ...common.evaluation.classification.cls_data_fetcher import PyTorchPreprocessedFetch
from ...common.test.cls_model_test_pipeline import ClsModelTestPipeline
from ...common.test.configs.default_preprocess_config import pytorch_resize_input_blob
from ...common.test.configs.test_config import TestClsConfig
from ...common.utils import set_pytorch_env, create_extended_parser

model_dict = {
    "alexnet": models.alexnet,

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 11 Column: 1

              from ...common.evaluation.classification.cls_data_fetcher import PyTorchPreprocessedFetch
from ...common.test.cls_model_test_pipeline import ClsModelTestPipeline
from ...common.test.configs.default_preprocess_config import pytorch_resize_input_blob
from ...common.test.configs.test_config import TestClsConfig
from ...common.utils import set_pytorch_env, create_extended_parser

model_dict = {
    "alexnet": models.alexnet,


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 12 Column: 1

              from ...common.test.cls_model_test_pipeline import ClsModelTestPipeline
from ...common.test.configs.default_preprocess_config import pytorch_resize_input_blob
from ...common.test.configs.test_config import TestClsConfig
from ...common.utils import set_pytorch_env, create_extended_parser

model_dict = {
    "alexnet": models.alexnet,

    "vgg11": models.vgg11,

            

Reported by Pylint.

Useless super delegation in method '__init__'
Error

Line: 40 Column: 5

              

class PyTorchClsModel(PyTorchModelPreparer):
    def __init__(self, height, width, model_name, original_model):
        super(PyTorchClsModel, self).__init__(height, width, model_name, original_model)


def main():
    set_pytorch_env()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from torchvision import models

from ..pytorch_model import (
    PyTorchModelPreparer,
    PyTorchModelProcessor,
    PyTorchDnnModelProcessor
)
from ...common.evaluation.classification.cls_data_fetcher import PyTorchPreprocessedFetch
from ...common.test.cls_model_test_pipeline import ClsModelTestPipeline

            

Reported by Pylint.

Missing class docstring
Error

Line: 39 Column: 1

              }


class PyTorchClsModel(PyTorchModelPreparer):
    def __init__(self, height, width, model_name, original_model):
        super(PyTorchClsModel, self).__init__(height, width, model_name, original_model)


def main():

            

Reported by Pylint.

samples/dnn/dnn_model_runner/dnn_conversion/pytorch/classification/py_to_py_resnet50.py
13 issues
Unable to import 'cv2'
Error

Line: 3 Column: 1

              import os

import cv2
import numpy as np
import torch
import torch.onnx
from torch.autograd import Variable
from torchvision import models


            

Reported by Pylint.

Unable to import 'torch'
Error

Line: 5 Column: 1

              
import cv2
import numpy as np
import torch
import torch.onnx
from torch.autograd import Variable
from torchvision import models



            

Reported by Pylint.

Unable to import 'torch.onnx'
Error

Line: 6 Column: 1

              import cv2
import numpy as np
import torch
import torch.onnx
from torch.autograd import Variable
from torchvision import models


def get_pytorch_onnx_model(original_model):

            

Reported by Pylint.

Unable to import 'torch.autograd'
Error

Line: 7 Column: 1

              import numpy as np
import torch
import torch.onnx
from torch.autograd import Variable
from torchvision import models


def get_pytorch_onnx_model(original_model):
    # define the directory for further converted model save

            

Reported by Pylint.

Unable to import 'torchvision'
Error

Line: 8 Column: 1

              import torch
import torch.onnx
from torch.autograd import Variable
from torchvision import models


def get_pytorch_onnx_model(original_model):
    # define the directory for further converted model save
    onnx_model_path = "models"

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os

import cv2
import numpy as np
import torch
import torch.onnx
from torch.autograd import Variable
from torchvision import models


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 1

              from torchvision import models


def get_pytorch_onnx_model(original_model):
    # define the directory for further converted model save
    onnx_model_path = "models"
    # define the name of further converted model
    onnx_model_name = "resnet50.onnx"


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 42 Column: 1

                  return full_model_path


def get_preprocessed_img(img_path):
    # read the image
    input_img = cv2.imread(img_path, cv2.IMREAD_COLOR)
    input_img = input_img.astype(np.float32)

    input_img = cv2.resize(input_img, (256, 256))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 70 Column: 1

                  return input_blob


def get_imagenet_labels(labels_path):
    with open(labels_path) as f:
        imagenet_labels = [line.strip() for line in f.readlines()]
    return imagenet_labels



            

Reported by Pylint.

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

Line: 71 Column: 31

              

def get_imagenet_labels(labels_path):
    with open(labels_path) as f:
        imagenet_labels = [line.strip() for line in f.readlines()]
    return imagenet_labels


def get_opencv_dnn_prediction(opencv_net, preproc_img, imagenet_labels):

            

Reported by Pylint.

modules/features2d/misc/java/test/SURFDescriptorExtractorTest.java
13 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 16

              
public class SURFDescriptorExtractorTest extends OpenCVTestCase {

    Feature2D extractor;
    int matSize;

    private Mat getTestImg() {
        Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255));
        Imgproc.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2);

            

Reported by PMD.

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

Line: 17

              public class SURFDescriptorExtractorTest extends OpenCVTestCase {

    Feature2D extractor;
    int matSize;

    private Mat getTestImg() {
        Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255));
        Imgproc.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2);
        Imgproc.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2);

            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 27

                      return cross;
    }

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

        Class[] cParams = {double.class, int.class, int.class, boolean.class, boolean.class};
        Object[] oValues = {100, 2, 4, true, false};

            

Reported by PMD.

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

Line: 38

                      matSize = 100;
    }

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

    public void testComputeMatListOfKeyPointMat() {
        KeyPoint point = new KeyPoint(55.775577545166016f, 44.224422454833984f, 16, 9.754629f, 8617.863f, 1, -1);

            

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

                      fail("Not yet implemented");
    }

    public void testComputeMatListOfKeyPointMat() {
        KeyPoint point = new KeyPoint(55.775577545166016f, 44.224422454833984f, 16, 9.754629f, 8617.863f, 1, -1);
        MatOfKeyPoint keypoints = new MatOfKeyPoint(point);
        Mat img = getTestImg();
        Mat descriptors = new Mat();


            

Reported by PMD.

Double-brace initialization should be avoided
Design

Line: 51

                      extractor.compute(img, keypoints, descriptors);

        Mat truth = new Mat(1, 128, CvType.CV_32FC1) {
            {
                put(0, 0,
                          0, 0, 0, 0, 0, 0, 0, 0, 0.058821894, 0.058821894, -0.045962855, 0.046261817, 0.0085156476,
                          0.0085754395, -0.0064509804, 0.0064509804, 0.00044069235, 0.00044069235, 0, 0, 0.00025723741,
                          0.00025723741, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.00025723741, 0.00025723741, -0.00044069235,
                          0.00044069235, 0, 0, 0.36278215, 0.36278215, -0.24688604, 0.26173124, 0.052068226, 0.052662034,

            

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

                      assertMatEqual(truth, descriptors, EPS);
    }

    public void testCreate() {
        assertNotNull(extractor);
    }

    public void testDescriptorSize() {
        assertEquals(128, extractor.descriptorSize());

            

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

                      assertNotNull(extractor);
    }

    public void testDescriptorSize() {
        assertEquals(128, extractor.descriptorSize());
    }

    public void testDescriptorType() {
        assertEquals(CvType.CV_32F, extractor.descriptorType());

            

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

                      assertEquals(128, extractor.descriptorSize());
    }

    public void testDescriptorType() {
        assertEquals(CvType.CV_32F, extractor.descriptorType());
    }

    public void testEmpty() {
//        assertFalse(extractor.empty());

            

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

                      assertEquals(CvType.CV_32F, extractor.descriptorType());
    }

    public void testEmpty() {
//        assertFalse(extractor.empty());
        fail("Not yet implemented");
    }

    public void testRead() {

            

Reported by PMD.

samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/OnCameraFrameRender.java
13 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 53

              
    @Override
    public Mat render(CvCameraViewFrame inputFrame) {
        Mat renderedFrame = new Mat(inputFrame.rgba().size(), inputFrame.rgba().type());
        Calib3d.undistort(inputFrame.rgba(), renderedFrame,
                mCalibrator.getCameraMatrix(), mCalibrator.getDistortionCoefficients());

        return renderedFrame;
    }

            

Reported by PMD.

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

Line: 53

              
    @Override
    public Mat render(CvCameraViewFrame inputFrame) {
        Mat renderedFrame = new Mat(inputFrame.rgba().size(), inputFrame.rgba().type());
        Calib3d.undistort(inputFrame.rgba(), renderedFrame,
                mCalibrator.getCameraMatrix(), mCalibrator.getDistortionCoefficients());

        return renderedFrame;
    }

            

Reported by PMD.

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

Line: 62

              }

class ComparisonFrameRender extends FrameRender {
    private int mWidth;
    private int mHeight;
    private Resources mResources;
    public ComparisonFrameRender(CameraCalibrator calibrator, int width, int height, Resources resources) {
        mCalibrator = calibrator;
        mWidth = width;

            

Reported by PMD.

Private field 'mWidth' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 62

              }

class ComparisonFrameRender extends FrameRender {
    private int mWidth;
    private int mHeight;
    private Resources mResources;
    public ComparisonFrameRender(CameraCalibrator calibrator, int width, int height, Resources resources) {
        mCalibrator = calibrator;
        mWidth = width;

            

Reported by PMD.

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

Line: 63

              
class ComparisonFrameRender extends FrameRender {
    private int mWidth;
    private int mHeight;
    private Resources mResources;
    public ComparisonFrameRender(CameraCalibrator calibrator, int width, int height, Resources resources) {
        mCalibrator = calibrator;
        mWidth = width;
        mHeight = height;

            

Reported by PMD.

Private field 'mHeight' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 63

              
class ComparisonFrameRender extends FrameRender {
    private int mWidth;
    private int mHeight;
    private Resources mResources;
    public ComparisonFrameRender(CameraCalibrator calibrator, int width, int height, Resources resources) {
        mCalibrator = calibrator;
        mWidth = width;
        mHeight = height;

            

Reported by PMD.

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

Line: 64

              class ComparisonFrameRender extends FrameRender {
    private int mWidth;
    private int mHeight;
    private Resources mResources;
    public ComparisonFrameRender(CameraCalibrator calibrator, int width, int height, Resources resources) {
        mCalibrator = calibrator;
        mWidth = width;
        mHeight = height;
        mResources = resources;

            

Reported by PMD.

Private field 'mResources' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 64

              class ComparisonFrameRender extends FrameRender {
    private int mWidth;
    private int mHeight;
    private Resources mResources;
    public ComparisonFrameRender(CameraCalibrator calibrator, int width, int height, Resources resources) {
        mCalibrator = calibrator;
        mWidth = width;
        mHeight = height;
        mResources = resources;

            

Reported by PMD.

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

Line: 74

              
    @Override
    public Mat render(CvCameraViewFrame inputFrame) {
        Mat undistortedFrame = new Mat(inputFrame.rgba().size(), inputFrame.rgba().type());
        Calib3d.undistort(inputFrame.rgba(), undistortedFrame,
                mCalibrator.getCameraMatrix(), mCalibrator.getDistortionCoefficients());

        Mat comparisonFrame = inputFrame.rgba();
        undistortedFrame.colRange(new Range(0, mWidth / 2)).copyTo(comparisonFrame.colRange(new Range(mWidth / 2, mWidth)));

            

Reported by PMD.

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

Line: 74

              
    @Override
    public Mat render(CvCameraViewFrame inputFrame) {
        Mat undistortedFrame = new Mat(inputFrame.rgba().size(), inputFrame.rgba().type());
        Calib3d.undistort(inputFrame.rgba(), undistortedFrame,
                mCalibrator.getCameraMatrix(), mCalibrator.getDistortionCoefficients());

        Mat comparisonFrame = inputFrame.rgba();
        undistortedFrame.colRange(new Range(0, mWidth / 2)).copyTo(comparisonFrame.colRange(new Range(mWidth / 2, mWidth)));

            

Reported by PMD.

modules/features2d/misc/java/test/BRIEFDescriptorExtractorTest.java
13 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 16

              
public class BRIEFDescriptorExtractorTest extends OpenCVTestCase {

    Feature2D extractor;
    int matSize;

    private Mat getTestImg() {
        Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255));
        Imgproc.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2);

            

Reported by PMD.

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

Line: 17

              public class BRIEFDescriptorExtractorTest extends OpenCVTestCase {

    Feature2D extractor;
    int matSize;

    private Mat getTestImg() {
        Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255));
        Imgproc.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2);
        Imgproc.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2);

            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 27

                      return cross;
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        extractor = createClassInstance(XFEATURES2D+"BriefDescriptorExtractor", DEFAULT_FACTORY, null, null);
        matSize = 100;
    }

            

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

                      matSize = 100;
    }

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

    public void testComputeMatListOfKeyPointMat() {
        KeyPoint point = new KeyPoint(55.775577545166016f, 44.224422454833984f, 16, 9.754629f, 8617.863f, 1, -1);

            

Reported by PMD.

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

Line: 38

                      fail("Not yet implemented");
    }

    public void testComputeMatListOfKeyPointMat() {
        KeyPoint point = new KeyPoint(55.775577545166016f, 44.224422454833984f, 16, 9.754629f, 8617.863f, 1, -1);
        MatOfKeyPoint keypoints = new MatOfKeyPoint(point);
        Mat img = getTestImg();
        Mat descriptors = new Mat();


            

Reported by PMD.

Double-brace initialization should be avoided
Design

Line: 47

                      extractor.compute(img, keypoints, descriptors);

        Mat truth = new Mat(1, 32, CvType.CV_8UC1) {
            {
                put(0, 0, 96, 0, 76, 24, 47, 182, 68, 137,
                          149, 195, 67, 16, 187, 224, 74, 8,
                          82, 169, 87, 70, 44, 4, 192, 56,
                          13, 128, 44, 106, 146, 72, 194, 245);
            }

            

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

                      assertMatEqual(truth, descriptors);
    }

    public void testCreate() {
        assertNotNull(extractor);
    }

    public void testDescriptorSize() {
        assertEquals(32, extractor.descriptorSize());

            

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

                      assertNotNull(extractor);
    }

    public void testDescriptorSize() {
        assertEquals(32, extractor.descriptorSize());
    }

    public void testDescriptorType() {
        assertEquals(CvType.CV_8U, extractor.descriptorType());

            

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

                      assertEquals(32, extractor.descriptorSize());
    }

    public void testDescriptorType() {
        assertEquals(CvType.CV_8U, extractor.descriptorType());
    }

    public void testEmpty() {
//        assertFalse(extractor.empty());

            

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

                      assertEquals(CvType.CV_8U, extractor.descriptorType());
    }

    public void testEmpty() {
//        assertFalse(extractor.empty());
        fail("Not yet implemented"); // BRIEF does not override empty() method
    }

    public void testRead() {

            

Reported by PMD.

platforms/maven/opencv-it/src/test/java/org/opencv/osgi/DeployOpenCVTest.java
13 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 43

                  protected BundleContext bundleContext;

    @Inject
    private LogService logService;

    /*
    This service is required to ensure that the native library has been loaded
    before any test is carried out.
    */

            

Reported by PMD.

Avoid unused private fields such as 'openCVInterface'.
Design

Line: 50

                  before any test is carried out.
    */
    @Inject
    private OpenCVInterface openCVInterface;

    @Configuration
    public static Option[] configuration() throws Exception {
        MavenArtifactUrlReference karafUrl = maven()
                .groupId("org.apache.karaf")

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 53

                  private OpenCVInterface openCVInterface;

    @Configuration
    public static Option[] configuration() throws Exception {
        MavenArtifactUrlReference karafUrl = maven()
                .groupId("org.apache.karaf")
                .artifactId("apache-karaf")
                .version(KARAF_VERSION)
                .type("tar.gz");

            

Reported by PMD.

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

Line: 54

              
    @Configuration
    public static Option[] configuration() throws Exception {
        MavenArtifactUrlReference karafUrl = maven()
                .groupId("org.apache.karaf")
                .artifactId("apache-karaf")
                .version(KARAF_VERSION)
                .type("tar.gz");
        return new Option[]{

            

Reported by PMD.

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

Line: 54

              
    @Configuration
    public static Option[] configuration() throws Exception {
        MavenArtifactUrlReference karafUrl = maven()
                .groupId("org.apache.karaf")
                .artifactId("apache-karaf")
                .version(KARAF_VERSION)
                .type("tar.gz");
        return new Option[]{

            

Reported by PMD.

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

Line: 54

              
    @Configuration
    public static Option[] configuration() throws Exception {
        MavenArtifactUrlReference karafUrl = maven()
                .groupId("org.apache.karaf")
                .artifactId("apache-karaf")
                .version(KARAF_VERSION)
                .type("tar.gz");
        return new Option[]{

            

Reported by PMD.

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

Line: 54

              
    @Configuration
    public static Option[] configuration() throws Exception {
        MavenArtifactUrlReference karafUrl = maven()
                .groupId("org.apache.karaf")
                .artifactId("apache-karaf")
                .version(KARAF_VERSION)
                .type("tar.gz");
        return new Option[]{

            

Reported by PMD.

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

Line: 65

                          .unpackDirectory(new File("../../../build/target/exam"))
            .useDeployFolder(false),
            keepRuntimeFolder(),
            mavenBundle()
            .groupId("org.opencv")
            .artifactId("opencv")
            .versionAsInProject(),
            logLevel(LogLevelOption.LogLevel.INFO)
        };

            

Reported by PMD.

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

Line: 65

                          .unpackDirectory(new File("../../../build/target/exam"))
            .useDeployFolder(false),
            keepRuntimeFolder(),
            mavenBundle()
            .groupId("org.opencv")
            .artifactId("opencv")
            .versionAsInProject(),
            logLevel(LogLevelOption.LogLevel.INFO)
        };

            

Reported by PMD.

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

Line: 65

                          .unpackDirectory(new File("../../../build/target/exam"))
            .useDeployFolder(false),
            keepRuntimeFolder(),
            mavenBundle()
            .groupId("org.opencv")
            .artifactId("opencv")
            .versionAsInProject(),
            logLevel(LogLevelOption.LogLevel.INFO)
        };

            

Reported by PMD.