NVIDIAGameWorks / kaolin-wisp

NVIDIA Kaolin Wisp is a PyTorch library powered by NVIDIA Kaolin Core to work with neural fields (including NeRFs, NGLOD, instant-ngp and VQAD).
Other
1.46k stars 131 forks source link

about the param 'at' of Camera.from_args() #74

Closed ZhouWeikun closed 1 year ago

ZhouWeikun commented 1 year ago

first, thanks for your excellent work. But, could you tell me how to compute the param 'at' for Camera.from_args() from other datasets like 'DTU'?

orperel commented 1 year ago

Hi @ZhouWeikun !

from_args accepts a view_matrix arg, a.k.a the w2c matrix. See the expected format here.

To give some context: the Camera object we use can accept all kind of args, you'll find some useful examples in the recipe here. The from_args constructor was created for convenience, to enable you create Cameras with a single call, rather than creating the extrinsic and intrinsic components separately. If you compare to the explicit creation methods here, you'll notice that they use the same arg names. What from_args does under the hood is compare the arg names to the available Camera extrinsic / intrinsic constructors and picks the correct signature combo for you if there is no ambiguity.

TLDR; you can call from_args and give it the view matrix upfront, without worrying about at, eye and from.

ZhouWeikun commented 1 year ago

Hi @orperel : Thanks for your reply, I have found that

camera = Camera.from_args(eye=torch.Tensor(cam_data['camera_look_at']['eye']),
                              at=torch.Tensor(cam_data['camera_look_at']['at']),
                              up=torch.Tensor(cam_data['camera_look_at']['up']),
                              width=cam_data['width'],
                              height=cam_data['height'],
                              focal_x=cam_data['intrinsics']['fx'],
                              focal_y=cam_data['intrinsics']['fy'],
                              x0=0.0,
                              y0=0.0,
                              near=0.0,
                              far=6.0)

has the same effect as

cam_extrinsics = CameraExtrinsics.from_view_matrix(torch.from_numpy(np.stack(cam_data['camera_view_matrix']).T))
cam_intrinsics = PinholeIntrinsics.from_focal(
                            width=cam_data['width'],
                            height=cam_data['height'],
                            focal_x=cam_data['intrinsics']['fx'],
                            focal_y=cam_data['intrinsics']['fy'],
                            x0=0.0,
                            y0=0.0,
                            near=0,
                            far=6)
camera = Camera(cam_extrinsics,cam_intrinsic)

As you said, that means I can construct a camera without worrying about at, eye and up. But I observed in intrinsics matrix:x0=800 and y0=800 , they are equal to img_width/2 and img_height/2. However from_args()and PinholeIntrinsics.from_focal()both accept x0=0 and y0=0. So x0,y0 means the offset form img_width/2,img_height/2 ?

orperel commented 1 year ago

Glad to hear! You're correct, x0 and y0 are offsets from the image center

ZhouWeikun commented 1 year ago

Thanks for your reply again, I think it's time to close it.