diff --git a/frigate/http.py b/frigate/http.py index f8d3e6325..703a6d6db 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -1,6 +1,7 @@ import base64 from datetime import datetime, timedelta import copy +import glob import logging import json import os @@ -657,8 +658,15 @@ def latest_frame(camera_name): frame = current_app.detected_frames_processor.get_current_frame( camera_name, draw_options ) - if frame is None: - frame = np.zeros((720, 1280, 3), np.uint8) + + if frame is None or datetime.now().timestamp() > ( + current_app.detected_frames_processor.get_current_frame_time(camera_name) + + 10 + ): + error_image = glob.glob("/opt/frigate/frigate/images/camera-error.jpg") + + if len(error_image) > 0: + frame = cv2.imread(error_image[0], cv2.IMREAD_UNCHANGED) height = int(request.args.get("h", str(frame.shape[0]))) width = int(height * frame.shape[1] / frame.shape[0]) diff --git a/frigate/images/camera-error.jpg b/frigate/images/camera-error.jpg new file mode 100644 index 000000000..ace648fde Binary files /dev/null and b/frigate/images/camera-error.jpg differ diff --git a/frigate/object_processing.py b/frigate/object_processing.py index 4ea3b5e6c..752e2e788 100644 --- a/frigate/object_processing.py +++ b/frigate/object_processing.py @@ -882,6 +882,10 @@ class TrackedObjectProcessor(threading.Thread): def get_current_frame(self, camera, draw_options={}): return self.camera_states[camera].get_current_frame(draw_options) + def get_current_frame_time(self, camera) -> int: + """Returns the latest frame time for a given camera.""" + return self.camera_states[camera].current_frame_time + def run(self): while not self.stop_event.is_set(): try: diff --git a/frigate/output.py b/frigate/output.py index 1a7549748..865a8d367 100644 --- a/frigate/output.py +++ b/frigate/output.py @@ -7,7 +7,6 @@ import queue import signal import subprocess as sp import threading -from multiprocessing import shared_memory from wsgiref.simple_server import make_server import cv2