HoHoNet icon indicating copy to clipboard operation
HoHoNet copied to clipboard

Spherical coordinate system used in codebase

Open johnwlambert opened this issue 3 years ago • 3 comments

Hi, thanks for your excellent work and repo. Question for you -- how are you defining your spherical coordinate system? From the code below, it seems you have a reflection about the y axis, since u is not negated in get_uni_sphere_xyz() (image unwraps from left to right clockwise, but theta unwraps right to left counterclockwise).

A more traditional spherical coordinate system is the one below: image where: Screen Shot 2021-10-08 at 1 49 46 PM

I noted that you were using r = \rho cos(\phi), if \phi=v and \rho=1, which you call c = np.cos(v). But this doesn't match the traditional spherical coordinate system. Could you explain a bit more about your derivation? Thanks.

https://github.com/sunset1995/HoHoNet/blob/master/vis_depth.py#L7

def get_uni_sphere_xyz(H, W):
    j, i = np.meshgrid(np.arange(H), np.arange(W), indexing='ij')
    u = (i+0.5) / W * 2 * np.pi
    v = ((j+0.5) / H - 0.5) * np.pi
    z = -np.sin(v)
    c = np.cos(v)
    y = c * np.sin(u)
    x = c * np.cos(u)
    sphere_xyz = np.stack([x, y, z], -1)
    return sphere_xyz

johnwlambert avatar Oct 08 '21 17:10 johnwlambert

Here is a good example of how the reflection leads to an incorrect reconstruction.

The window should be to the right of the bed, per the panorama: image

But in 3d, with this choice of coordinate system, the window ends up on the left of the bed: image

from https://github.com/sunset1995/HoHoNet/blob/master/assets/snapshot_depth.jpg and https://github.com/sunset1995/HoHoNet/blob/master/assets/pano_asmasuxybohhcj.png

johnwlambert avatar Oct 08 '21 17:10 johnwlambert

you can multiply by -1 to get the correct projection u = (i+0.5) / W * 2 * np.pi * -1

monschine avatar Dec 12 '21 14:12 monschine

Of course : - ) This is my suggestion.

johnwlambert avatar Dec 13 '21 02:12 johnwlambert