Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
1
Hello and welcome to listen to toil to they we're going to do the face recognition with the web cam
2
by playing the detect function that we made in the previous toils on each of the images coming from
3
the webcam.
4
All right.
5
So let's do this.
6
And if that doesn't take a while we might actually see the results at the end of this tutorial.
7
So the first thing we need is the last frame coming from the webcam because that's on this last frame
8
that we will apply the detect function and so to get this last frame we're going to create an object
9
of another class which is video capture.
10
So that's a class working on the web cam and basically this object will contain several entities several
11
informations and one of them will be the frame.
12
The last image last frame coming from the webcam.
13
So this object is going to be called Video underscore capture because this is actually an object from
14
the video capture class which is a class of the CB2 much all.
15
So let's not forget CB2 here video capture class and that class takes one argument actually which is
16
0 0 1 0.
17
If it's the webcam of the computer and one if it's a webcam coming from an external device that is if
18
you have an external webcam that you plugged into your computer.
19
I'm going to use the webcam of my computer the internal webcam so that's going to be zero.
20
But if you have an external webcam you will have to put one here.
21
All right.
22
So that's basically all we need to do to get this video capture object that contains the last frame
23
coming from the webcam.
24
And now we are ready to start the loop to apply to detect function on all the images coming from the
25
web cam that we get things through this video capture object and on all these images.
26
We will apply to detect function to detect the face and the eyes.
27
So that's why we're going to start a loop now which is not going to be a for loop because it's going
28
to be an infinite loop and we will break it by using the break trick.
29
And by then you know you can end the loop by just typing break and actually break will be applied.
30
If we type on q on the keyboard to turn off the webcam.
31
So this while loop.
32
The trick is to do well here and then trick which means we repeat infinitely until daybreak.
33
All right.
34
So what is the first step in it to do.
35
Well the first step is to get the last frame coming from the webcam and to get it.
36
We're going to use a method for more video capture object which is the read method and this read method
37
returns two elements and the second element is the last frame coming from the webcam.
38
And since we're only interested in that we're going to use this trick here underscore cummer frame because
39
the read method returns two elements and we are only interested in this one.
40
And the fact that we're putting an underscore here means that we won't get the first element returned
41
by this read method.
42
All right and so now we need to call this read method to get the last frame of the webcam and to do
43
this since this method is a method of the video capture class.
44
Well we need to take our video capture object then that and then read with some parenthesis.
45
Perfect.
46
That gets us the last frame of the webcam and now we are almost ready to apply to detect method.
47
Remember the Digic method not only takes the frame as input but also the gray that is the black and
48
white version of the frame and therefore we need to do something here to get this black and white version
49
of this frame that we just got thanks to the read method of our video capture object.
50
And to do this we're going to use the city color function CVG color is a function of our of each module
51
that allows to do some transformations on some frames.
52
So there will be some transformations on our original colored frame and this transformation will be
53
of course to convert this color image into black and white so that we can get the second argument here
54
Grey which will be the black and white version of this frame.
55
So let's call it actually gray black and white version of the frame.
56
And now we're going to take our city to Mudgal because we want to take the CVT color class which takes
57
two arguments the first one is of course frame because that's the image we want to convert into black
58
and white.
59
And the second one will be civil to that all in capital letters color underscore b g are to gray.
60
So what is this.
61
This argument Sivi to that color B.G. are two gray cells.
62
In fact to do an average on blue green and red and that's to take a scale of gray because you know cause
63
the Cascades are applied on the gray images.
64
But in order to get the right contrast of black and white well we need to do some average on the blue
65
red and green to get this contrast.
66
You know if we have some parts of the images that are with dark colors and some dark red blue green
67
Well we will get some dark gray in the great image.
68
So that's just a trick to obtain the right shades of gray.
69
All right then I think you guess what we have to do we have to frame the original color image and gray
70
which is the black and white version of the image.
71
So we are ready to apply the detect function.
72
We have the two arguments grand frame.
73
So basically we're ready to get the original image with the detector rectangles detecting the face and
74
the eyes.
75
So we're going to introduce a new voice will here that we're going to call canvas and that will be the
76
result of the detect function applied to our frame which is the last frame captured by the webcam and
77
gray the black and white version of this frame.
78
So what we simply need to do here is to call our detect function and then apply gray and frame gray
79
and frame and that will get us the last streamed image of the web cam with the rectangle detectors Okay.
80
Then we need to use some more tricks.
81
The first week we need to do is to display in an animated way all the successive outputs that is all
82
the successive processed images in a window.
83
And to do this we're going to use from RACV to Mudgal the eum show function.
84
So that's that is just a function that will do that for you.
85
Display all these processed images in an animated way in a window.
86
And so this show function takes two arguments.
87
The first one is video and the second one is the canvas canvas which is the output of the detect function.
88
That is the original image coming from the webcam but with the detector rectangles right then we need
89
to use another trick which will be used to stop the webcam and face the election process if we press
90
on cue on the keyboard.
91
So the trick to do that is to blame if conditions saying that if see that wait key and you put one and
92
0 x f f equals equals or in some quotes.
93
Q That's Q On the keyboard.
94
So is this then what do we want to do.
95
Remember where I told you about the while loop the infinite loop.
96
Well we want to break the process that is set stop everything.
97
So this well loop will be over and that will allow us to end the process.
98
So basically it's not very important to understand the techniques and syntax of this.
99
This just means that if we press on cue on the keyboard Well this will break the process.
100
No more facial recognition.
101
OK.
102
Perfect.
103
So actually the while loop is over so we can just go back to the main code and we have only two things
104
to do left.
105
The first thing is to turn off the webcam and to do this we take our video capture object and we're
106
going to use this release method to exactly turn up the webcam and eventually we need to destroy the
107
window inside which all the images were displayed and to do this we take our to Mudgal and then dart
108
and then we're going to use to destroy all Windows function and there we go the code is over.
109
Congratulations.
110
Now we're ready to detect our face and our eyes.
111
So let's do it right now because everything is ready.
112
So here we go.
113
I'm selecting all this.
114
You have to select all this code.
115
Make sure that you are in this fuller to be able to load the Cascades.
116
And if that's the case just press enter.
117
There we go.
118
The code is well executed and hi guys.
119
Welcome to my place.
120
This is actually where I'm recording all these tutorials for you.
121
So super happy to have you here.
122
As you can see well we are detecting very well my face and my eyes.
123
I think that's the case for you to execute your code.
124
So of course sometimes we see some false positive.
125
We can see some rectangle around my mouth detecting the eyes are open to the things that's my eye but
126
if I don't make too much expression or if I don't talk yet there we go.
127
We have this blue rectangle detects in my face and these two green rectangles detects in my eyes.
128
So there we go.
129
That works pretty well.
130
If you are not 100 percent convinced of the power of this model Well remember that in the next modules
131
we'll be using some much more powerful models open.
132
Definitely doesn't contain the most powerful models.
133
We actually saw it from module to module 2 will be about object detection and we actually tried Open
134
survie to detect some very cute bouncing dog that we actually filmed ourself.
135
But it really turned out to work very bad.
136
So instead we implemented a much more powerful model based on neural networks.
137
So hold onto that.
138
This is going to be interesting and mostly much more powerful.
139
So I was very happy to show you this.
140
This was just a warm up.
141
Keep up the good energy for what's coming next because it's going to be much more challenging but also
142
much more fascinating.
143
So I'll see you soon for the next module object detection.
144
But first I'll give you a little homework.
145
This will be the homework of this module one face detection and this will be about detecting some of
146
the features in the face.
147
So good luck with that.
148
And until then enjoy computer vision.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.