pytorch3d
pytorch3d copied to clipboard
Is compute_projection_matrix in FoVPerspectiveCameras correct?
❓ Questions on how to use PyTorch3D
Thanks a lot for the great work on this tool. I have a question about the compute_projection_matrix
function of FoVPerspectiveCameras
and hope you could give me a hand.
Essentially, I am wondering whether it is correct: https://github.com/facebookresearch/pytorch3d/blob/b95535c8b73299134bb2144a8b36edfffaf2e225/pytorch3d/renderer/cameras.py#L627-L638
To be specific, the projection matrix you define is:
where $n > 0, f > 0$ denotes the near and far planes and ${l, r, t, b }$ represents the x-max, x-min, y-max, and y-min boundaries.
According to this doc, the ideal situation is that $P_1$ will map
- the point of $[l, 0, n]$ to NDC's left boundary, i.e., x-coordinate to be 1;
- similarly, $[r, 0, n]$ to NDC's right boundary, i.e., x-coordinate to be -1;
- $[0, t, n]$ to NDC's right boundary, i.e., y-coordinate to be 1;
- $[0, b, n]$ to NDC's right boundary, i.e., y-coordinate to be -1.
However, I do not think $P_1$ can do it. Actually, I think $P_2$ should be implemented (pay attention to the negative sign of the third column):
I encounter some problems recently so I investigate the definition of the projection matrix. May I know whether I miss something? Thanks in advance.
As mentioned before the definition of K, min_x = -max_x. So, it doesn't matter +/- ...