Blur Mac Webcam Background Software

:linux:

:movie-camera:

ChromaCam is an AI-based desktop webcam application that enables users to remove, blur or replace your real-life background in video chat apps without a green screen. Almost all major video apps are supported, such as Skype, Zoom, WebEx, or streaming apps like OBS, XSplit, and more. Upload your own images to replace the background or apply a. Live Video Made Better. ManyCam is the go-to software to enhance your live video on streaming platform, video conferencing app and distant classes. Add multiple cameras and video sources, such as mobile and PowerPoint, use virtual backgrounds, create layers and presets, screencast desktop, and more. XSplit VCam: Virtual Green Screen in OBS. XSplit VCam makes cutting edge background removal and blurring possible, without the need for a green screen. Works with your favorite streaming softwares such as Open Broadcaster Software (OBS). Windows 10 64bit. Virtual Webcam Background allows you to use a virtual background or to blur the background of your webcam image similar to commercial programs like Zoom. Tensorflow with BodyPix is used to segment the image into foreground (person) and background using a neural network and v4l2loopback is used to create a virtual webcam.

April 9th, 2020

With many of us around the globe under shelter in place due to COVID-19video calls have become a lot more common. In particular, ZOOM hascontroversially become very popular. Arguably Zoom’s most interesting featureis the “Virtual Background” support which allows users to replacethe background behind them in their webcam video feed with any image (or video).

I’ve been using Zoom for a long time at work for Kubernetes open source meetings,usually from my company laptop. With daily “work from home” I’m now inclined touse my more powerful and ergonomic personal desktop for some of my open source work.

Unfortunately, Zoom’s linux client only supports the “chroma-key” A.K.A. “green screen”background removal method. This method requires a solid color backdrop, ideallya green screen with uniform lighting.

Since I do not have a green screen I decided to simply implement my own backgroundremoval, which was obviously better than cleaning my apartment or just usingmy laptop all the time. :grin:

It turns out we can actually get pretty decent results with off the shelf, open sourcecomponents and just a little of our own code.

# Reading The Camera

First thing’s first: How are we going to get the video feed from our webcam forprocessing?

Since I use Linux on my personal desktop (when not playing PC games) I chose touse the OpenCVpython bindings as I’m already familiar with them and they includeuseful image processing primatives in addition to V4L2 bindings for reading fromwebcams.

Reading a frame from the webcam with python-opencv is very simple:

For better results with my camera before capturing set:

Most video conferencing software seems to cap video to 720p @ 30 FPS or lower,but we won’t necessarily read every frame anyhow, this sets an upper limit.

Put the frame capture in a loop and we’ve got our video feed!

We can save a test frame with just:

And now we can see that our camera works. Success!

# Finding The Background

OK, now that we have a video feed, how do we identify the background so we canreplace it? This is the tricky part …

While Zoom doesn’t seem to have commented anywhere about how they implementedthis, the way it behaves makes me suspect that a neural network is involved,it’s hard to explain but the results look like one.Additionally, I found an article about Microsoft Teams implementing background blur with a convolutional neural network.

Creating our own network wouldn’t be too hard in principle – There are manyarticles and papers on the topic of image segmentation and plenty of opensource libraries and tools, but we need a fairly specialized dataset to getgood results.

Specifically we’d need lots of webcam like images with the idealhuman foreground marked pixel by pixel versus the background.

Building this sort of dataset in prepartion for training a neural net probably wouldbe a lot of work. Thankfully a research team at Google has already done all of this hardwork and open sourced a pre-trained neural network for “person segmentation”called BodyPix that works pretty well! ❤️

BodyPix is currently only available in TensorFlow.js form, so the easiestway to use it is from the body-pix-node library.

To get faster inference (prediction) in the browser a WebGL backend is preferred, but innode we can use the Tensorflow GPU backend(NOTE: this requires a NVIDIA Graphics Card, which I have).

