-
-
Notifications
You must be signed in to change notification settings - Fork 281
Background blurring 👤✨ #5387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Background blurring 👤✨ #5387
Conversation
WIP - added CameraFrameProcessor.kt WIP - finished frame processor WIP - got blurring down, thanks to Gemini for the YUV format conversion. Need to review that file format, I'm only familiar with ARGB. WIP - Got it working WIP - Connected it to the UI WIP - Fixed bug where turning off background blur stops frames from being sent over webRTC WIP - Optimized Video Frame I420 Buffer to Matrix WIP - Fixed rotation bug WIP - Fixed Bug where stoping BackgroundBlurFrameProcessor.kt doesn't send any more frames over WebRTC. It was a timestamp issue - Optimize object creation and passing and processing Signed-off-by: rapterjet2004 <[email protected]>
b63e1ab
to
9b6c990
Compare
Signed-off-by: rapterjet2004 <[email protected]>
Tested this PR.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment #5387 (comment)
- Turns off background blur when camera is turned off Signed-off-by: rapterjet2004 <[email protected]>
Not possible to fix, as the Selfie Segmentation Model only outputs square or landscape. Besides that, I removed the option for audio only calls, and made sure to turn off background blur when the camera is off, to avoid errors with state. |
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/5387.apk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you answer a video call, turn on background blur, and then stop your camera and then turn on camera, the person on the other end sees a blank screen. The video is displayed only a certain delay. (here delay is noticeable).
the above problem still exists for me.
This PR implements Background Blurring, an optional (by default off) effect that, like web and iOS, uses a low-memory on-device AI model to create a mask between the foreground/background, before using openCV to perform gaussian blur, along with several other file format conversions, necessary for image processing Y'UV frames to RGBA and vice-versa. In the future this PR also makes it easier to implement additional background effects, like background images, background videos/gifs, party hats, company logo overlays, and more.
Adds new files
BackgroundBlurFrameProcessor
an implementation ofVideoProcessor
which is an interface that WebRTC provides to perform operations on camera frames, andImageSegmentationHelper.SegmenterListener
, which is a small interface I wrote to handle asynchronous passing of camera frames from MediaPipe (You can actually handle it synchronously too, since the VideoProcessor operates on it's own thread, but this is cleaner)ImageSegmentationHelper
an edited version of google's. Basically a wrapper over MediaPipe'sImageSegmenter
which uses the on device AI Model to segment images between the foreground and background.BlurBackgroundViewModel
handles the state of the blur background functionality, which is by default offdownload_model.gradle
a small gradle file to download the on device AI Model on compile time, if not already found. The model is pretty light, just a couple hundred KBs. Also it's licensed for Commercial use under Apache v2.background_replace_24px
- Background Blur icon🖼️ Screenshots
🚧 TODO
onFrameCaptured
🏁 Checklist
/backport to stable-xx.x