Tsinghua-MARS-Lab / ViP3D

MIT License
133 stars 19 forks source link

how to visualize the experiments results #21

Open Wj-costumer opened 6 months ago

Wj-costumer commented 6 months ago

Hello, I have successfully run the code and I have two questions. First, I'd like to know how to visualize the experiments results and how can I render the nuscenes dataset scene like the pictures shown in your paper, and I would be appreciate it if you could provide the corresponding code or a tutorial! Second, I'm trying to project the track 3d-box on the image but there's something wrong. image_1_traj (2) As you can see, the coordinates of the boxes on the y-axis are offset downwards as a whole.
` boxes_3d = predictor_utils.to_numpy(results[0]['boxes_3d'].tensor) # lidar coordinate bboxes_3d = img_metas[0]['box_type_3d'][0](boxes_3d, 9) # convert to corners = bboxes_3d.corners # n 8 3 for cam_idx in range(6): lidar_to_image = lidar2img[0][cam_idx] image_idx = images[cam_idx] for i in range(len(bboxes_3d)): corners_lidar = corners[i].squeeze(0).cpu().numpy() # (8, 3) corners_lidar = np.concatenate([corners_lidar, np.ones((corners_lidar.shape[0], 1))], axis = 1) # 8 x 4 corners_image = corners_lidar @ lidar_to_image.T # torch.matmul(lidar_to_image, corners_lidar) # corners_image[:, :2] /= corners_image[:, [2]] # x, y / z if np.all((corners_image[:, 2] > 0) == True) == True: track_id = track_ids[i] track_cls = class_names[track_labels[i]] # ['car', 'truck', ...] color = colors[track_labels[i]] # [(0, 255, 255), ...]

画3d_track_instance

        image_idx = draw_cube_on_image(image_idx, corners_image[:, :2], color)
        corners_image = corners_image[:, :2].astype(int)

` As the results 'boxes_3d' are in lidar coordinate, I jusr convert them to the and return their corners. Then I project the corners using array 'lidar2img' on the raw images. Could you help me find the error? Thanks!

GentleSmile commented 6 months ago

We have not released the visualization code because the toolkit is quite complicated to setup. The box center have two formats, i.e., nuscenes format and KITTI format. They are converted here.