diff --git a/debian/prerm b/debian/prerm index 150e7b8..e7c2469 100755 --- a/debian/prerm +++ b/debian/prerm @@ -12,7 +12,7 @@ from shutil import rmtree if "remove" not in sys.argv and "purge" not in sys.argv: sys.exit(0) -# Don't try running this if it's already gome +# Don't try running this if it's already gone if not os.path.exists("/lib/security/howdy/cli"): sys.exit(0) diff --git a/src/cli/test.py b/src/cli/test.py index b748140..d15c6b9 100644 --- a/src/cli/test.py +++ b/src/cli/test.py @@ -1,4 +1,4 @@ -# Show a windows with the video stream and testing information +# Show a window with the video stream and testing information # Import required modules import configparser @@ -109,6 +109,17 @@ try: # Grab a single frame of video ret, frame = video_capture.read() + + try: + # Convert from color to grayscale + # First processing of frame, so frame errors show up here + frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) + except RuntimeError: + pass + except cv2.error: + print("\nUnknown camera, please check your 'device_path' config value.\n") + raise + frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) frame = clahe.apply(frame) # Make a frame to put overlays in @@ -159,7 +170,8 @@ try: rec_tm = time.time() # Get the locations of all faces and their locations - face_locations = face_detector(frame, 1) # upsample 1 time + # Upsample it once + face_locations = face_detector(frame, 1) rec_tm = time.time() - rec_tm # Loop though all faces and paint a circle around them diff --git a/src/compare.py b/src/compare.py index 17ac2a7..e26e14e 100644 --- a/src/compare.py +++ b/src/compare.py @@ -187,6 +187,8 @@ while True: # Convert from color to grayscale # First processing of frame, so frame errors show up here gsframe = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) + except RuntimeError: + gsframe = frame except cv2.error: print("\nUnknown camera, please check your 'device_path' config value.\n") raise diff --git a/src/pam.py b/src/pam.py index f539b32..b127cc6 100644 --- a/src/pam.py +++ b/src/pam.py @@ -18,21 +18,21 @@ def doAuth(pamh): """Starts authentication in a seperate process""" # Abort is Howdy is disabled - if config.getboolean("core", "disabled"): + if config.getboolean("core", "disabled", fallback=False): sys.exit(0) # Abort if we're in a remote SSH env - if config.getboolean("core", "ignore_ssh"): + if config.getboolean("core", "ignore_ssh", fallback=True): if "SSH_CONNECTION" in os.environ or "SSH_CLIENT" in os.environ or "SSHD_OPTS" in os.environ: sys.exit(0) # Abort if lid is closed - if config.getboolean("core", "ignore_closed_lid"): - if any('closed' in open(f).read() for f in glob.glob('/proc/acpi/button/lid/*/state')): + if config.getboolean("core", "ignore_closed_lid", fallback=True): + if any("closed" in open(f).read() for f in glob.glob("/proc/acpi/button/lid/*/state")): sys.exit(0) # Alert the user that we are doing face detection - if config.get("core", "detection_notice") == "true": + if config.getboolean("core", "detection_notice", fallback=False): pamh.conversation(pamh.Message(pamh.PAM_TEXT_INFO, "Attempting face detection")) # Run compare as python3 subprocess to circumvent python version and import issues @@ -40,7 +40,7 @@ def doAuth(pamh): # Status 10 means we couldn't find any face models if status == 10: - if not config.getboolean("core", "suppress_unknown"): + if not config.getboolean("core", "suppress_unknown", fallback=False): pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "No face model known")) return pamh.PAM_USER_UNKNOWN # Status 11 means we exceded the maximum retry count @@ -53,11 +53,11 @@ def doAuth(pamh): # Status 0 is a successful exit elif status == 0: # Show the success message if it isn't suppressed - if not config.getboolean("core", "no_confirmation"): + if not config.getboolean("core", "no_confirmation", fallback=False): pamh.conversation(pamh.Message(pamh.PAM_TEXT_INFO, "Identified face as " + pamh.get_user())) # Try to dismiss the lock screen if enabled - if config.get("core", "dismiss_lockscreen"): + if config.getboolean("core", "dismiss_lockscreen", fallback=False): # Run it as root with a timeout of 1s, and never ask for a password through the UI subprocess.Popen(["sudo", "timeout", "1", "loginctl", "unlock-sessions", "--no-ask-password"]) diff --git a/src/recorders/pyv4l2_reader.py b/src/recorders/pyv4l2_reader.py index 6d52871..d0efcf5 100644 --- a/src/recorders/pyv4l2_reader.py +++ b/src/recorders/pyv4l2_reader.py @@ -8,7 +8,7 @@ import sys from cv2 import cvtColor, COLOR_GRAY2BGR, CAP_PROP_FRAME_WIDTH, CAP_PROP_FRAME_HEIGHT try: - from v4l2.frame import Frame + from pyv4l2.frame import Frame except ImportError: print("Missing pyv4l2 module, please run:") print(" pip3 install pyv4l2\n")