def main(): ids, encodings = known_photos_loader.load_photos() process_this_frame = True with Camera.open_camera(): last_found_id = None while True: frame = Camera.get_frame() if process_this_frame: faces_locations = face_recognition.face_locations(frame) faces_encodings = face_recognition.face_encodings(frame, faces_locations) for face_encoding in faces_encodings: matches = face_recognition.compare_faces(encodings, face_encoding) if True in matches: index = matches.index(True) employee_id = ids[index] if last_found_id != employee_id: last_found_id = employee_id show_employee_welcome(employee_id) else: if last_found_id is not None: last_found_id = None LOGGER.warning("Face not recognized.") process_this_frame = not process_this_frame