1
00:00:00,060 --> 00:00:06,720
Hi, welcome to this new video, a you see, my environment looks different now because I'm not using

2
00:00:06,720 --> 00:00:15,210
Rebel for this particular video, I'm using a desktop based I.D. by charm to be exact.

3
00:00:16,170 --> 00:00:19,710
I'm not using a rebel because in this video, we're going to access.

4
00:00:20,770 --> 00:00:24,250
A computer device, the webcam to be exact.

5
00:00:25,720 --> 00:00:32,110
And because Ripple gives you a command line based, the Linux interface, you don't have access to the

6
00:00:32,110 --> 00:00:33,910
webcam or that's computer.

7
00:00:34,210 --> 00:00:35,260
It's just a server.

8
00:00:35,470 --> 00:00:40,000
It's actually a virtual server within a physical server.

9
00:00:40,330 --> 00:00:46,960
So you need to be able to access your computer a webcam to be able to follow this video that could be

10
00:00:46,960 --> 00:00:51,460
your laptop integrated webcam, or it could be a USB webcam.

11
00:00:51,470 --> 00:00:54,040
Also, so any webcam will work.

12
00:00:54,880 --> 00:01:02,560
Or it could also be a mobile phone connected to your computer through probably a third party app, which

13
00:01:02,560 --> 00:01:07,720
allows your computer to access the camera of your mobile phone.

14
00:01:08,080 --> 00:01:13,420
And then, with Python, you can access the video of the webcam.

15
00:01:14,620 --> 00:01:22,450
So what we would be doing in this lecture is we're going to write a script which detects faces in the

16
00:01:22,450 --> 00:01:25,360
webcam stream, so in real time.

17
00:01:26,260 --> 00:01:27,520
So I'm using my charm.

18
00:01:27,520 --> 00:01:34,630
You can use visual studio codes at home, whatever I.D. that you use in your local environment.

19
00:01:36,220 --> 00:01:39,250
I'll make sure that open service is stored in my environments.

20
00:01:39,490 --> 00:01:44,860
So PIP 3.9 install over CV Python.

21
00:01:47,170 --> 00:01:47,530
Yes.

22
00:01:47,920 --> 00:01:54,490
So open was installed, then I'm ready to create a main.

23
00:01:55,600 --> 00:02:06,220
The PUOi script here, so I'm just going to copy the code that we built previously where we detect faces

24
00:02:06,220 --> 00:02:07,190
in a video file.

25
00:02:07,420 --> 00:02:08,350
So that's the code.

26
00:02:09,310 --> 00:02:15,870
We only have to change a couple of lines to make this code work for webcam video.

27
00:02:16,690 --> 00:02:23,560
So the main object here is the video object, which we got from that file.

28
00:02:23,800 --> 00:02:33,130
Now, if you want to get the video from the webcam, then you want to remove that path and just place

29
00:02:33,130 --> 00:02:33,880
an integer.

30
00:02:34,000 --> 00:02:39,250
If it's zero, that means the first webcam of your computer will be accessed.

31
00:02:39,700 --> 00:02:42,880
If it's one, it could be the second webcam.

32
00:02:42,880 --> 00:02:50,110
For example, you might have a laptop and you might have also a USB cam connected to your laptop.

33
00:02:50,110 --> 00:02:52,910
So you have two cameras with zero.

34
00:02:52,930 --> 00:02:55,860
It's probably the integrated camera with one.

35
00:02:55,870 --> 00:02:59,080
It's probably the second camera.

36
00:02:59,650 --> 00:03:02,910
So I'm on a laptop, so I'm going to use zero here, right?

37
00:03:03,490 --> 00:03:04,570
So we have that.

38
00:03:05,350 --> 00:03:11,120
Then we have the highlights of the frame, the width, the face cascades.

39
00:03:11,180 --> 00:03:12,400
We need that also.

40
00:03:13,270 --> 00:03:16,440
And then we have these lines here.

41
00:03:16,450 --> 00:03:21,610
So we want to roids the video of the webcam in a file.

42
00:03:21,880 --> 00:03:27,190
So we want to keep these here than we have for success.

43
00:03:27,910 --> 00:03:29,260
We did take the faces.

44
00:03:29,800 --> 00:03:36,610
We draw a rectangle around the frames and then we write the frame in that output video.

45
00:03:38,660 --> 00:03:40,160
Prince Collins called for the release.

46
00:03:40,550 --> 00:03:41,240
So that's it.

47
00:03:41,780 --> 00:03:42,590
Let's run this.

48
00:03:49,050 --> 00:03:52,700
Oh, I don't have the Facebook Cascades five eczema.

49
00:03:53,130 --> 00:03:54,870
So let me upload that quickly.

50
00:03:58,530 --> 00:03:59,310
It it is.

51
00:04:04,110 --> 00:04:06,000
Just going to drag and drop it here.

52
00:04:08,260 --> 00:04:08,530
Yes.

53
00:04:08,670 --> 00:04:10,150
Faces that smell.

54
00:04:10,990 --> 00:04:13,090
Yes, that's it's run again.

55
00:04:20,550 --> 00:04:29,400
So my script is surrounding, but my camera has not been turned on, so maybe I want to try one here.

56
00:04:31,370 --> 00:04:31,970
Run again.

57
00:04:33,170 --> 00:04:39,820
Yeah, this time my camera has been turned on and it's probably recording, so I'm going to stop it

58
00:04:39,830 --> 00:04:40,160
now.

59
00:04:41,990 --> 00:04:45,020
And see what output that's Aivi is.

60
00:04:47,100 --> 00:04:55,980
So I'm going to open Vats in a folder and open into V. A. C. That opens the videos successfully.

61
00:05:00,110 --> 00:05:00,770
So that's me.

62
00:05:03,710 --> 00:05:04,550
Yes, it's worked.

63
00:05:06,040 --> 00:05:07,480
And that's a complete cause.

64
00:05:08,520 --> 00:05:13,440
So that's code shows how to record video from the camera and save it in a video file.

65
00:05:13,710 --> 00:05:20,280
And also, you saw that there was a rectangle around the face, although not 100 percent of the time,

66
00:05:20,280 --> 00:05:23,790
because the video was quite a low quality and better lighting.

67
00:05:25,200 --> 00:05:30,240
But anyway, this is how you do it with open CV and Python.

68
00:05:30,840 --> 00:05:32,490
So thank you, and I'll talk to you later.

