0% found this document useful (0 votes)
2 views42 pages

Project File

The document outlines the development of a Real-Time Visual Pattern Recognition system for analyzing human presence, utilizing AI and computer vision techniques. It details the system architecture, existing manual attendance systems, and the advantages of the proposed automated solution, which enhances efficiency and accuracy in attendance tracking. Future enhancements include database integration and mobile support, making it suitable for various controlled environments.

Uploaded by

hsrinithi05
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views42 pages

Project File

The document outlines the development of a Real-Time Visual Pattern Recognition system for analyzing human presence, utilizing AI and computer vision techniques. It details the system architecture, existing manual attendance systems, and the advantages of the proposed automated solution, which enhances efficiency and accuracy in attendance tracking. Future enhancements include database integration and mobile support, making it suitable for various controlled environments.

Uploaded by

hsrinithi05
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1

Project Title:

Real-Time Visual
Pattern Recognition
for Human Presence
Analysis

2
CONTENT

SERIA PARTICULARS PAG


L NO E
NO

1 ABSTRACT 6

2 INTRODUCTION 7

3 SYSTEM ARCHITECTURE 8

4 EXISTING SYSTEM 9

5 PROPOSED SYSTEM 10

6 HARDWARE AND SOFTWARE 11


SPECIFICATION

7 CODING 12

8 OUTPUT SCREEN 27

9 FUTURE ENHANCEMENT 29

10 CONCLUSION 30

3
ABSTRACT

The Real-Time Visual Pattern Recognition for Human Presence


Analysis system is an AI-based application designed to identify and
analyze human presence using computer vision and machine
learning techniques. The system is developed using the Flask
framework (Python) for backend processing and OpenCV for real-
time visual pattern detection and recognition, along with a web-
based interface (HTML, CSS) for system interaction. Authorized
users are enrolled into the system by capturing their visual identity,
which is stored as grayscale image patterns in a structured dataset.
When an individual appears in front of the camera, the system
detects and recognizes the visual patterns in real time and
automatically logs the presence information into a locally
maintained record file. The system also generates summarized
presence reports and supports real time monitoring. This approach
improves operational efficiency, accuracy, and security by
minimizing manual involvement and reducing identification errors.
The project highlights the practical application of artificial
intelligence and computer vision in automating presence analysis
and identity verification tasks. Future enhancements include
integration with a database for large-scale environments, mobile
platform support, and a real time analytics dashboard for advanced
presence trend analysis. Overall, the system provides a scalable
and reliable solution for controlled environments such as
institutions and workplaces.

4
INTRODUCTION

In traditional attendance tracking systems, manual methods such


as roll calls or ID card swiping are time-consuming, inefficient, and
prone to errors. To address these challenges, we have developed
an AI-powered Facial Recognition Attendance System that
automates the process using computer vision and machine
learning.

Our system leverages Flask for backend processing, OpenCV for


face detection and recognition, and a web interface for user
interaction. By detecting and recognizing faces in real-time, it
accurately marks attendance and stores the data for future
reference.

This solution enhances efficiency, reduces manual workload, and


minimizes fraudulent practices like proxy attendance. With
features like automatic face registration, live recognition, and
attendance reporting, it provides a seamless and reliable approach
to attendance management.

5
SYSTEM ARCHITECTURE
[Link] Layer

a. Main Page ([Link]) – Provides login options for Admin and


User

b. Admin Page ([Link]) – Calculates user attendance

c. User Page ([Link]) – Displays live video feed, Registers


new users and Marks attendance

2. Backend Layer
Flask Routes:

Route Purpose

/ Renders the main page

/user Displays user interface

/admin Displays admin interface

/video_feed Streams video from webcam

/register Registers new face

/mark_attendance_route Marks attendance

/calculate_attendance Calculates attendance stats

3. Data Layer
a. Face Data: Stored in registered_faces/ directory as grayscale
images
b. Attendance Data: Stored in yearly_attendance.csv,
Updated automatically after marking attendance

6
EXISTING SYSTEM

1. Manual Roll Call:

 Time-consuming and error-prone.


 Difficult to track large groups.

2. Card-Based Systems:

 Uses RFID or magnetic stripe cards.


 Prone to loss, damage, or misuse.

3. Biometric Systems:

 Fingerprint or iris-based systems.


 Requires physical contact, increasing hygiene concerns.
 Hardware maintenance and accuracy issues.

Limitations:

 Time-consuming process.
 High possibility of proxy attendance.
 Requires physical infrastructure and maintenance.
 Difficult to generate real-time reports.

7
PROPOSED SYSTEM
1. Face Recognition-Based Attendance:

