Got BodyPix and OBS Studio Virtual Camera to work with minimum fuss. You'll need:
- a recent copy of v4l2loopback; you can compile it from source by cloning https://github.com/umlaeute/v4l2loopback.git
- a recent copy of OBS Studio; you can compile it from source by cloning https://github.com/obsproject/obs-studio.git
- TF-BodyPix which you can install with
pip. You will need to install multiple dependencies (for example
tensorflow), some of which will only be listed at runtime (such as
Getting things to run once installed
/dev/video10 for OBS and
/dev/video11 for BodyPix. The important thing here is that OBS will enumerate the device in order when starting its Virtual Camera, therefor BodyPix needs to be last.
sudo modprobe -r v4l2loopback sudo modprobe v4l2loopback devices=2 \ video_nr=10,11 \ card_label="OBS Virtual Camera","BodyPix Camera" \ exclusive_caps=1 python3 -m tf_bodypix replace-background \ --source /dev/video0 \ --output /dev/video11 \ --background Documents/green.png
I recommend you wait a few seconds for TensorFlow-BodyPix to start streaming before starting OBS. Once in OBS you will find the
BodyPix Camera in the list of availble V4L2 sources. In the example above I used a 16×9 pixels green PNG image as background; I then remove the background using the
Chroma Key Filter on the V4L2 source inside OBS.
To stream locally (to Skype, Google Meet, …) use
Start Virtual Camera (in the lower-right hand of the screen) then select the
OBS Virtual Camera in the list of cameras.