d3d.dataset.nuscenes

class d3d.dataset.nuscenes.loader.NuscenesLoader(base_path, inzip=False, phase='training', trainval_split='official', trainval_random=False, trainval_byseq=False, nframes=0)[source]

Bases: d3d.dataset.base.TrackingDatasetBase

Load Nuscenes dataset into a usable format. Please use the d3d_nuscenes_convert command to convert the dataset first into following formats

  • Directory Structure:

    - <base_path directory>
        - trainval
            - scene_xxx(.zip)
            - ...
        - test
            - scene_xxx(.zip)
            - ...
    

For description of constructor parameters, please refer to d3d.dataset.base.TrackingDatasetBase

Parameters
  • base_path – directory containing the zip files, or the required data

  • inzip – whether the dataset is store in original zip archives or unzipped

  • phase – training, validation or testing

  • trainval_split – the ratio to split training dataset. See documentation of split_trainval_seq() for detail.

  • trainval_random – whether select the train/val split randomly. See documentation of split_trainval_seq() for detail.

  • nframes

    number of consecutive frames returned from the accessors

    • If it’s a positive number, then it returns adjacent frames with total number reduced

    • If it’s a negative number, absolute value of it is consumed

    • If it’s zero, then it act like object detection dataset, which means the methods will return unpacked data

  • trainval_byseq – Whether split trainval partitions by sequences instead of frames

VALID_OBJ_CLASSES

alias of d3d.dataset.nuscenes.constants.NuscenesDetectionClass

VALID_PTS_CLASSES

alias of d3d.dataset.nuscenes.constants.NuscenesSegmentationClass

annotation_3dobject(idx, raw=False, convert_tag=True, with_velocity=True)[source]

Return list of converted ground truth targets in lidar frame.

Parameters
  • idx – index of requested frame

  • raw – if false, targets will be converted to d3d d3d.abstraction.Target3DArray format, otherwise raw data will be returned in original format.

annotation_3dpoints(idx, names='lidar_top', parse_tag=True, convert_tag=True)[source]
Parameters
calibration_data(idx)[source]

Return the calibration data. Notices that we assume the calibration is fixed among one squence, so it always return a single object.

Parameters
  • idx – index of requested lidar frames

  • raw – If false, converted d3d.abstraction.TransformSet will be returned, otherwise raw data will be returned in original format

camera_data(idx, names=None)[source]

Return the camera image data

Parameters
  • names – name of requested camera sensors. The default sensor is the first element in VALID_CAM_NAMES.

  • idx – index of requested image frames, see description in lidar_data() method.

dump_segmentation_output(idx, segmentation, folder_out, raw2seg=True, default_class=15)[source]
Parameters
  • raw2seg (bool) – If set as true, input array will be considered as raw id (consistent with values stored in label)

  • default_class (Union[int, d3d.dataset.nuscenes.constants.NuscenesSegmentationClass]) – Class to be selected when the label is 0 (ignore)

  • idx (Union[int, tuple]) –

  • segmentation (numpy.ndarray) –

  • folder_out (str) –

identity(idx)[source]

Return something that can track the data back to original dataset

Parameters

idx – index of requested frame to be parsed

Returns

if nframes > 0, then the function return a list of ids which are consistent with other functions.

intermediate_data(idx, names=None, ninter_frames=None, formatted=False)[source]

Return the intermediate data (and annotations) between keyframes. For key frames data, please use corresponding function to load them

Parameters
  • idx – index of requested data frames

  • names – name of requested sensors.

  • ninter_frames – number of intermediate frames. If set to None, then all frames will be returned.

lidar_data(idx, names='lidar_top', formatted=False)[source]

If multiple frames are requested, the results will be a list of list. Outer list corresponds to frame names and inner list corresponds to time sequence. So len(names) × len(frames) data objects will be returned

Parameters
  • names – name of requested lidar sensors. The default frame is the first element in VALID_LIDAR_NAMES.

  • idx – index of requested lidar frames

  • formatted

    if true, the point cloud wrapped in a numpy record array will be returned

    • If single index is given, then the frame indexing is done on the whole dataset with trainval split

    • If a tuple is given, it’s considered to be a unique id of the frame (from identity() method), trainval split is ignored in this way and nframes offset is not added

