mirror of
https://github.com/boltgolt/howdy.git
synced 2024-09-12 09:41:18 +02:00
refactor: use only paths_factory
This commit is contained in:
parent
54ba84e033
commit
1f8ee26d3d
6 changed files with 30 additions and 26 deletions
|
@ -8,7 +8,6 @@ import json
|
|||
import configparser
|
||||
import builtins
|
||||
import numpy as np
|
||||
import paths
|
||||
import paths_factory
|
||||
|
||||
from recorders.video_capture import VideoCapture
|
||||
|
@ -31,7 +30,7 @@ import cv2
|
|||
# Test if at lest 1 of the data files is there and abort if it's not
|
||||
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 " + str(paths.dlib_data_dir))
|
||||
print("\n\tcd " + paths_factory.dlib_data_dir_path())
|
||||
print("\tsudo ./install.sh\n")
|
||||
sys.exit(1)
|
||||
|
||||
|
@ -55,9 +54,9 @@ enc_file = str(paths_factory.user_model_path(user))
|
|||
encodings = []
|
||||
|
||||
# Make the ./models folder if it doesn't already exist
|
||||
if not os.path.exists(paths.user_models_dir):
|
||||
if not os.path.exists(paths_factory.user_models_dir_path()):
|
||||
print(_("No face model folder found, creating one"))
|
||||
os.makedirs(paths.user_models_dir)
|
||||
os.makedirs(paths_factory.user_models_dir_path())
|
||||
|
||||
# To try read a premade encodings file if it exists
|
||||
try:
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
import os
|
||||
import sys
|
||||
import builtins
|
||||
import paths
|
||||
import paths_factory
|
||||
|
||||
from i18n import _
|
||||
|
@ -13,7 +12,7 @@ from i18n import _
|
|||
user = builtins.howdy_user
|
||||
|
||||
# Check if the models folder is there
|
||||
if not os.path.exists(paths.user_models_dir):
|
||||
if not os.path.exists(paths_factory.user_models_dir_path()):
|
||||
print(_("No models created yet, can't clear them if they don't exist"))
|
||||
sys.exit(1)
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import os
|
|||
import json
|
||||
import time
|
||||
import builtins
|
||||
import paths
|
||||
import paths_factory
|
||||
|
||||
from i18n import _
|
||||
|
@ -14,7 +13,7 @@ from i18n import _
|
|||
user = builtins.howdy_user
|
||||
|
||||
# Check if the models file has been created yet
|
||||
if not os.path.exists(paths.user_models_dir):
|
||||
if not os.path.exists(paths_factory.user_models_dir_path()):
|
||||
print(_("Face models have not been initialized yet, please run:"))
|
||||
print("\n\tsudo howdy -U " + user + " add\n")
|
||||
sys.exit(1)
|
||||
|
|
|
@ -5,7 +5,6 @@ import sys
|
|||
import os
|
||||
import json
|
||||
import builtins
|
||||
import paths
|
||||
import paths_factory
|
||||
|
||||
from i18n import _
|
||||
|
@ -22,7 +21,7 @@ if not builtins.howdy_args.arguments:
|
|||
sys.exit(1)
|
||||
|
||||
# Check if the models file has been created yet
|
||||
if not os.path.exists(paths.user_models_dir):
|
||||
if not os.path.exists(paths_factory.user_models_dir_path()):
|
||||
print(_("Face models have not been initialized yet, please run:"))
|
||||
print("\n\thowdy add\n")
|
||||
sys.exit(1)
|
||||
|
|
|
@ -23,7 +23,6 @@ import subprocess
|
|||
import snapshot
|
||||
import numpy as np
|
||||
import _thread as thread
|
||||
import paths
|
||||
import paths_factory
|
||||
from recorders.video_capture import VideoCapture
|
||||
from i18n import _
|
||||
|
@ -48,7 +47,7 @@ def init_detector(lock):
|
|||
# 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())):
|
||||
print(_("Data files have not been downloaded, please run the following commands:"))
|
||||
print("\n\tcd " + str(paths.dlib_data_dir))
|
||||
print("\n\tcd " + paths_factory.dlib_data_dir_path())
|
||||
print("\tsudo ./install.sh\n")
|
||||
lock.release()
|
||||
exit(1)
|
||||
|
|
|
@ -8,32 +8,41 @@ models = [
|
|||
]
|
||||
|
||||
|
||||
def shape_predictor_5_face_landmarks_path() -> PurePath:
|
||||
return paths.dlib_data_dir / models[0]
|
||||
def dlib_data_dir_path() -> str:
|
||||
return str(paths.dlib_data_dir)
|
||||
|
||||
|
||||
def mmod_human_face_detector_path() -> PurePath:
|
||||
return paths.dlib_data_dir / models[1]
|
||||
def shape_predictor_5_face_landmarks_path() -> str:
|
||||
return str(paths.dlib_data_dir / models[0])
|
||||
|
||||
|
||||
def dlib_face_recognition_resnet_model_v1_path() -> PurePath:
|
||||
return paths.dlib_data_dir / models[2]
|
||||
def mmod_human_face_detector_path() -> str:
|
||||
return str(paths.dlib_data_dir / models[1])
|
||||
|
||||
|
||||
def user_model_path(user: str) -> PurePath:
|
||||
return paths.user_models_dir / f"{user}.dat"
|
||||
def dlib_face_recognition_resnet_model_v1_path() -> str:
|
||||
return str(paths.dlib_data_dir / models[2])
|
||||
|
||||
|
||||
def config_file_path() -> PurePath:
|
||||
return paths.config_dir / "config.ini"
|
||||
def user_model_path(user: str) -> str:
|
||||
return str(paths.user_models_dir / f"{user}.dat")
|
||||
|
||||
|
||||
def config_file_path() -> str:
|
||||
return str(paths.config_dir / "config.ini")
|
||||
|
||||
|
||||
def snapshots_dir_path() -> PurePath:
|
||||
return paths.log_path / "snapshots"
|
||||
|
||||
|
||||
def snapshot_path(snapshot: str) -> PurePath:
|
||||
return snapshots_dir_path() / snapshot
|
||||
def snapshot_path(snapshot: str) -> str:
|
||||
return str(snapshots_dir_path() / snapshot)
|
||||
|
||||
def logo_path() -> PurePath:
|
||||
return paths.data_dir / "logo.png"
|
||||
|
||||
def user_models_dir_path() -> str:
|
||||
return str(paths.user_models_dir)
|
||||
|
||||
|
||||
def logo_path() -> str:
|
||||
return str(paths.data_dir / "logo.png")
|
||||
|
|
Loading…
Reference in a new issue