Glare detection in image [closed]
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);
}
}
anyone have an idea about this issue???