nerf-pytorch icon indicating copy to clipboard operation
nerf-pytorch copied to clipboard

About the ray directions

Open dwangxxx opened this issue 4 years ago • 3 comments

May I know the ray directions derivation? directions = torch.stack( [ (ii - width * 0.5) / focal_length, -(jj - height * 0.5) / focal_length, -torch.ones_like(ii), ], dim=-1, ) Why are the y-axis and z-axis negative? Could you give me some explanation? Thank you very much!!!

dwangxxx avatar Jul 08 '20 14:07 dwangxxx

Hi @dwangxxx,

Do these issues answer your question? https://github.com/bmild/nerf/issues/24 https://github.com/bmild/nerf/issues/46

I'd be happy to provide more details if you have further questions

krrish94 avatar Jul 10 '20 09:07 krrish94

Hi @dwangxxx,

Do these issues answer your question? bmild/nerf#24 bmild/nerf#46

I'd be happy to provide more details if you have further questions

Thanks for your reply. I've read these answers, but I still don't understand the code. Why are the y-axis and z-axis negative? When we caculate the camera extrinsics, the world coordinate system is converted to pixel coordinate system, where the y-axis and z-axis is not negative. The ray directions is converting pixel coordinate system to world coordinate system, why are the y-axis and z-axis negative? Could you provide me more details? Thank you!

dwangxxx avatar Jul 10 '20 11:07 dwangxxx

From what I understand, this code follows OpenGL standard - where the camera is facing -z direction by standard. The y axis is positive upwards and x is positive to the right. Because in tf/torch/numpy y indexing is top to bottom, the y axis needs to be flipped as well

IamMohitM avatar Jun 08 '23 14:06 IamMohitM