1
00:00:00,240 --> 00:00:06,330
We successfully finish receiving video from the drone camera and streaming it on the webcam.

2
00:00:06,480 --> 00:00:10,640
In this lesson we will be creating the face recognition part.

3
00:00:10,710 --> 00:00:15,710
First I want you to go to the tools folder where we set the hard cascade example.

4
00:00:15,780 --> 00:00:23,000
Right click on the file and copy this next go pasted in the model's folder and press OK.

5
00:00:23,220 --> 00:00:28,540
You can see that the hard cascade excel file has been set under the model's folder.

6
00:00:28,590 --> 00:00:36,460
Now go to the drone manager p y will be using the excel file to create the face recognition function.

7
00:00:36,540 --> 00:00:45,840
Let's start by setting the example path on the top set face detect XM alpha with Slash drone app slash

8
00:00:45,840 --> 00:00:53,490
models slash since the file name is long let's right click on the Excel file choose refactor and rename

9
00:00:53,940 --> 00:00:55,350
once you see the file name.

10
00:00:55,350 --> 00:00:58,770
Copy that and paste it to the path.

11
00:00:58,770 --> 00:01:00,690
Next we want to receive an error.

12
00:01:00,720 --> 00:01:05,800
If the example file doesn't exist so let's set a class named error.

13
00:01:05,820 --> 00:01:11,850
No face deduct XM Alpha as an exception followed by a message.

14
00:01:12,130 --> 00:01:16,010
Error no phase detect XM Alpha.

15
00:01:16,110 --> 00:01:22,410
Here I said exception class to be inherited with the straightforward class name so we can easily detect

16
00:01:22,470 --> 00:01:26,480
what the area is now scroll down to send command.

17
00:01:26,610 --> 00:01:29,550
We can also add if not statement.

18
00:01:29,550 --> 00:01:37,700
If not the OS path exist for the XM Alpha raisin error with the message that there is no XM Alpha.

19
00:01:40,140 --> 00:01:47,150
Let's go on and set self face cascade to see V cascade classifier and set the XM Alpha.

20
00:01:48,270 --> 00:01:54,240
We also want to set a flag to determine if we will enable the face detection or not.

21
00:01:54,240 --> 00:01:57,090
Initially we will set to false.

22
00:01:57,300 --> 00:02:03,940
Now scroll down so we can add some codes to the video method.

23
00:02:03,950 --> 00:02:11,840
Here we see the video JPEG generator will add the face detection method in here before we go into the

24
00:02:11,840 --> 00:02:13,010
face detection.

25
00:02:13,100 --> 00:02:20,460
We need to enable the face detection set that is enable face detect to true.

26
00:02:20,490 --> 00:02:27,130
Also let's add a disabled face to tech method so we can switch off the face detect.

27
00:02:27,140 --> 00:02:35,950
Here we need to set the self is enable face deductibles.

28
00:02:35,960 --> 00:02:44,030
Now let's go onto the video JPEG generator go into the video binary generator and add an if statement.

29
00:02:44,030 --> 00:02:49,850
If the face detectors enable if the patrol is on we need to stop the patrol.

30
00:02:49,850 --> 00:02:53,910
We've done this part in the open CV but we'll set it again.

31
00:02:53,970 --> 00:03:05,150
Grey will be set with CV CBT color first argument with the frame followed by CV color BGR to Gray next

32
00:03:05,150 --> 00:03:13,070
faces will be set to sell face cascade detect multi scale and the color gray followed by one point three

33
00:03:13,160 --> 00:03:16,820
and five which was determined in the sample code.

34
00:03:17,270 --> 00:03:23,750
If the face was detected we need to get the x y point width and height to set and faces

35
00:03:26,460 --> 00:03:30,500
once the face is detected we want to enclose it with the square.

36
00:03:30,630 --> 00:03:40,380
So we set the CV rectangle function and set the frame with x y x plus width and Y plus height followed

37
00:03:40,380 --> 00:03:44,730
by the color blue which will be 2 5 5.

38
00:03:44,750 --> 00:03:46,880
Come on 0 come on 0.

39
00:03:46,890 --> 00:03:49,590
The line thickness will be 2.

40
00:03:49,650 --> 00:03:52,880
In this example we will detect just one face.

41
00:03:53,010 --> 00:03:56,880
So once a face is detected we will break the for loop.

42
00:03:57,390 --> 00:04:05,280
Next go to server P Why go to where the patrol command is under the stop patrol command.

43
00:04:05,340 --> 00:04:06,940
Let's set the face detect.

44
00:04:06,940 --> 00:04:12,330
Command this command will be faced detect and track command.

45
00:04:12,330 --> 00:04:21,140
We still haven't set the tracking method but we'll get to it later on set to run drone enable face detect.

46
00:04:21,180 --> 00:04:28,320
Copy this command to create the stop face detect and track set to run drone disable face detect

47
00:04:32,190 --> 00:04:34,040
once we set the server IP why.

48
00:04:34,320 --> 00:04:41,620
Let's go to the controller HDMI out go to the events mode and copy the stop patrol button code and paste

49
00:04:41,620 --> 00:04:49,550
to twice change the button word to face detect and track and stop face detect and track.

50
00:04:49,710 --> 00:04:55,350
Remember to change the content to face detect and track and stop face detect and track

51
00:04:59,160 --> 00:05:00,350
now we've finished the code.

52
00:05:00,480 --> 00:05:03,590
So let's run the script and go for a test fly.

53
00:05:04,410 --> 00:05:11,040
Once we run the code go to the controller site let's press take off and wait until the video stream

54
00:05:11,040 --> 00:05:11,610
starts

55
00:05:15,610 --> 00:05:21,790
you can see that the camera is too low so I'll press on up to fly the drone so the height of my face

56
00:05:22,450 --> 00:05:27,010
once the camera fits my face I'll press the face detect and track button.

57
00:05:27,550 --> 00:05:31,690
Let me turn around so you can see the blue rectangles set on my face.

58
00:05:32,110 --> 00:05:35,410
I can move my face around and the rectangle will follow me.

59
00:05:37,420 --> 00:05:41,860
We've succeeded in setting the face detect function to our system.

60
00:05:41,950 --> 00:05:45,460
Now let's hit the stop phase detect and track button.

61
00:05:45,700 --> 00:05:48,150
I'm going to turn around again this time.

62
00:05:48,190 --> 00:05:55,240
You can see that the blue rectangle doesn't show up as the face detectors disabled press the land button

63
00:05:55,330 --> 00:05:57,910
to finish the process.

64
00:05:58,190 --> 00:05:58,690
Okay.

65
00:05:58,710 --> 00:05:59,620
Great job.

66
00:05:59,620 --> 00:06:03,580
Next we will go on to setting the tracking part see at the next lesson.