To make this easier to setup, we’ll start by setting up a small containerizedtensorflow-gpu + node environment / project. Using this with nvidia-docker ismuch easier than getting all of the right dependencies setup on your host, itonly requires docker and an up-to-date GPU driver on the host.

Now to serve the results… WARNING: I am not a node expert! This is justmy quick evening hack, bear with me :-)

The following simple script replies to an HTTP POSTed image with a binary mask(an 2d array of binary pixels, where zero pixels are the background).

We can use numpy and requests to convert a frame to a mask from ourpython script with the following method:

Which gives us a result something like:

Webcam Blur Background

While I was working on this, I spotted this tweet:

This is definitely the BEST background for video calls. 💯 pic.twitter.com/Urz62Kg32k

Blur Mac Webcam Background Software Download

— Ashley Willis (McNamara) (@ashleymcnamara) April 2, 2020

Blur Mac Webcam Background Software

Now that we have the foreground / background mask, it will be easy to replacethe background.

After grabbing the awesome “Virtual Background” picture from that twitter thread andcropping it to a 16:9 ratio image …

… we can do the following:

Which gives us:

The raw mask is clearly not tight enough due to the performance trade-offswe made with our BodyPix parameters but .. so far so good!

This background gave me an idea …

# Making It Fun

Now that we have the masking done, what can we do to make it look better?

The first obvious step is to smooth the mask out, with something like:

This can help a bit, but it’s pretty minor and just replacing the backgroundis a little boring, since we’ve hacked this up ourselves we can do anythinginstead of just a basic background removal …

Given that we’re using a Star Wars “virtual background” I decided to createhologram effect to fit in better. This also lets lean into blurring the mask.

First update the post processing to:

Now the edges are blurry which is good, but we need to start building the hologrameffect.

Hollywood holograms typically have the following properties:

  • washed out / monocrhomatic color, as if done with a bright laser
  • scan lines or a grid like effect, as if many beams created the image
  • “ghosting” as if the projection is done in layers or imperfectly reaching the correct distance

We can add these step by step.

First for the blue tint we just need to apply an OpenCV colormap:

Then we can add the scan lines with a halftone-like effect:

Next we can add some ghosting by adding weighted copies of the current effect,shifted along an axis:

Last: We’ll want to keep some of the original color, so let’s combinethe holo effect with the original frame similar to how we added the ghosting:

A frame with the hologram effect now looks like:

On it’s own this looks pretty :shrug:

But combined with our virtual background it looks more like:

There we go! :tada: (I promise it looks cooler with motion / video :upside_down_face:)

# Outputting Video

Now we’re just missing one thing … We can’t actually use this in a call yet.

To fix that, we’re going to use pyfakewebcam and v4l2loopback to create a fake webcam device.

We’re also going to actually wire this all up with docker.

First create a requirements.txt with our dependencies:

And then the Dockerfile for the fake camera app:

We’re going to need to install v4l2loopback from a shell:

And then configure a fake camera device:

We need the exclusive_caps setting for some apps (chrome, zoom) to work, the labelis just for our convenience when selecting the camera in apps, and the video numberjust makes this /dev/video20 if available, which is unlikely to be already in use.

Now we can update our script to create the fake camera:

We also need to note that pyfakewebcam expects images in RGB (red, green, blue)while our OpenCV operations are in BGR (blue, green, red) channel order.

We can fix this before outputting and then send a frame with:

All together the script looks like:

Now build the images:

And run them like:

Now make sure to start this before opening the camera with any apps, andbe sure to select the “v4l2loopback” / /dev/video20 camera in Zoom etc.

# The Finished Result

Here’s a quick clip I recorded of this in action:

Look! I’m dialing into the millenium falcon with an open source camera stack!

I’m pretty happy with how this came out. I’ll definitely be joining all of my meetings this way in the morning. :grin:

0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
3.0/5 rating 1 vote
3.0/5 rating 1 vote
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
Webcam background software
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)

Webcam Blur Effect

0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)
0.0/5 rating (0 votes)