Benjamin Elder published the great article Open Source Virtual Background which explained how to create a camera feed with a virtual background for use in conferencing applications. While the article itself is published here on GitHub, unfortunately, the code itself wasn't gathered together in a repository to make it easy for others to use. Additionally, the article was written for a Debian derivative. My machines run Fedora and CentOS so I put together this repository to make it easier for people running Fedora and CentOS to be able to replicate Ben's work.
- TCP port 9000 is used to connect the container running bodypix to the container running the fake camera over a bridged network which is automatically created.
- The camera output is limited (to improve performance) to 1280x720.
- The containers used are named
bodypix
andfakecam
.
- Fedora 31 or CentOS 7.7
- Docker CE 19.03.8
- Optional: NVIDIA graphics card with CUDA
support, for faster inference
- NVIDIA GPU drivers 418.x or later
- CUDA toolkit 10.1
- Clone the repository into
fakecam
directory:git clone ... fakecam cd fakecam
- Run
setup
:./setup
- Copy the image you want to use to
fakecam/background.jpg
. For example:cp backgrounds/star-wars-feature-vf-2019-summer-embed-07.jpg \ fakecam/background.jpg
- Build the Docker images:
./build
Run vbackcam
to start and stop the fake camera with the virtual background.
While the fake camera is running, open your conferencing application and select
v4l2loopback
or /dev/video20
as the camera.
- Copy the new background image into
fakecam/background.jpg
- Rebuild the
fakecam
Docker image:docker build --tag fakecam ./fakecam
- Add kernel modules with DKMS
- Backgrounds:
- Star Wars: The Rise of Skywalker Photos
- TrekCore.com Gallery
- Unsplash: The internet's source of freely usable images
- BodyPix: Real-time Person Segmentation in the Brower with TensorFlow.js
- Docker Engine
- node.js
- NVIDIA
- CUDA enabled GPUs
- CUDA toolkit
- cuDNN: CUDA Deep Neural Network library
- GPU drivers
- nvidia-docker: Build and run Docker containers leveraging NVIDIA GPUs
- Open Source Virtual Background
- OpenCV python bindings
- pyfakewebcam: A library for writing RGB frames to a fake webcam device on Linux
- TensorFlow: Open source library to help deliver
and train ML models
- TensorFlow GPU support
- TensorFlow.js: A library for machine learning in JavaScript
- Video for Linux Two (V4L2)
- Linux TV
- v4l2loopback: A kernel module to create V4L2 loopback devices
- v4l2ucp: Universal control panel for Video for Linux Two (V4L2) devices
Photo copyrights:
- Annie Leibovitz or Vanity Fair/Condé Nast
- Dorsa Masghati on Unsplash wallpapers
- Moosa Haleem on Unsplash wallpapers
- Nastuh Abootalebi on Unsplash interiors
- TrekCore.com
Copyright © 2020 Christopher Voltz
This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.