1515from  scipy .spatial .transform  import  Rotation  as  R 
1616from  tqdm  import  tqdm 
1717
18+ Color  =  Tuple [float , float , float , float ]
19+ 
1820# hack for now since dataset does not provide orientation information, only known after initial visual inspection 
1921ORIENTATION  =  {
2022    "48458663" : "landscape" ,
@@ -34,9 +36,7 @@ def load_json(js_path: Path) -> Dict[str, Any]:
3436    return  json_data 
3537
3638
37- def  log_annotated_bboxes (
38-     annotation : Dict [str , Any ]
39- ) ->  Tuple [npt .NDArray [np .float64 ], List [str ], List [Tuple [int , int , int , int ]]]:
39+ def  log_annotated_bboxes (annotation : Dict [str , Any ]) ->  Tuple [npt .NDArray [np .float64 ], List [str ], List [Color ]]:
4040    """ 
4141    Logs annotated oriented bounding boxes to Rerun. 
4242
@@ -56,8 +56,7 @@ def log_annotated_bboxes(
5656    # TODO(pablovela5620): Once #1581 or #1728 is resolved this can be removed 
5757    color_positions  =  np .linspace (0 , 1 , num_objects )
5858    colormap  =  plt .cm .get_cmap ("viridis" )
59-     color_array_float  =  [colormap (pos ) for  pos  in  color_positions ]
60-     color_list  =  [(int (r  *  255 ), int (g  *  255 ), int (b  *  255 ), int (a  *  255 )) for  r , g , b , a  in  color_array_float ]
59+     colors  =  [colormap (pos ) for  pos  in  color_positions ]
6160
6261    for  i , label_info  in  enumerate (annotation ["data" ]):
6362        uid  =  label_info ["uid" ]
@@ -75,15 +74,15 @@ def log_annotated_bboxes(
7574            position = centroid ,
7675            rotation_q = rot .as_quat (),
7776            label = label ,
78-             color = color_list [i ],
77+             color = colors [i ],
7978            timeless = True ,
8079        )
8180
8281        box3d  =  compute_box_3d (half_size , centroid , rotation )
8382        bbox_list .append (box3d )
8483        bbox_labels .append (label )
8584    bboxes_3d  =  np .array (bbox_list )
86-     return  bboxes_3d , bbox_labels , color_list 
85+     return  bboxes_3d , bbox_labels , colors 
8786
8887
8988def  compute_box_3d (
@@ -109,9 +108,7 @@ def compute_box_3d(
109108    return  bbox3d_raw 
110109
111110
112- def  log_line_segments (
113-     entity_path : str , bboxes_2d_filtered : npt .NDArray [np .float64 ], color : Tuple [int , int , int , int ], label : str 
114- ) ->  None :
111+ def  log_line_segments (entity_path : str , bboxes_2d_filtered : npt .NDArray [np .float64 ], color : Color , label : str ) ->  None :
115112    """ 
116113    Generates line segments for each object's bounding box in 2d. 
117114
@@ -236,7 +233,7 @@ def log_camera(
236233    entity_id : str ,
237234    bboxes : npt .NDArray [np .float64 ],
238235    bbox_labels : List [str ],
239-     color_list : List [Tuple [ int ,  int ,  int ,  int ] ],
236+     colors : List [Color ],
240237) ->  None :
241238    """Logs camera transform and 3D bounding boxes in the image frame.""" 
242239    w , h , fx , fy , cx , cy  =  np .loadtxt (intri_path )
@@ -250,7 +247,7 @@ def log_camera(
250247    rr .log_cleared (f"{ entity_id }  /bbox-2d-segments" , recursive = True )
251248    # Log line segments for each bounding box in the image 
252249    for  i , (label , bbox_2d ) in  enumerate (zip (bbox_labels , bboxes_2d )):
253-         log_line_segments (f"{ entity_id }  /bbox-2d-segments/{ label }  " , bbox_2d .reshape (- 1 , 2 ), color_list [i ], label )
250+         log_line_segments (f"{ entity_id }  /bbox-2d-segments/{ label }  " , bbox_2d .reshape (- 1 , 2 ), colors [i ], label )
254251
255252    rr .log_rigid3 (
256253        # pathlib makes it easy to get the parent, but log_rigid requires a string 
0 commit comments