The following issues were found

platforms/winpack_dldt/2021.1/patch.config.py
4 issues
Undefined variable 'applyPatch'
Error

Line: 1 Column: 1

              applyPatch('20201005-dldt-disable-unused-targets.patch')
applyPatch('20200413-dldt-pdb.patch')
applyPatch('20200604-dldt-disable-multidevice.patch')

            

Reported by Pylint.

Undefined variable 'applyPatch'
Error

Line: 2 Column: 1

              applyPatch('20201005-dldt-disable-unused-targets.patch')
applyPatch('20200413-dldt-pdb.patch')
applyPatch('20200604-dldt-disable-multidevice.patch')

            

Reported by Pylint.

Undefined variable 'applyPatch'
Error

Line: 3 Column: 1

              applyPatch('20201005-dldt-disable-unused-targets.patch')
applyPatch('20200413-dldt-pdb.patch')
applyPatch('20200604-dldt-disable-multidevice.patch')

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              applyPatch('20201005-dldt-disable-unused-targets.patch')
applyPatch('20200413-dldt-pdb.patch')
applyPatch('20200604-dldt-disable-multidevice.patch')

            

Reported by Pylint.

modules/java/generator/android-21/java/org/opencv/android/CameraGLSurfaceView.java
4 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 42

                      public boolean onCameraTexture(int texIn, int texOut, int width, int height);
    };

    private CameraTextureListener mTexListener;
    private CameraGLRendererBase mRenderer;

    public CameraGLSurfaceView(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: 43

                  };

    private CameraTextureListener mTexListener;
    private CameraGLRendererBase mRenderer;

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

        TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 52

                      int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
        styledAttrs.recycle();

        if(android.os.Build.VERSION.SDK_INT >= 21)
            mRenderer = new Camera2Renderer(this);
        else
            mRenderer = new CameraRenderer(this);

        setCameraIndex(cameraIndex);

            

Reported by PMD.

Overriding method merely calls super
Design

Line: 83

                  }

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

    @Override
    public void surfaceDestroyed(SurfaceHolder holder) {

            

Reported by PMD.

modules/gapi/test/gapi_mock_kernels.hpp
4 issues
syntax error
Error

Line: 26

                      static cv::GMatDesc outMeta(const cv::GMatDesc &in) { return in; }
    };

    G_TYPED_KERNEL(Bar, <cv::GMat(cv::GMat,cv::GMat)>, "test.kernels.bar")
    {
        static cv::GMatDesc outMeta(const cv::GMatDesc &in, const cv::GMatDesc &) { return in; }
    };

    G_TYPED_KERNEL(Baz, <cv::GScalar(cv::GMat)>, "test.kernels.baz")

            

Reported by Cppcheck.

syntax error
Error

Line: 26

                      static cv::GMatDesc outMeta(const cv::GMatDesc &in) { return in; }
    };

    G_TYPED_KERNEL(Bar, <cv::GMat(cv::GMat,cv::GMat)>, "test.kernels.bar")
    {
        static cv::GMatDesc outMeta(const cv::GMatDesc &in, const cv::GMatDesc &) { return in; }
    };

    G_TYPED_KERNEL(Baz, <cv::GScalar(cv::GMat)>, "test.kernels.baz")

            

Reported by Cppcheck.

syntax error
Error

Line: 26

                      static cv::GMatDesc outMeta(const cv::GMatDesc &in) { return in; }
    };

    G_TYPED_KERNEL(Bar, <cv::GMat(cv::GMat,cv::GMat)>, "test.kernels.bar")
    {
        static cv::GMatDesc outMeta(const cv::GMatDesc &in, const cv::GMatDesc &) { return in; }
    };

    G_TYPED_KERNEL(Baz, <cv::GScalar(cv::GMat)>, "test.kernels.baz")

            

Reported by Cppcheck.

syntax error
Error

Line: 26

                      static cv::GMatDesc outMeta(const cv::GMatDesc &in) { return in; }
    };

    G_TYPED_KERNEL(Bar, <cv::GMat(cv::GMat,cv::GMat)>, "test.kernels.bar")
    {
        static cv::GMatDesc outMeta(const cv::GMatDesc &in, const cv::GMatDesc &) { return in; }
    };

    G_TYPED_KERNEL(Baz, <cv::GScalar(cv::GMat)>, "test.kernels.baz")

            

Reported by Cppcheck.

samples/java/ant/src/SimpleSample.java
4 issues
System.out.println is used
Design

