Open
Conversation
This adds - `BackgroundBlurGPUProcessor` a file that handles the openGL logic, and acts as an abstraction over the inner workings of the image processing. OpenGL's logic is ... very unclear. I tried my best to document as much as possible, including any linear algebra that I had to perform. - `background_blur_vertex.glsl` the required vertex shader, needed to identify the position of each pixel on the screen, before the geometry, rasterization, and fragment shader steps of the openGL pipeline. - `gaussian_blur_frag_shader.glsl` the Gaussian Blur implementation, this is what actually performs the logic on the image pixels. The code is also somewhat unclear if you're not familiar with shaders or gaussian blur. It helps to read the technical article I commented from Intel. - `seg_mask_frag_shader.glsl` the masking operation implementation, very simple, just checking if the pixel should be blurred or retain it's original unblurred value - `testing_frag_shader` a simple fragment shader used for quick testing - `libyuv_android` a light weight helper lib for converting between image formats without the overhead of OpenCV Significant changes - `BackgroundBlurFrameProcessor` now holds it's own dedicated Thread and Handler for running OpenGL's GPU operations. It also takes in a reference to the `surfaceTextureHelper` from `CallActivity` to send the `VideoFrame` objects to the WebRTC `VideoSink` on the appropriate capture thread. Failing to do both of these causes a crash. Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
0e3b310 to
471db97
Compare
Contributor
|
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/5891.apk |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

🖼️ Screenshots
This PR addresses an issue with the previous implementation of Background Blurring. It used too much memory space, as openCV contains huge builds for every possible memory architecture supported on Android. This leads to duplicate files, large amounts of unnecessary code, and a larger download size. The MediaPipe library and the .tflite file used for foreground-background detection was trivial in comparison.
This is fixed by moving the entire blurring operation to openGL ES, a graphics framework that is built into Android, cutting out 100 MB from the build size while also increasing performance. This is done by the implementing Gaussian Blur algorithm from scratch in GLSL, the openGL Shader language.
This adds
BackgroundBlurGPUProcessora file that handles the openGL logic, and acts as an abstraction over the inner workings of the image processing. OpenGL's logic is ... very unclear. I tried my best to document as much as possible, including any linear algebra that I had to perform.background_blur_vertexthe required vertex shader, needed to identify the position of each pixel on the screen, before the geometry, rasterization, and fragment shader steps of the openGL pipeline.gaussian_blur_frag_shaderthe Gaussian Blur implementation, this is what actually performs the logic on the image pixels. The code is also somewhat unclear if you're not familiar with shaders or gaussian blur. It helps to read the technical article I commented from Intel.seg_mask_frag_shaderthe masking operation implementation, very simple, just checking if the pixel should be blurred or retain it's original unblurred valuetesting_frag_shadera simple fragment shader used for quick testinglibyuv_androida light weight helper lib for converting between image formats without the overhead of OpenCVCopied over from old PR
BackgroundBlurFrameProcessorA WebRTCVideoProcessorobject, this handles the video frame conversions and processing. Holds references to theImageSegmenterHelperand theBackgrounBlurGPUProcessor. It now holds it's own dedicated Thread and Handler for running OpenGL's GPU operations. It also takes in a reference to thesurfaceTextureHelperfromCallActivityto send theVideoFrameobjects to the WebRTCVideoSinkon the appropriate capture thread. Failing to do both of these causes a crash.BlurBackgroundViewModelImageSegmenterHelperuses MediaPipe to perform the segmentation mask (foreground / background separation). Really just a wrapper over the MediaPipe APIbackground_replace_24px🚧 TODO
🏁 Checklist
/backport to stable-xx.x