waymo-research / waymo-open-dataset

Waymo Open Dataset
https://www.waymo.com/open
Other
2.65k stars 606 forks source link

How should I project the lidar data to the camera image with the depth in v2? #845

Open NickLin910221 opened 2 months ago

NickLin910221 commented 2 months ago

I use following code to generate the 3D point cloud with [N, 3] in (x, y, z)

lidar_calib = read('lidar_calibration')
camera_calib = read('camera_calibration')
lidar_pose = read('lidar_pose')
vehicle_pose = read('vehicle_pose')
df = v2.merge(lidar_calib, lidar)
df = v2.merge(df, lidar_pose)
df = v2.merge(df, vehicle_pose)
df = v2.merge(df, camera_calib)

for i, (_, r) in enumerate(df.iterrows()):
    lidar = v2.LiDARComponent.from_dict(r)
    lidar_calib = v2.LiDARCalibrationComponent.from_dict(r)
    camera_calib = v2.CameraCalibrationComponent.from_dict(r)
    lidar_pose = v2.LiDARPoseComponent.from_dict(r)
    vehicle_pose = v2.VehiclePoseComponent.from_dict(r)
    if np.all(lidar.key.laser_name == 1) == True:
        print(lidar_calib)
        print(camera_calib)
        pc1 = lidar_utils.convert_range_image_to_point_cloud(lidar.range_image_return1, lidar_calib, lidar_pose.range_image_return1, vehicle_pose)
        with open(f'lidar{lidar.key.segment_context_name}_{lidar.key.frame_timestamp_micros}.npy', 'wb') as f:
            np.save(f, pc1)

The 3D point cloud data like this Screenshot from 2024-06-11 17-06-49 And the camera image like this 9820553434532681355_2820_000_2840_000_1557336854549627

And How to projection lidar distance on camera image in v2? I don't find any v2 function with projection the 3D data to 2D data on image like this? Screenshot from 2024-06-11 17-09-09

JingweiJ commented 1 month ago

You may first convert a range image from polar coordinates to Cartesian coordinates by convert_range_image_to_cartesian, then load camera projection (v2.LiDARCameraProjectionComponent), extrinsic and camera image size (v2.CameraCalibrationComponent) and call build_camera_depth_image.