Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Glare detection in image

Hi all,

i'm trying to detect glare in image using opencv 3.3.1 in my android application. i am use GaussianBlur and than using MinMaxLocResult get the min and max value of the glare. it's working find but sometime if background is black and image does not contain any glare also detect glare.

Here the code :-

   public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) 
   {
    final Mat imgSource = inputFrame.rgba();
    Mat grayScaleGaussianBlur = new Mat();
    Imgproc.cvtColor(imgSource, grayScaleGaussianBlur, Imgproc.COLOR_BGR2GRAY);
    Imgproc.GaussianBlur(grayScaleGaussianBlur, grayScaleGaussianBlur, new Size(5, 5), 0);

    Core.MinMaxLocResult minMaxLocResultBlur = Core.minMaxLoc(grayScaleGaussianBlur);

    final double maxval = minMaxLocResultBlur.maxVal;
    final double minval = minMaxLocResultBlur.minVal;


    if (maxval >= 253.0 && minval > 0.0 && minval < 20.0) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

    } else {
        if (popup.isShowing()) {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {

                }
            });

        } else {

            Bitmap rotatedBitmap = Bitmap.createBitmap(imgSource.cols(), imgSource.rows(), Bitmap.Config.ARGB_8888);
            Utils.matToBitmap(imgSource, rotatedBitmap);
        }
    }

Glare detection in image

Hi all,

i'm trying to detect glare in image using opencv 3.3.1 in my android application. i am use GaussianBlur and than using MinMaxLocResult get the min and max value of the glare. it's working find but sometime if background is black and image does not contain any glare also detect glare.

Here the code :-

   public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) 
   {
    final Mat imgSource Rgba = inputFrame.rgba();
    Mat grayScaleGaussianBlur = new Mat();
    Imgproc.cvtColor(imgSource, Imgproc.cvtColor(Rgba , grayScaleGaussianBlur, Imgproc.COLOR_BGR2GRAY);
    Imgproc.GaussianBlur(grayScaleGaussianBlur, grayScaleGaussianBlur, new Size(5, 5), 0);

    Core.MinMaxLocResult minMaxLocResultBlur = Core.minMaxLoc(grayScaleGaussianBlur);

    final double maxval = minMaxLocResultBlur.maxVal;
    final double minval = minMaxLocResultBlur.minVal;


    if (maxval >= 253.0 && minval > 0.0 && minval < 20.0) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

    } else {
        if (popup.isShowing()) {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {

                }
            });

        } else {

            Bitmap rotatedBitmap = Bitmap.createBitmap(imgSource.cols(), imgSource.rows(), Bitmap.createBitmap(Rgba.cols(), Rgba.rows(), Bitmap.Config.ARGB_8888);
            Utils.matToBitmap(imgSource, Utils.matToBitmap(Rgba, rotatedBitmap);
        }
    }
click to hide/show revision 3
retagged

Glare detection in image

Hi all,

i'm trying to detect glare in image using opencv 3.3.1 in my android application. i am use GaussianBlur and than using MinMaxLocResult get the min and max value of the glare. it's working find but sometime if background is black and image does not contain any glare also detect glare.

Here the code :-

   public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) 
   {
    final Mat Rgba = inputFrame.rgba();
    Mat grayScaleGaussianBlur = new Mat();
    Imgproc.cvtColor(Rgba , grayScaleGaussianBlur, Imgproc.COLOR_BGR2GRAY);
    Imgproc.GaussianBlur(grayScaleGaussianBlur, grayScaleGaussianBlur, new Size(5, 5), 0);

    Core.MinMaxLocResult minMaxLocResultBlur = Core.minMaxLoc(grayScaleGaussianBlur);

    final double maxval = minMaxLocResultBlur.maxVal;
    final double minval = minMaxLocResultBlur.minVal;


    if (maxval >= 253.0 && minval > 0.0 && minval < 20.0) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

    } else {
        if (popup.isShowing()) {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {

                }
            });

        } else {

            Bitmap rotatedBitmap = Bitmap.createBitmap(Rgba.cols(), Rgba.rows(), Bitmap.Config.ARGB_8888);
            Utils.matToBitmap(Rgba, rotatedBitmap);
        }
    }

Glare detection in image

Hi all,

i'm trying to detect glare in image using opencv 3.3.1 in my android application. i am use GaussianBlur and than using MinMaxLocResult get the min and max value of the glare. it's working find but sometime if background is black and image does not contain any glare also detect glare.

Here the code :-

   public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) 
   {
    final Mat Rgba = inputFrame.rgba();
    Mat grayScaleGaussianBlur = new Mat();
    Imgproc.cvtColor(Rgba , grayScaleGaussianBlur, Imgproc.COLOR_BGR2GRAY);
    Imgproc.GaussianBlur(grayScaleGaussianBlur, grayScaleGaussianBlur, new Size(5, 5), 0);

    Core.MinMaxLocResult minMaxLocResultBlur = Core.minMaxLoc(grayScaleGaussianBlur);

    final double maxval = minMaxLocResultBlur.maxVal;
    final double minval = minMaxLocResultBlur.minVal;


    if (maxval >= 253.0 && minval > 0.0 && minval < 20.0) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

    } else {
        if (popup.isShowing()) {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {

                }
            });

        } else {

            Bitmap rotatedBitmap = Bitmap.createBitmap(Rgba.cols(), Rgba.rows(), Bitmap.Config.ARGB_8888);
            Utils.matToBitmap(Rgba, rotatedBitmap);
        }
    }
click to hide/show revision 5
retagged

Glare detection in image

Hi all,

i'm trying to detect glare in image using opencv 3.3.1 in my android application. i am use GaussianBlur and than using MinMaxLocResult get the min and max value of the glare. it's working find but sometime if background is black and image does not contain any glare also detect glare.

Here the code :-

   public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) 
   {
    final Mat Rgba = inputFrame.rgba();
    Mat grayScaleGaussianBlur = new Mat();
    Imgproc.cvtColor(Rgba , grayScaleGaussianBlur, Imgproc.COLOR_BGR2GRAY);
    Imgproc.GaussianBlur(grayScaleGaussianBlur, grayScaleGaussianBlur, new Size(5, 5), 0);

    Core.MinMaxLocResult minMaxLocResultBlur = Core.minMaxLoc(grayScaleGaussianBlur);

    final double maxval = minMaxLocResultBlur.maxVal;
    final double minval = minMaxLocResultBlur.minVal;


    if (maxval >= 253.0 && minval > 0.0 && minval < 20.0) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

    } else {
        if (popup.isShowing()) {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {

                }
            });

        } else {

            Bitmap rotatedBitmap = Bitmap.createBitmap(Rgba.cols(), Rgba.rows(), Bitmap.Config.ARGB_8888);
            Utils.matToBitmap(Rgba, rotatedBitmap);
        }
    }