1212 print ("Cannot find ipywidgets...cannot run visualizations" )
1313
1414from avstack .environment .objects import VehicleState
15- from avstack .geometry import bbox
15+ from avstack .geometry import Attitude , GlobalOrigin3D , Position , bbox
1616from avstack .modules .perception .detections import BoxDetection
1717
18- from .snapshot import show_image_with_boxes
19-
18+ from avapi .utils import color_from_object_type
2019
21- # from avapi.evaluation import ResultManager, color_from_object_type
20+ from . snapshot import show_image_with_boxes
2221
2322
2423# ========================================================
@@ -91,6 +90,8 @@ def load_ground_truth_data(folder):
9190
9291
9392def replay_ground_truth_from_folder (folder , viz_type = "track" ):
93+ from avapi .evaluation import ResultManager
94+
9495 assert viz_type in ["track" , "track_percep" ]
9596 print ("Replaying ground truth data from {}" .format (folder ))
9697 ego_data , npc_data = load_ground_truth_data (folder )
@@ -120,6 +121,8 @@ def replay_ground_truth_from_folder(folder, viz_type="track"):
120121
121122
122123def replay_ground_truth_from_data_manager (DM , sensor = "main_camera" ):
124+ from avapi .evaluation import ResultManager
125+
123126 ego_data = [DM .get_ego (frame ) for frame in DM .frames ]
124127 npc_data = [DM .get_objects (frame ) for frame in DM .frames ]
125128
@@ -197,7 +200,7 @@ def replay_track_results(
197200 add_points_real .append ([])
198201 for pt in pts :
199202 if (pt is not None ) and (not isinstance (pt , str )):
200- pt .change_origin ( NominalOriginStandard )
203+ pt .change_reference ( GlobalOrigin3D , inplace = True )
201204 add_points_real [i ].append (pt )
202205 add_points = add_points_real
203206 if (highlight_track_IDs is None ) or (len (highlight_track_IDs ) == 0 ):
@@ -206,7 +209,7 @@ def replay_track_results(
206209 assert len (highlight_track_IDs ) == len (track_results ), len (highlight_track_IDs )
207210
208211 if ego_box is not None :
209- ego_box .change_origin ( NominalOriginStandard )
212+ ego_box .change_reference ( GlobalOrigin3D , inplace = True )
210213
211214 # Get all track locations and predictions ahead of time
212215 trk_points = {} # ID: frame: pt
@@ -216,7 +219,7 @@ def replay_track_results(
216219 for idx , tr in track_results .items ():
217220 for track in tr ["result" ].tracks :
218221 if isinstance (track , VehicleState ):
219- track .change_origin ( NominalOriginStandard )
222+ track .change_reference ( GlobalOrigin3D , inplace = True )
220223 if track .ID not in trk_points :
221224 trk_points [track .ID ] = {}
222225 trk_preds [track .ID ] = {}
@@ -229,7 +232,7 @@ def replay_track_results(
229232 raise NotImplementedError (type (track ))
230233 for truth in tr ["result" ].truths :
231234 if isinstance (truth , VehicleState ):
232- truth .change_origin ( NominalOriginStandard )
235+ truth .change_reference ( GlobalOrigin3D , inplace = True )
233236
234237 def f (idx ):
235238 axs_slider .clear ()
@@ -255,14 +258,9 @@ def plot_tracks(colors, tracks):
255258 if do_highlight :
256259 fac = 1.2
257260 box_enlarged = bbox .Box3D (
258- [
259- fac * track .box .h ,
260- fac * track .box .w ,
261- fac * track .box .l ,
262- track .position ,
263- track .box .attitude ,
264- ],
265- track .position .origin ,
261+ position = track .position ,
262+ attitude = track .attitude ,
263+ hwl = [fac * d for d in track .box .size ],
266264 )
267265 axs_slider .add_patch (
268266 _box_to_bev_rect (
@@ -361,7 +359,7 @@ def plot_tracks(colors, tracks):
361359 ):
362360 col = tuple (c / 255.0 for c in color )
363361 if "bev" in projection :
364- truth .box3d .change_origin ( NominalOriginStandard )
362+ truth .box3d .change_reference ( GlobalOrigin3D , inplace = True )
365363 rect = _box_to_bev_rect (
366364 truth .box3d ,
367365 col ,
@@ -376,7 +374,9 @@ def plot_tracks(colors, tracks):
376374
377375 # add fake elements to legend
378376 nominal_box = bbox .Box3D (
379- [2 , 2 , 4 , np .zeros ((3 ,)), np .quaternion (1 )], NominalOriginStandard
377+ position = Position (np .zeros ((3 ,)), GlobalOrigin3D ),
378+ attitude = Attitude (np .quaternion (1 ), GlobalOrigin3D ),
379+ hwl = [2 , 2 , 4 ],
380380 )
381381 # -- unsafe
382382 handles .append (
@@ -535,12 +535,12 @@ def replay_track_percep_results(
535535 track_boxes = []
536536 for trk in track_results [idx ]["result" ].tracks :
537537 trk_copy = deepcopy (trk ).as_object ()
538- trk_copy .change_origin (calib .origin )
538+ trk_copy .change_reference (calib .reference , inplace = True )
539539 track_boxes .append (trk_copy )
540540 box_colors = track_results [idx ]["result" ].colors ["detections" ]
541541 if show_truth :
542542 for truth in track_results [idx ]["result" ].truths :
543- truth .box .change_origin (calib .origin )
543+ truth .box .change_reference (calib .reference , inplace = True )
544544 track_boxes .append (truth )
545545 box_colors .extend (track_results [idx ]["result" ].colors ["truths" ])
546546 else :
@@ -553,7 +553,10 @@ def replay_track_percep_results(
553553 if "fv" in projection :
554554 img = DM .get_image (idx , sensor = sensor )
555555 img3d = show_image_with_boxes (
556- img , track_boxes , box_colors = box_colors , show = False , return_images = True
556+ img ,
557+ track_boxes ,
558+ box_colors = box_colors ,
559+ show = False ,
557560 )
558561 imgs_ALL ["fv" ] = (
559562 img3d [..., None ]
@@ -612,7 +615,7 @@ def _box_to_bev_rect(
612615 (left , bottom ),
613616 width ,
614617 height ,
615- angle ,
618+ angle = angle ,
616619 alpha = 0.9 ,
617620 edgecolor = color ,
618621 facecolor = facecolor ,
0 commit comments