MCG-NJU / SparseBEV

[ICCV 2023] SparseBEV: High-Performance Sparse 3D Object Detection from Multi-Camera Videos
https://arxiv.org/abs/2308.09244
MIT License
306 stars 21 forks source link

sampling points lidar2img问题 #64

Closed zhaoyangwei123 closed 3 months ago

zhaoyangwei123 commented 3 months ago

@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 commented 3 months ago

没有什么不同啊

zhaoyangwei123 commented 3 months ago

作者您好,非常感谢您的工作,我在此基础上加入一些loss的时候遇到一些梯度问题,能加您微信聊一下吗?

afterthat97 commented 3 months ago

我之前回复过你的邮件,里面有我的微信,你翻翻吧