Skip to main content

Remove backgrounds from video feeds in your web cam applications.

Project description

Background Remover

The Need

It's been good long while since Microsoft first released a Teams version for Linux and yet, one of Teams' coolest features doesn't exist in said Linux version: removable backgrounds. As someone who uses Linux for their daily driver, this annoys me.

Well, I'm an engineer, so of course, I found a solution.

Using OpenCV and a v4l2loopback device (basically a virtual webcam you can write data to), I threw together a Python application that takes your normal webcam input, removes and replaces the background, and outputs that to the created video device. Problem solved :)

Note, this will work anywhere WebCams are used, not just Teams

Now, the program can also be used to remove backgrounds from video files and save them as video files as well!

How to Use

WebCam Replacement

Dependencies: - python >= 3.8 (3.10 is what's supported officially) - pip - v4l2loopback

Setup:

  1. Configure v4l2loopback (may not be necessary):
    • Recommended something like this:
    export DEVICE_ARR=(`ls /sys/devices/virtual/video4linux | tr -d 'video'`); \
    sudo modprobe v4l2loopback \
        devices=1 exclusive_caps=1 video_nr=${DEVICE_ARR[1]} max_buffers=2 \
        card_label=v4l2lo
    
  2. Install with pip install bgrm

Then, you can run:

  • Run with python -m bgrm <options> (use --help to see all options)
  • Example: python -m bgrm -b ~/Pictures/Wallpapers/ni-skyline-wallpaper.png -w 320 -H 240 -s 2.0

File Replacement

You can also remove the background from video files. It works just like the WebCam, but instead of setting the --camera cli arg, you call the program like this:

python -m bgrm --file_mode -i <input file> -o <output file> <other options>

Build from Repo

You can also build the package yourself from source (or grab the latest version from the releases tab)

To do that you need the "poetry" build system.

Run poetry build and install the whl from the dist/ folder

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bgrm-9.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

bgrm-9-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file bgrm-9.tar.gz.

File metadata

  • Download URL: bgrm-9.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for bgrm-9.tar.gz
Algorithm Hash digest
SHA256 294f89294fcdc4dd6be87dab40acad67a01e452255d80f2ede827a7e02a78a99
MD5 0fc18e19701fc220fdf3d90ad6c52ce0
BLAKE2b-256 bcc12fb94a4391819fa5fb17f32b4a127deb2ae6af864972a43e53f2cef1e0f1

See more details on using hashes here.

File details

Details for the file bgrm-9-py3-none-any.whl.

File metadata

  • Download URL: bgrm-9-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for bgrm-9-py3-none-any.whl
Algorithm Hash digest
SHA256 fc0b64e8d42c43547775184adb312b06d665c47c18e9ff558eab4b19b166f39a
MD5 89cd0038901c175602e3958870238af7
BLAKE2b-256 aa2a5a0f23289242609cf501117bb4275cc8b1d43d15f590fcfc6c33cfc216a5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page