diff --git a/.gitignore b/.gitignore index 63ef476..6af4659 100644 --- a/.gitignore +++ b/.gitignore @@ -111,3 +111,17 @@ debian/howdy.substvars debian/files debian/debhelper-build-stamp debian/howdy + +# vscode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix \ No newline at end of file diff --git a/howdy/src/compare.py b/howdy/src/compare.py index da90195..3fd7f35 100644 --- a/howdy/src/compare.py +++ b/howdy/src/compare.py @@ -96,7 +96,7 @@ def send_to_ui(type, message): pass -# Make sure we were given an username to tast against +# Make sure we were given an username to test against if len(sys.argv) < 2: exit(12) @@ -150,6 +150,7 @@ end_report = config.getboolean("debug", "end_report", fallback=False) capture_failed = config.getboolean("snapshots", "capture_failed", fallback=False) capture_successful = config.getboolean("snapshots", "capture_successful", fallback=False) gtk_stdout = config.getboolean("debug", "gtk_stdout", fallback=False) +rotate = config.getint("video", "rotate", fallback=0) # Send the gtk outupt to the terminal if enabled in the config gtk_pipe = sys.stdout if gtk_stdout else subprocess.DEVNULL @@ -193,9 +194,11 @@ del lock # Fetch the max frame height max_height = config.getfloat("video", "max_height", fallback=0.0) -# Get the height of the image -height = video_capture.internal.get(cv2.CAP_PROP_FRAME_HEIGHT) or 1 +# Get the height of the image (which would be the width if screen is portrait oriented) +height = video_capture.internal.get(cv2.CAP_PROP_FRAME_HEIGHT) or 1 +if rotate == 2: + height = video_capture.internal.get(cv2.CAP_PROP_FRAME_WIDTH) or 1 # Calculate the amount the image has to shrink scaling_factor = (max_height / height) or 1 @@ -272,16 +275,30 @@ while True: dark_tries += 1 continue - # If the hight is too high + # If the height is too high if scaling_factor != 1: # Apply that factor to the frame frame = cv2.resize(frame, None, fx=scaling_factor, fy=scaling_factor, interpolation=cv2.INTER_AREA) gsframe = cv2.resize(gsframe, None, fx=scaling_factor, fy=scaling_factor, interpolation=cv2.INTER_AREA) - + # If camera is configured to rotate = 1, check portrait in addition to landscape + if rotate == 1: + if frames % 3 == 1: + frame = cv2.rotate(frame, cv2.ROTATE_90_COUNTERCLOCKWISE) + gsframe = cv2.rotate(gsframe, cv2.ROTATE_90_COUNTERCLOCKWISE) + if frames % 3 == 2: + frame = cv2.rotate(frame, cv2.ROTATE_90_CLOCKWISE) + gsframe = cv2.rotate(gsframe, cv2.ROTATE_90_CLOCKWISE) + # If camera is configured to rotate = 2, check portrait orientation + elif rotate == 2: + if frames % 2 == 0: + frame = cv2.rotate(frame, cv2.ROTATE_90_COUNTERCLOCKWISE) + gsframe = cv2.rotate(gsframe, cv2.ROTATE_90_COUNTERCLOCKWISE) + else: + frame = cv2.rotate(frame, cv2.ROTATE_90_CLOCKWISE) + gsframe = cv2.rotate(gsframe, cv2.ROTATE_90_CLOCKWISE) # Get all faces from that frame as encodings # Upsamples 1 time face_locations = face_detector(gsframe, 1) - # Loop through each face for fl in face_locations: if use_cnn: diff --git a/howdy/src/config.ini b/howdy/src/config.ini index d89c5dc..d02de0d 100644 --- a/howdy/src/config.ini +++ b/howdy/src/config.ini @@ -80,6 +80,12 @@ force_mjpeg = false # OPENCV only. exposure = -1 +# Rotate captured frames so faces are upright. +# Check landscape orientation only: rotate = 0 +# Check landscape and portrait orientation: rotate = 1 +# Check portrait orientation only: rotate = 2 +rotate = 0 + [snapshots] # Capture snapshots of failed login attempts and save them to disk with metadata # Snapshots are saved to the "snapshots" folder diff --git a/howdy/src/pam.py b/howdy/src/pam.py index 5dd3c5d..5e72f76 100644 --- a/howdy/src/pam.py +++ b/howdy/src/pam.py @@ -17,7 +17,7 @@ config.read(os.path.dirname(os.path.abspath(__file__)) + "/config.ini") def doAuth(pamh): """Starts authentication in a seperate process""" - # Abort is Howdy is disabled + # Abort if Howdy is disabled if config.getboolean("core", "disabled"): return pamh.PAM_AUTHINFO_UNAVAIL