Customize regions grid overlay

This commit is contained in:
tpjanssen 2023-11-19 11:53:21 +01:00
parent 7d157dfeb0
commit 2988969307
2 changed files with 23 additions and 4 deletions

View File

@ -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. 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` ### `GET /clips/<camera>-<id>.jpg`
JPG snapshot for the given camera and event id. JPG snapshot for the given camera and event id.

View File

@ -755,6 +755,20 @@ def grid_snapshot(camera_name):
500, 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_size = len(grid)
grid_coef = 1.0 / grid_size grid_coef = 1.0 / grid_size
width = detect.width width = detect.width
@ -775,7 +789,7 @@ def grid_snapshot(camera_name):
int((x + 1) * grid_coef * width), int((x + 1) * grid_coef * width),
int((y + 1) * grid_coef * height), int((y + 1) * grid_coef * height),
), ),
(0, 255, 0), draw_color,
2, 2,
) )
cv2.putText( cv2.putText(
@ -787,7 +801,7 @@ def grid_snapshot(camera_name):
), ),
cv2.FONT_HERSHEY_SIMPLEX, cv2.FONT_HERSHEY_SIMPLEX,
fontScale=0.5, fontScale=0.5,
color=(0, 255, 0), color=draw_color,
thickness=2, thickness=2,
) )
cv2.putText( cv2.putText(
@ -799,7 +813,7 @@ def grid_snapshot(camera_name):
), ),
cv2.FONT_HERSHEY_SIMPLEX, cv2.FONT_HERSHEY_SIMPLEX,
fontScale=0.5, fontScale=0.5,
color=(0, 255, 0), color=draw_color,
thickness=2, thickness=2,
) )
cv2.putText( cv2.putText(
@ -811,7 +825,7 @@ def grid_snapshot(camera_name):
), ),
cv2.FONT_HERSHEY_SIMPLEX, cv2.FONT_HERSHEY_SIMPLEX,
fontScale=0.5, fontScale=0.5,
color=(0, 255, 0), color=draw_color,
thickness=2, thickness=2,
) )