-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhmm.py
More file actions
50 lines (39 loc) · 1.49 KB
/
hmm.py
File metadata and controls
50 lines (39 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from datetime import date
import mysql.connector
import pickle
# Establish connection
conn = mysql.connector.connect(
host="sql6.freesqldatabase.com",
user="sql6702179",
password="eN5Tlp8Dky",
database="sql6702179"
)
def get_today_present(x=0):
cursor = conn.cursor()
if x == 0:
cursor.execute(f"SELECT username FROM attendance WHERE date = '{date.today()}' AND status = 'present'")
else:
cursor.execute(f"SELECT username FROM attendance WHERE date = '{date.today()}' AND status = 'absent'")
students_tuples = cursor.fetchall()
students = [student[0] for student in students_tuples]
cursor.close()
return students
attendance_taken = get_today_present()
def get_face_encodings():
cursor = conn.cursor()
cursor.execute("SELECT username, face_encodings FROM students")
face_encodings = cursor.fetchall()
cursor.close()
encodings_dict = {}
for username, encoding_blob in face_encodings:
encodings_dict[username] = pickle.loads(encoding_blob)
return encodings_dict
def mark_attendance(username, status):
cursor = conn.cursor()
cursor.execute("INSERT INTO attendance (username, date, status) VALUES (%s, %s, %s)",
(username, date.today(), status))
conn.commit()
cursor.close()
known_face_encodings = get_face_encodings()
known_face_encodings_list = list(known_face_encodings.values())
known_face_names = list(known_face_encodings.keys())