diff --git a/.travis.yml b/.travis.yml index e3eb3ce..2997d16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,19 +8,12 @@ script: # Install the binary, running the debian scripts in the process - sudo apt install ../*.deb -y - # Confirm the cv2 module has been installed correctly - - sudo /usr/bin/env python3 -c "import cv2; print(cv2.__version__);" - # Confirm the face_recognition module has been installed correctly - - sudo /usr/bin/env python3 -c "import face_recognition; print(face_recognition.__version__);" - - # Check if the username passthough works correctly with sudo - - 'howdy | ack-grep --passthru --color "current active user: travis"' - - 'sudo howdy | ack-grep --passthru --color "current active user: travis"' + - ./tests/importing.sh + - ./tests/passthrough.sh # Remove howdy from the installation - sudo apt purge howdy -y - notifications: email: on_success: never diff --git a/src/compare.py b/src/compare.py index dca8a88..b42dc38 100644 --- a/src/compare.py +++ b/src/compare.py @@ -42,16 +42,17 @@ dark_tries = 0 # Try to load the face model from the models folder try: models = json.load(open(os.path.dirname(os.path.abspath(__file__)) + "/models/" + user + ".dat")) - - # Put all models together into 1 array - encodings = [model["data"] for model in models] except FileNotFoundError: sys.exit(10) # Check if the file contains a model -if not encodings: +if len(models) < 1: sys.exit(10) +# Put all models together into 1 array +for model in models: + encodings += model["data"] + # Add the time needed to start the script timings.append(time.time()) @@ -63,12 +64,13 @@ if config.getboolean("video", "force_mjpeg"): # Set a magic number, will enable MJPEG but is badly documentated video_capture.set(cv2.CAP_PROP_FOURCC, 1196444237) -# Set the frame width and height if requested +# Get the height and width config values fw = config.getint("video", "frame_width") fh = config.getint("video", "frame_height") + +# Set the frame width and height if requested if fw != -1: video_capture.set(cv2.CAP_PROP_FRAME_WIDTH, fw) - if fh != -1: video_capture.set(cv2.CAP_PROP_FRAME_HEIGHT, fh) @@ -86,11 +88,13 @@ timings.append(time.time()) # Fetch the max frame height max_height = int(config.get("video", "max_height")) -# Start the read loop -frames = 0 +# Fetch config settings out of the loop timeout = config.getint("video", "timout") dark_threshold = config.getfloat("video", "dark_threshold") end_report = config.getboolean("debug", "end_report") + +# Start the read loop +frames = 0 while True: # Increment the frame count every loop frames += 1 @@ -145,7 +149,7 @@ while True: match_index += 1 # Try to find a match that's confident enough - if match * 10 < float(config.get("video", "certainty")) and match > 0: + if match * 10 < config.getfloat("video", "certainty") and match > 0: timings.append(time.time()) # If set to true in the config, print debug text diff --git a/tests/importing.sh b/tests/importing.sh new file mode 100755 index 0000000..3f7bddd --- /dev/null +++ b/tests/importing.sh @@ -0,0 +1,7 @@ +# Confirm the cv2 module has been installed correctly +echo "cv2 version:" +sudo /usr/bin/env python3 -c "import cv2; print(cv2.__version__);" + +# Confirm the face_recognition module has been installed correctly +echo "face_recognition version:" +sudo /usr/bin/env python3 -c "import face_recognition; print(face_recognition.__version__);" diff --git a/tests/passthrough.sh b/tests/passthrough.sh new file mode 100644 index 0000000..8822b50 --- /dev/null +++ b/tests/passthrough.sh @@ -0,0 +1,3 @@ +# Check if the username passthough works correctly with sudo +howdy | ack-grep --passthru --color "current active user: travis" +sudo howdy | ack-grep --passthru --color "current active user: travis" diff --git a/tests/video/match1.m4v b/tests/video/match1.m4v new file mode 100644 index 0000000..b3c2497 Binary files /dev/null and b/tests/video/match1.m4v differ diff --git a/tests/video/match2.m4v b/tests/video/match2.m4v new file mode 100644 index 0000000..7797c28 Binary files /dev/null and b/tests/video/match2.m4v differ diff --git a/tests/video/noMatch.m4v b/tests/video/noMatch.m4v new file mode 100644 index 0000000..dacd9a1 Binary files /dev/null and b/tests/video/noMatch.m4v differ