Python OpenCV Face Detection Introduction

In this Python OpenCV article iam going to talk about simple Face Detection Introduction. so basically in this article we are using HaarCascade Classifier. Face Detection is a computer technology that determines the locations and sizes of human faces in arbitrary (digital) images.

 

 

What Is Haar Cascade ?

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

 

One can also used predefined Haar Cascades which are available on Github

 

 

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 this is the complete code for Python OpenCV Face Detection Introduction

 

 

 

 

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 faces in the image.

 

 

 

In this line of code we want to show our image

 

 

 

 

So run the code and this will be the result

 

Python OpenCV Face Detection Introduction
Python OpenCV Face Detection Introduction

 

 

Watch the complete video

 

 

Subscribe and Get Free Video Courses & Articles in your Email

 

Codeloop
Share via
Copy link
Powered by Social Snap
×