Ask Your Question
0

Glare detection in image

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

david cairns gravatar image

updated 2018-12-19 01:40:24 -0500

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 close merge delete

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
-1

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
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 69 times

Last updated: Dec 19 '18