Line: 11

                static{ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }

  public static void main(String[] args) {
    System.out.println("Welcome to OpenCV " + Core.VERSION);
    Mat m = new Mat(5, 10, CvType.CV_8UC1, new Scalar(0));
    System.out.println("OpenCV Mat: " + m);
    Mat mr1 = m.row(1);
    mr1.setTo(new Scalar(1));
    Mat mc5 = m.col(5);

            

Reported by PMD.

System.out.println is used
Design

Line: 13

                public static void main(String[] args) {
    System.out.println("Welcome to OpenCV " + Core.VERSION);
    Mat m = new Mat(5, 10, CvType.CV_8UC1, new Scalar(0));
    System.out.println("OpenCV Mat: " + m);
    Mat mr1 = m.row(1);
    mr1.setTo(new Scalar(1));
    Mat mc5 = m.col(5);
    mc5.setTo(new Scalar(5));
    System.out.println("OpenCV Mat data:\n" + m.dump());

            

Reported by PMD.

System.out.println is used
Design

Line: 18

                  mr1.setTo(new Scalar(1));
    Mat mc5 = m.col(5);
    mc5.setTo(new Scalar(5));
    System.out.println("OpenCV Mat data:\n" + m.dump());
  }

}

            

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

              import org.opencv.core.CvType;
import org.opencv.core.Scalar;

class SimpleSample {

  static{ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }

