mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 18:55:23 +03:00
Support multiple box annotations
This commit is contained in:
parent
9ba7f5c2ae
commit
1eb9403dc1
@ -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
|
"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
|
"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
|
"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
|
"draw": {
|
||||||
"box": [0.5, 0.5, 0.25, 0.25], // box consists of x, 1, width, height which are on a scale between 0 - 1
|
// optional annotations that will be drawn on the snapshot
|
||||||
"color": [255, 0, 0], // color of the box, default is red
|
"boxes": [
|
||||||
"score": 100, // optional score of the object
|
{
|
||||||
},
|
"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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -107,23 +107,24 @@ class ExternalEventProcessor:
|
|||||||
p.write(png.tobytes())
|
p.write(png.tobytes())
|
||||||
|
|
||||||
# write jpg snapshot with optional annotations
|
# write jpg snapshot with optional annotations
|
||||||
if draw.get("box"):
|
if draw.get("boxes") and isinstance(draw.get("boxes"), list):
|
||||||
x = draw["box"][0] * camera_config.detect.width
|
for box in draw.get("boxes"):
|
||||||
y = draw["box"][1] * camera_config.detect.height
|
x = box["box"][0] * camera_config.detect.width
|
||||||
width = draw["box"][2] * camera_config.detect.width
|
y = box["box"][1] * camera_config.detect.height
|
||||||
height = draw["box"][3] * camera_config.detect.height
|
width = box["box"][2] * camera_config.detect.width
|
||||||
|
height = box["box"][3] * camera_config.detect.height
|
||||||
|
|
||||||
draw_box_with_label(
|
draw_box_with_label(
|
||||||
img_bytes,
|
img_bytes,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
x + width,
|
x + width,
|
||||||
y + height,
|
y + height,
|
||||||
label,
|
label,
|
||||||
f"{draw.get('score', '-')}% {int(width * height)}",
|
f"{box.get('score', '-')}% {int(width * height)}",
|
||||||
thickness=2,
|
thickness=2,
|
||||||
color=draw.get("color", (255, 0, 0)),
|
color=box.get("color", (255, 0, 0)),
|
||||||
)
|
)
|
||||||
|
|
||||||
ret, jpg = cv2.imencode(".jpg", img_bytes)
|
ret, jpg = cv2.imencode(".jpg", img_bytes)
|
||||||
with open(
|
with open(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user