Skip to content

Commit ff41fa8

Browse files
committed
Adding requirements.txt and students.csv
1 parent d63f547 commit ff41fa8

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

main.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import os
22
import pickle
33
import cv2
4+
import face_recognition_models
45
import face_recognition
56
import cvzone
67
import numpy as np
78
from datetime import datetime
8-
9+
import csv
910

1011
cap = cv2.VideoCapture(0)
1112
cap.set(3, 640)
@@ -26,8 +27,18 @@
2627
encodeListKnownWithIds = pickle.load(file)
2728
file.close()
2829
encodeListKnown, studentIds = encodeListKnownWithIds
29-
#print(studentIds)
30+
# print(studentIds)
31+
32+
# Load data from csv
33+
students = []
34+
with open('students.csv', mode='r') as csv_file:
35+
csv_reader = csv.DictReader(csv_file)
36+
for row in csv_reader:
37+
students.append(row)
3038

39+
modeType = 0
40+
counter = 0
41+
id = -1
3142

3243
while True:
3344
success, img = cap.read()
@@ -41,23 +52,22 @@
4152
imgBackground[162:162 + 480, 55:55 + 640] = img
4253
imgBackground[44:44 + 633, 808:808 + 414] = imgModeList[0]
4354

44-
4555
for encodeFace, faceLoc in zip(encodeCurFrame, faceCurFrame):
4656
matches = face_recognition.compare_faces(encodeListKnown, encodeFace)
4757
faceDis = face_recognition.face_distance(encodeListKnown, encodeFace)
48-
# print("matches", matches)
49-
# print("faceDis", faceDis)
58+
# print("matches", matches)
59+
# print("faceDis", faceDis)
5060

5161
matchIndex = np.argmin(faceDis)
52-
# print("Match Index", matchIndex)
62+
# print("Match Index", matchIndex)
5363
if matches[matchIndex]:
5464
y1, x2, y2, x1 = faceLoc
5565
y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
5666
bbox = 55 + x1, 162 + y1, x2 - x1, y2 - y1
5767
imgBackground = cvzone.cornerRect(imgBackground, bbox, rt=0)
58-
59-
68+
id = studentIds[matchIndex]
6069

6170
# cv2.imshow("Face Attendance", img)
6271
cv2.imshow("Face Attendance", imgBackground)
63-
cv2.waitKey(1)
72+
cv2.waitKey(1)
73+

requirements.txt

1.1 KB
Binary file not shown.

students.csv

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
id,name,total_attendance,major,standing,year,starting_year,last_attendance_time
2+
1,Emily Blunt,0,Acting,Freshman,2023,2023-09-01 08:00:00
3+
2,Elon Musk,0,Engineering,Sophomore,2022,2022-08-15 10:30:00
4+
3,Sam Altman,0,Computer Science,Senior,2022,2022-09-01 09:45:00
5+
4,Jeff Bezos,0,Business Administration,Junior,2022,2022-09-01 10:15:00
6+
5,Mark Zuckerberg,0,Computer Science,Sophomore,2023,2023-09-01 11:30:00
7+
6,Sundar Pichai,0,Computer Engineering,Junior,2022,2022-09-01 12:45:00
8+
7,Tim Cook,0,Computer Science,Senior,2022,2022-09-01 14:00:00
9+
8,Jack Ma,0,Business Administration,Sophomore,2023,2023-09-01 15:15:00
10+
9,Bill Gates,0,Computer Science,Senior,2022,2022-09-01 16:30:00
11+
10,Larry Page,0,Computer Science,Junior,2022,2022-09-01 17:45:00

0 commit comments

Comments
 (0)