import cv2 import threading import time import face_processing as fp from access_control import access_control from database import database, Student, Parent from displ SERIAL_PORT_STM32 = "COM12" SERIAL_PORT_DISPLAY = "COM15" CAMERA_INDEX = 0 cam = cv2.VideoCapture(CAMERA_INDEX) stm32 = access_control(SERIAL_PORT_STM32) display = global img global frame_ready frame_ready = False def read_webcam(): global img global frame_ready while True: ret, img = cam.read() frame_ready = True threading.Thread(target=read_webcam).start() while True: while not frame_ready: time.sleep(1) #Try to identify face if stm32.get_scan_state(): print("SCAN ACTIVE!") faces = fp.identify_face(img, target_condidence=0.6) if(len(faces)>0): print("Door Unlocked!, Locking in 5 seconds") stm32.unlock_door() time.sleep(5) stm32.lock_door() print("Door Locked!") print("DONE")