| import os | import os | ||||
| import time | import time | ||||
| import glob | import glob | ||||
| import cv2 | |||||
| import numpy as np | |||||
| class I3Locker: | class I3Locker: | ||||
| def run(self): | def run(self): | ||||
| print("starting mlock") | |||||
| self.proc = subprocess.Popen([ "mlock" ]) | self.proc = subprocess.Popen([ "mlock" ]) | ||||
| code = self.proc.wait() | code = self.proc.wait() | ||||
| if code == 0 or self.killed: | if code == 0 or self.killed: | ||||
| # Import here because it's sloow | # Import here because it's sloow | ||||
| import face_recognition | import face_recognition | ||||
| import cv2 | |||||
| import numpy as np | |||||
| # Read all face files | # Read all face files | ||||
| faceencs = [] | faceencs = [] | ||||
| if s == "Discharging" or s == "Unknown": | if s == "Discharging" or s == "Unknown": | ||||
| bat = True | bat = True | ||||
| if bat: | if bat: | ||||
| print("Waiting for enter before starting face recognition") | |||||
| self.waitForKey(keyboard, key) | self.waitForKey(keyboard, key) | ||||
| if self.killed: | |||||
| return 0 | |||||
| # Match faces, blocks until a match is found or we're killed | # Match faces, blocks until a match is found or we're killed | ||||
| self.runFaces(faceencs, paths, np, face_recognition, cv2) | self.runFaces(faceencs, paths, np, face_recognition, cv2) | ||||
| self.matching = True | self.matching = True | ||||
| def waitForKey(self, keyboard, key): | def waitForKey(self, keyboard, key): | ||||
| if self.killed: | |||||
| return | |||||
| print("Waiting for enter before starting face recognition") | |||||
| self.waitingProc = subprocess.Popen( | self.waitingProc = subprocess.Popen( | ||||
| f"xinput test '{keyboard}' | grep --line-buffered 'key press {key}' | exit", | f"xinput test '{keyboard}' | grep --line-buffered 'key press {key}' | exit", | ||||
| shell=True) | shell=True) | ||||
| # Blink IR blasters | # Blink IR blasters | ||||
| import cv2 | |||||
| cap = cv2.VideoCapture(self.dev) | cap = cv2.VideoCapture(self.dev) | ||||
| cap.release() | cap.release() | ||||