pose(idx, names='lidar_top', raw=False)[source]

Return (relative) pose of the vehicle for the frame. The base frame should be ground attached which means the base frame will follow a East-North-Up axis order.

Parameters
  • idx – index of requested frame

  • names – specify the sensor whose pose is requested. This option only make sense when the dataset contains separate timestamps for data from each sensor. In this case, the pose either comes from dataset, or from interpolation.

  • raw – if false, targets will be converted to d3d d3d.abstraction.EgoPose format, otherwise raw data will be returned in original format.

property pose_name

Return the sensor frame name whose coordinate the pose is reported in. This frame can be different from the default frame in the calibration TransformSet.

property sequence_ids

Return the list of sequence ids

property sequence_sizes

Return the mapping from sequence id to sequence sizes

timestamp(idx, names='lidar_top')[source]

Return the timestamp of frame specified by the index, represented by Unix timestamp in macroseconds (usually 16 digits integer)

Parameters
  • idx – index of requested frame

  • names – specify the sensor whose pose is requested. This option only make sense when the dataset contains separate timestamps for data from each sensor.

token(idx, names='lidar_top')[source]

Return the sample data token in original Nuscenes data given data index and sensor name

class d3d.dataset.nuscenes.loader.NuscenesObjectClass(value)[source]

Bases: enum.IntFlag

Categories and attributes of an annotation in Nuscenes dataset.

The ids are encoded into 4bytes integer:

0xFFFF
  │││└: level0 category
  ││└─: level1 category
  │└──: level2 category
  └───: attribute
animal = 1
property attribute

The attribute of the label

property attribute_name

Name of the attribute of the label

property category

The category of the label

property category_name

Name of the category of the label

property color
cycle_with_rider = 16384
cycle_without_rider = 20480
flat = 6
flat_driveable_surface = 22
flat_other = 70
flat_sidewalk = 38
flat_terrain = 54
classmethod from_nuscenes_id(nid)[source]

Get Nuscenes class object from Nuscenes ID

Parameters

nid (int) –

human = 2
human_pedestrian = 18
human_pedestrian_adult = 274
human_pedestrian_child = 530
human_pedestrian_construction_worker = 786
human_pedestrian_personal_mobility = 1042
human_pedestrian_police_officer = 1298
human_pedestrian_stroller = 1554
human_pedestrian_wheelchair = 1810
movable_object = 3
movable_object_barrier = 19
movable_object_debris = 35
movable_object_pushable_pullable = 51
movable_object_trafficcone = 67
noise = 16
property nuscenes_id

Get the Nuscenes ID of the label

classmethod parse(string)[source]

Parse the Nuscenes class from string

Parameters

string (str) –

pedestrian_moving = 32768
pedestrian_sitting_lying_down = 24576
pedestrian_standing = 28672
property pretty_name

Get the full name of the label with category and attribute

static = 7
static_manmade = 23
static_object = 5
static_object_bicycle_rack = 21
static_other = 55
static_vegetation = 39
to_detection()[source]

Convert the label to the class for detection

to_segmentation()[source]

Convert the label to the class for segmentation

Reference: https://github.com/nutonomy/nuscenes-devkit/blob/master/python-sdk/nuscenes/eval/lidarseg/README.md

unknown = 0
vehicle_bicycle = 4
vehicle_bus = 20
vehicle_bus_bendy = 276
vehicle_bus_rigid = 532
vehicle_car = 36
vehicle_construction = 52
vehicle_ego = 132
vehicle_emergency = 68
vehicle_emergency_ambulance = 324
vehicle_emergency_police = 580
vehicle_motorcycle = 84
vehicle_moving = 4096
vehicle_parked = 12288
vehicle_stopped = 8192
vehicle_trailer = 100
vehicle_truck = 116
class d3d.dataset.nuscenes.loader.NuscenesDetectionClass(value)[source]

Bases: enum.Enum

Label classes for detection in Nuscenes dataset.

barrier = 1
bicycle = 2
bus = 3
car = 4
property color
construction_vehicle = 5
ignore = 0
motorcycle = 6
pedestrian = 7
traffic_cone = 8
trailer = 9
truck = 10