Get_color() missing argument

Hello,

I’m currently getting used to working with the dataset, and am trying to project the 3D LiDAR points to a 2D plane using Matplotlib.

When I am drawing the bounding boxes of instances, I cannot seem to get the appropriate colour:

# get binary file path of LIDAR data. annotation tokens can be passed to visualise instances
data_path, boxes, _ = nusc.get_sample_data(lidar, selected_anntokens=[ann_token])

…before:

# draw instance boxes over the rendered LiDAR data
for box in boxes:
    c = np.array(nusc_explorer.get_color(box.name)) / 255.0
    box.render(ax, colors=(c, c, c))

…which results in:

TypeError: get_color() missing 1 required positional argument: 'category_name'

‘box.name’ is providing the string: ‘human.pedestrian.adult’, which should be fine, right? I don’t understand what is going wrong here.

Help would be very much appreciated. Can provide additional code/details if required.

Many thanks

Hi @Mauzey, I notice you didn’t provide a full code snippet. However, from my end, I’ve tried to replicate your issue, but am unable to reproduce it.

Here’s my (working) code snippet for your reference:

import numpy as np

from nuscenes.nuscenes import NuScenes
from nuscenes.nuscenes import NuScenesExplorer


nusc = NuScenes(version='v1.0-mini', dataroot='/data/sets/nuscenes', verbose=True)
nusc_explorer = NuScenesExplorer(nusc=nusc)

my_ann = nusc.sample_annotation[0]
ann_token = my_ann['token']

my_sample_token = my_ann['sample_token']
my_sample = nusc.get('sample', my_sample_token)

lidar = my_sample['data']['LIDAR_TOP']  # my_sample_data_token

# get binary file path of LIDAR data. annotation tokens can be passed to visualise instances
data_path, boxes, _ = nusc.get_sample_data(lidar, selected_anntokens=[ann_token])

# draw instance boxes over the rendered LiDAR data
for box in boxes:
    c = np.array(nusc_explorer.get_color(box.name)) / 255.0
    print(c)

Regardless, if all you are trying to do is just render the bounding boxes in the BEV, I would suggest doing it this way:

nusc.render_sample_data(my_sample['data']['LIDAR_TOP'], nsweeps=1, underlay_map=False) 

It’s a one-liner which saves you lots of effort :slight_smile:

For details on using our dev-kit, pls check out: https://www.nuscenes.org/nuscenes?tutorial=nuscenes

1 Like

This has definitely helped, thank you.

It’s a little overwhelming figuring out how to put everything together, but I’m getting the hang of it :smile:

2 Likes