The following issues were found

apps/traincascade/old_ml.hpp
11 issues
There is an unknown macro here somewhere. Configuration is required. If CV_WRAP_AS is a macro then please configure it.
Error

Line: 513

                                          CvParamGrid degreeGrid = CvSVM::get_default_grid(CvSVM::DEGREE),
                            bool balanced=false);
    CV_WRAP virtual float predict( const cv::Mat& sample, bool returnDFVal=false ) const;
    CV_WRAP_AS(predict_all) virtual void predict( cv::InputArray samples, cv::OutputArray results ) const;

    CV_WRAP virtual int get_support_vector_count() const;
    virtual const float* get_support_vector(int i) const;
    virtual CvSVMParams get_params() const { return params; }
    CV_WRAP virtual void clear();

            

Reported by Cppcheck.

There is an unknown macro here somewhere. Configuration is required. If CV_WRAP_AS is a macro then please configure it.
Error

Line: 513

                                          CvParamGrid degreeGrid = CvSVM::get_default_grid(CvSVM::DEGREE),
                            bool balanced=false);
    CV_WRAP virtual float predict( const cv::Mat& sample, bool returnDFVal=false ) const;
    CV_WRAP_AS(predict_all) virtual void predict( cv::InputArray samples, cv::OutputArray results ) const;

    CV_WRAP virtual int get_support_vector_count() const;
    virtual const float* get_support_vector(int i) const;
    virtual CvSVMParams get_params() const { return params; }
    CV_WRAP virtual void clear();

            

Reported by Cppcheck.

There is an unknown macro here somewhere. Configuration is required. If CV_WRAP_AS is a macro then please configure it.
Error

Line: 513

                                          CvParamGrid degreeGrid = CvSVM::get_default_grid(CvSVM::DEGREE),
                            bool balanced=false);
    CV_WRAP virtual float predict( const cv::Mat& sample, bool returnDFVal=false ) const;
    CV_WRAP_AS(predict_all) virtual void predict( cv::InputArray samples, cv::OutputArray results ) const;

    CV_WRAP virtual int get_support_vector_count() const;
    virtual const float* get_support_vector(int i) const;
    virtual CvSVMParams get_params() const { return params; }
    CV_WRAP virtual void clear();

            

Reported by Cppcheck.

There is an unknown macro here somewhere. Configuration is required. If CV_WRAP_AS is a macro then please configure it.
Error

Line: 513

                                          CvParamGrid degreeGrid = CvSVM::get_default_grid(CvSVM::DEGREE),
                            bool balanced=false);
    CV_WRAP virtual float predict( const cv::Mat& sample, bool returnDFVal=false ) const;
    CV_WRAP_AS(predict_all) virtual void predict( cv::InputArray samples, cv::OutputArray results ) const;

    CV_WRAP virtual int get_support_vector_count() const;
    virtual const float* get_support_vector(int i) const;
    virtual CvSVMParams get_params() const { return params; }
    CV_WRAP virtual void clear();

            

Reported by Cppcheck.

There is an unknown macro here somewhere. Configuration is required. If CV_WRAP_AS is a macro then please configure it.
Error

Line: 513

                                          CvParamGrid degreeGrid = CvSVM::get_default_grid(CvSVM::DEGREE),
                            bool balanced=false);
    CV_WRAP virtual float predict( const cv::Mat& sample, bool returnDFVal=false ) const;
    CV_WRAP_AS(predict_all) virtual void predict( cv::InputArray samples, cv::OutputArray results ) const;

    CV_WRAP virtual int get_support_vector_count() const;
    virtual const float* get_support_vector(int i) const;
    virtual CvSVMParams get_params() const { return params; }
    CV_WRAP virtual void clear();

            

Reported by Cppcheck.

There is an unknown macro here somewhere. Configuration is required. If CV_WRAP_AS is a macro then please configure it.
Error

Line: 513

                                          CvParamGrid degreeGrid = CvSVM::get_default_grid(CvSVM::DEGREE),
                            bool balanced=false);
    CV_WRAP virtual float predict( const cv::Mat& sample, bool returnDFVal=false ) const;
    CV_WRAP_AS(predict_all) virtual void predict( cv::InputArray samples, cv::OutputArray results ) const;

    CV_WRAP virtual int get_support_vector_count() const;
    virtual const float* get_support_vector(int i) const;
    virtual CvSVMParams get_params() const { return params; }
    CV_WRAP virtual void clear();

            

Reported by Cppcheck.

There is an unknown macro here somewhere. Configuration is required. If CV_WRAP_AS is a macro then please configure it.
Error

