Python OpenCV
About Lesson

In this Python OpenCV lesson we want to learn How to Detect Eye with Python OpenCV,  for this lesson we are using Haar Cascade Classifier, as we have already said that a Haar Cascade is basically a classifier which is used to detect the object for which it has been trained for, from the source. The Haar Cascade is trained by superimposing the positive image over a set of negative images.

 

 

This is the complete code for this lesson.

 

 

 

This is for loading our Haar Cascade Classifier that we have already copied in our directory.

 

 

In here we are going to detect the eyes, we can use detectMultiScale() and you need to give some parameters.

 

detecMultiScale() function is for detecting objects if it finds a face in the image it will return in the form of x,y,w,h. and it needs some parameters.

ScaleFactor: This parameter is for specifying  how much the image size is reduced at each image scale.

minNeighbors: Parameter specifying how many neighbors each candidate rectangle should have to retain it, this parameter will affect the quality of the detected faces. higher value results in fewer detections but with higher quality. 3~6 is a good value for it.

 

 

 

In this code we want to draw rectangle in the eyes in image.

 

 

 

Run the complete code and this will be the result.

How to Detect Eye with Python OpenCV
How to Detect Eye with Python OpenCV

 

 

Exercise Files
haarcascade_eye.
Size: 345.33 KB