Major Project Report ON Attendance Sytem With FACEAPP Using Python
Major Project Report ON Attendance Sytem With FACEAPP Using Python
Major Project Report ON Attendance Sytem With FACEAPP Using Python
ON
Session 2017-2020
1
DECLARATION
I hereby declare that this Major Project Report titled ”Attendance system with faceapp
using python” submitted by me to JEMTEC, Greater Noida is a bonafide work undertaken
during the period from Januray’20 to March’20 by me and has not been submitted to any
other University or Institution for the award of any degree diploma / certificate or
published any time before.
_____________________
2
ACKNOWLEDGEMENT
I offer my sincere thanks and humble regards to JEMTEC, Greater Noida for imparting us
very valuable professional training in BCA.
I pay my gratitude and sincere regards to Dr.Ruchi Agarwal, my project guide for giving
me the cream of her knowledge. I am thankful to her as she has been a constant source of
advice, motivation and inspiration. I am also thankful to her for giving his suggestions and
encouragement throughout the project work.
I take the opportunity to express my gratitude and thanks to our computer Lab staff and
library staff for providing me opportunity to utilize their resources for the completion of
the project.
I am also thankful to my family and friends for constantly motivating me to complete the
project and providing me an environment, which enhanced my knowledge.
Date: - 28/Apr/2020
Enroll. – 00525502017
_____________________
3
BONAFIDE CERTIFICATE
This is to certify that as per best of my belief the project entitled “Attndance system with
faceapp using python” is the bonafide research work carried out by BHOOMIKA BEHL
student of BCA, JEMTEC, Greater Noida, in partial fulfilment of the requirement for the
summer training report of the Degree of Bachelor of Computer Application.
4
CONTENTS
PAGE
S.NO. TOPIC
NO.
1. Declaration 2
2. Acknowledgements 3
3. Bonafide Certificate 4
4. Abstract 6
Chapter 1: Introduction
5. Project description 7 - 10
Objective of the study
6. Chapter 2: Software Requirements Specification 11 – 14
9. Chapter 5: Conclusion 36 – 37
11. Bibliography 40
5
ABSTRACT
The face is one of the easiest ways to distinguish the individual identity of each other. Face
recognition is a personal identification system that uses personal characteristics of a person
to identify the person's identity. Human face recognition procedure basically consists of
two phases, namely face detection, where this process takes place very rapidly in humans,
except under conditions where the object is located at a short distance away, the next is the
introduction, which recognize a face as individuals. Stage is then replicated and developed
as a model for facial image recognition (face recognition) is one of the much-studied
biometrics technology and developed by experts. The software requirements for this
project is pycharm. Further, this face recognition helps to mark the attendance of the
students by creating a excel sheet containing Id, name and time of the attendance.
6
CHAPTER 1:
INTRODUCTION
7
PROJECT DESCRIPTION
FACEAPP DATASET
The dataset of images (100 images per person) is created. Once the
dataset is created it is stored in the original file location with the name of
dataset itself.
FACEAPP TRAINING
Now the images of all the faces are trained whose datasets have been
created and stored it the form of yml extention file. This yml file is later
used to compare the images with faces of the people appearing in the
camera at that real time.
FACEAPP RECOGNITION
Third part is face recognition. In this, faces are recognised by comparing
to the datasets stored earlier in the form of yml format file. It compares
with number of images matching to the particular face which is appearing
at real time.
8
TRACK IMAGE
Fourth part is track image. In this, camera is turned on and our face is
recognised by the app and the we press Q for marking the attendance.
ATTENDANCE MARKED
In the last step, after pressing Q, attendance is marked hence creating an
excel sheet with the name, id and time of the attendance marked.
9
OBJECTIVE
The objective behind this project is to recognise the person by their faces appearing at real
time. Face app basically provides more security by detecting the person respective to their
faces. It is connected to attendance systems, which can be used in schools, colleges and
any other institutions or offices.
10
CHAPTER 2:
11
SOFTWARE REQUIREMENT SPECIFICATIONS
Overview:
Creating a dataset of images (100 images per person) for future detection.
Training of faces is done, and stored in the format or yml extension.
Face recognition is done by comparing the real time faces to the dataset which is
stored as yml file and featured their names, and states unknown if no matching is
found.
Attendance is marked in an excel sheet.
12
Interface Requirements:
Python 3.7
Numpy- it is the fundamental package for scientific computing with
Python. It contains among other things:
A powerful N-dimensional array object
Tools for integrating C/C++ and Fortran code
Useful linear algebra, Fourier transform and random number
capabilities
Opencv- python:
Step 1: Considering our prerequisites, we will require an image, to
begin with. Later we need to create a cascade classifier which will
eventually give us the features of the face.
Step 2: This step involves making use of OpenCV which will read
the image and the features file. So at this point, there are NumPy
arrays at the primary data points.All we need to do is to search for
the row and column values of the face NumPy and array. This is the
array with the face rectangle coordinates.
Step 3: This final step involves displaying the image with the
rectangular face box.
opencv_contrib_python:
OpenCV (open source computer vision) is a very powerful library
for image processing and machine learning tasks which also
13
supports Tensorflow, Torch/Pytorch and Caffe. Install OpenCV
master, and OpenCV contrib files from source using Cmake GUI.
Pillow:
pillow is a Python Imaging Library (PIL), which adds support for
opening, manipulating, and saving images. The current version
identifies and reads a large number of formats. Write support is
intentionally restricted to the most commonly used interchange and
presentation formats.
Pandas:
Pandas is a Software Library in Computer Programming. It is
written for the Python Programming Language. They are used in
Python to deal with data analysis and manipulation. To put it in
simpler words, Pandas help us to organize data and manipulate
the data by putting it in a tabular form.
Datetime:
Date and time are not a data type of its own, but a module
named datetime can be imported to work with the date as well as
time. Datetime module comes built into Python, so there is no need
to install it externally.
14
CHAPTER 3:
15
HARDWARE AND SOFTWARE REQUIREMENTS
Hardware Requirements:
Software Requirements:
16
CHAPTER 4:
17
SOURCE CODE AND OUTPUT SNAPSHOTS
1. Face dataset
import cv2
import os
cam = cv2.VideoCapture(0)
cam.set(3, 640) # set video width
cam.set(4, 480) # set video height
18
for (x,y,w,h) in faces:
cv2.imshow('image', img)
# Do a bit of cleanup
print("\n [INFO] Exiting Program and cleanup stuff")
cam.release()
cv2.destroyAllWindows()
19
20
2. Face training
import cv2
import numpy as np
from PIL import Image #pillow package
import os
recognizer = cv2.face.LBPHFaceRecognizer_create()
detector =
cv2.CascadeClassifier("haarcascade_frontalface_default.
xml");
PIL_img = Image.open(imagePath).convert('L') #
convert it to grayscale
img_numpy = np.array(PIL_img,'uint8')
id = int(os.path.split(imagePath)[-
1].split(".")[1])
faces = detector.detectMultiScale(img_numpy)
21
faceSamples.append(img_numpy[y:y+h,x:x+w])
ids.append(id)
return faceSamples,ids
22
3. Face recognition
import cv2
import numpy as np
import os
recognizer = cv2.face.LBPHFaceRecognizer_create()
recognizer.read('trainer/trainer.yml') #load trained
model
cascadePath = "haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(cascadePath);
font = cv2.FONT_HERSHEY_SIMPLEX
while True:
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
faces = faceCascade.detectMultiScale(
gray,
scaleFactor = 1.2,
minNeighbors = 5,
minSize = (int(minW), int(minH)),
)
for(x,y,w,h) in faces:
id, confidence =
23
recognizer.predict(gray[y:y+h,x:x+w])
cv2.imshow('camera',img)
# Do a bit of cleanup
print("\n [INFO] Exiting Program and cleanup stuff")
cam.release()
cv2.destroyAllWindows()
24
4. Track image
import tkinter as tk
import cv2,os
import shutil
import csv
import numpy as np
import pandas as pd
import datetime
import time
window = tk.Tk()
window.title("Face_Recogniser")
dialog_title = 'QUIT'
#window.geometry('1280x720')
window.configure(background='blue')
#window.attributes('-fullscreen', True)
window.grid_rowconfigure(0, weight=1)
25
window.grid_columnconfigure(0, weight=1)
#path = "profile.jpg"
#img = ImageTk.PhotoImage(Image.open(path))
#cv_img = cv2.imread("img541.jpg")
#canvas.pack(side="left")
26
message = tk.Label(window, text="Face-Recognition-Based-Attendance-
Management-
System" ,bg="Green" ,fg="white" ,width=50 ,height=3,font=('times',
30, 'italic bold underline'))
message.place(x=200, y=20)
lbl.place(x=400, y=200)
txt.place(x=700, y=215)
lbl2.place(x=400, y=300)
txt2 =
tk.Entry(window,width=20 ,bg="yellow" ,fg="red",font=('times', 15,
' bold ') )
txt2.place(x=700, y=315)
lbl3.place(x=400, y=400)
message.place(x=700, y=400)
27
lbl3 = tk.Label(window, text="Attendance :
",width=20 ,fg="red" ,bg="yellow" ,height=2 ,font=('times', 15, '
bold underline'))
lbl3.place(x=400, y=650)
message2 = tk.Label(window,
text="" ,fg="red" ,bg="yellow",activeforeground = "green",width=30
,height=2 ,font=('times', 15, ' bold '))
message2.place(x=700, y=650)
def clear():
txt.delete(0, 'end')
res = ""
message.configure(text= res)
def clear2():
txt2.delete(0, 'end')
res = ""
message.configure(text= res)
def is_number(s):
try:
float(s)
return True
except ValueError:
pass
try:
import unicodedata
unicodedata.numeric(s)
28
return True
pass
return False
def TakeImages():
Id=(txt.get())
name=(txt2.get())
cam = cv2.VideoCapture(0)
harcascadePath = "haarcascade_frontalface_default.xml"
detector=cv2.CascadeClassifier(harcascadePath)
sampleNum=0
while(True):
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
sampleNum=sampleNum+1
cv2.imshow('frame',img)
29
break
elif sampleNum>60:
break
cam.release()
cv2.destroyAllWindows()
with open('StudentDetails\StudentDetails.csv','a+') as
csvFile:
writer = csv.writer(csvFile)
writer.writerow(row)
csvFile.close()
message.configure(text= res)
else:
if(is_number(Id)):
message.configure(text= res)
if(name.isalpha()):
message.configure(text= res)
def TrainImages():
recognizer = cv2.face_LBPHFaceRecognizer.create()#recognizer =
cv2.face.LBPHFaceRecognizer_create()#$cv2.createLBPHFaceRecognizer()
harcascadePath = "haarcascade_frontalface_default.xml"
detector =cv2.CascadeClassifier(harcascadePath)
faces,Id = getImagesAndLabels("TrainingImage2")
recognizer.train(faces, np.array(Id))
recognizer.save("C:\\Users\\hp\\PycharmProjects\\Major\\Face-
Recognition-Based-Attendance-System-master\\trainer\\trainer.yml")
30
res = "Image Trained"#+",".join(str(f) for f in Id)
message.configure(text= res)
def getImagesAndLabels(path):
#print(imagePaths)
faces=[]
Ids=[]
#now looping through all the image paths and loading the Ids and
the images
pilImage=Image.open(imagePath).convert('L')
imageNp=np.array(pilImage,'uint8')
Id=int(os.path.split(imagePath)[-1].split(".")[1])
faces.append(imageNp)
Ids.append(Id)
return faces,Ids
def TrackImages():
recognizer =
cv2.face.LBPHFaceRecognizer_create()#cv2.createLBPHFaceRecognizer()
recognizer.read("C:\\Users\\hp\\PycharmProjects\\Major\\Face-
Recognition-Based-Attendance-System-master\\trainer\\trainer.yml")
31
harcascadePath = "haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(harcascadePath);
df=pd.read_csv("StudentDetails\StudentDetails.csv")
cam = cv2.VideoCapture(0)
font = cv2.FONT_HERSHEY_SIMPLEX
col_names = ['Id','Name','Date','Time']
while True:
ret, im =cam.read()
gray=cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
faces=faceCascade.detectMultiScale(gray, 1.2,5)
for(x,y,w,h) in faces:
cv2.rectangle(im,(x,y),(x+w,y+h),(225,0,0),2)
ts = time.time()
date =
datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d')
timeStamp =
datetime.datetime.fromtimestamp(ts).strftime('%H:%M:%S')
aa=df.loc[df['Id'] == Id]['Name'].values
tt=str(Id)+"-"+aa
attendance.loc[len(attendance)] =
[Id,aa,date,timeStamp]
else:
Id='Unknown'
tt=str(Id)
noOfFile=len(os.listdir("ImagesUnknown"))+1
32
cv2.imwrite("ImagesUnknown\Image"+str(noOfFile) +
".jpg", im[y:y+h,x:x+w])
attendance=attendance.drop_duplicates(subset=['Id'],keep='first')
cv2.imshow('im',im)
if (cv2.waitKey(1)==ord('q')):
break
ts = time.time()
date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d')
timeStamp = datetime.datetime.fromtimestamp(ts).strftime('%H:%M:
%S')
Hour,Minute,Second=timeStamp.split(":")
fileName="Attendance\
Attendance_"+date+"_"+Hour+"-"+Minute+"-"+Second+".csv"
attendance.to_csv(fileName,index=False)
cam.release()
cv2.destroyAllWindows()
#print(attendance)
res=attendance
message2.configure(text= res)
clearButton.place(x=950, y=200)
clearButton2.place(x=950, y=300)
33
takeImg.place(x=200, y=500)
trainImg.place(x=500, y=500)
trackImg.place(x=800, y=500)
quitWindow.place(x=1100, y=500)
copyWrite.tag_configure("superscript", offset=10)
copyWrite.configure(state="disabled",fg="red" )
copyWrite.pack(side="left")
copyWrite.place(x=800, y=750)
window.mainloop()
5. Attendance marking
34
35
36
CHAPTER-5
CONCLUSION
37
CONCLUSION
Face recognition is an emerging technology that can provide many benefits. Face
recognition can save resources and time, and even generate new income streams, for
companies that implement it right.
It’s difficult to be certain. Some experts predict that our faces will replace IDs, passports
and credit card pin numbers. Given the fact how convenient and cost-effective this
technology is, this prediction is not far-fetched.
If this prediction becomes a reality, any company that implemented the technology today
might gain a competitive advantage in the future.
Marking of attendance through face recognition can be very helpful when it comes to
appropriate and highly secured attendance.
In this type of attendance system, there are very few chances of marking the attendance
through proxies.
Hence, it can turn as the most secure way of marking the attendance.
38
CHAPTER-6
FUTURE SCOPE
39
FUTURE SCOPE
Today, one of the fields that uses facial recognition the most is security. Facial recognition
is a very effective tool that can help law enforcers recognize criminals and software
companies are leveraging the technology to help users access their technology. This
technology can be further developed to be used in other avenues such as ATMs, accessing
confidential files, or other sensitive materials. This can make other security measures such
as passwords and keys obsolete.
Another way that innovators are looking to implement facial recognition is within subways
and other transportation outlets. They are looking to leverage this technology to use faces
as credit cards to pay for your transportation fee. Instead of having to go to a booth to buy
a ticket for a fare, the face recognition would take your face, run it through a system, and
charge the account that you’ve previously created. This could potentially streamline the
process and optimize the flow of traffic drastically. The future is here.
As we took forward this project to connecting with attendance system, it turned out to be
so helpful.
Further, an app can be created for this whole process and can be used in schools, colleges
and other institutions. Or even in offices, malls, shops for marking the presence of the
employees.
40
BIBLOGRAPHY
1. https://facedetection.com/datasets/
2. https://docs.microsoft.com/en-us/azure/cognitive-services/Face/Overview
3. https://en.wikipedia.org/wiki/Facial_recognition_system
4. https://www.datacamp.com/community/tutorials/face-detection-python-opencv
5. Beymer, D. and Poggio, T. (1995) Face Recognition From One Example View,
A.I. Memo No. 1536, C.B.C.L. Paper No. 121. MIT
6. Goldstein, A.J., Harmon, L.D., and Lesk, A.B. (1971). Identification of human
faces. In Proc. IEEE, Vol. 59, page 748
41