Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automatic Webcam Selector

This program will automatically decide which webcam to use based on gaze detection. It is powered by the GazeTracking python module (https://github.com/antoinelame/GazeTracking).

Why use this?

If you have a multi-monitor setup, you may look disengaged in meetings when looking at your side monitors that don't have a webcam. If you have spare webcams lying around, this program allows you to put a webcam on each of your monitors, and it will then decide which one to display based on gaze detection (calculating which webcam you are most likely to be looking at).

Reliability

I've made this as a fun project, and from my limited testing it works quite well - despite the virtual camera quality being awful. Basically, I wouldn't recommend using it in client meetings...

Setup

  1. You will first want to install OBS (https://obsproject.com/), this uses the OBS virtual camera to pipe through videos
  2. Launch OBS, and click the "Start Virtual Camera" button, then click to stop the virtual camera and close the OBS app. This has now created a virtual camera that this program can use to pipe video into.
  3. Configure the settings for this program (see below)
  4. Run main.py and see magic happen. You will have to play whack-a-mole with installing requirements because I haven't included a requirements file - I should probably do that...
  5. Whilst the program is running, go into your favourite video conferencing app and select the OBS Virtual Camera. Voila.

Configuration

To start configuring the script, open the main.py file. There are various options to configure.

webcam_ids - This is a list of device ids for your webcams. Most likely starting from 0. The more cameras you have, the more likely the program is to run slower or require more compute resources. The time complexity will exponentially increase as more cameras are added (sorry, this isn't built for efficiency).

centre_webcam - The ID of the centre webcam. This will give other webcams a slight measurement boost as the centre-most webcam generally has the best visibility

measurement_range - This determines how many measurements are factored into deciding which webcamera to display at any given time. The larger this number, the more accurate the switching is likely to be, but it will also be slower. As a guide, if this is set to around 5, your cameras will be switching all over the place, but if it is set to 120, the script will probably be factoring in measurements that are 1 second old (not good).

cooldown_seconds - This is another protection against the program randomly flickering between cameras. Each time a camera is switched out for another one, the script will not switch cameras again until a cooldown has run for this amount of seconds.

virtual_cam_width - Self explanatory

virtual_cam_height - Self explanatory

virtual_cam_fps - Self explanatory. I'm not entirely sure if this actually does anything...

How does this work?

At its core, the program will constantly generate new captures from each of your cameras, and then generate an estimate of whether or not you are looking at that camera. A list of these measurements are stored for each camera, and depending on your configuration, the program will actively switch between cameras based on which one has the most positive detections (of you looking at it) for a given amount of readings (the measurement_range).

For every iteration of the main program loop, the frame generated by the camera you are most likely to be looking at, is then passed into the virtual camera, which you can select in conferencing apps.

About

A Python program to switch between multiple webcams, based on the one you are most likely to be looking at

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages