Commit 641f70d2 authored by Kyle Anderson's avatar Kyle Anderson
Browse files

Add test for authentication, improve modules

Added a module to test the authentication manually with some pictures, as well as improved the way the authentication module works.
parent 5d0be5d9
......@@ -74,9 +74,10 @@ def draw_rectangles_and_user_ids(image_frame, conversion: float, box_user_id_map
def run_face_recognition(frame, known_faces: dict, encoding_model: str = "hog", draw_rectangles: bool = False) -> list:
recognized_user_ids: list = []
original_frame = frame
# Convert input from BGR to RGB
cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
# Resize image to width of 750 PX to speed up processing.
rgb_image = imutils.resize(frame, width=750)
r = frame.shape[1] / float(rgb_image.shape[1])
......@@ -96,7 +97,7 @@ def run_face_recognition(frame, known_faces: dict, encoding_model: str = "hog",
if draw_rectangles:
draw_rectangles_and_user_ids(frame, r, box_user_id_mapping)
draw_rectangles_and_user_ids(original_frame, r, box_user_id_mapping)
return recognized_user_ids
......@@ -5,6 +5,8 @@ import cv2
DATA_DIR = "data"
DATASET_DIR = "dataset"
DATABASE_LOC = os.path.join(DATA_DIR, "database.pickle")
# Name for the display frame.
FRAME_NAME = "Frame"
# Directory for the face detection model.
......@@ -14,7 +16,7 @@ EMBEDDINGS_PROCESSOR_LOC = os.path.join(RES_DIRECTORY, "openface_nn4.small2.v1.t
def display_frame(frame):
"""Displays the frame to the user."""
cv2.imshow("Frame", frame)
cv2.imshow(FRAME_NAME, frame)
def start_video_stream(camera: int):
import argparse
import cv2
import imutils
import authenticate_user
import common
import data_handler
parser = argparse.ArgumentParser()
parser.add_argument("--image", type=str, help="Image on which to run recognition.", required=True)
args = parser.parse_args()
frame = cv2.imread(args.image)
frame = imutils.resize(frame, width=750)
authenticate_user.run_face_recognition(frame, data_handler.load_database(common.DATABASE_LOC), draw_rectangles=True)
while cv2.waitKey(1) & 0xFF != ord('q') and cv2.getWindowProperty(common.FRAME_NAME, 0) >= 0:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment