Skip to content

Instantly share code, notes, and snippets.

@caio2k
Last active November 22, 2020 21:28
Show Gist options
  • Save caio2k/ffd7c1df05cd2e1d32b8331bb269ee90 to your computer and use it in GitHub Desktop.
Save caio2k/ffd7c1df05cd2e1d32b8331bb269ee90 to your computer and use it in GitHub Desktop.
green background camera
#!/bin/bash
#by caio2k
#tested on debian10
#based on https://del.igh.tf/ul/bodypix-and-obs/
#install obs-studio and dependencies to compile v4l2 output plugin
sudo apt install obs-studio v4l2loopback-dkms cmake libobs-dev qtbase5-dev
git clone --recursive https://github.com/obsproject/obs-studio.git
git clone https://github.com/CatxFish/obs-v4l2sink.git
cd obs-v4l2sink/ && mkdir build && cd build
cmake -DLIBOBS_INCLUDE_DIR="../../obs-studio/libobs" -DCMAKE_INSTALL_PREFIX=/usr/local .. && make -j4
sudo make install
sudo ln -s /usr/local/lib/obs-plugins/v4l2sink.so /usr/lib/x86_64-linux-gnu/obs-plugins/
#install bodypix
pip install -U pip
pip install -U setuptools
pip3 install tf-bodypix[all]
#pip3 install tf_bodypix tensorflow tfjs_graph_converter pyfakewebcam
#configure v4l2 module
echo 'options v4l2loopback devices=2 exclusive_caps=1 video_nr=10,11 card_label="OBS Virtual Camera","BodyPix Camera"' > /etc/modprobe.d/v4l2loopback.conf
echo 'v4l2loopback' > /etc/modules-load.d/v4l2loopback.conf
modprobe v4l2loopback
python3 -m tf_bodypix replace-background --source /dev/video0 --output /dev/video11 --background Documents/green.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment