mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-04-10 01:15:54 +02:00
Use timestamp decorator helper in codebase
This commit is contained in:
parent
7bfe8e4f5b
commit
5075e4eee1
@ -20,7 +20,7 @@ import numpy as np
|
|||||||
from frigate.config import FrigateConfig, CameraConfig
|
from frigate.config import FrigateConfig, CameraConfig
|
||||||
from frigate.const import RECORD_DIR, CLIPS_DIR, CACHE_DIR
|
from frigate.const import RECORD_DIR, CLIPS_DIR, CACHE_DIR
|
||||||
from frigate.edgetpu import load_labels
|
from frigate.edgetpu import load_labels
|
||||||
from frigate.util import SharedMemoryFrameManager, draw_box_with_label, calculate_region
|
from frigate.util import SharedMemoryFrameManager, draw_box_with_label, draw_timestamp, calculate_region
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -268,23 +268,15 @@ class TrackedObject:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if timestamp:
|
if timestamp:
|
||||||
time_to_show = datetime.datetime.fromtimestamp(
|
draw_timestamp(
|
||||||
self.thumbnail_data["frame_time"]
|
frame_copy,
|
||||||
).strftime("%m/%d/%Y %H:%M:%S")
|
self.thumbnail_data["frame_time"],
|
||||||
size = cv2.getTextSize(
|
"%m/%d/%Y %H:%M:%S",
|
||||||
time_to_show, cv2.FONT_HERSHEY_SIMPLEX, fontScale=1, thickness=2
|
font_effect=None,
|
||||||
)
|
font_scale=1.0,
|
||||||
text_width = size[0][0]
|
font_thickness=2,
|
||||||
desired_size = max(150, 0.33 * best_frame.shape[1])
|
font_color=(255, 255, 255),
|
||||||
font_scale = desired_size / text_width
|
position="ul",
|
||||||
cv2.putText(
|
|
||||||
best_frame,
|
|
||||||
time_to_show,
|
|
||||||
(5, best_frame.shape[0] - 7),
|
|
||||||
cv2.FONT_HERSHEY_SIMPLEX,
|
|
||||||
fontScale=font_scale,
|
|
||||||
color=(255, 255, 255),
|
|
||||||
thickness=2,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
ret, jpg = cv2.imencode(".jpg", best_frame, [int(cv2.IMWRITE_JPEG_QUALITY), 70])
|
ret, jpg = cv2.imencode(".jpg", best_frame, [int(cv2.IMWRITE_JPEG_QUALITY), 70])
|
||||||
@ -407,17 +399,15 @@ class CameraState:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if draw_options.get("timestamp"):
|
if draw_options.get("timestamp"):
|
||||||
time_to_show = datetime.datetime.fromtimestamp(frame_time).strftime(
|
draw_timestamp(
|
||||||
"%m/%d/%Y %H:%M:%S"
|
|
||||||
)
|
|
||||||
cv2.putText(
|
|
||||||
frame_copy,
|
frame_copy,
|
||||||
time_to_show,
|
frame_time,
|
||||||
(10, 30),
|
"%m/%d/%Y %H:%M:%S",
|
||||||
cv2.FONT_HERSHEY_SIMPLEX,
|
font_effect=None,
|
||||||
fontScale=0.8,
|
font_scale=1.0,
|
||||||
color=(255, 255, 255),
|
font_thickness=2,
|
||||||
thickness=2,
|
font_color= (255, 255, 255),
|
||||||
|
position="ul",
|
||||||
)
|
)
|
||||||
|
|
||||||
return frame_copy
|
return frame_copy
|
||||||
|
Loading…
Reference in New Issue
Block a user