Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question about ViewMatrix Solving process] #40

Open
tomguluson92 opened this issue Jun 30, 2021 · 0 comments
Open

[Question about ViewMatrix Solving process] #40

tomguluson92 opened this issue Jun 30, 2021 · 0 comments

Comments

@tomguluson92
Copy link

tomguluson92 commented Jun 30, 2021

Hi Yen @yenchenlin ,
Thank you so much for your work in transporting nerf to PyTorch! I found a little confused
when meet with the process in solving the look-at view matrix.
The questions are listed in the code below, I sincerely hope you answer, thank you very much!

The puzzled point occurs due to the inconformity between code and the definition as below
image

def viewmatrix(z, up, center):
    """
        right-handed coordinate system.
    """
    vec2 = normalize(z)
    vec1_avg = up
    # **fixme**
    # do I need to normalize the vec1_avg = normalize(up) 
    # as well as reform the 
    # vec2 as normalize(normalize(poses[:, :3, 2].sum(0)) - center)?
    vec0 = normalize(np.cross(vec1_avg, vec2))
    vec1 = normalize(np.cross(vec2, vec0))
    m = np.stack([vec0, vec1, vec2, center], 1)
    # m (3, 4)
    return m

def poses_avg(poses):
    """
        input:  poses(N, 3, 5)
        output: c2w  (N, 3, 5)
        Last dim(4) is height, width, and focal length.
        Dim (3) is the center (Could I regard it as the eye position?) 
        Dim (2) is the z (However, I do not see a look - eye operation but only look)
        Dim (1) is the up vector, which represents the y axis.
    """

    hwf = poses[0, :3, -1:]  # (3, 1)
    center = poses[:, :3, 3].mean(0)  # (3,)
    vec2 = normalize(poses[:, :3, 2].sum(0)) # (3,)
    up = poses[:, :3, 1].sum(0)  # (3,)
    c2w = np.concatenate([viewmatrix(vec2, up, center), hwf], 1)
    
    return c2w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant