diff --git a/docs/docs/integrations/api.md b/docs/docs/integrations/api.md index fbdb5a25d..e7d85574d 100644 --- a/docs/docs/integrations/api.md +++ b/docs/docs/integrations/api.md @@ -307,11 +307,16 @@ Create a manual API with a given `label` (ex: doorbell press) to capture a speci "subLabel": "some_string", // add sub label to event "duration": 30, // predetermined length of event (default: 30 seconds) or can be to null for indeterminate length event "include_recording": true, // whether the event should save recordings along with the snapshot that is taken - "draw": { // optional bounding box that will be drawn on the snapshot - "box": [0.5, 0.5, 0.25, 0.25], // box consists of x, 1, width, height which are on a scale between 0 - 1 - "color": [255, 0, 0], // color of the box, default is red - "score": 100, // optional score of the object - }, + "draw": { + // optional annotations that will be drawn on the snapshot + "boxes": [ + { + "box": [0.5, 0.5, 0.25, 0.25], // box consists of x, 1, width, height which are on a scale between 0 - 1 + "color": [255, 0, 0], // color of the box, default is red + "score": 100 // optional score of the object + } + ] + } } ``` diff --git a/frigate/events/external.py b/frigate/events/external.py index 9dd8d98c9..87befe559 100644 --- a/frigate/events/external.py +++ b/frigate/events/external.py @@ -107,23 +107,24 @@ class ExternalEventProcessor: p.write(png.tobytes()) # write jpg snapshot with optional annotations - if draw.get("box"): - x = draw["box"][0] * camera_config.detect.width - y = draw["box"][1] * camera_config.detect.height - width = draw["box"][2] * camera_config.detect.width - height = draw["box"][3] * camera_config.detect.height + if draw.get("boxes") and isinstance(draw.get("boxes"), list): + for box in draw.get("boxes"): + x = box["box"][0] * camera_config.detect.width + y = box["box"][1] * camera_config.detect.height + width = box["box"][2] * camera_config.detect.width + height = box["box"][3] * camera_config.detect.height - draw_box_with_label( - img_bytes, - x, - y, - x + width, - y + height, - label, - f"{draw.get('score', '-')}% {int(width * height)}", - thickness=2, - color=draw.get("color", (255, 0, 0)), - ) + draw_box_with_label( + img_bytes, + x, + y, + x + width, + y + height, + label, + f"{box.get('score', '-')}% {int(width * height)}", + thickness=2, + color=box.get("color", (255, 0, 0)), + ) ret, jpg = cv2.imencode(".jpg", img_bytes) with open(