Skip to content

usbt0p/YOLO-Webcam-Simulator

Repository files navigation

YOLO Webcam Simulator

Hijack your webcam with YOLO detection and segmentation!

This is a simple repo containing the code for a virtual webcam interface that applies YOLO detection and segmentation in real time. It uses v4l2loopback trough pyvirtualcam to create a virtual webcam device that other applications can use, while the script processes the real webcam feed with YOLO and outputs the modified frames to the virtual webcam.

The main script is mock_webcam_good.py, which captures the webcam feed, runs YOLO inference. Since this is a YOLO-E model, you can specify the classes to detect by passing them as command line arguments. A thread allows you to change the detected classes in real time by typing in the terminal.

There are other 2 files in the repo, simple_yoloE_webcam.py and mock_webcam_basic.py, which are simpler versions of the main script, one without virtual cam and the other without dynamic class changing, just to demonstrate how easoy it is to set up this kind of stuff.

Usage

  1. Install the dependencies trough uv using uv sync.
  2. Make sure you have v4l2loopback installed and set up on your system. Depending on your Linux distro, you might have issues with the module not being signed and the kernel refusing to load it (modprobe ERROR: could not insert 'v4l2loopback': Key was rejected by service). You can fix it by disabling secure boot on your BIOS or by trying something like this.
  3. Run the script with the desired classes to detect:
python3 mock_webcam_good.py person glasses clothes
  1. In the terminal, you can type new classes to update the detection in real time:
> cat dog

About

Hijack your webcam with YOLO detection and segmentation! Virtual webcam interface with YOLO-E detection and label-changing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages