Skip to main content

YOLOv5 Object Detection Tutorial: Bounding Box Webcams For Zoom

Welcome to this simple-to-follow tutorial that will allow you to use YOLOv5 to create bounding boxes on your webcam. This tutorial is for Windows.
Created on November 22|Last edited on August 15

In this article, we'll explore how to quickly and easily set up YOLOv5 and get the output to appear as your webcam in Zoom calls. Of course, it'll also work for any application that uses your camera.
The level of this tutorial is definitely a beginner. I know—because I'm not a machine learning engineer, and I'm creating it.
Here's what I'll be covering.

Table Of Contents


Let's get going ...

What Is YOLOv5?

YOLOv5 is a real-time object detection algorithm that is able to identify objects in an image and display their bounding boxes. It is also able to classify the objects it detects and is used for a variety of tasks such as autonomous driving and security.
YOLOv5 is open-source and available from GitHub, and can be used for a variety of tasks such as autonomous driving, security, and surveillance.

The Setup

If you're curious about the hardware, I'm working on a Dell Precision 3571 laptop running Windows 11 Pro. This one, to be specific.
Regular readers will know that a while back I wrote a tutorial on creating bounding boxes with YOLOv5 via a webcam on Windows, but that one wasn't for use with Zoom.
But that's not the only difference. In this tutorial, we're going to take the beginning and end each a step further—to create a better structure but have no fear as it's actually easier to follow along than the YOLOv5 tutorial ... which was pretty darn easy. :)
In the end, you'll have a setup better suited for your ongoing ML explorations. Or just an easier route to getting up and running quickly.
So let's get going ...

Installing Anaconda

The first step (not included in my YOLOv5 tutorial because I thought it was more difficult than it is) is installing Anaconda.
Now, this might beg the question...

What Is Anaconda?

Anaconda is a free, open-source, and user-friendly distribution of Python and R programming languages. It comes with more than 1,500 data science packages to help you create amazing projects quickly and easily.
Anaconda also provides tools such as the Anaconda Navigator and Conda package manager that make it simple to manage the environments.
The reason we're using it here is that it has Python baked in, which we're going to need—and for those who want to carry forward exploring machine learning or just play with different versions of YOLO, the environmental aspect makes it far easier.
Environments are basically just self-contained instances of installs. So if you need a set of libraries for one project and not for another, different environments allow you to do that easily. You'll see a clear example of how this works below.

Download And Install Anaconda

The installation is painless.
Download the package:

And ... you guessed it ... install. :)
Click the downloaded file and ...

You'll notice this screen as you work your way through ...

I don't currently have another version of Python on my machine and want this option checked. If you want other programs accessing other versions of Python, however, you'll want to uncheck it.
And speaking of unchecking, I unchecked these options. If you want to get right to it, you may want to do the same.

And with that, you've got Anaconda installed, and with it a lot of the requirements that I had to install separately in the aforementioned YOLOv5 tutorial including Python, CUDA and PyTorch.
Let's move on to ...

Downloading And Setting Up YOLOv5

To download and set up YOLOv5 simply head over to https://github.com/ultralytics/yolov5. 
From there, you need to:

Then, you'll have downloaded the file "yolov5-master.zip".
The next step is to unzip it.

I don't know about you, but I'm not a fan of how GitHub sends the zipped file, with a folder inside the folder you've extracted to:

And I also like to keep things organized, so I personally have a folder named "Projects" on my Desktop where I keep my models and projects.
I'll just create a folder "YOLOv5" in there and copy the files over.

You don't need to do this, but I wanted to mention it so that if you see a different path for me than for you in the images below, you'll know why.

Installing OBS Studio

And finally, we need to install OBS Studio.
OBS does a lot of neat stuff, but for our purposes, we're using it for its ability to create a virtual camera using the output window from our YOLOv5 environment.
You can download OBS Studio from https://obsproject.com/download.
They'll walk you through some familiar steps:
Installing OBS Studio
To:

And finally:

You won't be using OBS quite yet, but you can leave it checked as we're actually almost done.

Setting Up Our Anaconda Environment

OK, now we have everything installed and/or sitting on our hard drive where we want it.
The next step is to create an environment. Basically, we're creating a self-contained environment to install YOLOv5 into. We can create one for YOLOv6, 7, and anything else we might want to as well, but we'll save that for future tutorials.
To set up your Anaconda environment, you'll first launch the Anaconda prompt:

and then create the environment for YOLOv5 by enter the following:
conda create --name yolov5 python=3.9
The Python version number may be different, so check for the latest version supported by PyTorch at the time of installation (obviously, it's 3.9 as I type this).
And check for:

When you enter the code, it'll look something like:

Next, we need to activate our environment by simply entering:
activate yolov5

Now that we have our environment and it's activated, we need to direct Anaconda to look in our YOLOv5 folder. To do this, navigate to the folder you've stored YOLOv5 in via Explorer (it might be your Desktop, or if you're like me, you've moved it to a different folder).
In short, you navigate to where the YOLOv5 files are stored, right-click in the address bar, and copy the address.

And from there, you type into the Anaconda prompt:
cd C:\Users\dave\OneDrive\Desktop\Projects\YOLOv5
Replacing the URL with your location, obviously.
Now Anaconda is in your YOLOv5 folder:


Installing The YOLOv5 Requirements

The next step is to install the required dependencies you're going to need.
This involved simply typing:
pip install -r requirements.txt
and hitting enter.

You'll need to be patient as it can take a minute, but it's pretty fast.
And now it's time to ...

Create Bounding Boxes With YOLOv5 On Your Webcam

Now it's time to start having some fun.
First, you'll need to make sure your camera isn't being used by other applications. So you can't magically switch during a Zoom call; for this next step, you'll need to have turned off your camera.
Once that's done, type the following command into Anaconda Prompt:
python detect.py --source 0
This detects your camera for use.
In my case the source is 0 (and most people), though I do have 2 cameras and I could use source 1 as well. Y In short, you may need to change the number but try 0 first.
💡
And you end up with:

But how do you make it your webcam?

YOLOv5 Bounding Boxes As Your Zoom Webcam

Now the part you've been waiting for, and interestingly it's perhaps the easiest.
Remember when we installed OBS Studio? Well, now it's time to launch it!
Once you've opened up OBS Studio, you simply:
  1. Click the + under Sources to add a source
  2. Select Window Capture
  3. Click OK
  4. Select the Window your YOLOv5 is running in (0 in my case)
  5. Resize the display to fill the OBS camera preview as you like
  6. Click "Start Virtual Camera"
  7. In Zoom select "OBS Virtual Camera" as your camera
And then ...

Enjoy!

Optimize Your YOLOv5 Experiments Right

Whether you're new to Machine Learning, Computer Vision, or just using YOLOv5 for object detection, building great habits and using the right tools for the job is mandatory.
So, click here and start using Weights & Biases for experiment tracking in under 5 minutes.
Here are just a few examples of what you can do:

Use Bounding Box Debugger To Visualize Model Predictions On The Validation Data During Training




Log Training And Validation Metrics And Easily Compare Them With Experiment Tracking




Visually Explore Your Model's Predictions And Datasets With W&B Tables



If you'd like to learn more about supercharging your training process using Weights & Biases, you may enjoy reading this report or watching the following video on training YOLOv5:


Good luck out there!

Iterate on AI agents and models faster. Try Weights & Biases today.