zju3dv / manhattan_sdf

Code for "Neural 3D Scene Reconstruction with the Manhattan-world Assumption" CVPR 2022 Oral
https://zju3dv.github.io/manhattan_sdf/
Other
500 stars 35 forks source link

why divide distance_map by depth_ratio? #22

Closed longbowzhang closed 2 years ago

longbowzhang commented 2 years ago

Hi @ghy0324, Thanks for the amazing and inspiring work! But I have a quick question w.r.t the depth calculation.Specifically, why do you divide distance_map by depth_ratio? what's the difference between distance and depth (I originally thought that distance d to the camera origin ray_o is exactly the depth value for corresponding pixel)? https://github.com/zju3dv/manhattan_sdf/blob/481974147523ac7d06c257433899cf5fe55caf04/lib/networks/network.py#L131

Looking forward to your reply.

ghy0324 commented 2 years ago

Hi! Thanks for your interest!

In short, depth is the z-axis component of distance.

Please first check the ray generation step. https://github.com/zju3dv/manhattan_sdf/blob/604944fd37cd8eb9045f4eb8ec4f994269981af4/lib/datasets/scannet.py#L92-L102 Note that the z-axis component of ray direction (in camera space) is 1.

We record the norm of ray direction (as depth_ratio here) and normalize it here. https://github.com/zju3dv/manhattan_sdf/blob/481974147523ac7d06c257433899cf5fe55caf04/lib/networks/network.py#L80-L81

Thus, the distance can be calculated by integral, and the depth can be calculated as distance / depth_ratio. https://github.com/zju3dv/manhattan_sdf/blob/481974147523ac7d06c257433899cf5fe55caf04/lib/networks/network.py#L130-L131