/fake-webcam

Create a fake webcam device and replace the background by an image

Primary LanguagePython

Fake webcam

Taken from this blog post Replace the video webcam background by an image. The person is extracted thanks to BodyPix using a CNN on TensorFlow.

Note the tensorflow-cpu for node.js was used, but the resulting video is quite slow and not smooth. A GPU would be better, as used in the blog post.

Tested with skype and zoom.

Run it

It is composed of a a Node.js server and a Python script:

  • Node.js server: receive the image from the python script, execute the Tensorflow image segmentation and return the result.
  • Python script: setup a fake webcam device, send the real webcam frames to the server, apply post-treatment to the frame and send it to the fake webcam.

The image background is the image found in ./background.jpg. There are some examples in the backgrounds directory.

Node.js

npm install node body-pix.js

Python

pip install -r requirements.txt python webcam.py

Fake webcam

The fakewebcam device requires some installation and permissions. See the repo.