Dataset
Dataset
count = 0
while count < 30:
ret, frame = cap.read()
if not ret:
break
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = haar.detectMultiScale(gray, scaleFactor=1.3,
minNeighbors=5)
cap.release()
cv2.destroyAllWindows()
image_paths = []
labels = []
label_map = {}
current_id = 0
for folder in os.listdir(dataset_path):
folder_path = os.path.join(dataset_path, folder)
if os.path.isdir(folder_path):
label_map[current_id] = folder
for image_file in os.listdir(folder_path):
image_path = os.path.join(folder_path, image_file)
gray_image = Image.open(image_path).convert('L')
img_np = np.array(gray_image, 'uint8')
faces = detector.detectMultiScale(img_np)
for (x, y, w, h) in faces:
face_roi = img_np[y:y+h, x:x+w]
image_paths.append(face_roi)
labels.append(current_id)
current_id += 1
recognizer.train(image_paths, np.array(labels))
recognizer.save(model_save)
return label_map
face_cascade =
cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
cap.release()
cv2.destroyAllWindows()
python
CopyEdit
import pandas as pd
import datetime
if not os.path.exists(excel_path):
df = pd.DataFrame(columns=["Name", "Date", "Time"])
else:
df = pd.read_excel(excel_path)
python
CopyEdit
import smtplib
from email.message import EmailMessage
if not absentees:
return
message = EmailMessage()
message['Subject'] = f"Absentee List - {today}"
message['From'] = "[email protected]"
message['To'] = faculty_email
message.set_content("Absent Students:\n" + "\n".join(absentees))
Would you like me to generate the corresponding HTML templates (student upload,
attendance view, report page), or a one-click .bat or .sh launcher?
You said:
yes
ChatGPT said:
Memory updated
Great! Let's start with the HTML templates first. I’ll give you the three main templates for:
1. Dashboard (dashboard.html)
2. Student Management (students.html)
3. Attendance Management (attendance.html)
4. Report View (report.html)
templates/dashboard.html
html
CopyEdit
<!DOCTYPE html>
<html>
<head>
<title>Dashboard</title>
</head>
<body>
<h1>Attendance System</h1>
<ul>
<li><a href="/students">Manage Students</a></li>
<li><a href="/lecturers">Manage Lecturers</a></li>
<li><a href="/attendance">View Attendance</a></li>
<li><a href="/report">Generate Report</a></li>
</ul>
</body>
</html>
👩🎓 templates/students.html
html
CopyEdit
<!DOCTYPE html>
<html>
<head>
<title>Students</title>
</head>
<body>
<h2>Student Management</h2>
<form method="POST" action="/add_student">
Student ID: <input type="text" name="student_id" required><br>
Name: <input type="text" name="name" required><br>
<button type="submit">Add Student (Capture Image)</button>
</form>
<h3>Registered Students</h3>
<ul>
{% for student in students %}
<li>
{{ student['Student ID'] }} - {{ student['Name'] }}
<a href="/delete_student/{{ student['Student ID']
}}">Delete</a>
</li>
{% endfor %}
</ul>
</body>
</html>
📅 templates/attendance.html
html
CopyEdit
<!DOCTYPE html>
<html>
<head>
<title>Attendance Records</title>
</head>
<body>
<h2>Attendance Records</h2>
<table border="1">
<thead>
<tr>
<th>Student ID</th>
<th>Name</th>
<th>Subject</th>
<th>Lecturer</th>
<th>Session Time</th>
<th>Duration</th>
<th>Date</th>
</tr>
</thead>
<tbody>
{% for row in attendance %}
<tr>
<td>{{ row['Student ID'] }}</td>
<td>{{ row['Name'] }}</td>
<td>{{ row['Subject'] }}</td>
<td>{{ row['Lecturer'] }}</td>
<td>{{ row['Session Time'] }}</td>
<td>{{ row['Duration'] }}</td>
<td>{{ row['Date'] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>
📊 templates/report.html
html
CopyEdit
<!DOCTYPE html>
<html>
<head>
<title>Absentee Report</title>
</head>
<body>
<h2>Absentee Summary - {{ date }}</h2>
<table border="1">
<thead>
<tr>
<th>Subject</th>
<th>Absentees Count</th>
</tr>
</thead>
<tbody>
{% for subject, count in report.items() %}
<tr>
<td>{{ subject }}</td>
<td>{{ count }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>