Ask Your Question
1

Glare detection in image [closed]

asked 2018-12-19 01:32:30 -0500

david cairns gravatar image

updated 2019-10-01 01:37:48 -0500

Akhil Patel gravatar 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);
        }
    }
edit retag flag offensive reopen merge delete

Closed for the following reason spam or advertising by mshabunin
close date 2019-04-04 06:38:59.624174

Comments

anyone have an idea about this issue???

david cairns gravatar imagedavid cairns ( 2018-12-19 03:23:13 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
10

answered 2018-12-19 06:34:15 -0500

Akhil Patel gravatar image

change the following line

       Imgproc.GaussianBlur(grayScaleGaussianBlur, grayScaleGaussianBlur, new Size(5, 5), 0);

to

       Imgproc.GaussianBlur(grayScaleGaussianBlur, grayScaleGaussianBlur, new Size(7, 7), 0);

also change the if condition

       if (maxval >= 253.0 && minval > 0.0 && minval < 20.0)

to

        if (maxval >= 253.0 && minval <= 0.0)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-12-19 01:32:30 -0500

Seen: 595 times

Last updated: Dec 19 '18