Thanks to [ajaichemmanam]'s great work on porting tensorflow-js/body-pix (Please see their jaw-dropping live demo if you miss it.) to Python,  an idea came to me that combining BodyPix and g_webcam to hide my messy room while working from home.


  • Raspberry Pi 4 (Pi3 or other SBCs may work too.)
  • USB Webcam (or RPi Camera Module)
  • Jailed laptop provided by the IT dept.

Data flow Extracts the human shape mask from the video stream by using BodyPix and composites it with the image or video file. And then feeds the raw video stream to ffmpeg via a pipe.

ffmpeg: Applies some filters (e.g. resizing, color-space conversion) to the input video stream and feeds it to v4l2loopback's virtual video device.

v4l2loopback: Provides virtual "loopback" video devices.

g_webcam (and its user-space application, uvc-gadget):  Emulates the UVC compatible webcam and uses the loopback video device as a video source.

Setup steps

Please refer to