Translate box dimensions from API call #9372
Replies: 3 comments 7 replies
-
The data is stored in events as |
Beta Was this translation helpful? Give feedback.
-
Thanks. x_left and y_top - so to get (x0, y0, x1, y1) I'd need ([0], [1]-[3], [0]+[2], [1]). I'd have thought ([0], [1], [0]+[2], [1]+[3]) would have been more logical? |
Beta Was this translation helpful? Give feedback.
-
Ok, worked it out thanks! However, we're still seeing inconsistencies between the coordinates returned in |
Beta Was this translation helpful? Give feedback.
-
I'm trying to get a snapshot of an event and get the closest possible bounding box for the associated license_plate.
I appreciate that the box dimensions in an mqtt message won't always align with the snapshot, particularly if it take a few ms to grab the snapshot after receiving an MQTT message.
To get around this, I'm making an API call to get the screenshot (
GET /api/events/<id>/snapshot.jpg
) and immediately get the event data (GET /api/events/<id>
).However, I've noticed that the box dimensions for a license_plate attribute in the API call are decimals, as distinct from x_min, y_min, x_max, y_max based on the image size within MQTT messages.
My question is simple - how to I translate the box coordinates in a
GET /api/events/<id>
so that I can manually draw a bounding box using a python draw command? I've tested the obvious of multiplying each of the 4 coordinates by image_width and image_height as appropriate, but I don't get a box anywhere near the right position on the snapshot.I suspect I'm doing something very obvious, but can't work it out!
plate = ( final_attribute[0]['box'][0]*image_height, final_attribute[0]['box'][1]*image_width, final_attribute[0]['box'][2]*image_height, final_attribute[0]['box'][3]*image_width ) draw.rectangle(plate, outline="green", width=2) _LOGGER.debug(f"Final Plate: {plate}")
Beta Was this translation helpful? Give feedback.
All reactions