From 466c859cb8fab6e72edf3586e2e3fd07ced70653 Mon Sep 17 00:00:00 2001 From: Sayafdine Said Date: Tue, 12 Sep 2023 22:59:47 +0200 Subject: [PATCH] refactor: remove useless conversion --- howdy/src/cli/add.py | 8 ++++---- howdy/src/cli/test.py | 6 +++--- howdy/src/compare.py | 8 ++++---- howdy/src/pam/meson.build | 3 +-- howdy/src/snapshot.py | 4 ++-- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/howdy/src/cli/add.py b/howdy/src/cli/add.py index 8ee9f25..9a2c9a0 100644 --- a/howdy/src/cli/add.py +++ b/howdy/src/cli/add.py @@ -40,16 +40,16 @@ config.read(paths_factory.config_file_path()) use_cnn = config.getboolean("core", "use_cnn", fallback=False) if use_cnn: - face_detector = dlib.cnn_face_detection_model_v1(str(paths_factory.mmod_human_face_detector_path())) + face_detector = dlib.cnn_face_detection_model_v1(paths_factory.mmod_human_face_detector_path()) else: face_detector = dlib.get_frontal_face_detector() -pose_predictor = dlib.shape_predictor(str(paths_factory.shape_predictor_5_face_landmarks_path())) -face_encoder = dlib.face_recognition_model_v1(str(paths_factory.dlib_face_recognition_resnet_model_v1_path())) +pose_predictor = dlib.shape_predictor(paths_factory.shape_predictor_5_face_landmarks_path()) +face_encoder = dlib.face_recognition_model_v1(paths_factory.dlib_face_recognition_resnet_model_v1_path()) user = builtins.howdy_user # The permanent file to store the encoded model in -enc_file = str(paths_factory.user_model_path(user)) +enc_file = paths_factory.user_model_path(user) # Known encodings encodings = [] diff --git a/howdy/src/cli/test.py b/howdy/src/cli/test.py index 934d535..f18c4eb 100644 --- a/howdy/src/cli/test.py +++ b/howdy/src/cli/test.py @@ -57,13 +57,13 @@ use_cnn = config.getboolean('core', 'use_cnn', fallback=False) if use_cnn: face_detector = dlib.cnn_face_detection_model_v1( - str(paths_factory.mmod_human_face_detector_path()) + paths_factory.mmod_human_face_detector_path() ) else: face_detector = dlib.get_frontal_face_detector() -pose_predictor = dlib.shape_predictor(str(paths_factory.shape_predictor_5_face_landmarks_path())) -face_encoder = dlib.face_recognition_model_v1(str(paths_factory.dlib_face_recognition_resnet_model_v1_path())) +pose_predictor = dlib.shape_predictor(paths_factory.shape_predictor_5_face_landmarks_path()) +face_encoder = dlib.face_recognition_model_v1(paths_factory.dlib_face_recognition_resnet_model_v1_path()) encodings = [] models = None diff --git a/howdy/src/compare.py b/howdy/src/compare.py index 00d0348..0b2213f 100644 --- a/howdy/src/compare.py +++ b/howdy/src/compare.py @@ -45,7 +45,7 @@ def init_detector(lock): global face_detector, pose_predictor, face_encoder # Test if at lest 1 of the data files is there and abort if it's not - if not os.path.isfile(str(paths_factory.shape_predictor_5_face_landmarks_path())): + if not os.path.isfile(paths_factory.shape_predictor_5_face_landmarks_path()): print(_("Data files have not been downloaded, please run the following commands:")) print("\n\tcd " + paths_factory.dlib_data_dir_path()) print("\tsudo ./install.sh\n") @@ -54,13 +54,13 @@ def init_detector(lock): # Use the CNN detector if enabled if use_cnn: - face_detector = dlib.cnn_face_detection_model_v1(str(paths_factory.mmod_human_face_detector_path())) + face_detector = dlib.cnn_face_detection_model_v1(paths_factory.mmod_human_face_detector_path()) else: face_detector = dlib.get_frontal_face_detector() # Start the others regardless - pose_predictor = dlib.shape_predictor(str(paths_factory.shape_predictor_5_face_landmarks_path())) - face_encoder = dlib.face_recognition_model_v1(str(paths_factory.dlib_face_recognition_resnet_model_v1_path())) + pose_predictor = dlib.shape_predictor(paths_factory.shape_predictor_5_face_landmarks_path()) + face_encoder = dlib.face_recognition_model_v1(paths_factory.dlib_face_recognition_resnet_model_v1_path()) # Note the time it took to initialize detectors timings["ll"] = time.time() - timings["ll"] diff --git a/howdy/src/pam/meson.build b/howdy/src/pam/meson.build index 80ffd82..35cdb03 100644 --- a/howdy/src/pam/meson.build +++ b/howdy/src/pam/meson.build @@ -10,8 +10,7 @@ subdir('po') paths_h = configure_file( input: 'paths.hh.in', output: 'paths.hh', - configuration: pam_module_conf_data, - install_dir: get_option('pam_dir') + configuration: pam_module_conf_data ) pamdir = get_option('pam_dir') != '' ? get_option('pam_dir') : join_paths(get_option('prefix'), get_option('libdir'), 'security') diff --git a/howdy/src/snapshot.py b/howdy/src/snapshot.py index 9e55ca0..ae40d47 100644 --- a/howdy/src/snapshot.py +++ b/howdy/src/snapshot.py @@ -30,7 +30,7 @@ def generate(frames, text_lines): # Add the Howdy logo if there's space to do so if len(frames) > 1: # Load the logo from file - logo = cv2.imread(str(paths_factory.logo_path())) + logo = cv2.imread(paths_factory.logo_path()) # Calculate the position of the logo logo_y = frame_height + 20 logo_x = frame_width * len(frames) - 210 @@ -54,7 +54,7 @@ def generate(frames, text_lines): # Generate a filename based on the current time filename = datetime.datetime.utcnow().strftime("%Y%m%dT%H%M%S.jpg") - filepath = str(paths_factory.snapshot_path(filename)) + filepath = paths_factory.snapshot_path(filename) # Write the image to that file cv2.imwrite(filepath, snap)