* [Galene] What I've learnt about background blur
@ 2024-12-16 12:53 Juliusz Chroboczek
2024-12-16 13:33 ` [Galene] " Tim Panton
0 siblings, 1 reply; 3+ messages in thread
From: Juliusz Chroboczek @ 2024-12-16 12:53 UTC (permalink / raw)
To: galene
What I've learned while implementing background blur.
There are multiple segmentation techniques
==========================================
The first step is to segment the image into background and foreground.
There are multiple techniques to do that, and they yield different
results.
In addition to the traditional techniques, such as chroma keying, there
are at least two ML-based approaches: semantic segmentation and depth
estimation. Semantic segmentation is trained to recognise human figures,
while depth estimation guesses the distance of every pixel from the
camera.
Both approaches work surprisingly well (computer vision is really close to
magic). They have different privacy issues: semantic segmentation will
unblur the background when a human walks by, and depth estimation will
unblur objects lying on your desk. (The obvious solution would be to do
both and combine the results, but that seems a little overkill.)
I've used semantic segmentation in Galene, since that's what MediaPipe
implements. I haven't experimented with depth estimation.
Blending is not that obvious
============================
The obvious postprocessing techniques is to blur the original image in
order to construct the blurred backgound. That's what both Jitsi Meet [1]
and LiveKit [2] do, and that's what I did initially. It turns out that it
doesn't yield very good results: it causes the foreground to bleed into
the background, causing a halo around the foreground figure.
Thankfully, the problem is well known in the Photoshop community, and the
simple solution is to mask before blurring: this way, you're blurring the
background only, and avoid bleeding the foreground into the background.
That's what Galene does now, and I find the results satisfactory, at least
on 640x400 videos. (I think this can be improved still, but I'm currently
waiting for my mana bar to replenish.)
Interestingly, Google Meet apparently does something more complicated:
they use a WebGL shader to vary the amount of blurring depending on
something or something else, and use a bilateral filter instead of
a Gaussian filter. Unfortunately, their posting on the subject [3] does
not make a lot of sense to me (they're applying a bilateral filter to
a monochrome mask? where does the CoC come from?), I suspect that the
technical writer did not fully undertand what the engineers told them.
[1]: https://github.com/jitsi/jitsi-meet/blob/master/react/features/stream-effects/virtual-background/JitsiStreamBackgroundEffect.ts#L102
[2]: https://github.com/livekit/track-processors-js/blob/main/src/transformers/BackgroundTransformer.ts#L143
[3]: https://research.google/blog/background-features-in-google-meet-powered-by-web-ml/
-- Juliusz
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Galene] Re: What I've learnt about background blur
2024-12-16 12:53 [Galene] What I've learnt about background blur Juliusz Chroboczek
@ 2024-12-16 13:33 ` Tim Panton
2024-12-16 13:42 ` Juliusz Chroboczek
0 siblings, 1 reply; 3+ messages in thread
From: Tim Panton @ 2024-12-16 13:33 UTC (permalink / raw)
To: Juliusz Chroboczek; +Cc: galene
You might want to keep an eye on
https://developer.chrome.com/docs/capabilities/shape-detection
Which is available behind a flag on chrome and safari.
I don’t know when FaceDetector will become widely enough available to be relied upon.
Perhaps never.
T.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Galene] Re: What I've learnt about background blur
2024-12-16 13:33 ` [Galene] " Tim Panton
@ 2024-12-16 13:42 ` Juliusz Chroboczek
0 siblings, 0 replies; 3+ messages in thread
From: Juliusz Chroboczek @ 2024-12-16 13:42 UTC (permalink / raw)
To: Tim Panton; +Cc: galene
> You might want to keep an eye on
> https://developer.chrome.com/docs/capabilities/shape-detection
> Which is available behind a flag on chrome and safari.
Interesting. It only seems to provide bounding boxes, though, not precise
masks.
> I don’t know when FaceDetector will become widely enough available to be
> relied upon. Perhaps never.
Probably. I've spent a year waiting on
https://developer.chrome.com/blog/background-blur
before they cancelled the feature. (My guess is that the Google Meet
people decided they prefer their native impementation, and that Chrome is
seen inside Google mainly as a platform for delivering Google services.
But that's just a guess.)
-- Juliusz
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-16 13:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-16 12:53 [Galene] What I've learnt about background blur Juliusz Chroboczek
2024-12-16 13:33 ` [Galene] " Tim Panton
2024-12-16 13:42 ` Juliusz Chroboczek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox