e1250 commited on
Commit
c1c755a
·
1 Parent(s): 4e69d39

feat: now the dashboared is synced with the backend and tested on an image

Browse files
api/routers/__pycache__/camera_stream.cpython-311.pyc CHANGED
Binary files a/api/routers/__pycache__/camera_stream.cpython-311.pyc and b/api/routers/__pycache__/camera_stream.cpython-311.pyc differ
 
api/routers/camera_stream.py CHANGED
@@ -74,21 +74,20 @@ async def websocket_detect(websocket: WebSocket, camera_id:str):
74
  detections, safety_detection = await asyncio.gather(detection_task, safety_task)
75
 
76
  boxes_center = []
 
77
  for box in detections.detections:
78
  print(type(box))
79
  xmin, ymin, xmax, ymax = box.xyxy
80
  xcenter = (xmax + xmin) / 2
81
  ycenter = (ymax + ymin) / 2
82
  boxes_center.append((int(xcenter), int(ycenter)))
 
83
 
84
- # print(depth_model)
85
  depth_points = await loop.run_in_executor(None, run_depth, image_array, boxes_center) if boxes_center else []
86
- # depth_points = []
87
- # print(depth_points)
88
- # print(type(depth_points))
89
- # print(boxes_center)
90
 
91
- metadata = CameraMetadata(camera_id=camera_id, is_danger = True if safety_detection else False, depth_points=depth_points)
 
 
92
  state.camera_metadata[camera_id] = metadata.model_dump()
93
 
94
  # Profiling
 
74
  detections, safety_detection = await asyncio.gather(detection_task, safety_task)
75
 
76
  boxes_center = []
77
+ boxes_center_ratio = []
78
  for box in detections.detections:
79
  print(type(box))
80
  xmin, ymin, xmax, ymax = box.xyxy
81
  xcenter = (xmax + xmin) / 2
82
  ycenter = (ymax + ymin) / 2
83
  boxes_center.append((int(xcenter), int(ycenter)))
84
+ boxes_center_ratio.append(xcenter / image_array.shape[1])
85
 
 
86
  depth_points = await loop.run_in_executor(None, run_depth, image_array, boxes_center) if boxes_center else []
 
 
 
 
87
 
88
+ detection_metadata = [{"depth": depth, "xRatio": xRatio} for depth, xRatio in zip(depth_points, boxes_center_ratio)]
89
+ metadata = CameraMetadata(camera_id=camera_id, is_danger = True if safety_detection else False, detection_metadata=detection_metadata)
90
+ print(metadata)
91
  state.camera_metadata[camera_id] = metadata.model_dump()
92
 
93
  # Profiling
contracts/__pycache__/camera_metadata.cpython-311.pyc CHANGED
Binary files a/contracts/__pycache__/camera_metadata.cpython-311.pyc and b/contracts/__pycache__/camera_metadata.cpython-311.pyc differ
 
contracts/camera_metadata.py CHANGED
@@ -5,4 +5,6 @@ from pydantic import BaseModel
5
  class CameraMetadata(BaseModel):
6
  camera_id: str
7
  is_danger: bool = False
8
- depth_points: List = []
 
 
 
5
  class CameraMetadata(BaseModel):
6
  camera_id: str
7
  is_danger: bool = False
8
+ detection_metadata: List
9
+ # depth_points: List = []
10
+ # box_detections_ratio: List = []