Line: 513

                                          CvParamGrid degreeGrid = CvSVM::get_default_grid(CvSVM::DEGREE),
                            bool balanced=false);
    CV_WRAP virtual float predict( const cv::Mat& sample, bool returnDFVal=false ) const;
    CV_WRAP_AS(predict_all) virtual void predict( cv::InputArray samples, cv::OutputArray results ) const;

    CV_WRAP virtual int get_support_vector_count() const;
    virtual const float* get_support_vector(int i) const;
    virtual CvSVMParams get_params() const { return params; }
    CV_WRAP virtual void clear();

            

Reported by Cppcheck.

There is an unknown macro here somewhere. Configuration is required. If CV_WRAP_AS is a macro then please configure it.
Error

Line: 513

                                          CvParamGrid degreeGrid = CvSVM::get_default_grid(CvSVM::DEGREE),
                            bool balanced=false);
    CV_WRAP virtual float predict( const cv::Mat& sample, bool returnDFVal=false ) const;
    CV_WRAP_AS(predict_all) virtual void predict( cv::InputArray samples, cv::OutputArray results ) const;

    CV_WRAP virtual int get_support_vector_count() const;
    virtual const float* get_support_vector(int i) const;
    virtual CvSVMParams get_params() const { return params; }
    CV_WRAP virtual void clear();

            

Reported by Cppcheck.

There is an unknown macro here somewhere. Configuration is required. If CV_WRAP_AS is a macro then please configure it.
Error

Line: 513

                                          CvParamGrid degreeGrid = CvSVM::get_default_grid(CvSVM::DEGREE),
                            bool balanced=false);
    CV_WRAP virtual float predict( const cv::Mat& sample, bool returnDFVal=false ) const;
    CV_WRAP_AS(predict_all) virtual void predict( cv::InputArray samples, cv::OutputArray results ) const;

    CV_WRAP virtual int get_support_vector_count() const;
    virtual const float* get_support_vector(int i) const;
    virtual CvSVMParams get_params() const { return params; }
    CV_WRAP virtual void clear();

            

Reported by Cppcheck.

There is an unknown macro here somewhere. Configuration is required. If CV_WRAP_AS is a macro then please configure it.
Error

Line: 513

                                          CvParamGrid degreeGrid = CvSVM::get_default_grid(CvSVM::DEGREE),
                            bool balanced=false);
    CV_WRAP virtual float predict( const cv::Mat& sample, bool returnDFVal=false ) const;
    CV_WRAP_AS(predict_all) virtual void predict( cv::InputArray samples, cv::OutputArray results ) const;

    CV_WRAP virtual int get_support_vector_count() const;
    virtual const float* get_support_vector(int i) const;
    virtual CvSVMParams get_params() const { return params; }
    CV_WRAP virtual void clear();

            

Reported by Cppcheck.

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

Line: 19

              public class MyGLSurfaceView extends CameraGLSurfaceView implements CameraGLSurfaceView.CameraTextureListener {

    static final String LOGTAG = "MyGLSurfaceView";
    protected int procMode = NativePart.PROCESSING_MODE_NO_PROCESSING;
    static final String[] procModeName = new String[] {"No Processing", "CPU", "OpenCL Direct", "OpenCL via OpenCV"};
    protected int  frameCounter;
    protected long lastNanoTime;
    TextView mFpsText = null;


            

Reported by PMD.

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

Line: 21

                  static final String LOGTAG = "MyGLSurfaceView";
    protected int procMode = NativePart.PROCESSING_MODE_NO_PROCESSING;
    static final String[] procModeName = new String[] {"No Processing", "CPU", "OpenCL Direct", "OpenCL via OpenCV"};
    protected int  frameCounter;
    protected long lastNanoTime;
    TextView mFpsText = null;

    public MyGLSurfaceView(Context context, AttributeSet attrs) {
        super(context, attrs);

            

Reported by PMD.

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

Line: 22

                  protected int procMode = NativePart.PROCESSING_MODE_NO_PROCESSING;
    static final String[] procModeName = new String[] {"No Processing", "CPU", "OpenCL Direct", "OpenCL via OpenCV"};
    protected int  frameCounter;
    protected long lastNanoTime;
    TextView mFpsText = null;

    public MyGLSurfaceView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

            

Reported by PMD.

Avoid using redundant field initializer for 'mFpsText'
Performance

Line: 23

                  static final String[] procModeName = new String[] {"No Processing", "CPU", "OpenCL Direct", "OpenCL via OpenCV"};
    protected int  frameCounter;
    protected long lastNanoTime;
    TextView mFpsText = null;

    public MyGLSurfaceView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


            

Reported by PMD.

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

Line: 23

                  static final String[] procModeName = new String[] {"No Processing", "CPU", "OpenCL Direct", "OpenCL via OpenCV"};
    protected int  frameCounter;
    protected long lastNanoTime;
    TextView mFpsText = null;

    public MyGLSurfaceView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


            

Reported by PMD.

Overriding method merely calls super
Design

Line: 37

                  }

    @Override
    public void surfaceCreated(SurfaceHolder holder) {
        super.surfaceCreated(holder);
        //NativePart.initCL();
    }

    @Override

            

Reported by PMD.

Overriding method merely calls super
Design

Line: 43

                  }

    @Override
    public void surfaceDestroyed(SurfaceHolder holder) {
        //NativePart.closeCL();
        super.surfaceDestroyed(holder);
    }

    public void setProcessingMode(int newMode) {

            

Reported by PMD.

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

Line: 56

              
        ((Activity) getContext()).runOnUiThread(new Runnable() {
            public void run() {
                Toast.makeText(getContext(), "Selected mode: " + procModeName[procMode], Toast.LENGTH_LONG).show();
            }
        });
    }

    @Override

            

