Computer scientist's way to clean up a room for online conferences
I use Linux (Ubuntu 20) on a X390 Thinkpad. And I have tons of meetings every day, Teams, Zoom, Webex, you name them. All of them have the same problem: They only provide basic functionality on Linux, which does not (really) include to blur the background or if the function is available (Zoom) it creates an insane CPU load. Since I'm too lazy to physically clean up the mess which is shown behind my desk (I'm not looking at it anyway, so what's the point?) I was looking for a geek way to solve the issue. I looked for a way to virtually clean up my room behind my desk. The idea is to create a virtual webcam device blurring the background of the real webcam input, which can be used by any of the conferencing software.
My first approaches included Fakecam (https://snapcraft.io/fakecam) and related scripts. However, they are all dependent on Tensorflow, which requires CUDA, which kind of requires an NVIDIA GPU. My notebook has an Intel graphics card, though, so the whole Tensorflow-CUDA stuff creates a CPU load of over 600%, rendering this approach pretty much useless.
However, I found an alternative here: https://github.com/fangfufu/Linux-Fake-Background-Webcam This approach uses the Mediapipe framework to process the selfie video, which is more efficient if only the CPU is used. The setup of v4l2loopback works as described in the Readme, however, the virtual video device created might not be /dev/video2. In my case it was /dev/video4, which is important when calling fake.py. It needs the virtual device with the -v parameter if it is different from video2. Compared to Fakecam, it has a very handy on-demand feature, which only starts the webcam once a client asks for the output of the fake webcam device. I checked the output using Cheese and found the following settings working for me:
Blur:
python3 fake.py -v /dev/video4 -W 640 -H 480 --no-background --no-foreground --background-blur 30 --background-blur-sigma-frac 5
The aspect ratio implicitly crops the webcam video, such that it doesn't show too much unnecessary background. The no-background and no-foreground settings remove the standard behavior of the script which adds images instead of blurring. The background-blur and -sigma-frac options showed the best background blur effect for me, while still keeping my head from being blurred. Blurring uses roughly 150-250% CPU.
With background instead of blurring:
python3 fake.py -v /dev/video4 -W 640 -H 480 -b background.jpg --no-foreground
The CPU load with a fixed background is roughly 150%. For Teams, the background appears horizontally mirrored. However, it is mirrored again on the client side.