Android camera Gaussian blur example code

I haven't written an article for a long time. I had this requirement in the previous project, but time is tight. I covered it with a translucent white picture, and the effect is

Well, no nonsense, let's see the effect first

Note that this is not a Gaussian blur of a simple picture, but a real-time processing of the camera

Principle:

Generally speaking, for each frame of the camera callback, the byte array is converted into bitmap through renderscript, and then the bitmap is Gaussian blurred. Fluency is good. After all, renderscript uses GPU to calculate, which is much faster than the ordinary method using CPU

Core code:

OK, these two methods are enough. Just give the returned bitmap to ImageView. I always thought it was implemented with JNI. After a try, I found that Java is also OK and the effect is good. There is no similar tutorial on the Internet, so I wrote it to those in need. By the way, you also need to add it to the build.gradle of the project

For specific usage and code, please refer to my GitHub cameraview. This control can also quickly help you realize the effects of camera preview, photographing, watermark and Gaussian blur, https://github.com/bertsir/CameraView

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>