Final Project Draft
Final Project Draft
<Title>
1. Objective(s):
To design and develop a facial recognition system for identifying and tracking individuals registered in the
system.
To enhance security by ensuring accurate identification through facial recognition technology.
To automate the attendance process to save time and reduce manual work.
3. Discussion:
Facial recognition technology leverages computer vision and machine learning to identify individuals based on
their unique facial features. By combining this with an Arduino-controlled hardware system, we can achieve an
efficient and secure identification process.
Hardware:
Camera (Webcam)
Computer
Software:
OpenCV Library
Python Programming Language
Visual Studio Code
5. Procedure:
Data Collection:
Capture facial data from registered individuals by taking a picture in multiple angles
Ensure proper lighting conditions to improve detection accuracy.
Preprocessing:
Apply image enhancement techniques such as normalization, and face alignment to improve accuracy.
Feature Extraction:
Develop a structured database to securely store facial data and attendance records.
Identification Process:
Design a Python program that compares detected faces with the stored data for identification.
SOURCE CODE:
import os
import cv2
import numpy as np
import face_recognition
import customtkinter as ctk
from PIL import Image, ImageTk
from datetime import datetime
import threading
import pywinstyles
# Initialize theme
ctk.set_appearance_mode("Dark")
ctk.set_default_color_theme("dark-blue")
# Locate directories
directories = os.path.dirname(os.path.abspath(_file_))
students_dir = os.path.join(directories, "Images", "Students")
attendance_path = os.path.join(directories, "Attendance.csv")
# Prepare attendance file
if not os.path.isdir(students_dir):
raise FileNotFoundError(f"Student images folder not found: {students_dir}")
if not os.path.isfile(attendance_path):
with open(attendance_path, "w") as f:
f.write("Name,Timestamp\n")
# Attendance function
def markAttendance(name):
with open(attendance_path, "r+", newline="") as f:
entries = f.readlines()
names = [e.split(',')[0] for e in entries]
if name not in names:
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
f.write(f"{name},{now}\n")
print(f"Marked {name} at {now}")
# GUI Application
class AttendanceApp(ctk.CTk):
def __init__(self):
super().__init__()
self.title("Face Recognition Attendance")
self.geometry("900x500")
pywinstyles.apply_style(self, style="mica")
self.unknown_count = 0
self.present_students = set()
# Camera frame
self.camera_frame = ctk.CTkFrame(self, corner_radius=15)
self.camera_frame.grid(row=0, column=0, padx=20, pady=20)
self.img_label = ctk.CTkLabel(self.camera_frame, text="")
self.img_label.pack()
# Control panel
self.control_panel = ctk.CTkFrame(self, width=300, corner_radius=15)
self.control_panel.grid(row=0, column=1, sticky="nsew", padx=10, pady=20)
self.protocol("WM_DELETE_WINDOW", self.on_closing)
self.cap = None
self.running = False
def start_camera(self):
if self.running: return
self.cap = cv2.VideoCapture(0)
if not self.cap.isOpened():
self.status_label.configure(text="Status:\nFailed to open camera.")
return
self.running = True
self.status_label.configure(text="Status:\nCamera running.")
threading.Thread(target=self.update_frame, daemon=True).start()
def update_frame(self):
THRESHOLD = 0.55
while self.running:
ret, frame = self.cap.read()
if not ret: break
# Draw
cv2.rectangle(frame, (left, top), (right, bottom), (255, 165, 0), 2)
cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (255, 165, 0), cv2.FILLED)
cv2.putText(frame, name, (left + 6, bottom - 6),
cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
self.cap.release()
def stop_camera(self):
if not self.running: return
self.running = False
self.status_label.configure(text="Status:\nCamera stopped.")
def on_closing(self):
self.stop_camera()
self.destroy()
if _name_ == '_main_':
app = AttendanceApp()
app.mainloop()
6. Output
<pic>
<description>
7. Conclusion:
This project successfully combines facial recognition technology to deliver a secure and automated identification
system. The integration of these technologies ensures improved security, efficiency, and accuracy in tracking
attendance and controlling access. By implementing this system, organizations can streamline attendance
management while enhancing overall security measures.
8. References