parent
5db34e226c
commit
fd300e52e3
5 changed files with 26 additions and 12 deletions
2
debian/prerm
vendored
2
debian/prerm
vendored
|
|
@ -12,7 +12,7 @@ from shutil import rmtree
|
||||||
if "remove" not in sys.argv and "purge" not in sys.argv:
|
if "remove" not in sys.argv and "purge" not in sys.argv:
|
||||||
sys.exit(0)
|
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"):
|
if not os.path.exists("/lib/security/howdy/cli"):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 required modules
|
||||||
import configparser
|
import configparser
|
||||||
|
|
@ -109,6 +109,17 @@ try:
|
||||||
|
|
||||||
# Grab a single frame of video
|
# Grab a single frame of video
|
||||||
ret, frame = video_capture.read()
|
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 = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
||||||
frame = clahe.apply(frame)
|
frame = clahe.apply(frame)
|
||||||
# Make a frame to put overlays in
|
# Make a frame to put overlays in
|
||||||
|
|
@ -159,7 +170,8 @@ try:
|
||||||
|
|
||||||
rec_tm = time.time()
|
rec_tm = time.time()
|
||||||
# Get the locations of all faces and their locations
|
# 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
|
rec_tm = time.time() - rec_tm
|
||||||
|
|
||||||
# Loop though all faces and paint a circle around them
|
# Loop though all faces and paint a circle around them
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,8 @@ while True:
|
||||||
# Convert from color to grayscale
|
# Convert from color to grayscale
|
||||||
# First processing of frame, so frame errors show up here
|
# First processing of frame, so frame errors show up here
|
||||||
gsframe = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
gsframe = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
||||||
|
except RuntimeError:
|
||||||
|
gsframe = frame
|
||||||
except cv2.error:
|
except cv2.error:
|
||||||
print("\nUnknown camera, please check your 'device_path' config value.\n")
|
print("\nUnknown camera, please check your 'device_path' config value.\n")
|
||||||
raise
|
raise
|
||||||
|
|
|
||||||
16
src/pam.py
16
src/pam.py
|
|
@ -18,21 +18,21 @@ def doAuth(pamh):
|
||||||
"""Starts authentication in a seperate process"""
|
"""Starts authentication in a seperate process"""
|
||||||
|
|
||||||
# Abort is Howdy is disabled
|
# Abort is Howdy is disabled
|
||||||
if config.getboolean("core", "disabled"):
|
if config.getboolean("core", "disabled", fallback=False):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# Abort if we're in a remote SSH env
|
# 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:
|
if "SSH_CONNECTION" in os.environ or "SSH_CLIENT" in os.environ or "SSHD_OPTS" in os.environ:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# Abort if lid is closed
|
# Abort if lid is closed
|
||||||
if config.getboolean("core", "ignore_closed_lid"):
|
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')):
|
if any("closed" in open(f).read() for f in glob.glob("/proc/acpi/button/lid/*/state")):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# Alert the user that we are doing face detection
|
# 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"))
|
pamh.conversation(pamh.Message(pamh.PAM_TEXT_INFO, "Attempting face detection"))
|
||||||
|
|
||||||
# Run compare as python3 subprocess to circumvent python version and import issues
|
# 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
|
# Status 10 means we couldn't find any face models
|
||||||
if status == 10:
|
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"))
|
pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "No face model known"))
|
||||||
return pamh.PAM_USER_UNKNOWN
|
return pamh.PAM_USER_UNKNOWN
|
||||||
# Status 11 means we exceded the maximum retry count
|
# Status 11 means we exceded the maximum retry count
|
||||||
|
|
@ -53,11 +53,11 @@ def doAuth(pamh):
|
||||||
# Status 0 is a successful exit
|
# Status 0 is a successful exit
|
||||||
elif status == 0:
|
elif status == 0:
|
||||||
# Show the success message if it isn't suppressed
|
# 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()))
|
pamh.conversation(pamh.Message(pamh.PAM_TEXT_INFO, "Identified face as " + pamh.get_user()))
|
||||||
|
|
||||||
# Try to dismiss the lock screen if enabled
|
# 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
|
# 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"])
|
subprocess.Popen(["sudo", "timeout", "1", "loginctl", "unlock-sessions", "--no-ask-password"])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import sys
|
||||||
from cv2 import cvtColor, COLOR_GRAY2BGR, CAP_PROP_FRAME_WIDTH, CAP_PROP_FRAME_HEIGHT
|
from cv2 import cvtColor, COLOR_GRAY2BGR, CAP_PROP_FRAME_WIDTH, CAP_PROP_FRAME_HEIGHT
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from v4l2.frame import Frame
|
from pyv4l2.frame import Frame
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("Missing pyv4l2 module, please run:")
|
print("Missing pyv4l2 module, please run:")
|
||||||
print(" pip3 install pyv4l2\n")
|
print(" pip3 install pyv4l2\n")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue