@afterthat97
B, Q, T, G, P, _ = sample_points.shape # [B, Q, T, G, P, 3]
N = 6
sample_points = sample_points.reshape(B, Q, T, G * P, 3)
# get the projection matrix
lidar2img = lidar2img[:, :, None, None, :, :] # [B, TN, 1, 1, 4, 4]
lidar2img = lidar2img.expand(B, T*N, Q, G * P, 4, 4)
lidar2img = lidar2img.reshape(B, T, N, Q, G*P, 4, 4)
# expand the points
ones = torch.ones_like(sample_points[..., :1])
sample_points = torch.cat([sample_points, ones], dim=-1) # [B, Q, GP, 4]
sample_points = sample_points[:, :, None, ..., None] # [B, Q, T, GP, 4]
sample_points = sample_points.expand(B, Q, N, T, G * P, 4, 1)
sample_points = sample_points.transpose(1, 3) # [B, T, N, Q, GP, 4, 1]
# project 3d sampling points to N views
sample_points_cam = torch.matmul(lidar2img, sample_points).squeeze(-1) # [B, T, N, Q, GP, 4]
# homo coord -> pixel coord
homo = sample_points_cam[..., 2:3]
homo_nonzero = torch.maximum(homo, torch.zeros_like(homo) + eps) #third dim is z which need to be 0 in x-y coord
sample_points_cam = sample_points_cam[..., 0:2] / homo_nonzero # [B, T, N, Q, GP, 2]
您好,我尝试使用您对 sampling points的投影方法,我按照此方法尝试将3D框投影到image上面查看效果,但是发现利用lidar2image之后无论在原图还是load过的图上画出的框子都不对,请问对于3D框您代码中的lidar2image需要有所不同吗?
@afterthat97 B, Q, T, G, P, _ = sample_points.shape # [B, Q, T, G, P, 3] N = 6