d3d.dataset.kitti
This module contains loaders for KITTI 3d object, KITTI tracking, KITTI raw datasets.
- class d3d.dataset.kitti.KittiObjectLoader(base_path, inzip=False, phase='training', trainval_split=0.8, trainval_random=False)[source]
Bases:
d3d.dataset.base.DetectionDatasetBase
Loader for KITTI object detection dataset, please organize the files into following structure
Zip Files:
- data_object_calib.zip - data_object_image_2.zip - data_object_image_3.zip - data_object_label_2.zip - data_object_velodyne.zip
Unzipped Structure:
- <base_path directory> - training - calib - image_2 - label_2 - velodyne - testing - calib - image_2 - velodyne
Note that the 3d objects labelled as DontCare are removed from the result of
annotation_3dobject()
.For description of constructor parameters, please refer to
d3d.dataset.base.DetectionDatasetBase
- 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()
for detail.trainval_random – whether select the train/val split randomly. See documentation of
split_trainval()
for detail.
- VALID_OBJ_CLASSES
- annotation_3dobject(idx, raw=False)[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
- calibration_data(idx, raw=False)[source]
Return the calibration data
- Parameters
idx – index of requested frame
raw – if false, converted
d3d.abstraction.TransformSet
will be returned, otherwise raw data will be returned in original format.
- camera_data(idx, names='cam2')[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
- dump_detection_output(idx, detections, fout)[source]
Save the detection in KITTI output format. We need raw calibration for R0_rect
- Parameters
detections (d3d.abstraction.Target3DArray) –
fout (Union[str, pathlib.Path, io.RawIOBase]) –
- Return type
None
- identity(idx)[source]
- Return something that can track the data back to original dataset. The result tuple can be passed
to any accessors above and directly access given data.
- Parameters
idx – index of requested frame to be parsed
- lidar_data(idx, names='velo', formatted=False)[source]
Return the lidar point cloud data
- Parameters
names – name of requested lidar sensors. The default sensor 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
- class d3d.dataset.kitti.KittiRawLoader(base_path, datatype='sync', inzip=True, phase='training', trainval_split=1, trainval_random=False, trainval_byseq=False, nframes=0)[source]
Bases:
d3d.dataset.base.TrackingDatasetBase
Load and parse raw data into a usable format, please organize the files into following structure
Zip Files:
- 2011_09_26_calib.zip [required] - 2011_09_26_drive_0001_extract.zip - ... - 2011_09_26_drive_0001_sync.zip - ... - 2011_09_26_drive_0001_tracklets.zip - ...
Unzipped Structure:
- <base_path directory> - 2011_09_26 - calib_cam_to_cam.txt - calib_imu_to_velo.txt - calib_velo_to_cam.txt - 2011_09_26_drive_0001_extract - image_00 - image_01 - image_02 - image_03 - oxts - velodyne_points - ... - 2011_09_26_drive_0001_sync - image_00 - image_01 - image_02 - image_03 - oxts - velodyne_points - tracklet_labels.xml - ...
For description of constructor parameters, please refer to
d3d.dataset.base.TrackingDatasetBase
Note that the 3d objects labelled as DontCare are removed from the result ofannotation_3dobject()
.- Parameters
datatype (str) – ‘sync’ (synced) / ‘extract’ (unsynced)
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
- annotation_3dobject(idx)[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.
- calibration_data(idx, raw=False)[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='cam2')[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.
- 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.
- lidar_data(idx, names='velo', 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, 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='velo')[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.
- class d3d.dataset.kitti.KittiTrackingLoader(base_path, inzip=False, phase='training', trainval_split=0.8, trainval_random=False, trainval_byseq=False, nframes=0)[source]
Bases:
d3d.dataset.base.TrackingDatasetBase
Loader for KITTI multi-object tracking dataset, please organize the files into following structure
Zip Files:
- data_tracking_calib.zip - data_tracking_image_2.zip - data_tracking_image_3.zip - data_tracking_label_2.zip - data_tracking_velodyne.zip - data_tracking_oxts.zip
Unzipped Structure:
- <base_path directory> - training - calib - image_02 - label_02 - oxts - velodyne - testing - calib - image_02 - oxts - velodyne
For description of constructor parameters, please refer to
d3d.dataset.base.TrackingDatasetBase
. Note that the 3d objects labelled as DontCare are removed from the result ofannotation_3dobject()
.- 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
- annotation_3dobject(idx, raw=False)[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.
- calibration_data(idx, raw=False)[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='cam2')[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.
- 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.
- lidar_data(idx, names='velo', 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, 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='velo')[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.
- class d3d.dataset.kitti.KittiObjectClass(value)[source]
Bases:
enum.Enum
Category of objects in KITTI dataset
- Car = 1
- Cyclist = 6
- DontCare = 0
- Misc = 8
- Pedestrian = 4
- Person = 5
- Person_sitting = 5
- Tram = 7
- Truck = 3
- Van = 2
- d3d.dataset.kitti.object.execute_official_evaluator(exec_path, label_path, result_path, output_path, model_name=None, show_output=True)[source]
Execute official evaluator from KITTI devkit
- Parameters
label_path – path to the extracted labels of kitti dataset
result_path – path to the results created by dump_detection_output
model_name – unique name of your model. KITTI tool requires sha1 as model name, but that’s not mandatory.
show_output – show_output option passed to Kitti evaluator
- Parma output_path
path to the output evaluation results
Note: to install prerequisites sudo apt install gnuplot texlive-extra-utils