From 0fb62ec39c3b4f5be3338a400b0b2c466fa76227 Mon Sep 17 00:00:00 2001 From: MikEarpp <72660689+MikEarpp@users.noreply.github.com> Date: Sun, 20 Dec 2020 14:53:04 +0100 Subject: [PATCH] Add mask endpoint --- frigate/http.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frigate/http.py b/frigate/http.py index 641ed80a7..afad570be 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -211,6 +211,7 @@ def mjpeg_feed(camera_name): return "Camera named {} not found".format(camera_name), 404 @bp.route('//latest.jpg') +@bp.route('//masked.jpg') def latest_frame(camera_name): if camera_name in current_app.frigate_config.cameras: # max out at specified FPS @@ -223,7 +224,11 @@ def latest_frame(camera_name): frame = cv2.resize(frame, dsize=(width, height), interpolation=cv2.INTER_AREA) - ret, jpg = cv2.imencode('.jpg', frame) + if '/masked.jpg' in request.path: + mask = cv2.addWeighted(frame, 0.5, cv2.cvtColor(cv2.resize(current_app.frigate_config.cameras[camera_name].mask, + dsize=(width, height), interpolation=cv2.INTER_AREA), cv2.COLOR_GRAY2RGB), 0.5, 0) + + ret, jpg = cv2.imencode('.jpg', frame if mask is None else mask) response = make_response(jpg.tobytes()) response.headers['Content-Type'] = 'image/jpg' return response