krrish94 / nerf-pytorch

A PyTorch re-implementation of Neural Radiance Fields
Other
887 stars 122 forks source link

About the ray directions #12

Open dwangxxx opened 4 years ago

dwangxxx commented 4 years ago

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!!!

krrish94 commented 4 years ago

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

dwangxxx commented 4 years ago

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!

IamMohitM commented 1 year ago

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