Skip to content

NVR with realtime local object detection for IP cameras

Customize regions grid overlay API (#8668)

tpjanssen8864e33d1ceb
diff --git a/docs/docs/integrations/api.md b/docs/docs/integrations/api.md
index 304cec60ec..a4efd85bfb 100644
--- a/docs/docs/integrations/api.md
+++ b/docs/docs/integrations/api.md
@@ -267,6 +267,11 @@ Returns the snapshot image from the specific point in that cameras recordings.
Returns the latest camera image with the regions grid overlaid.
+| param | Type | Description |
+| ------------ | ----- | ------------------------------------------------------------------------------------------ |
+| `color` | str | The color of the grid (red,green,blue,black,white). Defaults to "green". |
+| `font_scale` | float | Font scale. Can be used to increase font size on high resolution cameras. Defaults to 0.5. |
+
### `GET /clips/<camera>-<id>.jpg`
JPG snapshot for the given camera and event id.
diff --git a/frigate/http.py b/frigate/http.py
index 2a581ac9f2..1ca87bdf93 100644
--- a/frigate/http.py
+++ b/frigate/http.py
@@ -755,6 +755,20 @@ def grid_snapshot(camera_name):
500,
)
+ color_arg = request.args.get("color", default="", type=str).lower()
+ draw_font_scale = request.args.get("font_scale", default=0.5, type=float)
+
+ if color_arg == "red":
+ draw_color = (0, 0, 255)
+ elif color_arg == "blue":
+ draw_color = (255, 0, 0)
+ elif color_arg == "black":
+ draw_color = (0, 0, 0)
+ elif color_arg == "white":
+ draw_color = (255, 255, 255)
+ else:
+ draw_color = (0, 255, 0)
+
grid_size = len(grid)
grid_coef = 1.0 / grid_size
width = detect.width
@@ -775,7 +789,7 @@ def grid_snapshot(camera_name):
int((x + 1) * grid_coef * width),
int((y + 1) * grid_coef * height),
),
- (0, 255, 0),
+ draw_color,
2,
)
cv2.putText(
@@ -786,8 +800,8 @@ def grid_snapshot(camera_name):
int((y * grid_coef + 0.02) * height),
),
cv2.FONT_HERSHEY_SIMPLEX,
- fontScale=0.5,
- color=(0, 255, 0),
+ fontScale=draw_font_scale,
+ color=draw_color,
thickness=2,
)
cv2.putText(
@@ -798,8 +812,8 @@ def grid_snapshot(camera_name):
int((y * grid_coef + 0.05) * height),
),
cv2.FONT_HERSHEY_SIMPLEX,
- fontScale=0.5,
- color=(0, 255, 0),
+ fontScale=draw_font_scale,
+ color=draw_color,
thickness=2,
)
cv2.putText(
@@ -810,8 +824,8 @@ def grid_snapshot(camera_name):
int((y * grid_coef + 0.08) * height),
),
cv2.FONT_HERSHEY_SIMPLEX,
- fontScale=0.5,
- color=(0, 255, 0),
+ fontScale=draw_font_scale,
+ color=draw_color,
thickness=2,
)