|
|
@@ -8,8 +8,11 @@ import time |
|
|
|
import glob |
|
|
|
|
|
|
|
class I3Locker: |
|
|
|
def __init__(self): |
|
|
|
self.killed = False |
|
|
|
self.proc = None |
|
|
|
|
|
|
|
def run(self): |
|
|
|
print("starting mlock") |
|
|
|
self.proc = subprocess.Popen([ "mlock" ]) |
|
|
|
code = self.proc.wait() |
|
|
|
if code == 0 or self.killed: |
|
|
@@ -23,12 +26,16 @@ class I3Locker: |
|
|
|
self.proc.terminate() |
|
|
|
|
|
|
|
class FaceLocker: |
|
|
|
def run(self): |
|
|
|
def __init__(self): |
|
|
|
self.delay = 200 |
|
|
|
self.dev = 2 |
|
|
|
self.running = True |
|
|
|
self.running = False |
|
|
|
self.killed = False |
|
|
|
self.waitingProc = None |
|
|
|
|
|
|
|
def run(self): |
|
|
|
self.running = True |
|
|
|
|
|
|
|
# Import here because it's sloow |
|
|
|
import face_recognition |
|
|
|
import cv2 |
|
|
@@ -39,7 +46,7 @@ class FaceLocker: |
|
|
|
path = f"./faces/{getpass.getuser()}/*.npy" |
|
|
|
paths = [] |
|
|
|
for p in glob.glob(path): |
|
|
|
print(f"reading {p}") |
|
|
|
print(f"Reading {p}") |
|
|
|
faceencs.append(np.load(p)) |
|
|
|
paths.append(p) |
|
|
|
|
|
|
@@ -125,6 +132,7 @@ class FaceLocker: |
|
|
|
# Blink IR blasters |
|
|
|
import cv2 |
|
|
|
cap = cv2.VideoCapture(self.dev) |
|
|
|
time.sleep(0.1) |
|
|
|
cap.release() |
|
|
|
|
|
|
|
self.waitingProc.wait() |
|
|
@@ -141,6 +149,7 @@ lockers = [ |
|
|
|
] |
|
|
|
|
|
|
|
def runLocker(locker): |
|
|
|
print("Starting "+locker.__class__.__name__) |
|
|
|
ret = locker.run() |
|
|
|
if ret == 0: |
|
|
|
print(locker.__class__.__name__+" unlocked.") |