Custom Dataset Loader and Transformations (W2C, C2W)
Closed this issue · 1 comments
Hello. I want to write custom dataset loader. Dataset gives position and orientation of camera (in world frame).
I just want to know, for R and T, should I save w2c
transformation or c2w
transformation. When I say c2w
I mean, transformation that is constructed directly from the position and orientation of camera/vehicle given by dataset.
I am asking, because I was trying something, but it did not work. So I want to confirm. Another question, for method getWorld2View2
why you are transposing rotation matrix?
def getWorld2View2(R, t, translate=torch.tensor([0.0, 0.0, 0.0]), scale=1.0):
translate = translate.to(R.device)
Rt = torch.zeros((4, 4), device=R.device)
Rt[:3, :3] = R.transpose(0,1) # why transposed here?
#Rt[:3, :3] = R # Why not only R?
Rt[:3, 3] = t
Rt[3, 3] = 1.0
C2W = np.linalg.inv(Rt) # so this is correct notation C2W
cam_center = C2W[:3, 3]
cam_center = (cam_center + translate) * scale
C2W[:3, 3] = cam_center
Rt = np.linalg.inv(C2W)
return Rt
Hi, different datasets save different format of camera poses, you can choose whatever convenient to you. Here we follow the original pose definition in 3DGS for the Camera
class, where R=c2w[:3, :3]
and T=w2c[:3, 3]
. So in your mentioned getWorld2View2
, the R
should be transposed to construct Rt=w2c
.