mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 01:35:22 +03:00
Send error image when camera stream is not available
This commit is contained in:
parent
dff477d548
commit
1d648ed605
@ -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])
|
||||
|
||||
BIN
frigate/images/camera-error.jpg
Normal file
BIN
frigate/images/camera-error.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 143 KiB |
@ -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:
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user