o Uses OpenCV for real-time face detection and recognition.

o Contactless and automatic process.

2. Web-Based Interface:

o Developed using Flask for backend processing.

o HTML + CSS for a responsive user-friendly interface.

3. Centralized Data Storage:

o Stores attendance data in a CSV file (Future scope:


Database integration).

o Allows easy generation of attendance summaries.

4. Automated Reporting:

o Generates real-time attendance reports.

o Provides attendance statistics and percentages.

Advantages:

 Fast and accurate face recognition.


 Eliminates proxy attendance.
 User-friendly and contactless.
 Real-time tracking and reporting.
 Scalable and secure.

8
HARDWARE AND SOFTWARE
SPECIFICATIONS

Hardware Specifications:
 Processor : x64-based processor
 RAM : 4.00 GB and above
 Hard Disk : 300 GB and above

Software Specifications:

 Operating System : Windows 10 (64 bit)


 Front-End : HTML & CSS
 Backend : Python
 Tools : VS Code

9
CODING

[Link]:
[Link]
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-image:
url('../static/[Link]'); background-
size: cover;
background-position: center;
height: 100vh;
display: flex;
justify-content:
center; align-items:
center; color:
#b0c4de;
}
.container
{ display:
flex; width:
80%;
max-width: 1200px;
height: 60%;
background-color:
transparent; border-
radius: 12px;
10
overflow: hidden;
}
.container1
{ display:
flex;

11
align-items: center;
gap: 20px;
}
.left-column, .right-
column { flex: 1;
background-color:
transparent; display: flex;
justify-content:
center; align-items:
center;
}
.right-column {
flex-direction:
column; align-
items: flex-start;
padding: 40px;
}
h1 {
font-size: 2.5rem;
margin-bottom:
20px; color:
#c0c0c0;
text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5);
}
.button, .btn, button
{ padding: 12px
24px;
background-color: rgba(30, 144, 255,
0.8); color: #ffffff;
12
border: none;
border-radius:
8px; cursor:
pointer; font-
size: 1rem;

13
transition: background-color 0.3s
ease; box-shadow: 0 2px 6px
rgba(0, 0, 0, 0.3);
}
.button:hover, .btn:hover,
button:hover { background-color:
rgba(70, 130, 180, 0.8);
}
input,
button{ pad
ding: 10px;
font-size:
16px;
border: 1px solid
#ccc; border-
radius: 4px;
outline: none;
}
#camera-container
{ border: 2px solid
black; width: 640px;
height: 480px;
display: block;
}
.controls
{ display:
flex;
flex-direction: column;
gap: 10px;
14
}
#message {
margin-top: 10px;
}

[Link]
<!DOCTYPE html>

15
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<link rel="stylesheet" href="{{ url_for('static', filename='[Link]')
}}">
<title>Attendance System</title>
<script>
function handleUserClick(event) {
[Link]();
[Link]='{{ url_for("user_page") }}';
}

function handleAdminClick(event) {
[Link]();
[Link]='{{ url_for("admin_page") }}';
}
</script>
</head>
<body >
<div class="container">
<div class="left-column"></div>
<div class="right-column">
<h1>Face Recognition Attendance System</h1>
<div class="button-container">
<button class="btn"
onclick="handleAdminClick(event)">Admin</button>
<button class="btn"
onclick="handleUserClick(event)">User</button>
16
</div>

17
</div>
</div>
</body>
</html>

[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<link rel="stylesheet" href="{{ url_for('static', filename='[Link]')
}}">
<title>User Attendance</title>
<script>
function calculate_attendance(event) {
[Link]();
const name =
[Link]('input[name="name"]').value;
fetch('{{ url_for("calculate_attendance") }}', {
method:
'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({ 'name': name })
})
.then(response => [Link]())
.then(data => {

18
[Link]('message').innerText = [Link];
});
}
</script>

19
</head>
<body>
<div class="container">
<div class="left-column"></div>
<div class="right-column">
<h1>Calculate Attendance</h1>
<form onsubmit="calculate_attendance(event)">
<input type="text" name="name" placeholder="Enter
name" required>
<button type="submit">Calculate</button>
</form>
<p id="message"></p>
</div>
</div>
</body>
</html>

[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<link rel="stylesheet" href="{{ url_for('static', filename='[Link]')
}}">
<title>User Attendance</title>
<script>
function registerFace(event) {
[Link]();

20
const name =
[Link]('input[name="name"]').value;
fetch('{{ url_for("register") }}', {

21
method:
'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({ 'name': name })
})
.then(response => [Link]())
.then(data => {
[Link]('message').innerText = [Link];
});
}

