In this lesson we will be using open CV to start programming with Python.
First I want you to go to the open sea view Web site.
Just to make sure the link is TTP s call on slash slash open CV dot org once we open the page I want
you to go to the tutorials on the left side of the screen now want you to go to click on the main page
tab on your left look for the link open CV Python tutorials and click it here you will see some sample
codes using the open CV scroll down and find object detection in this lesson we will be talking about
object detections as you see you will find many other sample codes I think that object detection sample
is the best sample to understand most part of what we need to know when working with open CV now let's
click on object deduction click on face detection using hard cascades here I want you to scroll down
you can see the sample codes the object detection will enable you to get an image and recognize the
face and the eyes here you'll see the image of the kids and how the system recognize the faces and eyes
the process may seem complicated but if you see the sample code you can see how short of a code it is
open CV has so much potential and that is one of the reasons it's commonly used in apps which use authentication
technology.
Now I want to talk about how this all works.
Here you see the image and color in the process the image will be turned into a black and white image
by changing the color.
It makes the process easier to distinguish the objects in the image.
The first step is to go through the edge features the system will search for a part which is formed
in black and white in this gentleman's face.
The system will see a black part in a white part right below.
Once this color combination is detected the system will recognize that it is the eyes.
If this feature is not detected the system will ignore this part of the image.
If the system detects the eyes then it will go on to the next step which is the line features in this
step.
The system will detect a color pattern with black sides and a white in the middle.
This will again help recognize that this part are the eyes the process will go on by narrowing down
the image into smaller pieces until the system can recognize that the certain part are the eyes.
And this is called the HA cascade.
Let's scroll down to the code and see what it's doing.
Here you can see that the example is set in the variable face cascade the color an image is converted
into grayscale with the gray scaled image a face cascade object is set to detect where the faces if
there are multiple faces detected.
The process will go through a for loop twice once the face is detected it will be marked with an rectangle
just like this image.
Here you see eye cascade move up the code and you will find the hard cascade eye exam though has been
read.
Then the open see the object will detect the eyes once the eyes are detected.
Again they would be marked with green rectangles.
In the end the rectangles will be placed in the original image.
Each model information to detect the face and the eyes are in these Excel files.
So we will need to download these example files.
You can find the XM l files and get hub go to HDTV as call on slash slash get hub dot com slash open
CV slash open CV scroll down a bit and find data folder click on this folder and click on ha cascade.
The first one is to detect the eyes.
You'll see the exam L to detect the face in the middle of the list
you can see that there are many of examples which can detect who's wearing glasses or even where a cat
is is quite interesting so you might want to take a look of these examples.
Now let's go on to downloading X AML files.
First click on the hard cascade I examine.
Click on raw to get the raw text.
You can download by using the double get command with the link on top or you can right click on the
site and choose save as here I'll save it to my desktop.
Now we go back to the x amount list and choose hard cascade frontal face default x m.
Again we click on Raw and right click to save it onto my desktop here we've completed downloading the
example files.
Now let's go back to the sample code.
Now we need an image with the face the image in the sample already has the square shape so you will
need a simple image of a face.
Now it can be your face but if you don't want to use your face you can come to my Twitter account and
use my face.
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
click on my image and choose said image as we can change the name to be image and save it onto my desktop.
We've prepared the image and also the 2 x AML files to detect the face and eyes.
Let's move onto the next lesson and start programming.