  public static void main(String[] args) {
    System.out.println("Welcome to OpenCV " + Core.VERSION);

            

Reported by PMD.

samples/python/tutorial_code/ImgTrans/SobelDemo/sobel_demo.py
4 issues
Unable to import 'cv2'
Error

Line: 6 Column: 1

              @brief Sample code using Sobel and/or Scharr OpenCV functions to make a simple Edge Detector
"""
import sys
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: 9 Column: 1

              import cv2 as cv


def main(argv):
    ## [variables]
    # First we declare the variables we are going to use
    window_name = ('Sobel Demo - Simple Edge Detector')
    scale = 1
    delta = 0

            

Reported by Pylint.

Line too long (106/100)
Error

Line: 48 Column: 1

                  ## [sobel]
    # Gradient-X
    # grad_x = cv.Scharr(gray,ddepth,1,0)
    grad_x = cv.Sobel(gray, ddepth, 1, 0, ksize=3, scale=scale, delta=delta, borderType=cv.BORDER_DEFAULT)

    # Gradient-Y
    # grad_y = cv.Scharr(gray,ddepth,0,1)
    grad_y = cv.Sobel(gray, ddepth, 0, 1, ksize=3, scale=scale, delta=delta, borderType=cv.BORDER_DEFAULT)
    ## [sobel]

            

Reported by Pylint.

Line too long (106/100)
Error

Line: 52 Column: 1

              
    # Gradient-Y
    # grad_y = cv.Scharr(gray,ddepth,0,1)
    grad_y = cv.Sobel(gray, ddepth, 0, 1, ksize=3, scale=scale, delta=delta, borderType=cv.BORDER_DEFAULT)
    ## [sobel]

    ## [convert]
    # converting back to uint8
    abs_grad_x = cv.convertScaleAbs(grad_x)

            

Reported by Pylint.

samples/java/eclipse/HelloCV/src/Main.java
4 issues
System.out.println is used
Design

Line: 8

              public class Main {

    public static void main(String[] args) {
        System.out.println("Welcome to OpenCV " + Core.VERSION);
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat m  = Mat.eye(3, 3, CvType.CV_8UC1);
        System.out.println("m = " + m.dump());
    }


            

Reported by PMD.

System.out.println is used
Design

Line: 11

                      System.out.println("Welcome to OpenCV " + Core.VERSION);
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat m  = Mat.eye(3, 3, CvType.CV_8UC1);
        System.out.println("m = " + m.dump());
    }

}

            

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

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

public class Main {

    public static void main(String[] args) {
        System.out.println("Welcome to OpenCV " + Core.VERSION);
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat m  = Mat.eye(3, 3, CvType.CV_8UC1);

            

Reported by PMD.

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

Line: 11

                      System.out.println("Welcome to OpenCV " + Core.VERSION);
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat m  = Mat.eye(3, 3, CvType.CV_8UC1);
        System.out.println("m = " + m.dump());
    }

}

            

Reported by PMD.

samples/java/tutorial_code/ImgProc/HitMiss/HitMiss.java
4 issues
System.exit() should not be used in J2EE/JEE apps
Error

Line: 47

                      HighGui.moveWindow("Hit or Miss", 500, 200);

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

public class HitMiss
{

            

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

              }

public class HitMiss
{
    public static void main(String[] args) {
        // load the native OpenCV library
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        new HitMissRun().run();
    }

            

Reported by PMD.

Avoid unused imports such as 'org.opencv.core'
Design

Line: 1

              import org.opencv.core.*;
import org.opencv.highgui.HighGui;
import org.opencv.imgproc.Imgproc;

class HitMissRun{

    public void run() {
        Mat input_image = new Mat( 8, 8, CvType.CV_8UC1 );
        int row = 0, col = 0;

            

Reported by PMD.

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

Line: 9

              
    public void run() {
        Mat input_image = new Mat( 8, 8, CvType.CV_8UC1 );
        int row = 0, col = 0;
        input_image.put(row ,col,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 255, 255, 255, 0, 0, 0, 255,
                0, 255, 255, 255, 0, 0, 0, 0,
                0, 255, 255, 255, 0, 255, 0, 0,

            

Reported by PMD.

samples/wp8/OcvRotatingCube/PhoneXamlDirect3DApp1/PhoneXamlDirect3DApp1Comp/DirectXHelper.h
4 issues
syntax error
Error

Line: 34

                          unsigned int bufferSize = static_cast<unsigned int>(stream->Size);
            auto fileBuffer = ref new Streams::Buffer(bufferSize);
            return stream->ReadAsync(fileBuffer, bufferSize, Streams::InputStreamOptions::None);
        }).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^
        {
            auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
            Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
            return fileData;
        });

            

Reported by Cppcheck.

syntax error
Error

Line: 34

                          unsigned int bufferSize = static_cast<unsigned int>(stream->Size);
            auto fileBuffer = ref new Streams::Buffer(bufferSize);
            return stream->ReadAsync(fileBuffer, bufferSize, Streams::InputStreamOptions::None);
        }).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^
        {
            auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
            Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
            return fileData;
        });

            

Reported by Cppcheck.

syntax error
Error

Line: 34

                          unsigned int bufferSize = static_cast<unsigned int>(stream->Size);
            auto fileBuffer = ref new Streams::Buffer(bufferSize);
            return stream->ReadAsync(fileBuffer, bufferSize, Streams::InputStreamOptions::None);
        }).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^
        {
            auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
            Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
            return fileData;
        });

            

Reported by Cppcheck.

syntax error
Error

Line: 34

                          unsigned int bufferSize = static_cast<unsigned int>(stream->Size);
            auto fileBuffer = ref new Streams::Buffer(bufferSize);
            return stream->ReadAsync(fileBuffer, bufferSize, Streams::InputStreamOptions::None);
        }).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^
        {
            auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
            Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
            return fileData;
        });

            

Reported by Cppcheck.

samples/wp8/OcvImageManipulation/PhoneXamlDirect3DApp1/PhoneXamlDirect3DApp1Comp/DirectXHelper.h
4 issues
syntax error
Error

Line: 34

                          unsigned int bufferSize = static_cast<unsigned int>(stream->Size);
            auto fileBuffer = ref new Streams::Buffer(bufferSize);
            return stream->ReadAsync(fileBuffer, bufferSize, Streams::InputStreamOptions::None);
        }).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^
        {
            auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
            Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
            return fileData;
        });

            

Reported by Cppcheck.

syntax error
Error

Line: 34

                          unsigned int bufferSize = static_cast<unsigned int>(stream->Size);
            auto fileBuffer = ref new Streams::Buffer(bufferSize);
            return stream->ReadAsync(fileBuffer, bufferSize, Streams::InputStreamOptions::None);
        }).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^
        {
            auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
            Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
            return fileData;
        });

            

Reported by Cppcheck.

syntax error
Error

Line: 34

                          unsigned int bufferSize = static_cast<unsigned int>(stream->Size);
            auto fileBuffer = ref new Streams::Buffer(bufferSize);
            return stream->ReadAsync(fileBuffer, bufferSize, Streams::InputStreamOptions::None);
        }).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^
        {
            auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
            Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
            return fileData;
        });

            

Reported by Cppcheck.

syntax error
Error

Line: 34

                          unsigned int bufferSize = static_cast<unsigned int>(stream->Size);
            auto fileBuffer = ref new Streams::Buffer(bufferSize);
            return stream->ReadAsync(fileBuffer, bufferSize, Streams::InputStreamOptions::None);
        }).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^
        {
            auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
            Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
            return fileData;
        });

            

Reported by Cppcheck.

samples/python/_doc.py
4 issues
Use of exec
Error

Line: 21 Column: 17

                          try:
                execfile(fn, loc)           # Python 2
            except NameError:
                exec(open(fn).read(), loc)  # Python 3
        except Exception:
            pass
        if '__doc__' not in loc:
            print(fn)

            

Reported by Pylint.

Use of exec detected.
Security

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

                          try:
                execfile(fn, loc)           # Python 2
            except NameError:
                exec(open(fn).read(), loc)  # Python 3
        except Exception:
            pass
        if '__doc__' not in loc:
            print(fn)

            

Reported by Bandit.

Catching too general exception Exception
Error

Line: 22 Column: 16

                              execfile(fn, loc)           # Python 2
            except NameError:
                exec(open(fn).read(), loc)  # Python 3
        except Exception:
            pass
        if '__doc__' not in loc:
            print(fn)

            

Reported by Pylint.

Try, Except, Pass detected.
Security

Line: 22
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b110_try_except_pass.html

                              execfile(fn, loc)           # Python 2
            except NameError:
                exec(open(fn).read(), loc)  # Python 3
        except Exception:
            pass
        if '__doc__' not in loc:
            print(fn)

            

Reported by Bandit.