Alessio Grancini
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -255,24 +255,25 @@ def get_detection_data(image_data):
|
|
255 |
|
256 |
detections = []
|
257 |
for idx, obj in enumerate(objects_data):
|
258 |
-
|
|
|
259 |
x1, y1, x2, y2 = get_bbox_from_mask(mask)
|
260 |
depth_value = depth_at_center(depthmap, [x1, y1, x2, y2])
|
261 |
|
262 |
-
#
|
263 |
-
color_rgb = (int(color_bgr[2]), int(color_bgr[1]), int(color_bgr[0]))
|
264 |
|
265 |
detections.append({
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
|
277 |
response = {
|
278 |
"detections": detections,
|
|
|
255 |
|
256 |
detections = []
|
257 |
for idx, obj in enumerate(objects_data):
|
258 |
+
# Unpack all 6 values
|
259 |
+
cls_id, cls_name, center, mask, color_bgr, confidence = obj
|
260 |
x1, y1, x2, y2 = get_bbox_from_mask(mask)
|
261 |
depth_value = depth_at_center(depthmap, [x1, y1, x2, y2])
|
262 |
|
263 |
+
# Convert BGR to RGB
|
264 |
+
color_rgb = (int(color_bgr[2]), int(color_bgr[1]), int(color_bgr[0]))
|
265 |
|
266 |
detections.append({
|
267 |
+
"class_id": cls_id,
|
268 |
+
"class_name": cls_name,
|
269 |
+
"bounding_box": {
|
270 |
+
"vertices": get_box_vertices([x1, y1, x2, y2])
|
271 |
+
},
|
272 |
+
"position_3d": get_3d_position(center, depth_value, get_camera_matrix(depth_estimator)),
|
273 |
+
"distance": depth_value,
|
274 |
+
"color": color_rgb,
|
275 |
+
"confidence": float(confidence)
|
276 |
+
})
|
277 |
|
278 |
response = {
|
279 |
"detections": detections,
|