nerfstudio-project / gsplat

CUDA accelerated rasterization of gaussian splatting
https://docs.gsplat.studio/
Apache License 2.0
2.24k stars 284 forks source link

How to derive K from focal length and principal points #66

Open hturki opened 1 year ago

hturki commented 1 year ago

Thanks for the helpful project! Would it be possible to clarify how you derive the K matrix mentioned in https://docs.gsplat.studio/conventions/data_conventions.html given fx, fy, cx, cy (which may not be centered)? The internet gives different slightly different answers depending on the source (ie: some axes will be negative or not) and it would be very helpful to have this explicitly confirmed (and whether it lines up with the official GS 3D implementation).

fzhiheng commented 7 months ago

I have a similar question: why is the formula provided here for calculating the projection matrix K different from the matrices given by OpenGL? Why isn't K[2,3] multiplied by a coefficient of 2, and why is K[3,2] 1 instead of -1? Image 1 Image 2 The left image is from gsplat, and the right image is from OpenGL. Looking forward to your response!

fzhiheng commented 7 months ago

Thanks for the helpful project! Would it be possible to clarify how you derive the K matrix mentioned in https://docs.gsplat.studio/conventions/data_conventions.html given fx, fy, cx, cy (which may not be centered)? The internet gives different slightly different answers depending on the source (ie: some axes will be negative or not) and it would be very helpful to have this explicitly confirmed (and whether it lines up with the official GS 3D implementation).

I think it will be work that replacing top、bottom、right and left use function as follows: top = n cy / fy bottom = -n (H - cy) / fy right = n (W - cx) / fx left = -n cx / fx