nerfstudio-project / nerfstudio

A collaboration friendly studio for NeRFs
https://docs.nerf.studio
Apache License 2.0
8.91k stars 1.18k forks source link

NeRFStudio coordinate convention #1810

Open jh27kim opened 1 year ago

jh27kim commented 1 year ago

Hi,

I'm experimenting NeRFStudio using rendered images of a 3D mesh. But, when I provide a rendered image of a 3D mesh along with its c2w matrix, the camera is not located where I intended it to be on the viewer.

image

where angles are given as :

and the pose is computed as:

centers = np.array([
        radius * np.sin(theta) * np.sin(phi),
        radius * np.cos(theta),
        radius * np.sin(theta) * np.cos(phi),
    ]) 

targets = 0.

forward_vector = safe_normalize(centers - targets)
up_vector = np.array([0, 1, 0])
right_vector = safe_normalize(np.cross(up_vector, forward_vector))

up_vector = safe_normalize(np.cross(forward_vector, right_vector))

pose = np.eye(4)
pose[:3, :3] = np.stack((right_vector, up_vector, forward_vector), axis=-1)
pose[:3, 3] = centers 

Note that I disabled auto_orient_and_center_poses in camera_utils.py since the pose rendering is assumed to be noise-free.

MvWouden commented 1 year ago

Did you take a look at these resources?

  1. The data conventions.
  2. The code used to convert COLMAPs transformations.

Using these resources I was able to import my own camera poses, so I assume these may help you.

jh27kim commented 1 year ago

Thanks for the input ! Yes I have checked the data convention, and COMAP transformation looks like converting w2c -> c2w.

I followed dreamfusion camera sampling Stable Dreamfusion

But seems like the axis convention is little different.

tancik commented 1 year ago

Perhaps unrelated, but if you are interested in dreamfusion camera sampling, take a look at this - https://github.com/nerfstudio-project/nerfstudio/blob/generative/nerfstudio/data/datamanagers/dreamfusion_datamanager.py