This commit is contained in:
Josh Hawkins
2025-05-17 16:11:19 -06:00
committed by GitHub
parent ebae6cb1ed
commit 5d13925d2b
12 changed files with 45 additions and 14 deletions
+2 -1
View File
@@ -172,6 +172,7 @@ class CameraState:
# draw any attributes
for attribute in obj["current_attributes"]:
box = attribute["box"]
box_area = int((box[2] - box[0]) * (box[3] - box[1]))
draw_box_with_label(
frame_copy,
box[0],
@@ -179,7 +180,7 @@ class CameraState:
box[2],
box[3],
attribute["label"],
f"{attribute['score']:.0%}",
f"{attribute['score']:.0%} {str(box_area)}",
thickness=thickness,
color=color,
)
+3 -2
View File
@@ -12,6 +12,7 @@ from typing import Any, Callable
from py_vapid import Vapid01
from pywebpush import WebPusher
from titlecase import titlecase
from frigate.comms.base_communicator import Communicator
from frigate.comms.config_updater import ConfigSubscriber
@@ -325,8 +326,8 @@ class WebPushClient(Communicator): # type: ignore[misc]
sorted_objects.update(payload["after"]["data"]["sub_labels"])
title = f"{', '.join(sorted_objects).replace('_', ' ').title()}{' was' if state == 'end' else ''} detected in {', '.join(payload['after']['data']['zones']).replace('_', ' ').title()}"
message = f"Detected on {camera.replace('_', ' ').title()}"
title = f"{titlecase(', '.join(sorted_objects).replace('_', ' '))}{' was' if state == 'end' else ''} detected in {titlecase(', '.join(payload['after']['data']['zones']).replace('_', ' '))}"
message = f"Detected on {titlecase(camera.replace('_', ' '))}"
image = f"{payload['after']['thumb_path'].replace('/media/frigate', '')}"
# if event is ongoing open to live view otherwise open to recordings view
+4 -4
View File
@@ -5,12 +5,12 @@ import json
import logging
import multiprocessing as mp
import os
import re
import signal
import threading
from types import FrameType
from typing import Any, Optional, Union
import regex
from pathvalidate import ValidationError, sanitize_filename
from setproctitle import setproctitle
@@ -243,7 +243,7 @@ class EmbeddingsContext:
)
def rename_face(self, old_name: str, new_name: str) -> None:
valid_name_pattern = r"^[a-zA-Z0-9\s_-]{1,50}$"
valid_name_pattern = r"^[\p{L}\p{N}\s'_-]{1,50}$"
try:
sanitized_old_name = sanitize_filename(old_name, replacement_text="_")
@@ -251,9 +251,9 @@ class EmbeddingsContext:
except ValidationError as e:
raise ValueError(f"Invalid face name: {str(e)}")
if not re.match(valid_name_pattern, old_name):
if not regex.match(valid_name_pattern, old_name):
raise ValueError(f"Invalid old face name: {old_name}")
if not re.match(valid_name_pattern, new_name):
if not regex.match(valid_name_pattern, new_name):
raise ValueError(f"Invalid new face name: {new_name}")
if sanitized_old_name != old_name:
raise ValueError(f"Old face name contains invalid characters: {old_name}")
+2 -1
View File
@@ -474,6 +474,7 @@ class TrackedObject:
# draw any attributes
for attribute in self.thumbnail_data["attributes"]:
box = attribute["box"]
box_area = int((box[2] - box[0]) * (box[3] - box[1]))
draw_box_with_label(
best_frame,
box[0],
@@ -481,7 +482,7 @@ class TrackedObject:
box[2],
box[3],
attribute["label"],
f"{attribute['score']:.0%}",
f"{attribute['score']:.0%} {str(box_area)}",
thickness=thickness,
color=color,
)