function markAttendance(event) {
[Link]();
fetch('{{ url_for("mark_attendance_route"
) }}', { method: 'POST',
})
.then(response => [Link]())
.then(data => {
[Link]('message').innerText =
[Link];
});
}
</script>
</head>
<body>
<div class="container1">
<div id="camera-container">

22
<img src="{{ url_for('video_feed') }}" alt="Video Feed">
</div>

23
<div class="controls">
<h1>Mark Attendance</h1>
<form onsubmit="registerFace(event)">
<input type="text" name="name" placeholder="Enter
name to register" required>
<button type="submit">Register Face</button>
</form>
<form onsubmit="markAttendance(event)">
<button type="submit">Mark Attendance</button>
</form>
<p id="message"></p>
</div>
</div>
</body>
</html

import cv2
import os
import pandas as pd
import numpy as np

registered_faces_dir =
"registered_faces" attendance_file =
"yearly_attendance.csv"

face_cascade = [Link]([Link] +
"haarcascade_frontalface_default.xml")

24
if not [Link](registered_faces_dir):
[Link](registered_faces_dir)

def initialize_yearly_attendance():
if not [Link](attendance_file):
registered_faces = load_registered_faces()
df = [Link]({"Name": list(registered_faces.keys())})
df.to_csv(attendance_file, index=False)

def load_registered_faces():
registered_faces = {}
for filename in
[Link](registered_faces_dir): if
[Link]((".jpg", ".png")):
name = [Link](filename)[0]
filepath = [Link](registered_faces_dir,
filename) image = [Link](filepath, 0)
registered_faces[name] = image
return registered_faces

registered_faces =

load_registered_faces() def

recognize_face(detected_face):
detected_face = [Link](detected_face, (100,
100)) detected_face =
[Link](detected_face) registered_faces =
load_registered_faces()

25
for name, face in registered_faces.items():
face_resized = [Link](face, (100, 100))
face_normalized =
[Link](face_resized)

26
diff = [Link](detected_face,
face_normalized) score = [Link](diff)

if score < 50:


return name
return "Unknown"

def mark_attendance(name,
date): df =
pd.read_csv(attendance_file)

if date not in [Link]:


df[date] = "Absent"

if name in df["Name"].values:
[Link][df["Name"] == name, date] =
"Present"
msg = f"Attendance marked for {name} on
{date}.\n" elif name not in df["Name"].values:
new_entry = {"Name": name}
df = [Link](new_entry,
ignore_index=True) [Link][df["Name"] ==
name, date] = "Present"
msg = f"Attendance marked for {name} on
{date}.\n" else:
msg = f"Error: {name} not found in registered faces."
df.to_csv(attendance_file, index=False)
return msg
27
def
calculate_attendance_stats(nam
e): if not
[Link](attendance_file):

28
return

df =
pd.read_csv(attendance_file)
if name not in
df["Name"].values:
msg = f"No attendance data found for
{name}." return msg

person_data = [Link][df["Name"] == name]


total_days = len([Link]) - 1
present_days = (person_data ==
"Present").sum(axis=1).values[0] percentage = (present_days /
total_days) * 100 if total_days > 0 else 0

msg = f"Attendance Summary for {name}:\nTotal Days:


{total_days}\nDays Present: {present_days}\nAttendance Percentage:
{percentage:.2f}%"
return msg

def
add_name_to_attendance(name):
df = pd.read_csv(attendance_file)
if name not in df["Name"].values:
df = [Link]([df, [Link]({"Name": [name]})],
ignore_index=True)
df.to_csv(attendance_file, index=False)
msg = f"Added {name} to the attendance
file." else:
29
msg = f"{name} is already in the
attendance file." return msg

[Link]
from flask import Flask, render_template, Response, request, redirect,
url_for, jsonify

30
import cv2
import os
from datetime import
datetime import numpy as
np
from face_recognition import registered_faces, mark_attendance,
calculate_attendance_stats, recognize_face,
add_name_to_attendance, initialize_yearly_attendance,
registered_faces_dir

app = Flask( name )

# Initialize attendance
initialize_yearly_attendance()
face_cascade = [Link]([Link] +
"haarcascade_frontalface_default.xml")

# Global variables for video


capture video_capture =
[Link](0) output_frame
= None name="Unknown"

@[Link]('/')
def index():
return render_template('[Link]')

