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