From dc3d283d5da880a5fa104eb6604757eb27925ca8 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Mon, 13 Nov 2023 20:34:08 +0700 Subject: [PATCH] add c --- access_control_python/database.py | 8 +++---- access_control_python/espmega_mqtt.py | 2 +- access_control_python/main.py | 30 +++++++++++++-------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/access_control_python/database.py b/access_control_python/database.py index 9d886d2..507c12c 100644 --- a/access_control_python/database.py +++ b/access_control_python/database.py @@ -67,10 +67,10 @@ class Database: 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 log_access_student(self, parent: Parent): - statement = f'INSERT INTO face_detect.`access-log` (id, student_id, parent_id, `timestamp`) VALUES(NULL, {student.id}, NULL, NULL)' - self.cursor.execute(statement) - self.db.commit() + # def log_access_student(self, parent: Parent): + # statement = f'INSERT INTO face_detect.`access-log` (id, student_id, parent_id, `timestamp`) VALUES(NULL, {student.id}, NULL, NULL)' + # self.cursor.execute(statement) + # self.db.commit() def fetch_log() -> list: diff --git a/access_control_python/espmega_mqtt.py b/access_control_python/espmega_mqtt.py index ed267c7..e91d861 100644 --- a/access_control_python/espmega_mqtt.py +++ b/access_control_python/espmega_mqtt.py @@ -1,5 +1,5 @@ import paho.mqtt.client as pahomqtt -BROKER = "192.168.0.26" +BROKER = "192.168.0.239" BASE_TOPIC = "/facescan" class ESPMegaMQTT: input_buffer = [0]*16 diff --git a/access_control_python/main.py b/access_control_python/main.py index 79acb00..34de08b 100644 --- a/access_control_python/main.py +++ b/access_control_python/main.py @@ -52,19 +52,26 @@ while True: parent_face = fp.identify_face(img, target_condidence=0.6) parent_info = db.get_parent_info(parent_face) #TODO Fill in student info - db.log_access_parent(parent_info) # Log student data + if(parent_info != None): # Identified parent - print(parent_info) if(db.check_relationship(student_info,parent_info)): # Check if the detected parent is right for the detected student. - #TODO Log Access - display.set_page("Parent") + #TODO Log Access STDw/P + #TODO write parrent info to display access_control.unlock_door() # Door open + display.set_string("msg.txt","Get your kid") + #TODO Send timer to display time.sleep(10) - #display.set_string("msg.txt","Get your kid") + + #TODO Check if door can be locked + # if can lock, lock + #TODO If can't lock, say left open + #Countdown + # Activate Alarm else: - access_control.lock_door() # Lock Door - display.set_page("Scan") - display.set_string("msg.txt","Wrong student. \t Try Again") + + display.set_page("scan") + display.set_string("msg.txt","Wrong parent. \t Try Again") + #TODO Try again does not try again else: display.set_page("student") display.set_string("msg.txt","Cannot find parent data. \t Try Again") @@ -76,15 +83,8 @@ while True: elif (len(faces)>1): #More than one people, error. print("more than one people. \t try again") - display.set_page("Scan") display.set_string("msg.txt","More than one people. \t try again") time.sleep(2) - display.set_page("Scan") - pass - else: - #No one detected - print("No one detected \t try again")\ - display.set_page("Scan") pass print("DONE")