Smile Detection In Python OpenCV With HaarCascade

In this Python OpenCV article i want to show you Smile Detection With HaarCascade Classifier. so in this article iam using an image, you need to have an image in your working directory.

 

 

Also you can check Python GUI Development Tutorials in the below link.

1: PyQt5 GUI Development Tutorials

2: TKinter GUI Development Tutorials

3: Pyside2 GUI Development Tutorials 

4: Kivy GUI Development Tutorials

So now we are going to have a simple introduction to HaarCascade Classifier

 

What Is HaarCascade Classifier ?

So Haar Cascade is basically a classifier which is used to detect the object for which it has been trained for, from the source. also The Haar Cascade is trained by superimposing the positive image over a set of negative images. The training is generally done on a server and on various stages. Better results are obtained by using high quality images and increasing the amount of stages for which the classifier is trained.

 

you can also used predefined Haar Cascades which are available on github

 

 

 

So now this is the complete code for Smile Detection In Python OpenCV With HaarCascade

 

 

 

So in this line of code we have loaded the image, you need to have an image in your working directory.

 

 

 

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

 

 

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 is 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.

 

 

 

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

 

 

 

In this line of code we want to show our image

 

 

 

 

 

Run the complete code and this will be the result

Smile Detection In Python OpenCV With HaarCascade
Smile Detection In Python OpenCV With HaarCascade

 

 

 

 

 

 

Also you can Watch the complete video

Subscribe and Get Free Video Courses & Articles in your Email

 

Codeloop
Share via
Copy link
Powered by Social Snap
×