Commit d1bfb370 authored by Kyle Anderson's avatar Kyle Anderson

Small refactorings

Made some small changes to certain things that wouldn't be necessary in common anymore. Although, this will break some of the stuff that I was attempting to do before.
parent 385774bc
......@@ -123,8 +123,16 @@ def recognize_user(known_faces: dict, encoding_model: str = "hog", image_flip: i
return recognized_user
def recognize_user_from_database(database_loc: str = common.EMBEDDINGS_LOC, encoding_model: str = "hog",
def recognize_user_from_database(database_loc: str = common.DATABASE_LOC, encoding_model: str = "hog",
image_flip: int = None, draw_rectangles: bool = False):
"""
Recognizes a user
:param database_loc: The database containing the face encodings for users.
:param encoding_model: The encoding model to be used for recognition.
:param image_flip: The type of image flip to be applied to the image, if it will be upside-down or horizontally inverted.
:param draw_rectangles: True to draw the rectangles to the screen, false otherwise.
:return: The recognized user's id, or None if no user was recognized.
"""
return recognize_user(data_handler.load_database(database_loc), encoding_model=encoding_model,
image_flip=image_flip,
draw_rectangles=draw_rectangles)
......
......@@ -2,13 +2,9 @@ import os
import cv2
DATA_DIR = "./data"
DATASET_DIR = "./dataset"
EMBEDDINGS_LOC = os.path.join(DATA_DIR, "embeddings.pickle")
RECOGNITION_DATABASE_LOC = os.path.join(DATA_DIR, "recognition.pickle")
CASCADE_DIR = "./cascades"
# Output location for pickle database files
OUTPUT_DIR = "./output"
DATA_DIR = "data"
DATASET_DIR = "dataset"
DATABASE_LOC = os.path.join(DATA_DIR, "database.pickle")
RES_DIRECTORY = "./res"
# Directory for the face detection model.
......
......@@ -89,7 +89,7 @@ def register_users_in_dir(directory_location: str, encoding_model: str = "hog",
def register_users_and_save(directory_location: str = common.DATASET_DIR,
database_location: str = common.EMBEDDINGS_LOC, encoding_model="hog",
database_location: str = common.DATABASE_LOC, encoding_model="hog",
delete_images_on_complete: bool = True, show_output: bool = False,
overwrite_data: bool = False):
processed_users = register_users_in_dir(directory_location, encoding_model=encoding_model,
......
......@@ -135,6 +135,6 @@ if __name__ == "__main__":
default=common.DATASET_DIR)
parser.add_argument("--output", "-o", type=str,
help="Location of the output pickle database file to which the encodings should be written.",
default=common.EMBEDDINGS_LOC)
default=common.DATABASE_LOC)
args = parser.parse_args()
process_dataset(args.dataset, show_output=True, file_output=args.output)
......@@ -9,7 +9,7 @@ from sklearn.svm import SVC
import common
import data_handler
def train_and_save(facial_embeddings_database: str= common.EMBEDDINGS_LOC, output_file: str = common.RECOGNITION_DATABASE_LOC) -> None:
def train_and_save(facial_embeddings_database: str= common.DATABASE_LOC, output_file: str = common.RECOGNITION_DATABASE_LOC) -> None:
"""
Trains the database using the given facial embeddings database and outputs the results to file.
:param facial_embeddings_database: The facial embedding database location.
......
Markdown is supported
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