Skip to content

Commit cf466ed

Browse files
author
spencer@primus
committed
Add visualization tweaks to box plots
1 parent e964c35 commit cf466ed

2 files changed

Lines changed: 28 additions & 16 deletions

File tree

avapi/visualize/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def draw_box2d(image, qs, color=(255, 255, 255), thickness=2):
4343

4444

4545
def draw_projected_box3d(
46-
image, qs, color=(255, 255, 255), thickness=2, ID=None, fontscale=1
46+
image, qs, color=(255, 255, 255), thickness=2, ID=None, fontscale=1, filled=False
4747
):
4848
"""Draw 3d bounding box in image
4949
qs: (8,3) array of vertices for the 3d box in following order:
@@ -133,4 +133,8 @@ def draw_projected_box3d(
133133
lineType,
134134
)
135135

136+
# fill the box if asked
137+
if filled:
138+
raise NotImplementedError
139+
136140
return image

avapi/visualize/snapshot.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
from avstack import maskfilters
77
from avstack.datastructs import DataContainer
8-
from avstack.environment.objects import VehicleState
8+
from avstack.environment.objects import ObjectState
99
from avstack.geometry import Box2D, Box3D, bbox
1010
from avstack.geometry.transformations import project_to_image
1111
from avstack.modules.perception.detections import BoxDetection, MaskDetection
@@ -74,12 +74,12 @@ def show_boxes_bev(
7474
):
7575
continue # cannot show 2D boxes
7676
elif (
77-
isinstance(box, (VehicleState, Box3D))
77+
isinstance(box, (ObjectState, Box3D))
7878
or (isinstance(box, BoxDetection) and isinstance(box.box, Box3D))
7979
or (isinstance(box, BasicBoxTrack3D))
8080
or (isinstance(box, GroupTrack) and isinstance(box.state, BasicBoxTrack3D))
8181
):
82-
if isinstance(box, (BoxDetection, BasicBoxTrack3D, VehicleState)):
82+
if isinstance(box, (BoxDetection, BasicBoxTrack3D, ObjectState)):
8383
box = box.box
8484
elif isinstance(box, GroupTrack):
8585
box = box.state.box
@@ -237,6 +237,7 @@ def show_image_with_boxes(
237237
boxes,
238238
inline=False,
239239
box_colors="green",
240+
box_thickness=3,
240241
with_mask=False,
241242
show_IDs=True,
242243
fontscale=1,
@@ -286,13 +287,11 @@ def show_image_with_boxes(
286287

287288
# Show box
288289
if isinstance(box, Box2D) or (
289-
isinstance(
290-
box, (VehicleState, BoxDetection, MaskDetection, BasicBoxTrack2D)
291-
)
290+
isinstance(box, (ObjectState, BoxDetection, MaskDetection, BasicBoxTrack2D))
292291
and isinstance(box.box, Box2D)
293292
):
294293
if isinstance(
295-
box, (VehicleState, BoxDetection, MaskDetection, BasicBoxTrack2D)
294+
box, (ObjectState, BoxDetection, MaskDetection, BasicBoxTrack2D)
296295
):
297296
if isinstance(box, MaskDetection):
298297
mask = box.mask
@@ -302,19 +301,19 @@ def show_image_with_boxes(
302301
(int(box.xmin), int(box.ymin)),
303302
(int(box.xmax), int(box.ymax)),
304303
col,
305-
2,
304+
box_thickness,
306305
)
307306
bl_edge = (box.xmin, box.ymin)
308307
add_ID_to_image(img1, bl_edge, ID, fontscale=fontscale)
309308
elif (
310309
isinstance(box, (Box3D, BasicBoxTrack3D))
311310
or (
312-
isinstance(box, (VehicleState, BoxDetection, MaskDetection))
311+
isinstance(box, (ObjectState, BoxDetection, MaskDetection))
313312
and isinstance(box.box, Box3D)
314313
)
315314
or (isinstance(box, GroupTrack) and isinstance(box.state, BasicBoxTrack3D))
316315
):
317-
if isinstance(box, (VehicleState, BasicBoxTrack3D)):
316+
if isinstance(box, (ObjectState, BasicBoxTrack3D)):
318317
box = box.box
319318
elif isinstance(box, (BoxDetection, MaskDetection)):
320319
if isinstance(box, MaskDetection):
@@ -327,7 +326,12 @@ def show_image_with_boxes(
327326
img.calibration
328327
)
329328
img1 = draw_projected_box3d(
330-
img1, corners_3d_in_image, color=col, ID=ID, fontscale=fontscale
329+
img1,
330+
corners_3d_in_image,
331+
thickness=box_thickness,
332+
color=col,
333+
ID=ID,
334+
fontscale=fontscale,
331335
)
332336
elif isinstance(
333337
box,
@@ -352,7 +356,7 @@ def show_image_with_boxes(
352356
(int(addbox[0]), int(addbox[1])),
353357
(int(addbox[2]), int(addbox[3])),
354358
(255, 0, 0),
355-
2,
359+
box_thickness,
356360
)
357361

358362
# Show mask
@@ -406,6 +410,8 @@ def show_lidar_bev_with_boxes(
406410
extent=None,
407411
ground=None,
408412
box_colors="white",
413+
box_filled=False,
414+
box_thickness=3,
409415
filter_in_im=False,
410416
flipx=True,
411417
flipy=True,
@@ -483,12 +489,12 @@ def show_lidar_bev_with_boxes(
483489
):
484490
continue # cannot show 2D boxes
485491
elif (
486-
isinstance(box, (VehicleState, Box3D))
492+
isinstance(box, (ObjectState, Box3D))
487493
or (isinstance(box, BoxDetection) and isinstance(box.box, Box3D))
488494
or (isinstance(box, BasicBoxTrack3D))
489495
or (isinstance(box, GroupTrack) and isinstance(box.state, BasicBoxTrack3D))
490496
):
491-
if isinstance(box, (BoxDetection, BasicBoxTrack3D, VehicleState)):
497+
if isinstance(box, (BoxDetection, BasicBoxTrack3D, ObjectState)):
492498
box = box.box
493499
elif isinstance(box, GroupTrack):
494500
box = box.state.box
@@ -590,7 +596,9 @@ def show_lidar_bev_with_boxes(
590596
), f"{box_colors[i]}, {type(box_colors[i])}"
591597
lcolor = box_colors[i]
592598
box3d_pts_2d = (bev_corners - min_arr) / sc_arr
593-
img1 = draw_projected_box3d(img1, box3d_pts_2d, color=lcolor, thickness=2)
599+
img1 = draw_projected_box3d(
600+
img1, box3d_pts_2d, color=lcolor, thickness=box_thickness, filled=box_filled
601+
)
594602

595603
# Add tracks
596604
for i, vec in enumerate(vectors):

0 commit comments

Comments
 (0)