Compare commits
No commits in common. "5e019fef2063c0cc71ed8b7d33c475a4da46d07b" and "0a7ee559d8c5627df85f160355af602f9fac326b" have entirely different histories.
5e019fef20
...
0a7ee559d8
|
@ -1,23 +0,0 @@
|
|||
import paho.mqtt.client as mqtt
|
||||
|
||||
BASE_TOPIC = "/facescan"
|
||||
|
||||
class access_control:
|
||||
def __init__(self, serial_port: str):
|
||||
pass
|
||||
|
||||
def light_on(self):
|
||||
pass
|
||||
def light_off(self):
|
||||
pass
|
||||
def get_door_state(self) -> bool:
|
||||
pass
|
||||
|
||||
def get_scan_state(self) -> bool:
|
||||
pass
|
||||
|
||||
def lock_door(self):
|
||||
pass
|
||||
|
||||
def unlock_door(self):
|
||||
pass
|
|
@ -1,71 +0,0 @@
|
|||
import mysql.connector as sql
|
||||
from dataclasses import dataclass
|
||||
|
||||
HOST = "192.168.0.239"
|
||||
USER = "detector"
|
||||
PASSWORD = "n9ZvEmZ7xSKE7cPx"
|
||||
|
||||
@dataclass
|
||||
class Person():
|
||||
id: int
|
||||
name: str
|
||||
surname: str
|
||||
imagefile: str
|
||||
|
||||
@dataclass
|
||||
class Student(Person):
|
||||
pass
|
||||
|
||||
@dataclass
|
||||
class Parent(Person):
|
||||
pass
|
||||
|
||||
class database:
|
||||
db = None
|
||||
cursor = None
|
||||
def __init__(self) -> None:
|
||||
self.db = sql.connect(host=HOST,user =USER,password=PASSWORD,database="face_detect")
|
||||
self.cursor = self.db.cursor()
|
||||
pass
|
||||
def get_student_info(self, filename: str) -> Student:
|
||||
statement = (f'SELECT * FROM students WHERE imagefile=\"{filename}\"')
|
||||
self.cursor.execute(statement)
|
||||
result = self.cursor.fetchone()
|
||||
if len(result) == 0:
|
||||
return None
|
||||
student = Student(result[0],result[1],result[2],result[3])
|
||||
return student
|
||||
def get_parent_info(self, filename: str):
|
||||
statement = (f'SELECT * FROM parents WHERE imagefile=\"{filename}\"')
|
||||
self.cursor.execute(statement)
|
||||
result = self.cursor.fetchone()
|
||||
if len(result) == 0:
|
||||
return None
|
||||
parent = Parent(result[0],result[1],result[2],result[3])
|
||||
return parent
|
||||
def check_relationship_file(self, student_filename: str, parent_filename: str):
|
||||
statement = f'SELECT id FROM `parent-student-relations` psr WHERE psr.student_id = (SELECT id FROM students WHERE students.imagefile = \"{student_filename}\") AND psr.parent_id = (SELECT id FROM parents WHERE parents.imagefile = "{parent_filename}")'
|
||||
self.cursor.execute(statement)
|
||||
return self.cursor.fetchone() != None
|
||||
def check_relationship(self, student: Student, parent: Parent):
|
||||
statement = f'SELECT id FROM `parent-student-relations` psr WHERE psr.student_id = {student.id} AND psr.parent_id = {parent.id}'
|
||||
self.cursor.execute(statement)
|
||||
return self.cursor.fetchone() != None
|
||||
def log_access_student_file(self, student_filename: str, parent_filename: str):
|
||||
statement = f'INSERT INTO face_detect.`access-log` (id, student_id, parent_id, `timestamp`) VALUES(NULL, (SELECT id FROM students WHERE students.imagefile = \"{student_filename}\"), (SELECT id FROM parents WHERE parents.imagefile = "{parent_filename}"), NULL)'
|
||||
self.cursor.execute(statement)
|
||||
self.db.commit()
|
||||
def log_access_parent_file(self, parent_filename: str):
|
||||
statement = f'INSERT INTO face_detect.`access-log` (id, student_id, parent_id, `timestamp`) VALUES(NULL, NULL, (SELECT id FROM parents WHERE parents.imagefile = "{parent_filename}"), NULL)'
|
||||
self.cursor.execute(statement)
|
||||
self.db.commit()
|
||||
def log_access_student(self, student: Student, parent: Parent):
|
||||
statement = f'INSERT INTO face_detect.`access-log` (id, student_id, parent_id, `timestamp`) VALUES(NULL, {student.id}, {parent.id}, NULL)'
|
||||
self.cursor.execute(statement)
|
||||
self.db.commit()
|
||||
def log_access_parent(self, parent: Parent):
|
||||
statement = f'INSERT INTO face_detect.`access-log` (id, student_id, parent_id, `timestamp`) VALUES(NULL, NULL, {parent.id}, NULL)'
|
||||
self.cursor.execute(statement)
|
||||
self.db.commit()
|
||||
def fetch_log() -> list:
|
||||
pass
|
|
@ -1,3 +0,0 @@
|
|||
class Display:
|
||||
def __init__(self) -> None:
|
||||
pass
|
|
@ -1,7 +0,0 @@
|
|||
class espmega_mqtt:
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
def write_pwm():
|
||||
pass
|
||||
def read_digital():
|
||||
pass
|
|
@ -3,14 +3,12 @@ import threading
|
|||
import time
|
||||
import face_processing as fp
|
||||
from access_control import access_control
|
||||
from database import database, Student, Parent
|
||||
|
||||
SERIAL_PORT_STM32 = "COM12"
|
||||
SERIAL_PORT_DISPLAY = "COM15"
|
||||
SERIAL_PORT = "COM12"
|
||||
CAMERA_INDEX = 0
|
||||
|
||||
cam = cv2.VideoCapture(CAMERA_INDEX)
|
||||
stm32 = access_control(SERIAL_PORT_STM32)
|
||||
stm32 = access_control(SERIAL_PORT)
|
||||
|
||||
global img
|
||||
global frame_ready
|
||||
|
|
|
@ -2,5 +2,3 @@ pyserial
|
|||
line_notify
|
||||
opencv-python
|
||||
requests
|
||||
mysql-connector-python
|
||||
paho-mqtt
|
Loading…
Reference in New Issue