1
00:00:01,170 --> 00:00:06,850
In this lesson we will be using open CV to start programming with Python.

2
00:00:06,900 --> 00:00:10,080
First I want you to go to the open sea view Web site.

3
00:00:10,410 --> 00:00:19,390
Just to make sure the link is TTP s call on slash slash open CV dot org once we open the page I want

4
00:00:19,390 --> 00:00:26,200
you to go to the tutorials on the left side of the screen now want you to go to click on the main page

5
00:00:26,200 --> 00:00:36,480
tab on your left look for the link open CV Python tutorials and click it here you will see some sample

6
00:00:36,480 --> 00:00:47,100
codes using the open CV scroll down and find object detection in this lesson we will be talking about

7
00:00:47,160 --> 00:00:55,340
object detections as you see you will find many other sample codes I think that object detection sample

8
00:00:55,340 --> 00:01:02,900
is the best sample to understand most part of what we need to know when working with open CV now let's

9
00:01:02,900 --> 00:01:11,950
click on object deduction click on face detection using hard cascades here I want you to scroll down

10
00:01:12,520 --> 00:01:19,230
you can see the sample codes the object detection will enable you to get an image and recognize the

11
00:01:19,230 --> 00:01:26,680
face and the eyes here you'll see the image of the kids and how the system recognize the faces and eyes

12
00:01:28,630 --> 00:01:34,660
the process may seem complicated but if you see the sample code you can see how short of a code it is

13
00:01:35,590 --> 00:01:42,970
open CV has so much potential and that is one of the reasons it's commonly used in apps which use authentication

14
00:01:42,970 --> 00:01:45,320
technology.

15
00:01:45,460 --> 00:01:48,790
Now I want to talk about how this all works.

16
00:01:49,120 --> 00:01:55,980
Here you see the image and color in the process the image will be turned into a black and white image

17
00:01:57,180 --> 00:01:58,560
by changing the color.

18
00:01:58,590 --> 00:02:02,410
It makes the process easier to distinguish the objects in the image.

19
00:02:03,280 --> 00:02:10,020
The first step is to go through the edge features the system will search for a part which is formed

20
00:02:10,020 --> 00:02:15,090
in black and white in this gentleman's face.

21
00:02:15,120 --> 00:02:18,710
The system will see a black part in a white part right below.

22
00:02:19,440 --> 00:02:25,610
Once this color combination is detected the system will recognize that it is the eyes.

23
00:02:25,680 --> 00:02:30,780
If this feature is not detected the system will ignore this part of the image.

24
00:02:31,530 --> 00:02:39,030
If the system detects the eyes then it will go on to the next step which is the line features in this

25
00:02:39,030 --> 00:02:39,550
step.

26
00:02:39,550 --> 00:02:45,430
The system will detect a color pattern with black sides and a white in the middle.

27
00:02:45,430 --> 00:02:52,070
This will again help recognize that this part are the eyes the process will go on by narrowing down

28
00:02:52,070 --> 00:02:58,780
the image into smaller pieces until the system can recognize that the certain part are the eyes.

29
00:02:59,030 --> 00:03:02,360
And this is called the HA cascade.

30
00:03:02,360 --> 00:03:05,610
Let's scroll down to the code and see what it's doing.

31
00:03:05,630 --> 00:03:12,950
Here you can see that the example is set in the variable face cascade the color an image is converted

32
00:03:12,950 --> 00:03:21,650
into grayscale with the gray scaled image a face cascade object is set to detect where the faces if

33
00:03:21,650 --> 00:03:23,970
there are multiple faces detected.

34
00:03:24,050 --> 00:03:32,090
The process will go through a for loop twice once the face is detected it will be marked with an rectangle

35
00:03:32,660 --> 00:03:35,540
just like this image.

36
00:03:35,870 --> 00:03:42,560
Here you see eye cascade move up the code and you will find the hard cascade eye exam though has been

37
00:03:42,560 --> 00:03:43,770
read.

38
00:03:43,850 --> 00:03:49,160
Then the open see the object will detect the eyes once the eyes are detected.

39
00:03:49,310 --> 00:03:52,830
Again they would be marked with green rectangles.

40
00:03:53,540 --> 00:03:57,140
In the end the rectangles will be placed in the original image.

41
00:03:58,790 --> 00:04:04,550
Each model information to detect the face and the eyes are in these Excel files.

42
00:04:04,910 --> 00:04:08,330
So we will need to download these example files.

43
00:04:08,330 --> 00:04:18,740
You can find the XM l files and get hub go to HDTV as call on slash slash get hub dot com slash open

44
00:04:18,820 --> 00:04:31,690
CV slash open CV scroll down a bit and find data folder click on this folder and click on ha cascade.

45
00:04:31,930 --> 00:04:34,420
The first one is to detect the eyes.

46
00:04:34,660 --> 00:04:38,500
You'll see the exam L to detect the face in the middle of the list

47
00:04:41,410 --> 00:04:47,170
you can see that there are many of examples which can detect who's wearing glasses or even where a cat

48
00:04:47,200 --> 00:04:53,170
is is quite interesting so you might want to take a look of these examples.

49
00:04:53,200 --> 00:04:56,350
Now let's go on to downloading X AML files.

50
00:04:56,350 --> 00:04:59,850
First click on the hard cascade I examine.

51
00:05:00,070 --> 00:05:02,940
Click on raw to get the raw text.

52
00:05:03,310 --> 00:05:09,070
You can download by using the double get command with the link on top or you can right click on the

53
00:05:09,070 --> 00:05:13,800
site and choose save as here I'll save it to my desktop.

54
00:05:17,310 --> 00:05:25,200
Now we go back to the x amount list and choose hard cascade frontal face default x m.

55
00:05:25,340 --> 00:05:33,810
Again we click on Raw and right click to save it onto my desktop here we've completed downloading the

56
00:05:33,810 --> 00:05:35,980
example files.

57
00:05:36,030 --> 00:05:38,420
Now let's go back to the sample code.

58
00:05:38,460 --> 00:05:45,210
Now we need an image with the face the image in the sample already has the square shape so you will

59
00:05:45,210 --> 00:05:48,060
need a simple image of a face.

60
00:05:48,090 --> 00:05:54,540
Now it can be your face but if you don't want to use your face you can come to my Twitter account and

61
00:05:54,540 --> 00:05:56,310
use my face.

62
00:05:56,310 --> 00:06:06,150
My account is as a k a i j u n this is a picture of me when I used to compete in the Olympics right

63
00:06:06,150 --> 00:06:14,880
click on my image and choose said image as we can change the name to be image and save it onto my desktop.

64
00:06:14,880 --> 00:06:20,220
We've prepared the image and also the 2 x AML files to detect the face and eyes.

65
00:06:21,630 --> 00:06:24,630
Let's move onto the next lesson and start programming.
