nutonomy / nuscenes-devkit

The devkit of the nuScenes dataset.
https://www.nuScenes.org
Other
2.18k stars 616 forks source link

The number of points is inconsistent with the number of labels #1076

Closed magical1998 closed 1 month ago

magical1998 commented 2 months ago

Hello, my problem is that after converting the nuScenes format to the KITTI format, the numbers I read for the point cloud set and the corresponding label set are inconsistent. The size of the point set is (138752,), and it should be (34688, 4) points, but the corresponding number of label sets is 8672, where 8672*4=34688. I think this is not a coincidence, but I don’t know if I have missed anything.

whyekit-motional commented 2 months ago

@magical1998 pls provide a working code snippet to reproduce your issue

magical1998 commented 2 months ago

import numpy as np

调用函数,替换'your_file.bin'为你的文件路径

file_path='I:/data/sets/nuscenes/samples/LIDAR_TOP/' label_path='I:/data/sets/nuscenes/lidarseg/v1.0-trainval/' points=np.fromfile(file_path+'n015-2018-07-24-10-42-41+0800__LIDAR_TOP__1532400339698223.pcd.bin',dtype=np.float32) labels=np.fromfile(label_path+'8b31aa5cac3846a6a197c507523926f9_lidarseg.bin',dtype=np.float32) print(labels) point-labels

magical1998 commented 2 months ago

Hello, the point cloud file and the label file are the corresponding files found through the .json file. If the point cloud file has one point for every four digits, the final number of point clouds will still be four times the number of labels. I am not sure. The reasons, I hope to receive your answer

whyekit-motional commented 2 months ago

@magical1998 I'm afraid I cannot reproduce your error:

import os.path as osp

import numpy as np
from nuscenes.utils.data_classes import LidarPointCloud

nusc_data_root = '/data/sets/nuscenes'

# Load pointcloud.
pcl_path = osp.join(nusc_data_root, 'samples/LIDAR_TOP/n015-2018-07-24-10-42-41+0800__LIDAR_TOP__1532400339698223.pcd.bin')
pc = LidarPointCloud.from_file(pcl_path)
points = pc.points.T
print(points.shape)  # (34752, 4)

# Load labels.
lidarseg_labels_filename = osp.join(nusc_data_root, 'lidarseg/v1.0-trainval/8b31aa5cac3846a6a197c507523926f9_lidarseg.bin')
points_label = np.fromfile(lidarseg_labels_filename, dtype=np.uint8)
print(points_label.shape)  # (34752,)

assert len(points) == len(points_label)