Hi, welcome to this new video, a you see, my environment looks different now because I'm not using
Rebel for this particular video, I'm using a desktop based I.D. by charm to be exact.
I'm not using a rebel because in this video, we're going to access.
A computer device, the webcam to be exact.
And because Ripple gives you a command line based, the Linux interface, you don't have access to the
webcam or that's computer.
It's just a server.
It's actually a virtual server within a physical server.
So you need to be able to access your computer a webcam to be able to follow this video that could be
your laptop integrated webcam, or it could be a USB webcam.
Also, so any webcam will work.
Or it could also be a mobile phone connected to your computer through probably a third party app, which
allows your computer to access the camera of your mobile phone.
And then, with Python, you can access the video of the webcam.
So what we would be doing in this lecture is we're going to write a script which detects faces in the
webcam stream, so in real time.
So I'm using my charm.
You can use visual studio codes at home, whatever I.D. that you use in your local environment.
I'll make sure that open service is stored in my environments.
So PIP 3.9 install over CV Python.
Yes.
So open was installed, then I'm ready to create a main.
The PUOi script here, so I'm just going to copy the code that we built previously where we detect faces
in a video file.
So that's the code.
We only have to change a couple of lines to make this code work for webcam video.
So the main object here is the video object, which we got from that file.
Now, if you want to get the video from the webcam, then you want to remove that path and just place
an integer.
If it's zero, that means the first webcam of your computer will be accessed.
If it's one, it could be the second webcam.
For example, you might have a laptop and you might have also a USB cam connected to your laptop.
So you have two cameras with zero.
It's probably the integrated camera with one.
It's probably the second camera.
So I'm on a laptop, so I'm going to use zero here, right?
So we have that.
Then we have the highlights of the frame, the width, the face cascades.
We need that also.
And then we have these lines here.
So we want to roids the video of the webcam in a file.
So we want to keep these here than we have for success.
We did take the faces.
We draw a rectangle around the frames and then we write the frame in that output video.
Prince Collins called for the release.
So that's it.
Let's run this.
Oh, I don't have the Facebook Cascades five eczema.
So let me upload that quickly.
It it is.
Just going to drag and drop it here.
Yes.
Faces that smell.
Yes, that's it's run again.
So my script is surrounding, but my camera has not been turned on, so maybe I want to try one here.
Run again.
Yeah, this time my camera has been turned on and it's probably recording, so I'm going to stop it
now.
And see what output that's Aivi is.
So I'm going to open Vats in a folder and open into V. A. C. That opens the videos successfully.
So that's me.
Yes, it's worked.
And that's a complete cause.
So that's code shows how to record video from the camera and save it in a video file.
And also, you saw that there was a rectangle around the face, although not 100 percent of the time,
because the video was quite a low quality and better lighting.
But anyway, this is how you do it with open CV and Python.
So thank you, and I'll talk to you later.