2

I've come across an interesting artifact while blurring images in an Android application with OpenCV 3.0.0 on a Nexus 9 tablet.

This is the input image: input image

And this is what I get after blurring the image with OpenCV blur(). Notice, there are color curves on the white/gray wall. blurred image with artifacts

My code is based on the OpenCV Camera Preview tutorial.

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
    mRgba = inputFrame.rgba();
    mGray = inputFrame.gray();

    Imgproc.blur(mRgba, mRgba, new org.opencv.core.Size(20,20));

    return mRgba;
}

I get the same effect when blurring inside C++ library called by the application.

The strange thing is that if I save the blurred image as a png like this:

Mat bgr = new Mat(mRgba.size(), CvType.CV_8UC3);
Imgproc.cvtColor(mRgba, bgr, Imgproc.COLOR_RGBA2BGR);

Imgcodecs.imwrite("blurred.png", bgr);

then the artifacts are not there. Also on a different phone (HTC HD2) there are no artifacts.

I've set the frame size to 640x480, so the blurred image (as returned by onCameraFrame) must be resized by a factor of 3 in the function deliverAndDrawFrame in class CameraBridgeViewBase when being drawn onto the canvas. But when I save a video of the blurred input using MediaRecorder from the surface (like here, thus the bitmap that is drawn onto screen and into the video is the same), there are again no artifacts.

So I'm at a loss, what is the source of the color curves and how to get rid of them. Do you have any suggestions?

Thanks.

Community
  • 1
  • 1
SimonFojtu
  • 564
  • 5
  • 13

0 Answers0