0
0
Fork 0
mirror of https://github.com/boltgolt/howdy.git synced 2024-09-19 09:51:19 +02:00

Fixed old references to first config system, fixed typo

This commit is contained in:
boltgolt 2018-02-01 16:01:17 +01:00
parent 799bab81a6
commit 8c3039b0d0
4 changed files with 16 additions and 9 deletions

View file

@ -4,7 +4,7 @@ Windows Hello™ style authentication for Ubuntu. Use your build in IR emitters
### Installation
Fist we need to install pam-python, fswebcam and OpenCV from the Ubuntu repositories:
First we need to install pam-python, fswebcam and OpenCV from the Ubuntu repositories:
```
sudo apt install libpam-python fswebcam libopencv-dev python-opencv

View file

@ -11,7 +11,7 @@ import configparser
# Read config from disk
config = configparser.ConfigParser()
config.read(os.path.dirname(__file__) + "/config.ini")
config.read(os.path.dirname(os.path.abspath(__file__)) + "/config.ini")
def stop(status):
"""Stop the execution and close video stream"""
@ -34,7 +34,7 @@ tries = 0
# Try to load the face model from the models folder
try:
encodings = json.load(open(os.path.dirname(__file__) + "/models/" + user + ".dat"))
encodings = json.load(open(os.path.dirname(os.path.abspath(__file__)) + "/models/" + user + ".dat"))
except FileNotFoundError:
sys.exit(10)

View file

@ -9,14 +9,19 @@ import sys
import json
# Import config and extra functions
import config
import configparser
import utils
# Read config from disk
config = configparser.ConfigParser()
config.read(os.path.dirname(os.path.abspath(__file__)) + "/config.ini")
def captureFrame(delay):
"""Capture and encode 1 frame of video"""
global encodings
# Call fswebcam to save a frame to /tmp with a set delay
subprocess.call(["fswebcam", "-S", str(delay), "--no-banner", "-d", "/dev/video" + str(config.device_id), tmp_file], stderr=open(os.devnull, "wb"))
subprocess.call(["fswebcam", "-S", str(delay), "--no-banner", "-d", "/dev/video" + str(config.get("video", "device_id")), tmp_file], stderr=open(os.devnull, "wb"))
# Get the faces in htat image
ref = face_recognition.load_image_file(tmp_file)
@ -62,6 +67,8 @@ except FileNotFoundError:
# If a file does exist, ask the user what needs to be done
if encodings != False:
encodings = utils.print_menu(encodings)
else:
encodings = []
print("\nLearning face for the user account " + user)
print("Please look straight into the camera for 5 seconds")

4
pam.py
View file

@ -10,13 +10,13 @@ import ConfigParser
# Read config from disk
config = ConfigParser.ConfigParser()
config.read(os.path.dirname(__file__) + "/config.ini")
config.read(os.path.dirname(os.path.abspath(__file__)) + "/config.ini")
def doAuth(pamh):
"""Start authentication in a seperate process"""
# Run compair as python3 subprocess to circumvent python version and import issues
status = subprocess.call(["python3", os.path.dirname(__file__) + "/compair.py", pamh.get_user()])
status = subprocess.call(["python3", os.path.dirname(os.path.abspath(__file__)) + "/compair.py", pamh.get_user()])
# Status 10 means we couldn't find any face models
if status == 10: