add overlays, pkgs

This commit is contained in:
2023-07-13 13:09:17 +02:00
parent c7aef44265
commit e21a47a2b5
34 changed files with 8812 additions and 2 deletions

View File

@@ -0,0 +1,155 @@
diff --git a/howdy/src/cli/add.py b/howdy/src/cli/add.py
index 8951e31..4f793d7 100644
--- a/howdy/src/cli/add.py
+++ b/howdy/src/cli/add.py
@@ -30,9 +30,9 @@ import cv2
config_path = "/etc/howdy"
# Test if at lest 1 of the data files is there and abort if it's not
-if not os.path.isfile(config_path + "/dlib-data/shape_predictor_5_face_landmarks.dat"):
+if not os.path.isfile("@pkgdatadir@/dlib-data/shape_predictor_5_face_landmarks.dat"):
print(_("Data files have not been downloaded, please run the following commands:"))
- print("\n\tcd " + config_path + "/dlib-data")
+ print("\n\tcd " + "@pkgdatadir@/dlib-data")
print("\tsudo ./install.sh\n")
sys.exit(1)
@@ -42,23 +42,23 @@ config.read(config_path + "/config.ini")
use_cnn = config.getboolean("core", "use_cnn", fallback=False)
if use_cnn:
- face_detector = dlib.cnn_face_detection_model_v1(config_path + "/dlib-data/mmod_human_face_detector.dat")
+ face_detector = dlib.cnn_face_detection_model_v1("@pkgdatadir@/dlib-data/mmod_human_face_detector.dat")
else:
face_detector = dlib.get_frontal_face_detector()
-pose_predictor = dlib.shape_predictor(config_path + "/dlib-data/shape_predictor_5_face_landmarks.dat")
-face_encoder = dlib.face_recognition_model_v1(config_path + "/dlib-data/dlib_face_recognition_resnet_model_v1.dat")
+pose_predictor = dlib.shape_predictor("@pkgdatadir@/dlib-data/shape_predictor_5_face_landmarks.dat")
+face_encoder = dlib.face_recognition_model_v1("@pkgdatadir@/dlib-data/dlib_face_recognition_resnet_model_v1.dat")
user = builtins.howdy_user
# The permanent file to store the encoded model in
-enc_file = config_path + "/models/" + user + ".dat"
+enc_file = "/var/lib/howdy/models/" + user + ".dat"
# Known encodings
encodings = []
# Make the ./models folder if it doesn't already exist
-if not os.path.exists(config_path + "/models"):
+if not os.path.exists("/var/lib/howdy/models"):
print(_("No face model folder found, creating one"))
- os.makedirs(config_path + "/models")
+ os.makedirs("/var/lib/howdy/models")
# To try read a premade encodings file if it exists
try:
diff --git a/howdy/src/cli/clear.py b/howdy/src/cli/clear.py
index 6fa5f3e..fc7676c 100644
--- a/howdy/src/cli/clear.py
+++ b/howdy/src/cli/clear.py
@@ -8,7 +8,7 @@ import builtins
from i18n import _
# Get the full path to this file
-path = "/etc/howdy/models"
+path = "/var/lib/howdy/models"
# Get the passed user
user = builtins.howdy_user
diff --git a/howdy/src/cli/list.py b/howdy/src/cli/list.py
index 3532e9f..b9e2a31 100644
--- a/howdy/src/cli/list.py
+++ b/howdy/src/cli/list.py
@@ -10,7 +10,7 @@ import builtins
from i18n import _
# Get the absolute path and the username
-path = "/etc/howdy"
+path = "/var/lib/howdy"
user = builtins.howdy_user
# Check if the models file has been created yet
diff --git a/howdy/src/cli/remove.py b/howdy/src/cli/remove.py
index 6321e0b..7c13d79 100644
--- a/howdy/src/cli/remove.py
+++ b/howdy/src/cli/remove.py
@@ -9,7 +9,7 @@ import builtins
from i18n import _
# Get the absolute path and the username
-path = "/etc/howdy"
+path = "/var/lib/howdy"
user = builtins.howdy_user
# Check if enough arguments have been passed
diff --git a/howdy/src/cli/test.py b/howdy/src/cli/test.py
index d54929a..fa45500 100644
--- a/howdy/src/cli/test.py
+++ b/howdy/src/cli/test.py
@@ -59,20 +59,20 @@ use_cnn = config.getboolean('core', 'use_cnn', fallback=False)
if use_cnn:
face_detector = dlib.cnn_face_detection_model_v1(
- path + "/dlib-data/mmod_human_face_detector.dat"
+ "@pkgdatadir@/dlib-data/mmod_human_face_detector.dat"
)
else:
face_detector = dlib.get_frontal_face_detector()
-pose_predictor = dlib.shape_predictor(path + "/dlib-data/shape_predictor_5_face_landmarks.dat")
-face_encoder = dlib.face_recognition_model_v1(path + "/dlib-data/dlib_face_recognition_resnet_model_v1.dat")
+pose_predictor = dlib.shape_predictor("@pkgdatadir@/dlib-data/shape_predictor_5_face_landmarks.dat")
+face_encoder = dlib.face_recognition_model_v1("@pkgdatadir@/dlib-data/dlib_face_recognition_resnet_model_v1.dat")
encodings = []
models = None
try:
user = builtins.howdy_user
- models = json.load(open(path + "/models/" + user + ".dat"))
+ models = json.load(open("/var/lib/howdy/models/" + user + ".dat"))
for model in models:
encodings += model["data"]
diff --git a/howdy/src/compare.py b/howdy/src/compare.py
index be19464..86a8d8f 100644
--- a/howdy/src/compare.py
+++ b/howdy/src/compare.py
@@ -48,22 +48,22 @@ 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(PATH + "/dlib-data/shape_predictor_5_face_landmarks.dat"):
+ if not os.path.isfile("@pkgdatadir@/dlib-data/shape_predictor_5_face_landmarks.dat"):
print(_("Data files have not been downloaded, please run the following commands:"))
- print("\n\tcd " + PATH + "/dlib-data")
+ print("\n\tcd " + "@pkgdatadir@/dlib-data")
print("\tsudo ./install.sh\n")
lock.release()
exit(1)
# Use the CNN detector if enabled
if use_cnn:
- face_detector = dlib.cnn_face_detection_model_v1(PATH + "/dlib-data/mmod_human_face_detector.dat")
+ face_detector = dlib.cnn_face_detection_model_v1("@pkgdatadir@/dlib-data/mmod_human_face_detector.dat")
else:
face_detector = dlib.get_frontal_face_detector()
# Start the others regardless
- pose_predictor = dlib.shape_predictor(PATH + "/dlib-data/shape_predictor_5_face_landmarks.dat")
- face_encoder = dlib.face_recognition_model_v1(PATH + "/dlib-data/dlib_face_recognition_resnet_model_v1.dat")
+ pose_predictor = dlib.shape_predictor("@pkgdatadir@/dlib-data/shape_predictor_5_face_landmarks.dat")
+ face_encoder = dlib.face_recognition_model_v1("@pkgdatadir@/dlib-data/dlib_face_recognition_resnet_model_v1.dat")
# Note the time it took to initialize detectors
timings["ll"] = time.time() - timings["ll"]
@@ -129,7 +129,7 @@ face_encoder = None
# Try to load the face model from the models folder
try:
- models = json.load(open(PATH + "/models/" + user + ".dat"))
+ models = json.load(open("/var/lib/howdy/models/" + user + ".dat"))
for model in models:
encodings += model["data"]