WEBVTT 00:00.510 --> 00:01.740 Then the border strip. 00:01.750 --> 00:04.110 Now let us start writing our program. 00:04.180 --> 00:08.220 The first thing is we need to import the module on which we are going to work. 00:08.590 --> 00:11.050 So all you have to do is import CB do. 00:11.050 --> 00:14.250 That's basically the first step of all the programs. 00:14.260 --> 00:19.360 You have to import all the modules all the packages that you are going to use in your program. 00:19.360 --> 00:25.600 The second thing that we need to do is we need to use our classifier so far that we have to use see 00:25.670 --> 00:32.620 we do want to add insight that we have a method call cascade classifier and have we need to go wide 00:32.650 --> 00:39.120 are high cascade classified file name let us store the result in our variable. 00:39.510 --> 00:41.210 I would call it as detect. 00:41.430 --> 00:47.130 We are just using this method to load are required to examine the classifier. 00:47.160 --> 00:54.210 Now the second thing we need to do is we need to use our image or that we need to use CV to model and 00:54.210 --> 01:00.190 Henry will be using a method called video capture and inside that we to capture. 01:00.210 --> 01:06.660 If you're using a webcam you can give 0 or 1 according to the webcam code and if you want to go in a 01:06.660 --> 01:12.190 specific image name in the same data clear that is my next stop on Oculus. 01:12.300 --> 01:13.580 My image name. 01:13.620 --> 01:20.400 So let me use you laundered G.P.S. and stored that in a variable called i am B underscore image that 01:20.400 --> 01:21.960 is imported image. 01:21.960 --> 01:30.010 Now we have to read an image for that we will be using a metaphor or are embodied image as je. 01:30.090 --> 01:32.390 Now this is going to give us to the dance. 01:32.460 --> 01:38.250 The first one will be true and false that this method has actually the damage it does when they're done 01:38.310 --> 01:38.790 true. 01:39.240 --> 01:41.600 Otherwise it is going to return false. 01:41.610 --> 01:47.090 The second is we are going to get the dimensions of our image that is pixel dimension. 01:47.100 --> 01:50.280 So we need to store the result into two variables. 01:50.660 --> 01:57.870 So either dig as obvious the desired result for true and false and then I n d that word stole my image 01:57.880 --> 01:58.900 coordinates. 01:58.980 --> 02:06.530 So finally I have my pixel and coordinates off my image and I am G and I have to enforce that I actually 02:06.530 --> 02:12.920 had the image on NA now and the next thing we need to follow up is we need to convert our image into 02:12.930 --> 02:18.750 grayscale image because this hard gasket classify it a strain for grayscale images. 02:18.900 --> 02:23.020 So we need to convert all our images into a grayscale image. 02:23.130 --> 02:27.970 So for that we just need to use a CBD colour method or RC We do more. 02:28.650 --> 02:34.980 Let me stall my result into my green variable and then use my CV to module and then CBD colour method 02:35.190 --> 02:37.010 and then pass out my image. 02:37.170 --> 02:40.560 And the second panel on me do I need to pass as colour barometer. 02:43.070 --> 02:49.100 Now that is done we have used our import Image and convert that into a grayscale image. 02:49.160 --> 02:57.500 Remember we are going to use BGR to great for C++ you might get a result of biology degree if you search 02:57.500 --> 03:01.100 for a stack overflow for any doubt or any error. 03:01.100 --> 03:03.980 Now we have converted our image into a grayscale image. 03:04.010 --> 03:09.630 The next thing we need to do is do decreases are different sizes in our input image. 03:09.680 --> 03:16.490 So for that we are going to lose our detect and side that we have a method called detect my D scheme 03:16.970 --> 03:22.280 which will take three input the first input will be out of place in image next when we are resizing 03:22.280 --> 03:29.260 come on and then our neighbouring code and everything will be stored inside our variable called faces. 03:29.690 --> 03:35.650 So this will detect faces an image and a quarter done the result into our faces. 03:35.660 --> 03:38.000 Now currently we are not marking any features. 03:38.000 --> 03:40.710 We are not drawing any scrap or what our phase. 03:40.790 --> 03:42.640 We just have the coordinates. 03:42.890 --> 03:49.610 We will get four coordinates inside our office coordinate it means x y width and height. 03:49.730 --> 03:50.920 What I mean by that. 03:51.260 --> 03:58.150 So let me take an example on paint supporting my program was able to find Mark fees so you could determine 03:58.190 --> 04:00.900 coordinates like X Y W and H. 04:00.950 --> 04:02.270 That is my width and height. 04:02.540 --> 04:09.330 So what is going to be x x and y will be my coordinates from the point that a nice office. 04:09.650 --> 04:11.450 So it would be something lying here. 04:11.630 --> 04:15.410 So that would be my X call my way the next would be w. 04:15.590 --> 04:18.630 So that would be my width of the face and then the height. 04:19.100 --> 04:23.900 So with the help of my width and height I can actually find the coordinates at this point. 04:23.900 --> 04:29.300 Also this point and this point so we can draw a square or rectangle whatever we want. 04:29.630 --> 04:32.770 So it would be returning me coordinates of X come away. 04:32.770 --> 04:37.070 That is this coordinate and it would have done me w and H. 04:37.940 --> 04:44.910 So it will be utilizing that to draw our square on our face before missing things and drawing us quite 04:44.960 --> 04:46.180 what our image. 04:46.190 --> 04:49.490 Let me just try to show my image that the sprint by image. 04:50.000 --> 04:52.910 So there would be tons of code that is currently left. 04:53.240 --> 04:56.080 But let me see if I am doing everything right. 04:56.090 --> 04:57.620 Let me just show on image. 04:57.710 --> 05:06.170 So for that I would be using a come on CB to then I am sure Hey you need to pass two arguments The first 05:06.170 --> 05:09.050 one will be the title off your window. 05:09.050 --> 05:14.520 If I open and even with maybe just a command prompt you will see that this is that item. 05:14.930 --> 05:21.550 So we need to give a title and the second barometer that we need to pass is the image that we want to 05:21.550 --> 05:21.880 show. 05:22.330 --> 05:24.850 So for now I am destroying my image. 05:25.120 --> 05:27.040 It is the original image. 05:27.040 --> 05:29.780 I'm just telling you the step of how shall. 05:29.800 --> 05:36.020 Later on we'll be passing the image that actually have Facebook nice and have the square. 05:36.040 --> 05:40.230 Now after showing an image you need to perform three step every time. 05:40.450 --> 05:42.060 The first one will be our Vicki. 05:42.070 --> 05:44.270 The second one will be of release of image. 05:44.320 --> 05:46.760 And the third one will be destroying off window. 05:46.780 --> 05:47.950 So let me do that. 05:48.500 --> 05:49.770 So let me right. 05:49.790 --> 05:52.140 See we do not read keep and head. 05:52.150 --> 05:56.860 I need to pass milliseconds for which I need to open my image. 05:56.860 --> 06:03.970 So if I was one it would be one millisecond and if I pass zero that would be means a stable image unless 06:03.970 --> 06:05.260 and until I close that. 06:06.010 --> 06:08.030 So ahead if I pass five under. 06:08.260 --> 06:12.760 So that means the image would be open only for 500 milliseconds. 06:12.760 --> 06:16.540 Let me pass this zero so I can close it whenever I want. 06:16.540 --> 06:20.290 The next thing we want to do is we want to release that image that we have captured. 06:20.650 --> 06:23.140 So we have captured important image. 06:23.170 --> 06:24.390 I need to release that. 06:24.970 --> 06:31.030 And after that after destroy all the windows that I'm currently utilizing them as a resource for my 06:31.030 --> 06:32.050 program. 06:32.050 --> 06:36.190 So this is a basic code in which we are just opening an image. 06:36.190 --> 06:39.610 We are not currently showing any nice face. 06:39.610 --> 06:42.700 We are just opening an image I can come in. 06:42.700 --> 06:48.940 These two lines are called Jump on my command line and then on Michael. 06:49.140 --> 06:53.640 Here you can see I was able to open my Elon Musk image. 06:53.640 --> 06:54.720 This looks fine. 06:54.720 --> 06:56.830 I have the coordinates of the face. 06:56.830 --> 07:02.640 Now all I have to do is use the coordinates that are not available of this particular phase and draw 07:02.640 --> 07:04.280 a square all that. 07:04.290 --> 07:05.610 Here we are using zero. 07:05.610 --> 07:08.480 That means it is open as a stable window. 07:08.520 --> 07:13.700 And I can close that if I used a 60 millisecond window. 07:13.700 --> 07:14.870 Let me run this one again. 07:16.560 --> 07:18.220 You can see it goes just tumbling. 07:18.510 --> 07:20.400 Let me with a 600 millisecond 07:23.840 --> 07:28.370 it was quite stable but I would definitely prefer zero.