Python Mini Report PDF
Python Mini Report PDF
ON
Face Detection
Submitted in partial fulfilment of the requirement for the award of the degree of
B.TECH
in
Submitted By
Certified that this project report FACE DETECTION is the bonafide work of
RAHUL KUMAR SINGH (RA1611003040165) who carried out the project work under
my supervision.
It is our privilege to express our sincerest regards to our project coordinator, G.Paavai Anand
for her valuable inputs, able guidance, encouragement, whole-hearted cooperation and
constructive criticism throughout the duration of our project.
We deeply express our sincere thanks to our Head of Department Dr .S.Prasanna Devi, for
encouraging and allowing us to present the project on the topic “Face Detection” at our
department premises for the partial fulfillment of the requirements leading to the award of
B-Tech degree.
We take this opportunity to thank all our faculty members, Dean, Dr.K.Duraivelu, and
Management who have directly or indirectly helped our project. Last but not the least we
express our thanks to our friends for their cooperation and support
TABLE OF CONTENTS
ABSTRACT
1.INTRODUCTION
2.PROBLEM DEFINITION
4.ALGORITHM IMPLEMENTATION
5.SOURCE CODE
6.SCREENSHOTS
8.CONCLUSION
ABSTARCT
Face detection refers to computer technology that is able to identify the presence of people’s faces
within digital images. In order to work, face detection applications use machine learning and
formulas known as algorithms to detecting human faces. These larger images might contain
numerous objects that aren’t faces such as landscapes, buildings and other parts of humans.
So, this project face detection is a kind of script written in python using CV2 and cascade classifier
which can be extended to machine learning which when given a sample image containing more
than 1 faces it first saves the original image exactly of its original size in all four dimensions. Then,
the given classifier detects all the faces from the given input image and it crops it from the two
dimensions length and breath in the scale factor of 1:3 ratio. After cropping this it saves all the
face images separately in jpeg format every time we will run the program.
Hence, Face detection just means that a system is able to identify that there is a human face present
in an image or video. Face detection has several applications, only one of which is facial
recognition. Face detection can also be used to auto focus cameras. And it can be used to count
how many people have entered a particular area. It can even be used for marketing purposes. For
example, advertisements can be displayed the moment a face is recognized.
INTRODUCTION
This report describes the implementation of the face detection process based on the concept of
python and machine learning classifier and as we know that face detection is a computer
technology being used in a variety of applications that identifies human faces in digital images so
the purpose of this project is to detect the no of faces in a given image and also it crops out all the
faces separately into different images. The idea behind this project is very simple that id face
detection which is based on the application of python script and a classifier which can be used in
extended machine learning and also it can classify any no of faces in a given input image very
easily. The process works using a computer application that captures a digital image of an
individual’s face sometimes taken from a video frames and compares it to images in a database
of stored records. While facial recognition isn’t 100% accurate, it can very accurately determine
when there is a strong chance that an person’s face matches someone in the database.
PROBLEM DEFINITION
The project consists of a face recognition system in which an input image is given in which the
number of faces is more than one and using the algorithm and classifier we use to detect the faces
and accordingly it crops it into a certain ratio in two dimension that is length and breath. After all
this it saves the separate images in jpeg form which tells the no of count of faces which was the
We are taking the raw image as an input in which the number of faces is more than one and then
we save the real image and its path too and after that we are importing cv2 classifier and defining
the four dimensional variables for length breath height and width then after we are detecting the
faces using cascade class and cropping that image in the scale ratio of 1:3 and saving it separately
into jpeg format. Hence, we can use this for an extended machine learning application also in
future.
ALGORITHM IMPLEMENTATION
• We will go to the main function where we will create a class called crop which will be
called later.
• We will define the four types of variables for the various dimensions of the given input
image
• Then by calling the classifier we will crop the image in the ratio of 1:3 in length and height.
import cv2
class CropFace:
def cropimages(self):
#image_og = cv2.imread(self.imagepath)
image = cv2.imread(self.imagepath, 0)
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml')
faces = face_cascade.detectMultiScale(
image, scaleFactor=1.3, minNeighbors=5)
# [[x,y,w,h],[x,y,w,h]]
faces_found = []
for x, y, w, h in faces:
facecrop = image[y:y + h, x:x + w]
faces_found.append(facecrop)
# Stores the coordinates where we have to crop the image
return faces_found
faces = face_cascade.detectMultiScale(
image, scaleFactor=1.3, minNeighbors=5)
# [[x,y,w,h],[x,y,w,h]]
faces_found = []
if __name__ == "__main__":
crop = CropFace("img2.jpg")
img = cv2.imread("img2.jpg")
cv2.imshow("Original image",img)
faces = crop.cropimages()
crop.saveimages(faces)
SCREENSHOTS
Original image
NUMBER OF FACES : 3
PROS AND CONS:
The best part of this idea is it can be implemented in many potential machine learning concepts
which is very useful in our future There are lots of applications of face recognition. Face
recognition is already being used to unlock phones and specific applications. Face recognition is
also used for biometric surveillance. Banks, retail stores, stadiums, airports and other facilities use
And the cons part is, this isn’t that much accurate and efficient as per our future complex
requirements.
CONCLUSION:
The best part of this project is that the code is really simple and understandable which is written
in python language. As we have not usede any complex classifiers this is the simplest way for
face detection which we could extend it to the concept of machine learning in future.