Reported by PMD.

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

Line: 65

                  public void onCameraViewStarted(int width, int height) {
        ((Activity) getContext()).runOnUiThread(new Runnable() {
            public void run() {
                Toast.makeText(getContext(), "onCameraViewStarted", Toast.LENGTH_SHORT).show();
            }
        });
        NativePart.initCL();
        frameCounter = 0;
        lastNanoTime = System.nanoTime();

            

Reported by PMD.

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

Line: 77

                  public void onCameraViewStopped() {
        ((Activity) getContext()).runOnUiThread(new Runnable() {
            public void run() {
                Toast.makeText(getContext(), "onCameraViewStopped", Toast.LENGTH_SHORT).show();
            }
        });
    }

    @Override

            

Reported by PMD.

samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Activity.java
11 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 27

              
    private static final String  TAG = "Puzzle15::Activity";

    private CameraBridgeViewBase mOpenCvCameraView;
    private Puzzle15Processor    mPuzzle15;
    private MenuItem             mItemHideNumbers;
    private MenuItem             mItemStartNewGame;



            

Reported by PMD.

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

Line: 28

                  private static final String  TAG = "Puzzle15::Activity";

    private CameraBridgeViewBase mOpenCvCameraView;
    private Puzzle15Processor    mPuzzle15;
    private MenuItem             mItemHideNumbers;
    private MenuItem             mItemStartNewGame;


    private int                  mGameWidth;

            

Reported by PMD.

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

Line: 29

              
    private CameraBridgeViewBase mOpenCvCameraView;
    private Puzzle15Processor    mPuzzle15;
    private MenuItem             mItemHideNumbers;
    private MenuItem             mItemStartNewGame;


    private int                  mGameWidth;
    private int                  mGameHeight;

            

Reported by PMD.

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

Line: 30

                  private CameraBridgeViewBase mOpenCvCameraView;
    private Puzzle15Processor    mPuzzle15;
    private MenuItem             mItemHideNumbers;
    private MenuItem             mItemStartNewGame;


    private int                  mGameWidth;
    private int                  mGameHeight;


            

Reported by PMD.

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

Line: 33

                  private MenuItem             mItemStartNewGame;


    private int                  mGameWidth;
    private int                  mGameHeight;

    private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {

        @Override

            

Reported by PMD.

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

Line: 34

              

    private int                  mGameWidth;
    private int                  mGameHeight;

    private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {

        @Override
        public void onManagerConnected(int status) {

            

Reported by PMD.

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

Line: 36

                  private int                  mGameWidth;
    private int                  mGameHeight;

    private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {

        @Override
        public void onManagerConnected(int status) {
            switch (status) {
                case LoaderCallbackInterface.SUCCESS:

            

Reported by PMD.

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

Line: 36

                  private int                  mGameWidth;
    private int                  mGameHeight;

    private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {

        @Override
        public void onManagerConnected(int status) {
            switch (status) {
                case LoaderCallbackInterface.SUCCESS:

            

Reported by PMD.

A switch with less than three branches is inefficient, use a if statement instead.
Performance

Line: 40

              
        @Override
        public void onManagerConnected(int status) {
            switch (status) {
                case LoaderCallbackInterface.SUCCESS:
                {
                    Log.i(TAG, "OpenCV loaded successfully");

                    /* Now enable camera view to start receiving frames */

            

Reported by PMD.

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

Line: 60

                  @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        Log.d(TAG, "Creating and setting view");
        mOpenCvCameraView = (CameraBridgeViewBase) new JavaCameraView(this, -1);
        setContentView(mOpenCvCameraView);
        mOpenCvCameraView.setVisibility(CameraBridgeViewBase.VISIBLE);

            

Reported by PMD.

modules/imgcodecs/misc/java/test/ImgcodecsTest.java
11 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 11

              
public class ImgcodecsTest extends OpenCVTestCase {

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

    public void testImencodeStringMatListOfByte() {
        MatOfByte buff = new MatOfByte();

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 15

                      fail("Not yet implemented");
    }

    public void testImencodeStringMatListOfByte() {
        MatOfByte buff = new MatOfByte();
        assertEquals(0, buff.total());
        assertTrue( Imgcodecs.imencode(".jpg", gray127, buff) );
        assertFalse(0 == buff.total());
    }

            

Reported by PMD.

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

Line: 15

                      fail("Not yet implemented");
    }

    public void testImencodeStringMatListOfByte() {
        MatOfByte buff = new MatOfByte();
        assertEquals(0, buff.total());
        assertTrue( Imgcodecs.imencode(".jpg", gray127, buff) );
        assertFalse(0 == buff.total());
    }

            

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

                      assertFalse(0 == buff.total());
    }

    public void testImencodeStringMatListOfByteListOfInteger() {
        MatOfInt  params40 = new MatOfInt(Imgcodecs.IMWRITE_JPEG_QUALITY, 40);
        MatOfInt  params90 = new MatOfInt(Imgcodecs.IMWRITE_JPEG_QUALITY, 90);
        /* or
        MatOfInt  params = new MatOfInt();
        params.fromArray(Imgcodecs.IMWRITE_JPEG_QUALITY, 40);

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 22

                      assertFalse(0 == buff.total());
    }

    public void testImencodeStringMatListOfByteListOfInteger() {
        MatOfInt  params40 = new MatOfInt(Imgcodecs.IMWRITE_JPEG_QUALITY, 40);
        MatOfInt  params90 = new MatOfInt(Imgcodecs.IMWRITE_JPEG_QUALITY, 90);
        /* or
        MatOfInt  params = new MatOfInt();
        params.fromArray(Imgcodecs.IMWRITE_JPEG_QUALITY, 40);

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 39

                      assertTrue(buff40.total() < buff90.total());
    }

    public void testImreadString() {
        dst = Imgcodecs.imread(OpenCVTestRunner.LENA_PATH);
        assertFalse(dst.empty());
        assertEquals(3, dst.channels());
        assertTrue(512 == dst.cols());
        assertTrue(512 == dst.rows());

            

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

                      assertTrue(buff40.total() < buff90.total());
    }

    public void testImreadString() {
        dst = Imgcodecs.imread(OpenCVTestRunner.LENA_PATH);
        assertFalse(dst.empty());
        assertEquals(3, dst.channels());
        assertTrue(512 == dst.cols());
        assertTrue(512 == dst.rows());

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 47

                      assertTrue(512 == dst.rows());
    }

    public void testImreadStringInt() {
        dst = Imgcodecs.imread(OpenCVTestRunner.LENA_PATH, 0);
        assertFalse(dst.empty());
        assertEquals(1, dst.channels());
        assertTrue(512 == dst.cols());
        assertTrue(512 == dst.rows());

            

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

                      assertTrue(512 == dst.rows());
    }

    public void testImreadStringInt() {
        dst = Imgcodecs.imread(OpenCVTestRunner.LENA_PATH, 0);
        assertFalse(dst.empty());
        assertEquals(1, dst.channels());
        assertTrue(512 == dst.cols());
        assertTrue(512 == dst.rows());

            

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

                      assertTrue(512 == dst.rows());
    }

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

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

            

Reported by PMD.

modules/core/misc/java/src/java/core+Rect2d.java
11 issues
Overridable method 'set' called during object construction
Error

Line: 31

                  }

    public Rect2d(double[] vals) {
        set(vals);
    }

    public void set(double[] vals) {
        if (vals != null) {
            x = vals.length > 0 ? (double) vals[0] : 0;

            

Reported by PMD.

Object clone() should be implemented with super.clone()
Error

Line: 48

                      }
    }

    public Rect2d clone() {
        return new Rect2d(x, y, width, height);
    }

    public Point tl() {
        return new Point(x, y);

            

Reported by PMD.

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

Line: 6

              //javadoc:Rect2d_
public class Rect2d {

    public double x, y, width, height;

    public Rect2d(double x, double y, double width, double height) {
        this.x = x;
        this.y = y;
        this.width = width;

            

Reported by PMD.

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

Line: 6

              //javadoc:Rect2d_
public class Rect2d {

    public double x, y, width, height;

    public Rect2d(double x, double y, double width, double height) {
        this.x = x;
        this.y = y;
        this.width = width;

            

Reported by PMD.

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

Line: 6

              //javadoc:Rect2d_
public class Rect2d {

    public double x, y, width, height;

    public Rect2d(double x, double y, double width, double height) {
        this.x = x;
        this.y = y;
        this.width = width;

            

Reported by PMD.

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

Line: 6

              //javadoc:Rect2d_
public class Rect2d {

    public double x, y, width, height;

    public Rect2d(double x, double y, double width, double height) {
        this.x = x;
        this.y = y;
        this.width = width;

            

Reported by PMD.

clone() method should be implemented only if implementing Cloneable interface
Error

Line: 48

                      }
    }

    public Rect2d clone() {
        return new Rect2d(x, y, width, height);
    }

    public Point tl() {
        return new Point(x, y);

            

Reported by PMD.

clone() method should throw CloneNotSupportedException
Error

Line: 48

                      }
    }

    public Rect2d clone() {
        return new Rect2d(x, y, width, height);
    }

    public Point tl() {
        return new Point(x, y);

            

Reported by PMD.

Use one line for each declaration, it enhances code readability.
Design

Line: 6

              //javadoc:Rect2d_
public class Rect2d {

    public double x, y, width, height;

    public Rect2d(double x, double y, double width, double height) {
        this.x = x;
        this.y = y;
        this.width = width;

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 30

                      this((double) p.x, (double) p.y, (double) s.width, (double) s.height);
    }

    public Rect2d(double[] vals) {
        set(vals);
    }

    public void set(double[] vals) {
        if (vals != null) {

            

Reported by PMD.

modules/core/misc/java/src/java/core+Rect.java
11 issues
Overridable method 'set' called during object construction
Error

Line: 31

                  }

    public Rect(double[] vals) {
        set(vals);
    }

    public void set(double[] vals) {
        if (vals != null) {
            x = vals.length > 0 ? (int) vals[0] : 0;

            

Reported by PMD.

Object clone() should be implemented with super.clone()
Error

Line: 48

                      }
    }

    public Rect clone() {
        return new Rect(x, y, width, height);
    }

    public Point tl() {
        return new Point(x, y);

            

Reported by PMD.

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

Line: 6

              //javadoc:Rect_
public class Rect {

    public int x, y, width, height;

    public Rect(int x, int y, int width, int height) {
        this.x = x;
        this.y = y;
        this.width = width;

            

Reported by PMD.

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

Line: 6

              //javadoc:Rect_
public class Rect {

    public int x, y, width, height;

    public Rect(int x, int y, int width, int height) {
        this.x = x;
        this.y = y;
        this.width = width;

            

Reported by PMD.

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

Line: 6

              //javadoc:Rect_
public class Rect {

    public int x, y, width, height;

    public Rect(int x, int y, int width, int height) {
        this.x = x;
        this.y = y;
        this.width = width;

            

Reported by PMD.

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

Line: 6

              //javadoc:Rect_
public class Rect {

    public int x, y, width, height;

    public Rect(int x, int y, int width, int height) {
        this.x = x;
        this.y = y;
        this.width = width;

            

Reported by PMD.

clone() method should be implemented only if implementing Cloneable interface
Error

Line: 48

                      }
    }

    public Rect clone() {
        return new Rect(x, y, width, height);
    }

    public Point tl() {
        return new Point(x, y);

            

Reported by PMD.

clone() method should throw CloneNotSupportedException
Error

Line: 48

                      }
    }

    public Rect clone() {
        return new Rect(x, y, width, height);
    }

    public Point tl() {
        return new Point(x, y);

            

Reported by PMD.

Use one line for each declaration, it enhances code readability.
Design

Line: 6

              //javadoc:Rect_
public class Rect {

    public int x, y, width, height;

    public Rect(int x, int y, int width, int height) {
        this.x = x;
        this.y = y;
        this.width = width;

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 30

                      this((int) p.x, (int) p.y, (int) s.width, (int) s.height);
    }

    public Rect(double[] vals) {
        set(vals);
    }

    public void set(double[] vals) {
        if (vals != null) {

            

Reported by PMD.

samples/python/tutorial_code/ImgTrans/MakeBorder/copy_make_border.py
11 issues
Unable to import 'cv2'
Error

Line: 7 Column: 1

              """
import sys
from random import randint
import cv2 as cv


def main(argv):
    ## [variables]
    # First we declare the variables we are going to use

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              import cv2 as cv


def main(argv):
    ## [variables]
    # First we declare the variables we are going to use
    borderType = cv.BORDER_CONSTANT
    window_name = "copyMakeBorder Demo"
    ## [variables]

            

Reported by Pylint.

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

Line: 13 Column: 5

              def main(argv):
    ## [variables]
    # First we declare the variables we are going to use
    borderType = cv.BORDER_CONSTANT
    window_name = "copyMakeBorder Demo"
    ## [variables]
    ## [load]
    imageName = argv[0] if len(argv) > 0 else 'lena.jpg'


            

Reported by Pylint.

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

Line: 17 Column: 5

                  window_name = "copyMakeBorder Demo"
    ## [variables]
    ## [load]
    imageName = argv[0] if len(argv) > 0 else 'lena.jpg'

    # Loads an image
    src = cv.imread(cv.samples.findFile(imageName), cv.IMREAD_COLOR)

    # Check if image is loaded fine

            

Reported by Pylint.

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Security blacklist

Line: 47
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b311-random

                  ## [init_arguments]
    while 1:
        ## [update_value]
        value = [randint(0, 255), randint(0, 255), randint(0, 255)]
        ## [update_value]
        ## [copymakeborder]
        dst = cv.copyMakeBorder(src, top, bottom, left, right, borderType, None, value)
        ## [copymakeborder]
        ## [display]

            

Reported by Bandit.

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Security blacklist

Line: 47
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b311-random

                  ## [init_arguments]
    while 1:
        ## [update_value]
        value = [randint(0, 255), randint(0, 255), randint(0, 255)]
        ## [update_value]
        ## [copymakeborder]
        dst = cv.copyMakeBorder(src, top, bottom, left, right, borderType, None, value)
        ## [copymakeborder]
        ## [display]

            

Reported by Bandit.

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Security blacklist

Line: 47
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b311-random

                  ## [init_arguments]
    while 1:
        ## [update_value]
        value = [randint(0, 255), randint(0, 255), randint(0, 255)]
        ## [update_value]
        ## [copymakeborder]
        dst = cv.copyMakeBorder(src, top, bottom, left, right, borderType, None, value)
        ## [copymakeborder]
        ## [display]

            

Reported by Bandit.

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

Line: 56 Column: 9

                      cv.imshow(window_name, dst)
        ## [display]
        ## [check_keypress]
        c = cv.waitKey(500)

        if c == 27:
            break
        elif c == 99: # 99 = ord('c')
            borderType = cv.BORDER_CONSTANT

            

Reported by Pylint.

Unnecessary "elif" after "break"
Error

Line: 58 Column: 9

                      ## [check_keypress]
        c = cv.waitKey(500)

        if c == 27:
            break
        elif c == 99: # 99 = ord('c')
            borderType = cv.BORDER_CONSTANT
        elif c == 114: # 114 = ord('r')
            borderType = cv.BORDER_REPLICATE

            

Reported by Pylint.

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

Line: 61 Column: 13

                      if c == 27:
            break
        elif c == 99: # 99 = ord('c')
            borderType = cv.BORDER_CONSTANT
        elif c == 114: # 114 = ord('r')
            borderType = cv.BORDER_REPLICATE
        ## [check_keypress]
    return 0


            

Reported by Pylint.

samples/python/gabor_threads.py
11 issues
Unable to import 'cv2'
Error

Line: 21 Column: 1

              from __future__ import print_function

import numpy as np
import cv2 as cv

from multiprocessing.pool import ThreadPool


def build_filters():

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 57 Column: 5

              
    try:
        img_fn = sys.argv[1]
    except:
        img_fn = 'baboon.jpg'

    img = cv.imread(cv.samples.findFile(img_fn))
    if img is None:
        print('Failed to load image file:', img_fn)

            

Reported by Pylint.

Line too long (133/100)
Error

Line: 8 Column: 1

              =========

Sample demonstrates:
- use of multiple Gabor filter convolutions to get Fractalius-like image effect (http://www.redfieldplugins.com/filterFractalius.htm)
- use of python threading to accelerate the computation

Usage
-----
gabor_threads.py [image filename]

            

Reported by Pylint.

standard import "from multiprocessing.pool import ThreadPool" should be placed before "import numpy as np"
Error

Line: 23 Column: 1

              import numpy as np
import cv2 as cv

from multiprocessing.pool import ThreadPool


def build_filters():
    filters = []
    ksize = 31

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 1

              from multiprocessing.pool import ThreadPool


def build_filters():
    filters = []
    ksize = 31
    for theta in np.arange(0, np.pi, np.pi / 16):
        kern = cv.getGaborKernel((ksize, ksize), 4.0, theta, 10.0, 0.5, 0, ktype=cv.CV_32F)
        kern /= 1.5*kern.sum()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 35 Column: 1

                      filters.append(kern)
    return filters

def process(img, filters):
    accum = np.zeros_like(img)
    for kern in filters:
        fimg = cv.filter2D(img, cv.CV_8UC3, kern)
        np.maximum(accum, fimg, accum)
    return accum

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 42 Column: 1

                      np.maximum(accum, fimg, accum)
    return accum

def process_threaded(img, filters, threadn = 8):
    accum = np.zeros_like(img)
    def f(kern):
        return cv.filter2D(img, cv.CV_8UC3, kern)
    pool = ThreadPool(processes=threadn)
    for fimg in pool.imap_unordered(f, filters):

            

Reported by Pylint.

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

Line: 44 Column: 5

              
def process_threaded(img, filters, threadn = 8):
    accum = np.zeros_like(img)
    def f(kern):
        return cv.filter2D(img, cv.CV_8UC3, kern)
    pool = ThreadPool(processes=threadn)
    for fimg in pool.imap_unordered(f, filters):
        np.maximum(accum, fimg, accum)
    return accum

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 51 Column: 1

                      np.maximum(accum, fimg, accum)
    return accum

def main():
    import sys
    from common import Timer

    try:
        img_fn = sys.argv[1]

            

Reported by Pylint.

Import outside toplevel (sys)
Error

Line: 52 Column: 5

                  return accum

def main():
    import sys
    from common import Timer

    try:
        img_fn = sys.argv[1]
    except:

            

Reported by Pylint.

modules/python/test/test.py
11 issues
Unused import unittest
Error

Line: 14 Column: 1

              sys.dont_write_bytecode = True  # Don't generate .pyc files / __pycache__ directories

import os
import unittest

# Python 3 moved urlopen to urllib.requests
try:
    from urllib.request import urlopen
except ImportError:

            

Reported by Pylint.

Unused urlopen imported from urllib.request
Error

Line: 18 Column: 5

              
# Python 3 moved urlopen to urllib.requests
try:
    from urllib.request import urlopen
except ImportError:
    from urllib import urlopen

from tests_common import NewOpenCVTests


            

Reported by Pylint.

Unused argument 'pattern'
Error

Line: 27 Column: 31

              
basedir = os.path.abspath(os.path.dirname(__file__))

def load_tests(loader, tests, pattern):
    cwd = os.getcwd()
    config_file = 'opencv_python_tests.cfg'
    locations = [cwd, basedir]
    if os.path.exists(config_file):
        with open(config_file, 'r') as f:

            

Reported by Pylint.

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

Line: 13 Column: 1

              import sys
sys.dont_write_bytecode = True  # Don't generate .pyc files / __pycache__ directories

import os
import unittest

# Python 3 moved urlopen to urllib.requests
try:
    from urllib.request import urlopen

            

Reported by Pylint.

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

Line: 14 Column: 1

              sys.dont_write_bytecode = True  # Don't generate .pyc files / __pycache__ directories

import os
import unittest

# Python 3 moved urlopen to urllib.requests
try:
    from urllib.request import urlopen
except ImportError:

            

Reported by Pylint.

Import "from tests_common import NewOpenCVTests" should be placed at the top of the module
Error

Line: 22 Column: 1

              except ImportError:
    from urllib import urlopen

from tests_common import NewOpenCVTests


basedir = os.path.abspath(os.path.dirname(__file__))

def load_tests(loader, tests, pattern):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 1

              
basedir = os.path.abspath(os.path.dirname(__file__))

def load_tests(loader, tests, pattern):
    cwd = os.getcwd()
    config_file = 'opencv_python_tests.cfg'
    locations = [cwd, basedir]
    if os.path.exists(config_file):
        with open(config_file, 'r') as f:

            

Reported by Pylint.

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

Line: 32 Column: 40

                  config_file = 'opencv_python_tests.cfg'
    locations = [cwd, basedir]
    if os.path.exists(config_file):
        with open(config_file, 'r') as f:
            locations += [str(s).strip() for s in f.readlines()]
    else:
        print('WARNING: OpenCV tests config file ({}) is missing, running subset of tests'.format(config_file))

    tests_pattern = os.environ.get('OPENCV_PYTEST_FILTER', 'test_*') + '.py'

            

Reported by Pylint.

Line too long (111/100)
Error

Line: 35 Column: 1

                      with open(config_file, 'r') as f:
            locations += [str(s).strip() for s in f.readlines()]
    else:
        print('WARNING: OpenCV tests config file ({}) is missing, running subset of tests'.format(config_file))

    tests_pattern = os.environ.get('OPENCV_PYTEST_FILTER', 'test_*') + '.py'
    if tests_pattern != 'test_*.py':
        print('Tests filter: {}'.format(tests_pattern))


            

Reported by Pylint.

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

Line: 42 Column: 9

                      print('Tests filter: {}'.format(tests_pattern))

    processed = set()
    for l in locations:
        if not os.path.isabs(l):
            l = os.path.normpath(os.path.join(cwd, l))
        if l in processed:
            continue
        processed.add(l)

            

Reported by Pylint.

modules/objdetect/misc/python/test/test_qrcode_detect.py
11 issues
Unable to import 'cv2'
Error

Line: 9 Column: 1

              '''
import os
import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests

class qrcode_detector_test(NewOpenCVTests):


            

Reported by Pylint.

Unable to import 'tests_common'
Error

Line: 11 Column: 1

              import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests

class qrcode_detector_test(NewOpenCVTests):

    def test_detect(self):
        img = cv.imread(os.path.join(self.extraTestDataPath, 'cv/qrcode/link_ocv.jpg'))

            

Reported by Pylint.

Unused numpy imported as np
Error

Line: 8 Column: 1

              ===============================================================================
'''
import os
import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests

class qrcode_detector_test(NewOpenCVTests):

            

Reported by Pylint.

Unused variable 'straight_qrcode'
Error

Line: 27 Column: 25

                      img = cv.imread(os.path.join(self.extraTestDataPath, 'cv/qrcode/link_ocv.jpg'))
        self.assertFalse(img is None)
        detector = cv.QRCodeDetector()
        retval, points, straight_qrcode = detector.detectAndDecode(img)
        self.assertEqual(retval, "https://opencv.org/")
        self.assertEqual(points.shape, (1, 4, 2))

    def test_detect_multi(self):
        img = cv.imread(os.path.join(self.extraTestDataPath, 'cv/qrcode/multiple/6_qrcodes.png'))

            

Reported by Pylint.

Unused variable 'straight_qrcode'
Error

Line: 43 Column: 39

                      img = cv.imread(os.path.join(self.extraTestDataPath, 'cv/qrcode/multiple/6_qrcodes.png'))
        self.assertFalse(img is None)
        detector = cv.QRCodeDetector()
        retval, decoded_data, points, straight_qrcode = detector.detectAndDecodeMulti(img)
        self.assertTrue(retval)
        self.assertEqual(len(decoded_data), 6)
        self.assertEqual(decoded_data[0], "TWO STEPS FORWARD")
        self.assertEqual(decoded_data[1], "EXTRA")
        self.assertEqual(decoded_data[2], "SKIP")

            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

              
from tests_common import NewOpenCVTests

class qrcode_detector_test(NewOpenCVTests):

    def test_detect(self):
        img = cv.imread(os.path.join(self.extraTestDataPath, 'cv/qrcode/link_ocv.jpg'))
        self.assertFalse(img is None)
        detector = cv.QRCodeDetector()

            

Reported by Pylint.

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

Line: 13 Column: 1

              
from tests_common import NewOpenCVTests

class qrcode_detector_test(NewOpenCVTests):

    def test_detect(self):
        img = cv.imread(os.path.join(self.extraTestDataPath, 'cv/qrcode/link_ocv.jpg'))
        self.assertFalse(img is None)
        detector = cv.QRCodeDetector()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 5

              
class qrcode_detector_test(NewOpenCVTests):

    def test_detect(self):
        img = cv.imread(os.path.join(self.extraTestDataPath, 'cv/qrcode/link_ocv.jpg'))
        self.assertFalse(img is None)
        detector = cv.QRCodeDetector()
        retval, points = detector.detect(img)
        self.assertTrue(retval)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 5

                      self.assertTrue(retval)
        self.assertEqual(points.shape, (1, 4, 2))

    def test_detect_and_decode(self):
        img = cv.imread(os.path.join(self.extraTestDataPath, 'cv/qrcode/link_ocv.jpg'))
        self.assertFalse(img is None)
        detector = cv.QRCodeDetector()
        retval, points, straight_qrcode = detector.detectAndDecode(img)
        self.assertEqual(retval, "https://opencv.org/")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 31 Column: 5

                      self.assertEqual(retval, "https://opencv.org/")
        self.assertEqual(points.shape, (1, 4, 2))

    def test_detect_multi(self):
        img = cv.imread(os.path.join(self.extraTestDataPath, 'cv/qrcode/multiple/6_qrcodes.png'))
        self.assertFalse(img is None)
        detector = cv.QRCodeDetector()
        retval, points = detector.detectMulti(img)
        self.assertTrue(retval)

            

Reported by Pylint.