forked from Github/frigate
Replace green screen with error message and force camera_fps to 0 (#4544)
* Move to images specific folder * Send error image when camera stream is not available * Immediately set camera_fps to 0 if camera crashes * Cache error image so it is not read from file system on each run * Move camera fps set
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import base64
|
||||
from datetime import datetime, timedelta
|
||||
import copy
|
||||
import glob
|
||||
import logging
|
||||
import json
|
||||
import os
|
||||
@@ -62,6 +63,7 @@ def create_app(
|
||||
app.stats_tracking = stats_tracking
|
||||
app.detected_frames_processor = detected_frames_processor
|
||||
app.plus_api = plus_api
|
||||
app.camera_error_image = None
|
||||
|
||||
app.register_blueprint(bp)
|
||||
|
||||
@@ -657,8 +659,20 @@ 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
|
||||
):
|
||||
if current_app.camera_error_image is None:
|
||||
error_image = glob.glob("/opt/frigate/frigate/images/camera-error.jpg")
|
||||
|
||||
if len(error_image) > 0:
|
||||
current_app.camera_error_image = cv2.imread(
|
||||
error_image[0], cv2.IMREAD_UNCHANGED
|
||||
)
|
||||
|
||||
frame = current_app.camera_error_image
|
||||
|
||||
height = int(request.args.get("h", str(frame.shape[0])))
|
||||
width = int(height * frame.shape[1] / frame.shape[0])
|
||||
|
||||
Reference in New Issue
Block a user