scaleapi / pandaset-devkit

Other
248 stars 59 forks source link

How to visualise point cloud data with bounding boxes #115

Open LGNWJQ opened 2 years ago

LGNWJQ commented 2 years ago

How to visualise point cloud data with bounding boxes

gch commented 2 years ago

You can grab the corners of each cuboid using the provided functions from the devkit, and then use code like the following to actually plot them (via whatever library you are using)

dataset_idx = '002'
time_idx = 0
cuboids = dataset[dataset_idx].cuboids
cuboids.load()
for idx, row in cuboids[time_idx].iterrows():
    box = pandaset.geometry.center_box_to_corners([row['position.x'],
                                                   row['position.y'],
                                                   row['position.z'],
                                                   row['dimensions.x'],
                                                   row['dimensions.y'],
                                                   row['dimensions.z'],
                                                   row['yaw']])
    bottom = [0,1,2,3,0]
    top = [4,5,6,7,4]
    edge1 = [0, 4]
    edge2 = [1, 5]
    edge3 = [2, 6]
    edge4 = [3, 7]
    for edgeset in [bottom, top, edge1, edge2, edge3, edge4]:
        ### REPLACE WITH YOUR FAVORITE DRAWING TOOL
        pass