Alessio Grancini
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -258,6 +258,10 @@ def get_detection_data(image_data):
|
|
| 258 |
cls_id, cls_name, center, mask, _ = obj
|
| 259 |
x1, y1, x2, y2 = get_bbox_from_mask(mask)
|
| 260 |
depth_value = depth_at_center(depthmap, [x1, y1, x2, y2])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
|
| 262 |
detections.append({
|
| 263 |
"class_id": cls_id,
|
|
@@ -267,6 +271,8 @@ def get_detection_data(image_data):
|
|
| 267 |
},
|
| 268 |
"position_3d": get_3d_position(center, depth_value, get_camera_matrix(depth_estimator)),
|
| 269 |
"distance": depth_value
|
|
|
|
|
|
|
| 270 |
})
|
| 271 |
|
| 272 |
response = {
|
|
|
|
| 258 |
cls_id, cls_name, center, mask, _ = obj
|
| 259 |
x1, y1, x2, y2 = get_bbox_from_mask(mask)
|
| 260 |
depth_value = depth_at_center(depthmap, [x1, y1, x2, y2])
|
| 261 |
+
# Get color in RGB format (OpenCV uses BGR)
|
| 262 |
+
color_bgr = objects_data[idx][4] # cls_clr from the objects_data
|
| 263 |
+
color_rgb = (color_bgr[2], color_bgr[1], color_bgr[0]) # Convert BGR to RGB
|
| 264 |
+
|
| 265 |
|
| 266 |
detections.append({
|
| 267 |
"class_id": cls_id,
|
|
|
|
| 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(objects_data[idx][5]) # Add confidence score
|
| 276 |
})
|
| 277 |
|
| 278 |
response = {
|