fraunhoferhhi / neural-deferred-shading

Multi-View Mesh Reconstruction with Neural Deferred Shading (CVPR 2022)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Camera convention

YaroslavShchekaturov opened this issue · comments

Hi there!

Which camera convention do you use? Is Rt a c2w or w2c matrix here?

def to_gl_camera(camera, resolution, n=1000, f=5000):

    projection_matrix = Renderer.projection(fx=camera.K[0,0],
                                            fy=camera.K[1,1],
                                            cx=camera.K[0,2],
                                            cy=camera.K[1,2],
                                            n=n,
                                            f=f,
                                            width=resolution[1],
                                            height=resolution[0],
                                            device=camera.device)

    Rt = torch.eye(4, device=camera.device)
    Rt[:3, :3] = camera.R
    Rt[:3, 3] = camera.t

    gl_transform = torch.tensor([[1., 0,  0,  0],
                                [0,  1., 0,  0],
                                [0,  0, -1., 0],
                                [0,  0,  0,  1.]], device=camera.device)

    Rt = gl_transform @ Rt
    return projection_matrix @ Rt

Hi!

Rt is w2c (there is a formula in the README in Section Reconstructing Custom Scenes).

So for the given function, Rt transforms a world point to OpenCV camera space, and the matrix gl_transform transforms the point from OpenCV camera space to OpenGL camera space. The projection_matrix uses OpenGL conventions for the clip space transformation.

Dear @mworchel
Thank you very much for your response!