@[Link]('/
user') def
user_page():
31
return render_template('[Link]')

@[Link]('/admin')

32
def admin_page():
return render_template('[Link]')

@[Link]('/video_feed')
def video_feed():
"""Stream video feed to the
browser.""" def generate_frames():
global
output_frame
while True:
ret, frame =
video_capture.read() if not
ret:
brea
k else:
ret, buffer = [Link]('.jpg',
frame) frame = [Link]()
frame_array = [Link]([Link](frame,
np.uint8), cv2.IMREAD_COLOR)
gray_frame = [Link](frame_array,
cv2.COLOR_BGR2GRAY) faces =
face_cascade.detectMultiScale(gray_frame,
scaleFactor=1.1,
minNeighbors=5, minSize=(100, 100))

for (x, y, w, h) in faces:


face_roi = gray_frame[y:y+h,
x:x+w] name =
recognize_face(face_roi)
33
[Link](frame_array, (x, y), (x+w, y+h), (0, 255, 0),
2) [Link](frame_array, name, (x, y-10),
cv2.FONT_HERSHEY_SIMPLEX, 0.8, (255, 255, 255), 2)

output_frame = frame_array.copy()

34
_, encoded_image = [Link]('.jpg',
output_frame) yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' +
bytearray(encoded_image) +
b'\r\n')

return Response(generate_frames(), mimetype='multipart/x-mixed-


replace; boundary=frame')

@[Link]('/register',
methods=['POST']) def register():
"""Register a new face."""
name =
[Link]('name').strip() if
not name:
return redirect(url_for('index1'))

ret, frame = video_capture.read()


gray_frame = [Link](frame, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray_frame,
scaleFactor=1.1, minNeighbors=5, minSize=(100, 100))

if len(faces) > 0:
x, y, w, h = faces[0]
face_to_register = gray_frame[y:y+h, x:x+w]
file_path = [Link](registered_faces_dir, f"{name}.jpg")
[Link](file_path, face_to_register)
message =
add_name_to_attendance(name) else:
35
message = "No face detected. Try again."

36
return jsonify(message=message)

@[Link]('/mark_attendance_route',
methods=['POST']) def mark_attendance_route():
"""Mark attendance for recognized
faces.""" global output_frame
if output_frame is not None:
gray_frame = [Link](output_frame,
cv2.COLOR_BGR2GRAY) faces =
face_cascade.detectMultiScale(gray_frame, scaleFactor=1.1,
minNeighbors=5, minSize=(100, 100))
today_date = [Link]().strftime("%Y-%m-%d")

for (x, y, w, h) in faces:


face_roi = gray_frame[y:y+h,
x:x+w] name =
recognize_face(face_roi)
if name != "Unknown":
message = mark_attendance(name,
today_date) return jsonify(message=message)

@[Link]('/calculate_attendance',
methods=['POST']) def calculate_attendance():
name = [Link]('name').strip()
message =
calculate_attendance_stats(name) return
jsonify(message=message)

if name == '
37
main ':
[Link](debug=True)

38
OUTPUT SCREEN

Admin :

39
User :

40
FUTURE ENHANCEMENT
[Link] Integration

 Replace CSV with MySQL or PostgreSQL for better data


consistency and faster retrieval.
 Use SQLAlchemy for efficient handling of large datasets.

2. Real-Time Analytics

 Add a dashboard using [Link] or Plotly to display attendance


stats.
 Include daily, weekly, and monthly attendance reports.

3. Improved Face Recognition

 Use a deep learning model like FaceNet for higher accuracy.


 Implement data augmentation (rotation, scaling) to improve
recognition in different lighting conditions.

4. Cloud-Based Storage

 Migrate data to AWS or Google Cloud for scalability and


accessibility.
 Ensure secure data backup and faster response times.

5. Notification System

 Send email/SMS notifications for daily attendance


status and low attendance alerts.
 Improve user engagement and real-time updates.

6. Multi-Camera Support

 Enable multiple camera streams using OpenCV’s multi-


threading capability.
 Expand coverage and improve recognition accuracy.

41
CONCLUSION
The Smart Attendance Tracker successfully automates
attendance tracking using AI-powered facial recognition. By
leveraging Flask for backend processing, OpenCV for real-time
face detection and recognition, and a user- friendly HTML + CSS
interface, the system offers a reliable and efficient solution for
managing attendance.

The system reduces manual workload, eliminates errors, and


prevents proxy attendance by accurately recognizing faces and
storing data in a structured format. The ability to calculate
attendance summaries and display real-time reports enhances
operational efficiency.

Future enhancements such as database integration, real-time


analytics, and improved face recognition models will further
increase scalability, accuracy, and user experience. By combining
AI, machine learning, and cloud technologies, this system provides
a modern and secure approach to attendance management.

The Smart Attendance Tracker is a scalable and intelligent solution


that modernizes attendance tracking and improves operational
efficiency!

42

You might also like